LLVMFuzzerTestOneInput:
   55|  6.60k|{
   56|  6.60k|  tjhandle handle = NULL;
   57|  6.60k|  short *imgBuf = NULL, *srcBuf;
   58|  6.60k|  unsigned char *dstBuf = NULL;
   59|  6.60k|  int width = 0, height = 0, ti;
   60|  6.60k|  FILE *file = NULL;
   61|  6.60k|  struct test tests[NUMTESTS] = {
   62|       |    /*
   63|       |      BU Pixel      JPEG          Subsampling  Fst Qual Prg Ari No    Rst
   64|       |         Format     Colorspace    Level        DCT              Realc Rows */
   65|  6.60k|    { 0, TJPF_RGB,  TJCS_YCbCr,   TJSAMP_444,  1,  100, 0,  0,  1,    0    },
   66|  6.60k|    { 0, TJPF_BGR,  TJCS_DEFAULT, TJSAMP_422,  0,  90,  0,  0,  0,    0    },
   67|  6.60k|    { 0, TJPF_RGBX, TJCS_RGB,     TJSAMP_420,  0,  75,  0,  1,  0,    1    },
   68|  6.60k|    { 0, TJPF_BGRA, TJCS_DEFAULT, TJSAMP_411,  0,  50,  0,  0,  0,    0    },
   69|  6.60k|    { 0, TJPF_XRGB, TJCS_GRAY,    TJSAMP_GRAY, 0,  25,  0,  0,  0,    0    },
   70|  6.60k|    { 0, TJPF_GRAY, TJCS_DEFAULT, TJSAMP_GRAY, 0,  10,  1,  0,  0,    0    },
   71|  6.60k|    { 1, TJPF_CMYK, TJCS_YCCK,    TJSAMP_440,  0,  1,   1,  1,  0,    1    }
   72|  6.60k|  };
   73|       |
   74|  6.60k|  if ((file = fmemopen((void *)data, size, "r")) == NULL)
  ------------------
  |  Branch (74:7): [True: 0, False: 6.60k]
  ------------------
   75|      0|    goto bailout;
   76|       |
   77|  6.60k|  if ((handle = tj3Init(TJINIT_COMPRESS)) == NULL)
  ------------------
  |  | 1280|  6.60k|#define tj3Init(initType)  tj3InitVersion(initType, TURBOJPEG_VERSION_NUMBER)
  |  |  ------------------
  |  |  |  |   34|  6.60k|#define TURBOJPEG_VERSION_NUMBER  3002000
  |  |  ------------------
  ------------------
  |  Branch (77:7): [True: 0, False: 6.60k]
  ------------------
   78|      0|    goto bailout;
   79|       |
   80|  52.8k|  for (ti = 0; ti < NUMTESTS; ti++) {
  ------------------
  |  |   42|  52.8k|#define NUMTESTS  7
  ------------------
  |  Branch (80:16): [True: 46.2k, False: 6.60k]
  ------------------
   81|  46.2k|    int pf = tests[ti].pf;
   82|  46.2k|    size_t dstSize = 0, maxBufSize, i, sum = 0;
   83|       |
   84|       |    /* Test non-default compression options on specific iterations. */
   85|  46.2k|    tj3Set(handle, TJPARAM_BOTTOMUP, tests[ti].bottomUp);
   86|  46.2k|    tj3Set(handle, TJPARAM_COLORSPACE, tests[ti].colorspace);
   87|  46.2k|    tj3Set(handle, TJPARAM_FASTDCT, tests[ti].fastDCT);
   88|  46.2k|    tj3Set(handle, TJPARAM_PROGRESSIVE, tests[ti].progressive);
   89|  46.2k|    tj3Set(handle, TJPARAM_ARITHMETIC, tests[ti].arithmetic);
   90|  46.2k|    tj3Set(handle, TJPARAM_NOREALLOC, tests[ti].noRealloc);
   91|  46.2k|    tj3Set(handle, TJPARAM_RESTARTROWS, tests[ti].restartRows);
   92|       |
   93|  46.2k|    tj3Set(handle, TJPARAM_MAXPIXELS, 1048576);
   94|       |    /* tj3LoadImage12() will refuse to load images larger than 1 Megapixel, so
   95|       |       we don't need to check the width and height here. */
   96|  46.2k|    fseek(file, 0, SEEK_SET);
   97|  46.2k|    if ((imgBuf = _tj3LoadImageFromFileHandle12(handle, file, &width, 1,
  ------------------
  |  Branch (97:9): [True: 34.6k, False: 11.5k]
  ------------------
   98|  46.2k|                                                &height, &pf)) == NULL) {
   99|  34.6k|      if (size < 2)
  ------------------
  |  Branch (99:11): [True: 175, False: 34.4k]
  ------------------
  100|    175|        continue;
  101|       |
  102|       |      /* Derive image dimensions from input data.  Use first 2 bytes to
  103|       |         influence width/height. */
  104|  34.4k|      width = (data[0] % 64) + 8;   /* 8-71 */
  105|  34.4k|      height = (data[1] % 64) + 8;  /* 8-71 */
  106|       |
  107|  34.4k|      size_t required_size = 2 + (size_t)width * height *
  108|  34.4k|                             tjPixelSize[tests[ti].pf] * 2;
  109|  34.4k|      if (size < required_size) {
  ------------------
  |  Branch (109:11): [True: 30.7k, False: 3.76k]
  ------------------
  110|       |        /* Not enough data - try smaller dimensions */
  111|  30.7k|        width = 8;
  112|  30.7k|        height = 8;
  113|  30.7k|        required_size = 2 + (size_t)width * height *
  114|  30.7k|                        tjPixelSize[tests[ti].pf] * 2;
  115|  30.7k|        if (size < required_size)
  ------------------
  |  Branch (115:13): [True: 25.2k, False: 5.50k]
  ------------------
  116|  25.2k|          continue;
  117|  30.7k|      }
  118|       |
  119|       |      /* Skip header bytes. */
  120|  9.26k|      srcBuf = (short *)(data + 2);
  121|  9.26k|    } else
  122|  11.5k|      srcBuf = imgBuf;
  123|       |
  124|  20.8k|    dstSize = maxBufSize = tj3JPEGBufSize(width, height, tests[ti].subsamp);
  125|  20.8k|    if (tj3Get(handle, TJPARAM_NOREALLOC)) {
  ------------------
  |  Branch (125:9): [True: 2.95k, False: 17.8k]
  ------------------
  126|  2.95k|      if ((dstBuf = (unsigned char *)tj3Alloc(dstSize)) == NULL)
  ------------------
  |  Branch (126:11): [True: 0, False: 2.95k]
  ------------------
  127|      0|        goto bailout;
  128|  2.95k|    } else
  129|  17.8k|      dstBuf = NULL;
  130|       |
  131|  20.8k|    if (size >= 34)
  ------------------
  |  Branch (131:9): [True: 17.7k, False: 3.05k]
  ------------------
  132|  17.7k|      tj3SetICCProfile(handle, (unsigned char *)&data[2], 32);
  133|       |
  134|  20.8k|    tj3Set(handle, TJPARAM_SUBSAMP, tests[ti].subsamp);
  135|  20.8k|    tj3Set(handle, TJPARAM_QUALITY, tests[ti].quality);
  136|  20.8k|    if (tj3Compress12(handle, srcBuf, width, 0, height, pf, &dstBuf,
  ------------------
  |  Branch (136:9): [True: 20.8k, False: 0]
  ------------------
  137|  20.8k|                      &dstSize) == 0) {
  138|       |      /* Touch all of the output data in order to catch uninitialized reads
  139|       |         when using MemorySanitizer. */
  140|   371M|      for (i = 0; i < dstSize; i++)
  ------------------
  |  Branch (140:19): [True: 371M, False: 20.8k]
  ------------------
  141|   371M|        sum += dstBuf[i];
  142|  20.8k|    }
  143|       |
  144|  20.8k|    tj3Free(dstBuf);
  145|  20.8k|    dstBuf = NULL;
  146|  20.8k|    tj3Free(imgBuf);
  147|  20.8k|    imgBuf = NULL;
  148|       |
  149|       |    /* Prevent the sum above from being optimized out.  This test should never
  150|       |       be true, but the compiler doesn't know that. */
  151|  20.8k|    if (sum > 255 * maxBufSize)
  ------------------
  |  Branch (151:9): [True: 0, False: 20.8k]
  ------------------
  152|      0|      goto bailout;
  153|  20.8k|  }
  154|       |
  155|  6.60k|bailout:
  156|  6.60k|  tj3Free(dstBuf);
  157|  6.60k|  tj3Free(imgBuf);
  158|  6.60k|  if (file) fclose(file);
  ------------------
  |  Branch (158:7): [True: 6.60k, False: 0]
  ------------------
  159|  6.60k|  tj3Destroy(handle);
  160|  6.60k|  return 0;
  161|  6.60k|}

jsimd_set_huff_encode_one_block:
 1432|  23.1k|{
 1433|  23.1k|  init_simd((j_common_ptr)cinfo);
 1434|       |
 1435|  23.1k|  if (sizeof(JCOEF) != 2)
  ------------------
  |  Branch (1435:7): [Folded, False: 23.1k]
  ------------------
 1436|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1437|  23.1k|  if (!cinfo->entropy)
  ------------------
  |  Branch (1437:7): [True: 0, False: 23.1k]
  ------------------
 1438|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1439|       |
 1440|  23.1k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1441|  23.1k|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|  23.1k|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (1441:7): [True: 23.1k, False: 0]
  ------------------
 1442|  23.1k|      cinfo->master->simd_huffman &&
  ------------------
  |  Branch (1442:7): [True: 23.1k, False: 0]
  ------------------
 1443|  23.1k|      IS_ALIGNED_SSE(jconst_huff_encode_one_block)) {
  ------------------
  |  |   45|  23.1k|#define IS_ALIGNED_SSE(ptr)  (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
  |  |  ------------------
  |  |  |  |   43|  23.1k|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (45:30): [True: 23.1k, False: 0]
  |  |  ------------------
  ------------------
 1444|  23.1k|    cinfo->entropy->huff_encode_one_block_simd =
 1445|  23.1k|      jsimd_huff_encode_one_block_sse2;
 1446|  23.1k|    return JSIMD_SSE2;
  ------------------
  |  |   42|  23.1k|#define JSIMD_SSE2       0x08
  ------------------
 1447|  23.1k|  }
 1448|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
 1449|       |  if ((cinfo->master->simd_support & JSIMD_NEON) &&
 1450|       |      cinfo->master->simd_huffman) {
 1451|       |    cinfo->entropy->huff_encode_one_block_simd =
 1452|       |      jsimd_huff_encode_one_block_neon;
 1453|       |    return JSIMD_NEON;
 1454|       |  }
 1455|       |#endif
 1456|       |
 1457|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1458|  23.1k|}
jsimd_set_encode_mcu_AC_first_prepare:
 1464|  21.5k|{
 1465|  21.5k|  init_simd((j_common_ptr)cinfo);
 1466|       |
 1467|  21.5k|  if (sizeof(JCOEF) != 2)
  ------------------
  |  Branch (1467:7): [Folded, False: 21.5k]
  ------------------
 1468|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1469|       |
 1470|  21.5k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1471|  21.5k|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|  21.5k|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (1471:7): [True: 21.5k, False: 0]
  ------------------
 1472|  21.5k|      cinfo->master->simd_huffman) {
  ------------------
  |  Branch (1472:7): [True: 21.5k, False: 0]
  ------------------
 1473|  21.5k|    *method = jsimd_encode_mcu_AC_first_prepare_sse2;
 1474|  21.5k|    return JSIMD_SSE2;
  ------------------
  |  |   42|  21.5k|#define JSIMD_SSE2       0x08
  ------------------
 1475|  21.5k|  }
 1476|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
 1477|       |  if ((cinfo->master->simd_support & JSIMD_NEON) &&
 1478|       |      cinfo->master->simd_huffman) {
 1479|       |    *method = jsimd_encode_mcu_AC_first_prepare_neon;
 1480|       |    return JSIMD_NEON;
 1481|       |  }
 1482|       |#endif
 1483|       |
 1484|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1485|  21.5k|}
jsimd_set_encode_mcu_AC_refine_prepare:
 1491|  14.3k|{
 1492|  14.3k|  init_simd((j_common_ptr)cinfo);
 1493|       |
 1494|  14.3k|  if (sizeof(JCOEF) != 2)
  ------------------
  |  Branch (1494:7): [Folded, False: 14.3k]
  ------------------
 1495|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1496|       |
 1497|  14.3k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1498|  14.3k|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|  14.3k|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (1498:7): [True: 14.3k, False: 0]
  ------------------
 1499|  14.3k|      cinfo->master->simd_huffman) {
  ------------------
  |  Branch (1499:7): [True: 14.3k, False: 0]
  ------------------
 1500|  14.3k|    *method = jsimd_encode_mcu_AC_refine_prepare_sse2;
 1501|  14.3k|    return JSIMD_SSE2;
  ------------------
  |  |   42|  14.3k|#define JSIMD_SSE2       0x08
  ------------------
 1502|  14.3k|  }
 1503|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
 1504|       |  if ((cinfo->master->simd_support & JSIMD_NEON) &&
 1505|       |      cinfo->master->simd_huffman) {
 1506|       |    *method = jsimd_encode_mcu_AC_refine_prepare_neon;
 1507|       |    return JSIMD_NEON;
 1508|       |  }
 1509|       |#endif
 1510|       |
 1511|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1512|  14.3k|}
jsimd.c:init_simd:
   56|  59.0k|{
   57|  59.0k|#ifndef NO_GETENV
   58|  59.0k|  char env[2] = { 0 };
   59|  59.0k|#endif
   60|  59.0k|  unsigned int simd_support = cinfo->is_decompressor ?
  ------------------
  |  Branch (60:31): [True: 0, False: 59.0k]
  ------------------
   61|      0|                              ((j_decompress_ptr)cinfo)->master->simd_support :
   62|  59.0k|                              ((j_compress_ptr)cinfo)->master->simd_support;
   63|  59.0k|  unsigned int simd_huffman = cinfo->is_decompressor ?
  ------------------
  |  Branch (63:31): [True: 0, False: 59.0k]
  ------------------
   64|      0|                              ((j_decompress_ptr)cinfo)->master->simd_huffman :
   65|  59.0k|                              ((j_compress_ptr)cinfo)->master->simd_huffman;
   66|       |
   67|  59.0k|  if (simd_support != JSIMD_UNDEFINED)
  ------------------
  |  |   49|  59.0k|#define JSIMD_UNDEFINED  ~(JSIMD_MAX * 2U - 1U)
  |  |  ------------------
  |  |  |  |   48|  59.0k|#define JSIMD_MAX        0x100
  |  |  ------------------
  ------------------
  |  Branch (67:7): [True: 55.2k, False: 3.77k]
  ------------------
   68|  55.2k|    return;
   69|       |
   70|  3.77k|  simd_support = jpeg_simd_cpu_support();
   71|       |
   72|  3.77k|#ifndef NO_GETENV
   73|       |  /* Force different settings through environment variables */
   74|  3.77k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
   75|  3.77k|  if (!GETENV_S(env, 2, "JSIMD_FORCESSE2") && !strcmp(env, "1"))
  ------------------
  |  Branch (75:7): [True: 3.77k, False: 0]
  |  Branch (75:47): [True: 0, False: 3.77k]
  ------------------
   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|  3.77k|  if (!GETENV_S(env, 2, "JSIMD_FORCENONE") && !strcmp(env, "1"))
  ------------------
  |  Branch (95:7): [True: 3.77k, False: 0]
  |  Branch (95:47): [True: 0, False: 3.77k]
  ------------------
   96|      0|    simd_support = 0;
   97|  3.77k|  if (!GETENV_S(env, 2, "JSIMD_NOHUFFENC") && !strcmp(env, "1"))
  ------------------
  |  Branch (97:7): [True: 3.77k, False: 0]
  |  Branch (97:47): [True: 0, False: 3.77k]
  ------------------
   98|      0|    simd_huffman = 0;
   99|  3.77k|#endif
  100|       |
  101|  3.77k|  if (cinfo->is_decompressor) {
  ------------------
  |  Branch (101:7): [True: 0, False: 3.77k]
  ------------------
  102|      0|    ((j_decompress_ptr)cinfo)->master->simd_support = simd_support;
  103|      0|    ((j_decompress_ptr)cinfo)->master->simd_huffman = simd_huffman;
  104|  3.77k|  } else {
  105|  3.77k|    ((j_compress_ptr)cinfo)->master->simd_support = simd_support;
  106|  3.77k|    ((j_compress_ptr)cinfo)->master->simd_huffman = simd_huffman;
  107|  3.77k|  }
  108|  3.77k|}

rdpng-12.c:rgb_to_cmyk:
   29|  12.8M|{
   30|  12.8M|  double ctmp = 1.0 - ((double)r / (double)maxval);
   31|  12.8M|  double mtmp = 1.0 - ((double)g / (double)maxval);
   32|  12.8M|  double ytmp = 1.0 - ((double)b / (double)maxval);
   33|  12.8M|  double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
  ------------------
  |  |  515|  25.6M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 1.90M, False: 10.9M]
  |  |  |  Branch (515:27): [True: 1.27M, False: 11.5M]
  |  |  |  Branch (515:39): [True: 1.04M, False: 861k]
  |  |  ------------------
  ------------------
   34|       |
   35|  12.8M|  if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
  ------------------
  |  Branch (35:7): [True: 6.77M, False: 6.05M]
  ------------------
   36|  6.05M|  else {
   37|  6.05M|    ctmp = (ctmp - ktmp) / (1.0 - ktmp);
   38|  6.05M|    mtmp = (mtmp - ktmp) / (1.0 - ktmp);
   39|  6.05M|    ytmp = (ytmp - ktmp) / (1.0 - ktmp);
   40|  6.05M|  }
   41|  12.8M|  *c = (_JSAMPLE)((double)maxval - ctmp * (double)maxval + 0.5);
   42|  12.8M|  *m = (_JSAMPLE)((double)maxval - mtmp * (double)maxval + 0.5);
   43|  12.8M|  *y = (_JSAMPLE)((double)maxval - ytmp * (double)maxval + 0.5);
   44|  12.8M|  *k = (_JSAMPLE)((double)maxval - ktmp * (double)maxval + 0.5);
   45|  12.8M|}
rdppm-12.c:rgb_to_cmyk:
   29|  24.9M|{
   30|  24.9M|  double ctmp = 1.0 - ((double)r / (double)maxval);
   31|  24.9M|  double mtmp = 1.0 - ((double)g / (double)maxval);
   32|  24.9M|  double ytmp = 1.0 - ((double)b / (double)maxval);
   33|  24.9M|  double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
  ------------------
  |  |  515|  49.9M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 2.00M, False: 22.9M]
  |  |  |  Branch (515:27): [True: 1.32M, False: 23.6M]
  |  |  |  Branch (515:39): [True: 930k, False: 1.07M]
  |  |  ------------------
  ------------------
   34|       |
   35|  24.9M|  if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
  ------------------
  |  Branch (35:7): [True: 15.4M, False: 9.49M]
  ------------------
   36|  9.49M|  else {
   37|  9.49M|    ctmp = (ctmp - ktmp) / (1.0 - ktmp);
   38|  9.49M|    mtmp = (mtmp - ktmp) / (1.0 - ktmp);
   39|  9.49M|    ytmp = (ytmp - ktmp) / (1.0 - ktmp);
   40|  9.49M|  }
   41|  24.9M|  *c = (_JSAMPLE)((double)maxval - ctmp * (double)maxval + 0.5);
   42|  24.9M|  *m = (_JSAMPLE)((double)maxval - mtmp * (double)maxval + 0.5);
   43|  24.9M|  *y = (_JSAMPLE)((double)maxval - ytmp * (double)maxval + 0.5);
   44|  24.9M|  *k = (_JSAMPLE)((double)maxval - ktmp * (double)maxval + 0.5);
   45|  24.9M|}

jpeg_CreateCompress:
   39|  52.8k|{
   40|  52.8k|  int i;
   41|       |
   42|       |  /* Guard against version mismatches between library and caller. */
   43|  52.8k|  cinfo->mem = NULL;            /* so jpeg_destroy knows mem mgr not called */
   44|  52.8k|  if (version != JPEG_LIB_VERSION)
  ------------------
  |  |    4|  52.8k|#define JPEG_LIB_VERSION  62
  ------------------
  |  Branch (44:7): [True: 0, False: 52.8k]
  ------------------
   45|      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)))
  ------------------
   46|  52.8k|  if (structsize != sizeof(struct jpeg_compress_struct))
  ------------------
  |  Branch (46:7): [True: 0, False: 52.8k]
  ------------------
   47|      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)))
  ------------------
   48|  52.8k|             (int)sizeof(struct jpeg_compress_struct), (int)structsize);
   49|       |
   50|       |  /* For debugging purposes, we zero the whole master structure.
   51|       |   * But the application has already set the err pointer, and may have set
   52|       |   * client_data, so we have to save and restore those fields.
   53|       |   * Note: if application hasn't set client_data, tools like Purify may
   54|       |   * complain here.
   55|       |   */
   56|  52.8k|  {
   57|  52.8k|    struct jpeg_error_mgr *err = cinfo->err;
   58|  52.8k|    void *client_data = cinfo->client_data; /* ignore Purify complaint here */
   59|  52.8k|    memset(cinfo, 0, sizeof(struct jpeg_compress_struct));
   60|  52.8k|    cinfo->err = err;
   61|  52.8k|    cinfo->client_data = client_data;
   62|  52.8k|  }
   63|  52.8k|  cinfo->is_decompressor = FALSE;
  ------------------
  |  |  207|  52.8k|#define FALSE   0               /* values of boolean */
  ------------------
   64|       |
   65|       |  /* Initialize a memory manager instance for this object */
   66|  52.8k|  jinit_memory_mgr((j_common_ptr)cinfo);
   67|       |
   68|       |  /* Zero out pointers to permanent structures. */
   69|  52.8k|  cinfo->progress = NULL;
   70|  52.8k|  cinfo->dest = NULL;
   71|       |
   72|  52.8k|  cinfo->comp_info = NULL;
   73|       |
   74|   264k|  for (i = 0; i < NUM_QUANT_TBLS; i++) {
  ------------------
  |  |   68|   264k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (74:15): [True: 211k, False: 52.8k]
  ------------------
   75|   211k|    cinfo->quant_tbl_ptrs[i] = NULL;
   76|       |#if JPEG_LIB_VERSION >= 70
   77|       |    cinfo->q_scale_factor[i] = 100;
   78|       |#endif
   79|   211k|  }
   80|       |
   81|   264k|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|   264k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (81:15): [True: 211k, False: 52.8k]
  ------------------
   82|   211k|    cinfo->dc_huff_tbl_ptrs[i] = NULL;
   83|   211k|    cinfo->ac_huff_tbl_ptrs[i] = NULL;
   84|   211k|  }
   85|       |
   86|       |#if JPEG_LIB_VERSION >= 80
   87|       |  /* Must do it here for emit_dqt in case jpeg_write_tables is used */
   88|       |  cinfo->block_size = DCTSIZE;
   89|       |  cinfo->natural_order = jpeg_natural_order;
   90|       |  cinfo->lim_Se = DCTSIZE2 - 1;
   91|       |#endif
   92|       |
   93|  52.8k|  cinfo->script_space = NULL;
   94|       |
   95|  52.8k|  cinfo->input_gamma = 1.0;     /* in case application forgets */
   96|       |
   97|  52.8k|  cinfo->data_precision = BITS_IN_JSAMPLE;
  ------------------
  |  |   34|  52.8k|#define BITS_IN_JSAMPLE  8
  ------------------
   98|       |
   99|       |  /* OK, I'm ready */
  100|  52.8k|  cinfo->global_state = CSTATE_START;
  ------------------
  |  |   44|  52.8k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  101|       |
  102|       |  /* The master struct is used to store extension parameters, so we allocate it
  103|       |   * here.
  104|       |   */
  105|  52.8k|  cinfo->master = (struct jpeg_comp_master *)
  106|  52.8k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  52.8k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  107|  52.8k|                                  sizeof(my_comp_master));
  108|  52.8k|  memset(cinfo->master, 0, sizeof(my_comp_master));
  109|  52.8k|#ifdef WITH_SIMD
  110|  52.8k|  cinfo->master->simd_support = JSIMD_UNDEFINED;
  ------------------
  |  |   49|  52.8k|#define JSIMD_UNDEFINED  ~(JSIMD_MAX * 2U - 1U)
  |  |  ------------------
  |  |  |  |   48|  52.8k|#define JSIMD_MAX        0x100
  |  |  ------------------
  ------------------
  111|  52.8k|  cinfo->master->simd_huffman = 1;
  112|  52.8k|#endif
  113|  52.8k|}
jpeg_destroy_compress:
  122|  52.8k|{
  123|  52.8k|  jpeg_destroy((j_common_ptr)cinfo); /* use common routine */
  124|  52.8k|}
jpeg_suppress_tables:
  153|  20.8k|{
  154|  20.8k|  int i;
  155|  20.8k|  JQUANT_TBL *qtbl;
  156|  20.8k|  JHUFF_TBL *htbl;
  157|       |
  158|   104k|  for (i = 0; i < NUM_QUANT_TBLS; i++) {
  ------------------
  |  |   68|   104k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (158:15): [True: 83.3k, False: 20.8k]
  ------------------
  159|  83.3k|    if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL)
  ------------------
  |  Branch (159:9): [True: 41.6k, False: 41.6k]
  ------------------
  160|  41.6k|      qtbl->sent_table = suppress;
  161|  83.3k|  }
  162|       |
  163|   104k|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|   104k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (163:15): [True: 83.3k, False: 20.8k]
  ------------------
  164|  83.3k|    if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL)
  ------------------
  |  Branch (164:9): [True: 41.6k, False: 41.6k]
  ------------------
  165|  41.6k|      htbl->sent_table = suppress;
  166|  83.3k|    if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL)
  ------------------
  |  Branch (166:9): [True: 41.6k, False: 41.6k]
  ------------------
  167|  41.6k|      htbl->sent_table = suppress;
  168|  83.3k|  }
  169|  20.8k|}
jpeg_finish_compress:
  181|  20.8k|{
  182|  20.8k|  JDIMENSION iMCU_row;
  183|       |
  184|  20.8k|  if (cinfo->global_state == CSTATE_SCANNING ||
  ------------------
  |  |   45|  41.6k|#define CSTATE_SCANNING  101    /* start_compress done, write_scanlines OK */
  ------------------
  |  Branch (184:7): [True: 20.8k, False: 0]
  ------------------
  185|  20.8k|      cinfo->global_state == CSTATE_RAW_OK) {
  ------------------
  |  |   46|      0|#define CSTATE_RAW_OK    102    /* start_compress done, write_raw_data OK */
  ------------------
  |  Branch (185:7): [True: 0, False: 0]
  ------------------
  186|       |    /* Terminate first pass */
  187|  20.8k|    if (cinfo->next_scanline < cinfo->image_height)
  ------------------
  |  Branch (187:9): [True: 0, False: 20.8k]
  ------------------
  188|      0|      ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  189|  20.8k|    (*cinfo->master->finish_pass) (cinfo);
  190|  20.8k|  } else if (cinfo->global_state != CSTATE_WRCOEFS)
  ------------------
  |  |   47|      0|#define CSTATE_WRCOEFS   103    /* jpeg_write_coefficients done */
  ------------------
  |  Branch (190:14): [True: 0, False: 0]
  ------------------
  191|      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)))
  ------------------
  192|       |  /* Perform any remaining passes */
  193|   116k|  while (!cinfo->master->is_last_pass) {
  ------------------
  |  Branch (193:10): [True: 95.7k, False: 20.8k]
  ------------------
  194|  95.7k|    (*cinfo->master->prepare_for_pass) (cinfo);
  195|  11.3M|    for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) {
  ------------------
  |  Branch (195:24): [True: 11.2M, False: 95.7k]
  ------------------
  196|  11.2M|      if (cinfo->progress != NULL) {
  ------------------
  |  Branch (196:11): [True: 0, False: 11.2M]
  ------------------
  197|      0|        cinfo->progress->pass_counter = (long)iMCU_row;
  198|      0|        cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows;
  199|      0|        (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
  200|      0|      }
  201|       |      /* We bypass the main controller and invoke coef controller directly;
  202|       |       * all work is being done from the coefficient buffer.
  203|       |       */
  204|  11.2M|      if (cinfo->data_precision <= 8) {
  ------------------
  |  Branch (204:11): [True: 0, False: 11.2M]
  ------------------
  205|      0|        if (cinfo->coef->compress_data == NULL)
  ------------------
  |  Branch (205:13): [True: 0, False: 0]
  ------------------
  206|      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)))
  ------------------
  207|      0|        if (!(*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE)NULL))
  ------------------
  |  Branch (207:13): [True: 0, False: 0]
  ------------------
  208|      0|          ERREXIT(cinfo, JERR_CANT_SUSPEND);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  209|  11.2M|      } else if (cinfo->data_precision <= 12) {
  ------------------
  |  Branch (209:18): [True: 11.2M, False: 0]
  ------------------
  210|  11.2M|        if (cinfo->coef->compress_data_12 == NULL)
  ------------------
  |  Branch (210:13): [True: 0, False: 11.2M]
  ------------------
  211|      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)))
  ------------------
  212|  11.2M|        if (!(*cinfo->coef->compress_data_12) (cinfo, (J12SAMPIMAGE)NULL))
  ------------------
  |  Branch (212:13): [True: 0, False: 11.2M]
  ------------------
  213|      0|          ERREXIT(cinfo, JERR_CANT_SUSPEND);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  214|  11.2M|      } else {
  215|      0|#ifdef C_LOSSLESS_SUPPORTED
  216|      0|        if (cinfo->coef->compress_data_16 == NULL)
  ------------------
  |  Branch (216:13): [True: 0, False: 0]
  ------------------
  217|      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)))
  ------------------
  218|      0|        if (!(*cinfo->coef->compress_data_16) (cinfo, (J16SAMPIMAGE)NULL))
  ------------------
  |  Branch (218:13): [True: 0, False: 0]
  ------------------
  219|      0|          ERREXIT(cinfo, JERR_CANT_SUSPEND);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  220|       |#else
  221|       |        ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  222|       |#endif
  223|      0|      }
  224|  11.2M|    }
  225|  95.7k|    (*cinfo->master->finish_pass) (cinfo);
  226|  95.7k|  }
  227|       |  /* Write EOI, do final cleanup */
  228|  20.8k|  (*cinfo->marker->write_file_trailer) (cinfo);
  229|  20.8k|  (*cinfo->dest->term_destination) (cinfo);
  230|       |  /* We can use jpeg_abort to release memory and reset global_state */
  231|  20.8k|  jpeg_abort((j_common_ptr)cinfo);
  232|  20.8k|}
jpeg_write_m_header:
  266|  17.7k|{
  267|  17.7k|  if (cinfo->next_scanline != 0 ||
  ------------------
  |  Branch (267:7): [True: 0, False: 17.7k]
  ------------------
  268|  17.7k|      (cinfo->global_state != CSTATE_SCANNING &&
  ------------------
  |  |   45|  35.5k|#define CSTATE_SCANNING  101    /* start_compress done, write_scanlines OK */
  ------------------
  |  Branch (268:8): [True: 0, False: 17.7k]
  ------------------
  269|      0|       cinfo->global_state != CSTATE_RAW_OK &&
  ------------------
  |  |   46|  17.7k|#define CSTATE_RAW_OK    102    /* start_compress done, write_raw_data OK */
  ------------------
  |  Branch (269:8): [True: 0, False: 0]
  ------------------
  270|      0|       cinfo->global_state != CSTATE_WRCOEFS))
  ------------------
  |  |   47|      0|#define CSTATE_WRCOEFS   103    /* jpeg_write_coefficients done */
  ------------------
  |  Branch (270:8): [True: 0, False: 0]
  ------------------
  271|      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)))
  ------------------
  272|       |
  273|  17.7k|  (*cinfo->marker->write_marker_header) (cinfo, marker, datalen);
  274|  17.7k|}
jpeg_write_m_byte:
  278|   818k|{
  279|   818k|  (*cinfo->marker->write_marker_byte) (cinfo, val);
  280|   818k|}

jpeg_start_compress:
   45|  20.8k|{
   46|  20.8k|  if (cinfo->global_state != CSTATE_START)
  ------------------
  |  |   44|  20.8k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (46:7): [True: 0, False: 20.8k]
  ------------------
   47|      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)))
  ------------------
   48|       |
   49|  20.8k|  if (write_all_tables)
  ------------------
  |  Branch (49:7): [True: 20.8k, False: 0]
  ------------------
   50|  20.8k|    jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */
  ------------------
  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  ------------------
   51|       |
   52|       |  /* (Re)initialize error mgr and destination modules */
   53|  20.8k|  (*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
   54|  20.8k|  (*cinfo->dest->init_destination) (cinfo);
   55|       |  /* Perform master selection of active modules */
   56|  20.8k|  jinit_compress_master(cinfo);
   57|       |  /* Set up for the first pass */
   58|  20.8k|  (*cinfo->master->prepare_for_pass) (cinfo);
   59|       |  /* Ready for application to drive first pass through _jpeg_write_scanlines
   60|       |   * or _jpeg_write_raw_data.
   61|       |   */
   62|  20.8k|  cinfo->next_scanline = 0;
   63|  20.8k|  cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING);
  ------------------
  |  |   46|      0|#define CSTATE_RAW_OK    102    /* start_compress done, write_raw_data OK */
  ------------------
                cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING);
  ------------------
  |  |   45|  20.8k|#define CSTATE_SCANNING  101    /* start_compress done, write_scanlines OK */
  ------------------
  |  Branch (63:26): [True: 0, False: 20.8k]
  ------------------
   64|  20.8k|}
jpeg12_write_scanlines:
   87|  20.8k|{
   88|  20.8k|#if BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED)
   89|  20.8k|  JDIMENSION row_ctr, rows_left;
   90|       |
   91|  20.8k|#ifdef C_LOSSLESS_SUPPORTED
   92|  20.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (92:7): [True: 0, False: 20.8k]
  ------------------
   93|       |#if BITS_IN_JSAMPLE == 8
   94|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
   95|       |#else
   96|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (96:9): [True: 0, False: 0]
  ------------------
   97|      0|        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (97:9): [True: 0, False: 0]
  ------------------
   98|      0|#endif
   99|      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)))
  ------------------
  100|      0|  } else
  101|  20.8k|#endif
  102|  20.8k|  {
  103|  20.8k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  20.8k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (103:9): [True: 0, False: 20.8k]
  ------------------
  104|      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)))
  ------------------
  105|  20.8k|  }
  106|       |
  107|  20.8k|  if (cinfo->global_state != CSTATE_SCANNING)
  ------------------
  |  |   45|  20.8k|#define CSTATE_SCANNING  101    /* start_compress done, write_scanlines OK */
  ------------------
  |  Branch (107:7): [True: 0, False: 20.8k]
  ------------------
  108|      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)))
  ------------------
  109|  20.8k|  if (cinfo->next_scanline >= cinfo->image_height)
  ------------------
  |  Branch (109:7): [True: 0, False: 20.8k]
  ------------------
  110|      0|    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
  ------------------
  |  |  283|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  284|      0|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
  ------------------
  111|       |
  112|       |  /* Call progress monitor hook if present */
  113|  20.8k|  if (cinfo->progress != NULL) {
  ------------------
  |  Branch (113:7): [True: 0, False: 20.8k]
  ------------------
  114|      0|    cinfo->progress->pass_counter = (long)cinfo->next_scanline;
  115|      0|    cinfo->progress->pass_limit = (long)cinfo->image_height;
  116|      0|    (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
  117|      0|  }
  118|       |
  119|       |  /* Give master control module another chance if this is first call to
  120|       |   * _jpeg_write_scanlines.  This lets output of the frame/scan headers be
  121|       |   * delayed so that application can write COM, etc, markers between
  122|       |   * jpeg_start_compress and _jpeg_write_scanlines.
  123|       |   */
  124|  20.8k|  if (cinfo->master->call_pass_startup)
  ------------------
  |  Branch (124:7): [True: 5.67k, False: 15.1k]
  ------------------
  125|  5.67k|    (*cinfo->master->pass_startup) (cinfo);
  126|       |
  127|       |  /* Ignore any extra scanlines at bottom of image. */
  128|  20.8k|  rows_left = cinfo->image_height - cinfo->next_scanline;
  129|  20.8k|  if (num_lines > rows_left)
  ------------------
  |  Branch (129:7): [True: 0, False: 20.8k]
  ------------------
  130|      0|    num_lines = rows_left;
  131|       |
  132|  20.8k|  row_ctr = 0;
  133|  20.8k|  if (cinfo->main->_process_data == NULL)
  ------------------
  |  |  140|  20.8k|#define _process_data  process_data_12
  ------------------
  |  Branch (133:7): [True: 0, False: 20.8k]
  ------------------
  134|      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)))
  ------------------
  135|  20.8k|  (*cinfo->main->_process_data) (cinfo, scanlines, &row_ctr, num_lines);
  ------------------
  |  |  140|  20.8k|#define _process_data  process_data_12
  ------------------
  136|  20.8k|  cinfo->next_scanline += row_ctr;
  137|  20.8k|  return row_ctr;
  138|       |#else
  139|       |  ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  140|       |  return 0;
  141|       |#endif
  142|  20.8k|}

jinit_arith_encoder:
  913|  5.67k|{
  914|  5.67k|  arith_entropy_ptr entropy;
  915|  5.67k|  int i;
  916|       |
  917|  5.67k|  entropy = (arith_entropy_ptr)
  918|  5.67k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  5.67k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  919|  5.67k|                                sizeof(arith_entropy_encoder));
  920|  5.67k|  cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
  921|  5.67k|  entropy->pub.start_pass = start_pass;
  922|  5.67k|  entropy->pub.finish_pass = finish_pass;
  923|       |
  924|       |  /* Mark tables unallocated */
  925|  96.4k|  for (i = 0; i < NUM_ARITH_TBLS; i++) {
  ------------------
  |  |   70|  96.4k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (925:15): [True: 90.8k, False: 5.67k]
  ------------------
  926|  90.8k|    entropy->dc_stats[i] = NULL;
  927|  90.8k|    entropy->ac_stats[i] = NULL;
  928|  90.8k|  }
  929|       |
  930|       |  /* Initialize index for fixed probability estimation */
  931|  5.67k|  entropy->fixed_bin[0] = 113;
  932|  5.67k|}
jcarith.c:start_pass:
  829|  53.9k|{
  830|  53.9k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  831|  53.9k|  int ci, tbl;
  832|  53.9k|  jpeg_component_info *compptr;
  833|       |
  834|  53.9k|  if (gather_statistics)
  ------------------
  |  Branch (834:7): [True: 0, False: 53.9k]
  ------------------
  835|       |    /* Make sure to avoid that in the master control logic!
  836|       |     * We are fully adaptive here and need no extra
  837|       |     * statistics gathering pass!
  838|       |     */
  839|      0|    ERREXIT(cinfo, JERR_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  840|       |
  841|       |  /* We assume jcmaster.c already validated the progressive scan parameters. */
  842|       |
  843|       |  /* Select execution routines */
  844|  53.9k|  if (cinfo->progressive_mode) {
  ------------------
  |  Branch (844:7): [True: 51.0k, False: 2.83k]
  ------------------
  845|  51.0k|    if (cinfo->Ah == 0) {
  ------------------
  |  Branch (845:9): [True: 25.5k, False: 25.5k]
  ------------------
  846|  25.5k|      if (cinfo->Ss == 0)
  ------------------
  |  Branch (846:11): [True: 2.83k, False: 22.7k]
  ------------------
  847|  2.83k|        entropy->pub.encode_mcu = encode_mcu_DC_first;
  848|  22.7k|      else
  849|  22.7k|        entropy->pub.encode_mcu = encode_mcu_AC_first;
  850|  25.5k|    } else {
  851|  25.5k|      if (cinfo->Ss == 0)
  ------------------
  |  Branch (851:11): [True: 2.83k, False: 22.7k]
  ------------------
  852|  2.83k|        entropy->pub.encode_mcu = encode_mcu_DC_refine;
  853|  22.7k|      else
  854|  22.7k|        entropy->pub.encode_mcu = encode_mcu_AC_refine;
  855|  25.5k|    }
  856|  51.0k|  } else
  857|  2.83k|    entropy->pub.encode_mcu = encode_mcu;
  858|       |
  859|       |  /* Allocate & initialize requested statistics areas */
  860|   130k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (860:16): [True: 76.6k, False: 53.9k]
  ------------------
  861|  76.6k|    compptr = cinfo->cur_comp_info[ci];
  862|       |    /* DC needs no table for refinement scan */
  863|  76.6k|    if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
  ------------------
  |  Branch (863:9): [True: 8.51k, False: 68.1k]
  |  Branch (863:42): [True: 22.7k, False: 45.4k]
  |  Branch (863:60): [True: 11.3k, False: 11.3k]
  ------------------
  864|  19.8k|      tbl = compptr->dc_tbl_no;
  865|  19.8k|      if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
  ------------------
  |  |   70|  19.8k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (865:11): [True: 0, False: 19.8k]
  |  Branch (865:22): [True: 0, False: 19.8k]
  ------------------
  866|      0|        ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
  ------------------
  |  |  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)))
  ------------------
  867|  19.8k|      if (entropy->dc_stats[tbl] == NULL)
  ------------------
  |  Branch (867:11): [True: 8.51k, False: 11.3k]
  ------------------
  868|  8.51k|        entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
  869|  8.51k|          ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
  ------------------
  |  |  889|  8.51k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                        ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
  ------------------
  |  |   69|  8.51k|#define DC_STAT_BINS  64
  ------------------
  870|  19.8k|      memset(entropy->dc_stats[tbl], 0, DC_STAT_BINS);
  ------------------
  |  |   69|  19.8k|#define DC_STAT_BINS  64
  ------------------
  871|       |      /* Initialize DC predictions to 0 */
  872|  19.8k|      entropy->last_dc_val[ci] = 0;
  873|  19.8k|      entropy->dc_context[ci] = 0;
  874|  19.8k|    }
  875|       |    /* AC needs no table when not present */
  876|  76.6k|    if (cinfo->progressive_mode == 0 || cinfo->Se) {
  ------------------
  |  Branch (876:9): [True: 8.51k, False: 68.1k]
  |  Branch (876:41): [True: 45.4k, False: 22.7k]
  ------------------
  877|  53.9k|      tbl = compptr->ac_tbl_no;
  878|  53.9k|      if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
  ------------------
  |  |   70|  53.9k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (878:11): [True: 0, False: 53.9k]
  |  Branch (878:22): [True: 0, False: 53.9k]
  ------------------
  879|      0|        ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
  ------------------
  |  |  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)))
  ------------------
  880|  53.9k|      if (entropy->ac_stats[tbl] == NULL)
  ------------------
  |  Branch (880:11): [True: 8.51k, False: 45.4k]
  ------------------
  881|  8.51k|        entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
  882|  8.51k|          ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
  ------------------
  |  |  889|  8.51k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                        ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
  ------------------
  |  |   70|  8.51k|#define AC_STAT_BINS  256
  ------------------
  883|  53.9k|      memset(entropy->ac_stats[tbl], 0, AC_STAT_BINS);
  ------------------
  |  |   70|  53.9k|#define AC_STAT_BINS  256
  ------------------
  884|       |#ifdef CALCULATE_SPECTRAL_CONDITIONING
  885|       |      if (cinfo->progressive_mode)
  886|       |        /* Section G.1.3.2: Set appropriate arithmetic conditioning value Kx */
  887|       |        cinfo->arith_ac_K[tbl] = cinfo->Ss +
  888|       |                                 ((8 + cinfo->Se - cinfo->Ss) >> 4);
  889|       |#endif
  890|  53.9k|    }
  891|  76.6k|  }
  892|       |
  893|       |  /* Initialize arithmetic encoding variables */
  894|  53.9k|  entropy->c = 0;
  895|  53.9k|  entropy->a = 0x10000L;
  896|  53.9k|  entropy->sc = 0;
  897|  53.9k|  entropy->zc = 0;
  898|  53.9k|  entropy->ct = 11;
  899|  53.9k|  entropy->buffer = -1;  /* empty */
  900|       |
  901|       |  /* Initialize restart stuff */
  902|  53.9k|  entropy->restarts_to_go = cinfo->restart_interval;
  903|  53.9k|  entropy->next_restart_num = 0;
  904|  53.9k|}
jcarith.c:encode_mcu_DC_first:
  369|   989k|{
  370|   989k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  371|   989k|  JBLOCKROW block;
  372|   989k|  unsigned char *st;
  373|   989k|  int blkn, ci, tbl;
  374|   989k|  int v, v2, m;
  375|   989k|  ISHIFT_TEMPS
  376|       |
  377|       |  /* Emit restart marker if needed */
  378|   989k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (378:7): [True: 989k, False: 0]
  ------------------
  379|   989k|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (379:9): [True: 269k, False: 719k]
  ------------------
  380|   269k|      emit_restart(cinfo, entropy->next_restart_num);
  381|   269k|      entropy->restarts_to_go = cinfo->restart_interval;
  382|   269k|      entropy->next_restart_num++;
  383|   269k|      entropy->next_restart_num &= 7;
  384|   269k|    }
  385|   989k|    entropy->restarts_to_go--;
  386|   989k|  }
  387|       |
  388|       |  /* Encode the MCU data blocks */
  389|  6.92M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (389:18): [True: 5.93M, False: 989k]
  ------------------
  390|  5.93M|    block = MCU_data[blkn];
  391|  5.93M|    ci = cinfo->MCU_membership[blkn];
  392|  5.93M|    tbl = cinfo->cur_comp_info[ci]->dc_tbl_no;
  393|       |
  394|       |    /* Compute the DC value after the required point transform by Al.
  395|       |     * This is simply an arithmetic right shift.
  396|       |     */
  397|  5.93M|    m = IRIGHT_SHIFT((int)((*block)[0]), cinfo->Al);
  ------------------
  |  |  117|  5.93M|#define IRIGHT_SHIFT(x, shft)   ((x) >> (shft))
  ------------------
  398|       |
  399|       |    /* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */
  400|       |
  401|       |    /* Table F.4: Point to statistics bin S0 for DC coefficient coding */
  402|  5.93M|    st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
  403|       |
  404|       |    /* Figure F.4: Encode_DC_DIFF */
  405|  5.93M|    if ((v = m - entropy->last_dc_val[ci]) == 0) {
  ------------------
  |  Branch (405:9): [True: 4.22M, False: 1.71M]
  ------------------
  406|  4.22M|      arith_encode(cinfo, st, 0);
  407|  4.22M|      entropy->dc_context[ci] = 0;      /* zero diff category */
  408|  4.22M|    } else {
  409|  1.71M|      entropy->last_dc_val[ci] = m;
  410|  1.71M|      arith_encode(cinfo, st, 1);
  411|       |      /* Figure F.6: Encoding nonzero value v */
  412|       |      /* Figure F.7: Encoding the sign of v */
  413|  1.71M|      if (v > 0) {
  ------------------
  |  Branch (413:11): [True: 610k, False: 1.10M]
  ------------------
  414|   610k|        arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
  415|   610k|        st += 2;                        /* Table F.4: SP = S0 + 2 */
  416|   610k|        entropy->dc_context[ci] = 4;    /* small positive diff category */
  417|  1.10M|      } else {
  418|  1.10M|        v = -v;
  419|  1.10M|        arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
  420|  1.10M|        st += 3;                        /* Table F.4: SN = S0 + 3 */
  421|  1.10M|        entropy->dc_context[ci] = 8;    /* small negative diff category */
  422|  1.10M|      }
  423|       |      /* Figure F.8: Encoding the magnitude category of v */
  424|  1.71M|      m = 0;
  425|  1.71M|      if (v -= 1) {
  ------------------
  |  Branch (425:11): [True: 1.51M, False: 203k]
  ------------------
  426|  1.51M|        arith_encode(cinfo, st, 1);
  427|  1.51M|        m = 1;
  428|  1.51M|        v2 = v;
  429|  1.51M|        st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
  430|  5.28M|        while (v2 >>= 1) {
  ------------------
  |  Branch (430:16): [True: 3.77M, False: 1.51M]
  ------------------
  431|  3.77M|          arith_encode(cinfo, st, 1);
  432|  3.77M|          m <<= 1;
  433|  3.77M|          st += 1;
  434|  3.77M|        }
  435|  1.51M|      }
  436|  1.71M|      arith_encode(cinfo, st, 0);
  437|       |      /* Section F.1.4.4.1.2: Establish dc_context conditioning category */
  438|  1.71M|      if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
  ------------------
  |  Branch (438:11): [True: 0, False: 1.71M]
  ------------------
  439|      0|        entropy->dc_context[ci] = 0;    /* zero diff category */
  440|  1.71M|      else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
  ------------------
  |  Branch (440:16): [True: 1.34M, False: 364k]
  ------------------
  441|  1.34M|        entropy->dc_context[ci] += 8;   /* large diff category */
  442|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  443|  1.71M|      st += 14;
  444|  5.48M|      while (m >>= 1)
  ------------------
  |  Branch (444:14): [True: 3.77M, False: 1.71M]
  ------------------
  445|  3.77M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (445:33): [True: 2.47M, False: 1.29M]
  ------------------
  446|  1.71M|    }
  447|  5.93M|  }
  448|       |
  449|   989k|  return TRUE;
  ------------------
  |  |  210|   989k|#define TRUE    1
  ------------------
  450|   989k|}
jcarith.c:emit_restart:
  326|  7.28M|{
  327|  7.28M|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  328|  7.28M|  int ci;
  329|  7.28M|  jpeg_component_info *compptr;
  330|       |
  331|  7.28M|  finish_pass(cinfo);
  332|       |
  333|  7.28M|  emit_byte(0xFF, cinfo);
  334|  7.28M|  emit_byte(JPEG_RST0 + restart_num, cinfo);
  ------------------
  |  | 1166|  7.28M|#define JPEG_RST0       0xD0    /* RST0 marker code */
  ------------------
  335|       |
  336|       |  /* Re-initialize statistics areas */
  337|  16.7M|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (337:16): [True: 9.44M, False: 7.28M]
  ------------------
  338|  9.44M|    compptr = cinfo->cur_comp_info[ci];
  339|       |    /* DC needs no table for refinement scan */
  340|  9.44M|    if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
  ------------------
  |  Branch (340:9): [True: 809k, False: 8.63M]
  |  Branch (340:42): [True: 2.15M, False: 6.47M]
  |  Branch (340:60): [True: 1.07M, False: 1.07M]
  ------------------
  341|  1.88M|      memset(entropy->dc_stats[compptr->dc_tbl_no], 0, DC_STAT_BINS);
  ------------------
  |  |   69|  1.88M|#define DC_STAT_BINS  64
  ------------------
  342|       |      /* Reset DC predictions to 0 */
  343|  1.88M|      entropy->last_dc_val[ci] = 0;
  344|  1.88M|      entropy->dc_context[ci] = 0;
  345|  1.88M|    }
  346|       |    /* AC needs no table when not present */
  347|  9.44M|    if (cinfo->progressive_mode == 0 || cinfo->Se) {
  ------------------
  |  Branch (347:9): [True: 809k, False: 8.63M]
  |  Branch (347:41): [True: 6.47M, False: 2.15M]
  ------------------
  348|  7.28M|      memset(entropy->ac_stats[compptr->ac_tbl_no], 0, AC_STAT_BINS);
  ------------------
  |  |   70|  7.28M|#define AC_STAT_BINS  256
  ------------------
  349|  7.28M|    }
  350|  9.44M|  }
  351|       |
  352|       |  /* Reset arithmetic encoding variables */
  353|  7.28M|  entropy->c = 0;
  354|  7.28M|  entropy->a = 0x10000L;
  355|  7.28M|  entropy->sc = 0;
  356|  7.28M|  entropy->zc = 0;
  357|  7.28M|  entropy->ct = 11;
  358|  7.28M|  entropy->buffer = -1;  /* empty */
  359|  7.28M|}
jcarith.c:emit_byte:
  124|   118M|{
  125|   118M|  struct jpeg_destination_mgr *dest = cinfo->dest;
  126|       |
  127|   118M|  *dest->next_output_byte++ = (JOCTET)val;
  128|   118M|  if (--dest->free_in_buffer == 0)
  ------------------
  |  Branch (128:7): [True: 3.60k, False: 118M]
  ------------------
  129|  3.60k|    if (!(*dest->empty_output_buffer) (cinfo))
  ------------------
  |  Branch (129:9): [True: 0, False: 3.60k]
  ------------------
  130|      0|      ERREXIT(cinfo, JERR_CANT_SUSPEND);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  131|   118M|}
jcarith.c:arith_encode:
  226|  1.08G|{
  227|  1.08G|  register arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
  228|  1.08G|  register unsigned char nl, nm;
  229|  1.08G|  register JLONG qe, temp;
  230|  1.08G|  register int sv;
  231|       |
  232|       |  /* Fetch values from our compact representation of Table D.2:
  233|       |   * Qe values and probability estimation state machine
  234|       |   */
  235|  1.08G|  sv = *st;
  236|  1.08G|  qe = jpeg_aritab[sv & 0x7F];  /* => Qe_Value */
  237|  1.08G|  nl = qe & 0xFF;  qe >>= 8;    /* Next_Index_LPS + Switch_MPS */
  238|  1.08G|  nm = qe & 0xFF;  qe >>= 8;    /* Next_Index_MPS */
  239|       |
  240|       |  /* Encode & estimation procedures per sections D.1.4 & D.1.5 */
  241|  1.08G|  e->a -= qe;
  242|  1.08G|  if (val != (sv >> 7)) {
  ------------------
  |  Branch (242:7): [True: 313M, False: 773M]
  ------------------
  243|       |    /* Encode the less probable symbol */
  244|   313M|    if (e->a >= qe) {
  ------------------
  |  Branch (244:9): [True: 238M, False: 75.4M]
  ------------------
  245|       |      /* If the interval size (qe) for the less probable symbol (LPS)
  246|       |       * is larger than the interval size for the MPS, then exchange
  247|       |       * the two symbols for coding efficiency, otherwise code the LPS
  248|       |       * as usual: */
  249|   238M|      e->c += e->a;
  250|   238M|      e->a = qe;
  251|   238M|    }
  252|   313M|    *st = (sv & 0x80) ^ nl;     /* Estimate_after_LPS */
  253|   773M|  } else {
  254|       |    /* Encode the more probable symbol */
  255|   773M|    if (e->a >= 0x8000L)
  ------------------
  |  Branch (255:9): [True: 449M, False: 324M]
  ------------------
  256|   449M|      return;  /* A >= 0x8000 -> ready, no renormalization required */
  257|   324M|    if (e->a < qe) {
  ------------------
  |  Branch (257:9): [True: 82.5M, False: 241M]
  ------------------
  258|       |      /* If the interval size (qe) for the less probable symbol (LPS)
  259|       |       * is larger than the interval size for the MPS, then exchange
  260|       |       * the two symbols for coding efficiency: */
  261|  82.5M|      e->c += e->a;
  262|  82.5M|      e->a = qe;
  263|  82.5M|    }
  264|   324M|    *st = (sv & 0x80) ^ nm;     /* Estimate_after_MPS */
  265|   324M|  }
  266|       |
  267|       |  /* Renormalization & data output per section D.1.6 */
  268|   788M|  do {
  269|   788M|    e->a <<= 1;
  270|   788M|    e->c <<= 1;
  271|   788M|    if (--e->ct == 0) {
  ------------------
  |  Branch (271:9): [True: 96.1M, False: 692M]
  ------------------
  272|       |      /* Another byte is ready for output */
  273|  96.1M|      temp = e->c >> 19;
  274|  96.1M|      if (temp > 0xFF) {
  ------------------
  |  Branch (274:11): [True: 3.85M, False: 92.2M]
  ------------------
  275|       |        /* Handle overflow over all stacked 0xFF bytes */
  276|  3.85M|        if (e->buffer >= 0) {
  ------------------
  |  Branch (276:13): [True: 3.85M, False: 0]
  ------------------
  277|  3.85M|          if (e->zc)
  ------------------
  |  Branch (277:15): [True: 14.3k, False: 3.83M]
  ------------------
  278|  14.8k|            do emit_byte(0x00, cinfo);
  279|  14.8k|            while (--e->zc);
  ------------------
  |  Branch (279:20): [True: 492, False: 14.3k]
  ------------------
  280|  3.85M|          emit_byte(e->buffer + 1, cinfo);
  281|  3.85M|          if (e->buffer + 1 == 0xFF)
  ------------------
  |  Branch (281:15): [True: 14.6k, False: 3.83M]
  ------------------
  282|  14.6k|            emit_byte(0x00, cinfo);
  283|  3.85M|        }
  284|  3.85M|        e->zc += e->sc;  /* carry-over converts stacked 0xFF bytes to 0x00 */
  285|  3.85M|        e->sc = 0;
  286|       |        /* Note: The 3 spacer bits in the C register guarantee
  287|       |         * that the new buffer byte can't be 0xFF here
  288|       |         * (see page 160 in the P&M JPEG book). */
  289|  3.85M|        e->buffer = temp & 0xFF;  /* new output byte, might overflow later */
  290|  92.2M|      } else if (temp == 0xFF) {
  ------------------
  |  Branch (290:18): [True: 661k, False: 91.6M]
  ------------------
  291|   661k|        ++e->sc;  /* stack 0xFF byte (which might overflow later) */
  292|  91.6M|      } else {
  293|       |        /* Output all stacked 0xFF bytes, they will not overflow any more */
  294|  91.6M|        if (e->buffer == 0)
  ------------------
  |  Branch (294:13): [True: 555k, False: 91.0M]
  ------------------
  295|   555k|          ++e->zc;
  296|  91.0M|        else if (e->buffer >= 0) {
  ------------------
  |  Branch (296:18): [True: 89.0M, False: 2.02M]
  ------------------
  297|  89.0M|          if (e->zc)
  ------------------
  |  Branch (297:15): [True: 358k, False: 88.6M]
  ------------------
  298|   499k|            do emit_byte(0x00, cinfo);
  299|   499k|            while (--e->zc);
  ------------------
  |  Branch (299:20): [True: 141k, False: 358k]
  ------------------
  300|  89.0M|          emit_byte(e->buffer, cinfo);
  301|  89.0M|        }
  302|  91.6M|        if (e->sc) {
  ------------------
  |  Branch (302:13): [True: 625k, False: 90.9M]
  ------------------
  303|   625k|          if (e->zc)
  ------------------
  |  Branch (303:15): [True: 1.70k, False: 623k]
  ------------------
  304|  1.92k|            do emit_byte(0x00, cinfo);
  305|  1.92k|            while (--e->zc);
  ------------------
  |  Branch (305:20): [True: 219, False: 1.70k]
  ------------------
  306|   640k|          do {
  307|   640k|            emit_byte(0xFF, cinfo);
  308|   640k|            emit_byte(0x00, cinfo);
  309|   640k|          } while (--e->sc);
  ------------------
  |  Branch (309:20): [True: 15.7k, False: 625k]
  ------------------
  310|   625k|        }
  311|  91.6M|        e->buffer = temp & 0xFF;  /* new output byte (can still overflow) */
  312|  91.6M|      }
  313|  96.1M|      e->c &= 0x7FFFFL;
  314|  96.1M|      e->ct += 8;
  315|  96.1M|    }
  316|   788M|  } while (e->a < 0x8000L);
  ------------------
  |  Branch (316:12): [True: 149M, False: 638M]
  ------------------
  317|   638M|}
jcarith.c:encode_mcu_AC_first:
  460|  9.77M|{
  461|  9.77M|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  462|  9.77M|  JBLOCKROW block;
  463|  9.77M|  unsigned char *st;
  464|  9.77M|  int tbl, k, ke;
  465|  9.77M|  int v, v2, m;
  466|       |
  467|       |  /* Emit restart marker if needed */
  468|  9.77M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (468:7): [True: 9.77M, False: 0]
  ------------------
  469|  9.77M|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (469:9): [True: 3.23M, False: 6.53M]
  ------------------
  470|  3.23M|      emit_restart(cinfo, entropy->next_restart_num);
  471|  3.23M|      entropy->restarts_to_go = cinfo->restart_interval;
  472|  3.23M|      entropy->next_restart_num++;
  473|  3.23M|      entropy->next_restart_num &= 7;
  474|  3.23M|    }
  475|  9.77M|    entropy->restarts_to_go--;
  476|  9.77M|  }
  477|       |
  478|       |  /* Encode the MCU data block */
  479|  9.77M|  block = MCU_data[0];
  480|  9.77M|  tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
  481|       |
  482|       |  /* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */
  483|       |
  484|       |  /* Establish EOB (end-of-block) index */
  485|   283M|  for (ke = cinfo->Se; ke > 0; ke--)
  ------------------
  |  Branch (485:24): [True: 276M, False: 7.11M]
  ------------------
  486|       |    /* We must apply the point transform by Al.  For AC coefficients this
  487|       |     * is an integer division with rounding towards 0.  To do this portably
  488|       |     * in C, we shift after obtaining the absolute value.
  489|       |     */
  490|   276M|    if ((v = (*block)[jpeg_natural_order[ke]]) >= 0) {
  ------------------
  |  Branch (490:9): [True: 269M, False: 7.12M]
  ------------------
  491|   269M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (491:11): [True: 1.28M, False: 268M]
  ------------------
  492|   269M|    } else {
  493|  7.12M|      v = -v;
  494|  7.12M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (494:11): [True: 1.36M, False: 5.75M]
  ------------------
  495|  7.12M|    }
  496|       |
  497|       |  /* Figure F.5: Encode_AC_Coefficients */
  498|  25.8M|  for (k = cinfo->Ss; k <= ke; k++) {
  ------------------
  |  Branch (498:23): [True: 16.0M, False: 9.77M]
  ------------------
  499|  16.0M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  500|  16.0M|    arith_encode(cinfo, st, 0);         /* EOB decision */
  501|  51.3M|    for (;;) {
  502|  51.3M|      if ((v = (*block)[jpeg_natural_order[k]]) >= 0) {
  ------------------
  |  Branch (502:11): [True: 33.2M, False: 18.0M]
  ------------------
  503|  33.2M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (503:13): [True: 7.77M, False: 25.4M]
  ------------------
  504|  7.77M|          arith_encode(cinfo, st + 1, 1);
  505|  7.77M|          arith_encode(cinfo, entropy->fixed_bin, 0);
  506|  7.77M|          break;
  507|  7.77M|        }
  508|  33.2M|      } else {
  509|  18.0M|        v = -v;
  510|  18.0M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (510:13): [True: 8.26M, False: 9.82M]
  ------------------
  511|  8.26M|          arith_encode(cinfo, st + 1, 1);
  512|  8.26M|          arith_encode(cinfo, entropy->fixed_bin, 1);
  513|  8.26M|          break;
  514|  8.26M|        }
  515|  18.0M|      }
  516|  35.2M|      arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  517|  35.2M|    }
  518|  16.0M|    st += 2;
  519|       |    /* Figure F.8: Encoding the magnitude category of v */
  520|  16.0M|    m = 0;
  521|  16.0M|    if (v -= 1) {
  ------------------
  |  Branch (521:9): [True: 5.78M, False: 10.2M]
  ------------------
  522|  5.78M|      arith_encode(cinfo, st, 1);
  523|  5.78M|      m = 1;
  524|  5.78M|      v2 = v;
  525|  5.78M|      if (v2 >>= 1) {
  ------------------
  |  Branch (525:11): [True: 2.71M, False: 3.06M]
  ------------------
  526|  2.71M|        arith_encode(cinfo, st, 1);
  527|  2.71M|        m <<= 1;
  528|  2.71M|        st = entropy->ac_stats[tbl] +
  529|  2.71M|             (k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
  ------------------
  |  Branch (529:15): [True: 751k, False: 1.96M]
  ------------------
  530|  3.71M|        while (v2 >>= 1) {
  ------------------
  |  Branch (530:16): [True: 994k, False: 2.71M]
  ------------------
  531|   994k|          arith_encode(cinfo, st, 1);
  532|   994k|          m <<= 1;
  533|   994k|          st += 1;
  534|   994k|        }
  535|  2.71M|      }
  536|  5.78M|    }
  537|  16.0M|    arith_encode(cinfo, st, 0);
  538|       |    /* Figure F.9: Encoding the magnitude bit pattern of v */
  539|  16.0M|    st += 14;
  540|  19.7M|    while (m >>= 1)
  ------------------
  |  Branch (540:12): [True: 3.71M, False: 16.0M]
  ------------------
  541|  3.71M|      arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (541:31): [True: 1.20M, False: 2.51M]
  ------------------
  542|  16.0M|  }
  543|       |  /* Encode EOB decision only if k <= cinfo->Se */
  544|  9.77M|  if (k <= cinfo->Se) {
  ------------------
  |  Branch (544:7): [True: 8.98M, False: 785k]
  ------------------
  545|  8.98M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  546|  8.98M|    arith_encode(cinfo, st, 1);
  547|  8.98M|  }
  548|       |
  549|  9.77M|  return TRUE;
  ------------------
  |  |  210|  9.77M|#define TRUE    1
  ------------------
  550|  9.77M|}
jcarith.c:encode_mcu_DC_refine:
  559|   989k|{
  560|   989k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  561|   989k|  unsigned char *st;
  562|   989k|  int Al, blkn;
  563|       |
  564|       |  /* Emit restart marker if needed */
  565|   989k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (565:7): [True: 989k, False: 0]
  ------------------
  566|   989k|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (566:9): [True: 269k, False: 719k]
  ------------------
  567|   269k|      emit_restart(cinfo, entropy->next_restart_num);
  568|   269k|      entropy->restarts_to_go = cinfo->restart_interval;
  569|   269k|      entropy->next_restart_num++;
  570|   269k|      entropy->next_restart_num &= 7;
  571|   269k|    }
  572|   989k|    entropy->restarts_to_go--;
  573|   989k|  }
  574|       |
  575|   989k|  st = entropy->fixed_bin;      /* use fixed probability estimation */
  576|   989k|  Al = cinfo->Al;
  577|       |
  578|       |  /* Encode the MCU data blocks */
  579|  6.92M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (579:18): [True: 5.93M, False: 989k]
  ------------------
  580|       |    /* We simply emit the Al'th bit of the DC coefficient value. */
  581|  5.93M|    arith_encode(cinfo, st, (MCU_data[blkn][0][0] >> Al) & 1);
  582|  5.93M|  }
  583|       |
  584|   989k|  return TRUE;
  ------------------
  |  |  210|   989k|#define TRUE    1
  ------------------
  585|   989k|}
jcarith.c:encode_mcu_AC_refine:
  594|  9.77M|{
  595|  9.77M|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  596|  9.77M|  JBLOCKROW block;
  597|  9.77M|  unsigned char *st;
  598|  9.77M|  int tbl, k, ke, kex;
  599|  9.77M|  int v;
  600|       |
  601|       |  /* Emit restart marker if needed */
  602|  9.77M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (602:7): [True: 9.77M, False: 0]
  ------------------
  603|  9.77M|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (603:9): [True: 3.23M, False: 6.53M]
  ------------------
  604|  3.23M|      emit_restart(cinfo, entropy->next_restart_num);
  605|  3.23M|      entropy->restarts_to_go = cinfo->restart_interval;
  606|  3.23M|      entropy->next_restart_num++;
  607|  3.23M|      entropy->next_restart_num &= 7;
  608|  3.23M|    }
  609|  9.77M|    entropy->restarts_to_go--;
  610|  9.77M|  }
  611|       |
  612|       |  /* Encode the MCU data block */
  613|  9.77M|  block = MCU_data[0];
  614|  9.77M|  tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
  615|       |
  616|       |  /* Section G.1.3.3: Encoding of AC coefficients */
  617|       |
  618|       |  /* Establish EOB (end-of-block) index */
  619|   489M|  for (ke = cinfo->Se; ke > 0; ke--)
  ------------------
  |  Branch (619:24): [True: 482M, False: 6.90M]
  ------------------
  620|       |    /* We must apply the point transform by Al.  For AC coefficients this
  621|       |     * is an integer division with rounding towards 0.  To do this portably
  622|       |     * in C, we shift after obtaining the absolute value.
  623|       |     */
  624|   482M|    if ((v = (*block)[jpeg_natural_order[ke]]) >= 0) {
  ------------------
  |  Branch (624:9): [True: 479M, False: 2.83M]
  ------------------
  625|   479M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (625:11): [True: 1.36M, False: 478M]
  ------------------
  626|   479M|    } else {
  627|  2.83M|      v = -v;
  628|  2.83M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (628:11): [True: 1.49M, False: 1.33M]
  ------------------
  629|  2.83M|    }
  630|       |
  631|       |  /* Establish EOBx (previous stage end-of-block) index */
  632|  27.2M|  for (kex = ke; kex > 0; kex--)
  ------------------
  |  Branch (632:18): [True: 20.2M, False: 6.97M]
  ------------------
  633|  20.2M|    if ((v = (*block)[jpeg_natural_order[kex]]) >= 0) {
  ------------------
  |  Branch (633:9): [True: 13.6M, False: 6.64M]
  ------------------
  634|  13.6M|      if (v >>= cinfo->Ah) break;
  ------------------
  |  Branch (634:11): [True: 1.34M, False: 12.2M]
  ------------------
  635|  13.6M|    } else {
  636|  6.64M|      v = -v;
  637|  6.64M|      if (v >>= cinfo->Ah) break;
  ------------------
  |  Branch (637:11): [True: 1.44M, False: 5.19M]
  ------------------
  638|  6.64M|    }
  639|       |
  640|       |  /* Figure G.10: Encode_AC_Coefficients_SA */
  641|  88.3M|  for (k = cinfo->Ss; k <= ke; k++) {
  ------------------
  |  Branch (641:23): [True: 78.6M, False: 9.77M]
  ------------------
  642|  78.6M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  643|  78.6M|    if (k > kex)
  ------------------
  |  Branch (643:9): [True: 6.74M, False: 71.8M]
  ------------------
  644|  6.74M|      arith_encode(cinfo, st, 0);       /* EOB decision */
  645|   135M|    for (;;) {
  646|   135M|      if ((v = (*block)[jpeg_natural_order[k]]) >= 0) {
  ------------------
  |  Branch (646:11): [True: 89.5M, False: 46.2M]
  ------------------
  647|  89.5M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (647:13): [True: 38.7M, False: 50.8M]
  ------------------
  648|  38.7M|          if (v >> 1)                   /* previously nonzero coef */
  ------------------
  |  Branch (648:15): [True: 23.3M, False: 15.3M]
  ------------------
  649|  23.3M|            arith_encode(cinfo, st + 2, (v & 1));
  650|  15.3M|          else {                        /* newly nonzero coef */
  651|  15.3M|            arith_encode(cinfo, st + 1, 1);
  652|  15.3M|            arith_encode(cinfo, entropy->fixed_bin, 0);
  653|  15.3M|          }
  654|  38.7M|          break;
  655|  38.7M|        }
  656|  89.5M|      } else {
  657|  46.2M|        v = -v;
  658|  46.2M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (658:13): [True: 39.9M, False: 6.33M]
  ------------------
  659|  39.9M|          if (v >> 1)                   /* previously nonzero coef */
  ------------------
  |  Branch (659:15): [True: 24.3M, False: 15.5M]
  ------------------
  660|  24.3M|            arith_encode(cinfo, st + 2, (v & 1));
  661|  15.5M|          else {                        /* newly nonzero coef */
  662|  15.5M|            arith_encode(cinfo, st + 1, 1);
  663|  15.5M|            arith_encode(cinfo, entropy->fixed_bin, 1);
  664|  15.5M|          }
  665|  39.9M|          break;
  666|  39.9M|        }
  667|  46.2M|      }
  668|  57.1M|      arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  669|  57.1M|    }
  670|  78.6M|  }
  671|       |  /* Encode EOB decision only if k <= cinfo->Se */
  672|  9.77M|  if (k <= cinfo->Se) {
  ------------------
  |  Branch (672:7): [True: 8.97M, False: 791k]
  ------------------
  673|  8.97M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  674|  8.97M|    arith_encode(cinfo, st, 1);
  675|  8.97M|  }
  676|       |
  677|  9.77M|  return TRUE;
  ------------------
  |  |  210|  9.77M|#define TRUE    1
  ------------------
  678|  9.77M|}
jcarith.c:encode_mcu:
  687|   630k|{
  688|   630k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  689|   630k|  jpeg_component_info *compptr;
  690|   630k|  JBLOCKROW block;
  691|   630k|  unsigned char *st;
  692|   630k|  int blkn, ci, tbl, k, ke;
  693|   630k|  int v, v2, m;
  694|       |
  695|       |  /* Emit restart marker if needed */
  696|   630k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (696:7): [True: 630k, False: 0]
  ------------------
  697|   630k|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (697:9): [True: 269k, False: 360k]
  ------------------
  698|   269k|      emit_restart(cinfo, entropy->next_restart_num);
  699|   269k|      entropy->restarts_to_go = cinfo->restart_interval;
  700|   269k|      entropy->next_restart_num++;
  701|   269k|      entropy->next_restart_num &= 7;
  702|   269k|    }
  703|   630k|    entropy->restarts_to_go--;
  704|   630k|  }
  705|       |
  706|       |  /* Encode the MCU data blocks */
  707|  4.41M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (707:18): [True: 3.78M, False: 630k]
  ------------------
  708|  3.78M|    block = MCU_data[blkn];
  709|  3.78M|    ci = cinfo->MCU_membership[blkn];
  710|  3.78M|    compptr = cinfo->cur_comp_info[ci];
  711|       |
  712|       |    /* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */
  713|       |
  714|  3.78M|    tbl = compptr->dc_tbl_no;
  715|       |
  716|       |    /* Table F.4: Point to statistics bin S0 for DC coefficient coding */
  717|  3.78M|    st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
  718|       |
  719|       |    /* Figure F.4: Encode_DC_DIFF */
  720|  3.78M|    if ((v = (*block)[0] - entropy->last_dc_val[ci]) == 0) {
  ------------------
  |  Branch (720:9): [True: 1.69M, False: 2.08M]
  ------------------
  721|  1.69M|      arith_encode(cinfo, st, 0);
  722|  1.69M|      entropy->dc_context[ci] = 0;      /* zero diff category */
  723|  2.08M|    } else {
  724|  2.08M|      entropy->last_dc_val[ci] = (*block)[0];
  725|  2.08M|      arith_encode(cinfo, st, 1);
  726|       |      /* Figure F.6: Encoding nonzero value v */
  727|       |      /* Figure F.7: Encoding the sign of v */
  728|  2.08M|      if (v > 0) {
  ------------------
  |  Branch (728:11): [True: 693k, False: 1.39M]
  ------------------
  729|   693k|        arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
  730|   693k|        st += 2;                        /* Table F.4: SP = S0 + 2 */
  731|   693k|        entropy->dc_context[ci] = 4;    /* small positive diff category */
  732|  1.39M|      } else {
  733|  1.39M|        v = -v;
  734|  1.39M|        arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
  735|  1.39M|        st += 3;                        /* Table F.4: SN = S0 + 3 */
  736|  1.39M|        entropy->dc_context[ci] = 8;    /* small negative diff category */
  737|  1.39M|      }
  738|       |      /* Figure F.8: Encoding the magnitude category of v */
  739|  2.08M|      m = 0;
  740|  2.08M|      if (v -= 1) {
  ------------------
  |  Branch (740:11): [True: 2.07M, False: 5.09k]
  ------------------
  741|  2.07M|        arith_encode(cinfo, st, 1);
  742|  2.07M|        m = 1;
  743|  2.07M|        v2 = v;
  744|  2.07M|        st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
  745|  18.9M|        while (v2 >>= 1) {
  ------------------
  |  Branch (745:16): [True: 16.8M, False: 2.07M]
  ------------------
  746|  16.8M|          arith_encode(cinfo, st, 1);
  747|  16.8M|          m <<= 1;
  748|  16.8M|          st += 1;
  749|  16.8M|        }
  750|  2.07M|      }
  751|  2.08M|      arith_encode(cinfo, st, 0);
  752|       |      /* Section F.1.4.4.1.2: Establish dc_context conditioning category */
  753|  2.08M|      if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
  ------------------
  |  Branch (753:11): [True: 0, False: 2.08M]
  ------------------
  754|      0|        entropy->dc_context[ci] = 0;    /* zero diff category */
  755|  2.08M|      else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
  ------------------
  |  Branch (755:16): [True: 2.07M, False: 10.2k]
  ------------------
  756|  2.07M|        entropy->dc_context[ci] += 8;   /* large diff category */
  757|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  758|  2.08M|      st += 14;
  759|  18.9M|      while (m >>= 1)
  ------------------
  |  Branch (759:14): [True: 16.8M, False: 2.08M]
  ------------------
  760|  16.8M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (760:33): [True: 10.5M, False: 6.29M]
  ------------------
  761|  2.08M|    }
  762|       |
  763|       |    /* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */
  764|       |
  765|  3.78M|    tbl = compptr->ac_tbl_no;
  766|       |
  767|       |    /* Establish EOB (end-of-block) index */
  768|   163M|    for (ke = DCTSIZE2 - 1; ke > 0; ke--)
  ------------------
  |  |   67|  3.78M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (768:29): [True: 161M, False: 2.14M]
  ------------------
  769|   161M|      if ((*block)[jpeg_natural_order[ke]]) break;
  ------------------
  |  Branch (769:11): [True: 1.64M, False: 159M]
  ------------------
  770|       |
  771|       |    /* Figure F.5: Encode_AC_Coefficients */
  772|  60.8M|    for (k = 1; k <= ke; k++) {
  ------------------
  |  Branch (772:17): [True: 57.1M, False: 3.78M]
  ------------------
  773|  57.1M|      st = entropy->ac_stats[tbl] + 3 * (k - 1);
  774|  57.1M|      arith_encode(cinfo, st, 0);       /* EOB decision */
  775|  78.6M|      while ((v = (*block)[jpeg_natural_order[k]]) == 0) {
  ------------------
  |  Branch (775:14): [True: 21.5M, False: 57.1M]
  ------------------
  776|  21.5M|        arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  777|  21.5M|      }
  778|  57.1M|      arith_encode(cinfo, st + 1, 1);
  779|       |      /* Figure F.6: Encoding nonzero value v */
  780|       |      /* Figure F.7: Encoding the sign of v */
  781|  57.1M|      if (v > 0) {
  ------------------
  |  Branch (781:11): [True: 28.2M, False: 28.8M]
  ------------------
  782|  28.2M|        arith_encode(cinfo, entropy->fixed_bin, 0);
  783|  28.8M|      } else {
  784|  28.8M|        v = -v;
  785|  28.8M|        arith_encode(cinfo, entropy->fixed_bin, 1);
  786|  28.8M|      }
  787|  57.1M|      st += 2;
  788|       |      /* Figure F.8: Encoding the magnitude category of v */
  789|  57.1M|      m = 0;
  790|  57.1M|      if (v -= 1) {
  ------------------
  |  Branch (790:11): [True: 53.1M, False: 3.95M]
  ------------------
  791|  53.1M|        arith_encode(cinfo, st, 1);
  792|  53.1M|        m = 1;
  793|  53.1M|        v2 = v;
  794|  53.1M|        if (v2 >>= 1) {
  ------------------
  |  Branch (794:13): [True: 49.8M, False: 3.27M]
  ------------------
  795|  49.8M|          arith_encode(cinfo, st, 1);
  796|  49.8M|          m <<= 1;
  797|  49.8M|          st = entropy->ac_stats[tbl] +
  798|  49.8M|               (k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
  ------------------
  |  Branch (798:17): [True: 5.83M, False: 44.0M]
  ------------------
  799|   204M|          while (v2 >>= 1) {
  ------------------
  |  Branch (799:18): [True: 154M, False: 49.8M]
  ------------------
  800|   154M|            arith_encode(cinfo, st, 1);
  801|   154M|            m <<= 1;
  802|   154M|            st += 1;
  803|   154M|          }
  804|  49.8M|        }
  805|  53.1M|      }
  806|  57.1M|      arith_encode(cinfo, st, 0);
  807|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  808|  57.1M|      st += 14;
  809|   261M|      while (m >>= 1)
  ------------------
  |  Branch (809:14): [True: 204M, False: 57.1M]
  ------------------
  810|   204M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (810:33): [True: 93.2M, False: 111M]
  ------------------
  811|  57.1M|    }
  812|       |    /* Encode EOB decision only if k <= DCTSIZE2 - 1 */
  813|  3.78M|    if (k <= DCTSIZE2 - 1) {
  ------------------
  |  |   67|  3.78M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (813:9): [True: 3.02M, False: 753k]
  ------------------
  814|  3.02M|      st = entropy->ac_stats[tbl] + 3 * (k - 1);
  815|  3.02M|      arith_encode(cinfo, st, 1);
  816|  3.02M|    }
  817|  3.78M|  }
  818|       |
  819|   630k|  return TRUE;
  ------------------
  |  |  210|   630k|#define TRUE    1
  ------------------
  820|   630k|}
jcarith.c:finish_pass:
  140|  7.33M|{
  141|  7.33M|  arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
  142|  7.33M|  JLONG temp;
  143|       |
  144|       |  /* Section D.1.8: Termination of encoding */
  145|       |
  146|       |  /* Find the e->c in the coding interval with the largest
  147|       |   * number of trailing zero bits */
  148|  7.33M|  if ((temp = (e->a - 1 + e->c) & 0xFFFF0000UL) < e->c)
  ------------------
  |  Branch (148:7): [True: 5.59M, False: 1.74M]
  ------------------
  149|  5.59M|    e->c = temp + 0x8000L;
  150|  1.74M|  else
  151|  1.74M|    e->c = temp;
  152|       |  /* Send remaining bytes to output */
  153|  7.33M|  e->c <<= e->ct;
  154|  7.33M|  if (e->c & 0xF8000000UL) {
  ------------------
  |  Branch (154:7): [True: 101k, False: 7.23M]
  ------------------
  155|       |    /* One final overflow has to be handled */
  156|   101k|    if (e->buffer >= 0) {
  ------------------
  |  Branch (156:9): [True: 101k, False: 0]
  ------------------
  157|   101k|      if (e->zc)
  ------------------
  |  Branch (157:11): [True: 5.90k, False: 95.5k]
  ------------------
  158|  6.07k|        do emit_byte(0x00, cinfo);
  159|  6.07k|        while (--e->zc);
  ------------------
  |  Branch (159:16): [True: 171, False: 5.90k]
  ------------------
  160|   101k|      emit_byte(e->buffer + 1, cinfo);
  161|   101k|      if (e->buffer + 1 == 0xFF)
  ------------------
  |  Branch (161:11): [True: 618, False: 100k]
  ------------------
  162|    618|        emit_byte(0x00, cinfo);
  163|   101k|    }
  164|   101k|    e->zc += e->sc;  /* carry-over converts stacked 0xFF bytes to 0x00 */
  165|   101k|    e->sc = 0;
  166|  7.23M|  } else {
  167|  7.23M|    if (e->buffer == 0)
  ------------------
  |  Branch (167:9): [True: 60.4k, False: 7.17M]
  ------------------
  168|  60.4k|      ++e->zc;
  169|  7.17M|    else if (e->buffer >= 0) {
  ------------------
  |  Branch (169:14): [True: 1.86M, False: 5.31M]
  ------------------
  170|  1.86M|      if (e->zc)
  ------------------
  |  Branch (170:11): [True: 7.00k, False: 1.85M]
  ------------------
  171|  10.5k|        do emit_byte(0x00, cinfo);
  172|  10.5k|        while (--e->zc);
  ------------------
  |  Branch (172:16): [True: 3.55k, False: 7.00k]
  ------------------
  173|  1.86M|      emit_byte(e->buffer, cinfo);
  174|  1.86M|    }
  175|  7.23M|    if (e->sc) {
  ------------------
  |  Branch (175:9): [True: 4.55k, False: 7.23M]
  ------------------
  176|  4.55k|      if (e->zc)
  ------------------
  |  Branch (176:11): [True: 66, False: 4.49k]
  ------------------
  177|     79|        do emit_byte(0x00, cinfo);
  178|     79|        while (--e->zc);
  ------------------
  |  Branch (178:16): [True: 13, False: 66]
  ------------------
  179|  4.64k|      do {
  180|  4.64k|        emit_byte(0xFF, cinfo);
  181|  4.64k|        emit_byte(0x00, cinfo);
  182|  4.64k|      } while (--e->sc);
  ------------------
  |  Branch (182:16): [True: 93, False: 4.55k]
  ------------------
  183|  4.55k|    }
  184|  7.23M|  }
  185|       |  /* Output final bytes only if they are not 0x00 */
  186|  7.33M|  if (e->c & 0x7FFF800L) {
  ------------------
  |  Branch (186:7): [True: 7.28M, False: 53.4k]
  ------------------
  187|  7.28M|    if (e->zc)  /* output final pending zero bytes */
  ------------------
  |  Branch (187:9): [True: 60.0k, False: 7.22M]
  ------------------
  188|  69.4k|      do emit_byte(0x00, cinfo);
  189|  69.4k|      while (--e->zc);
  ------------------
  |  Branch (189:14): [True: 9.42k, False: 60.0k]
  ------------------
  190|  7.28M|    emit_byte((e->c >> 19) & 0xFF, cinfo);
  191|  7.28M|    if (((e->c >> 19) & 0xFF) == 0xFF)
  ------------------
  |  Branch (191:9): [True: 3.31k, False: 7.28M]
  ------------------
  192|  3.31k|      emit_byte(0x00, cinfo);
  193|  7.28M|    if (e->c & 0x7F800L) {
  ------------------
  |  Branch (193:9): [True: 362k, False: 6.92M]
  ------------------
  194|   362k|      emit_byte((e->c >> 11) & 0xFF, cinfo);
  195|   362k|      if (((e->c >> 11) & 0xFF) == 0xFF)
  ------------------
  |  Branch (195:11): [True: 0, False: 362k]
  ------------------
  196|      0|        emit_byte(0x00, cinfo);
  197|   362k|    }
  198|  7.28M|  }
  199|  7.33M|}

j12init_c_coef_controller:
  437|  20.8k|{
  438|  20.8k|  my_coef_ptr coef;
  439|       |
  440|  20.8k|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  20.8k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (440:7): [True: 0, False: 20.8k]
  ------------------
  441|      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)))
  ------------------
  442|       |
  443|  20.8k|  coef = (my_coef_ptr)
  444|  20.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  20.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  445|  20.8k|                                sizeof(my_coef_controller));
  446|  20.8k|  memset(coef, 0, sizeof(my_coef_controller));
  447|  20.8k|  cinfo->coef = (struct jpeg_c_coef_controller *)coef;
  448|  20.8k|  coef->pub.start_pass = start_pass_coef;
  449|       |
  450|       |  /* Create the coefficient buffer. */
  451|  20.8k|  if (need_full_buffer) {
  ------------------
  |  Branch (451:7): [True: 18.0k, False: 2.83k]
  ------------------
  452|  18.0k|#ifdef FULL_COEF_BUFFER_SUPPORTED
  453|       |    /* Allocate a full-image virtual array for each component, */
  454|       |    /* padded to a multiple of samp_factor DCT blocks in each direction. */
  455|  18.0k|    int ci;
  456|  18.0k|    jpeg_component_info *compptr;
  457|       |
  458|  62.0k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (458:46): [True: 43.9k, False: 18.0k]
  ------------------
  459|  43.9k|         ci++, compptr++) {
  460|  43.9k|      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
  461|  43.9k|        ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
  ------------------
  |  |  889|  43.9k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                      ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
  ------------------
  |  |  207|  43.9k|#define FALSE   0               /* values of boolean */
  ------------------
  462|  43.9k|         (JDIMENSION)jround_up((long)compptr->width_in_blocks,
  463|  43.9k|                               (long)compptr->h_samp_factor),
  464|  43.9k|         (JDIMENSION)jround_up((long)compptr->height_in_blocks,
  465|  43.9k|                               (long)compptr->v_samp_factor),
  466|  43.9k|         (JDIMENSION)compptr->v_samp_factor);
  467|  43.9k|    }
  468|       |#else
  469|       |    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  470|       |#endif
  471|  18.0k|  } else {
  472|       |    /* We only need a single-MCU buffer. */
  473|  2.83k|    JBLOCKROW buffer;
  474|  2.83k|    int i;
  475|       |
  476|  2.83k|    buffer = (JBLOCKROW)
  477|  2.83k|      (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  2.83k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  478|  2.83k|                                  C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
  ------------------
  |  |   80|  2.83k|#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on data units/MCU */
  ------------------
  479|  31.2k|    for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
  ------------------
  |  |   80|  31.2k|#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on data units/MCU */
  ------------------
  |  Branch (479:17): [True: 28.3k, False: 2.83k]
  ------------------
  480|  28.3k|      coef->MCU_buffer[i] = buffer + i;
  481|  28.3k|    }
  482|       |    coef->whole_image[0] = NULL; /* flag for no virtual arrays */
  483|  2.83k|  }
  484|  20.8k|}
jccoefct-12.c:start_pass_coef:
  104|   116k|{
  105|   116k|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  106|       |
  107|   116k|  coef->iMCU_row_num = 0;
  108|   116k|  start_iMCU_row(cinfo);
  109|       |
  110|   116k|  switch (pass_mode) {
  111|  2.83k|  case JBUF_PASS_THRU:
  ------------------
  |  Branch (111:3): [True: 2.83k, False: 113k]
  ------------------
  112|  2.83k|    if (coef->whole_image[0] != NULL)
  ------------------
  |  Branch (112:9): [True: 0, False: 2.83k]
  ------------------
  113|      0|      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  114|  2.83k|    coef->pub._compress_data = compress_data;
  ------------------
  |  |  132|  2.83k|#define _compress_data  compress_data_12
  ------------------
  115|  2.83k|    break;
  116|      0|#ifdef FULL_COEF_BUFFER_SUPPORTED
  117|  18.0k|  case JBUF_SAVE_AND_PASS:
  ------------------
  |  Branch (117:3): [True: 18.0k, False: 98.5k]
  ------------------
  118|  18.0k|    if (coef->whole_image[0] == NULL)
  ------------------
  |  Branch (118:9): [True: 0, False: 18.0k]
  ------------------
  119|      0|      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  120|  18.0k|    coef->pub._compress_data = compress_first_pass;
  ------------------
  |  |  132|  18.0k|#define _compress_data  compress_data_12
  ------------------
  121|  18.0k|    break;
  122|  95.7k|  case JBUF_CRANK_DEST:
  ------------------
  |  Branch (122:3): [True: 95.7k, False: 20.8k]
  ------------------
  123|  95.7k|    if (coef->whole_image[0] == NULL)
  ------------------
  |  Branch (123:9): [True: 0, False: 95.7k]
  ------------------
  124|      0|      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  125|  95.7k|    coef->pub._compress_data = compress_output;
  ------------------
  |  |  132|  95.7k|#define _compress_data  compress_data_12
  ------------------
  126|  95.7k|    break;
  127|      0|#endif
  128|      0|  default:
  ------------------
  |  Branch (128:3): [True: 0, False: 116k]
  ------------------
  129|      0|    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  130|      0|    break;
  131|   116k|  }
  132|   116k|}
jccoefct-12.c:start_iMCU_row:
   77|  14.5M|{
   78|  14.5M|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
   79|       |
   80|       |  /* In an interleaved scan, an MCU row is the same as an iMCU row.
   81|       |   * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
   82|       |   * But at the bottom of the image, process only what's left.
   83|       |   */
   84|  14.5M|  if (cinfo->comps_in_scan > 1) {
  ------------------
  |  Branch (84:7): [True: 4.10M, False: 10.4M]
  ------------------
   85|  4.10M|    coef->MCU_rows_per_iMCU_row = 1;
   86|  10.4M|  } else {
   87|  10.4M|    if (coef->iMCU_row_num < (cinfo->total_iMCU_rows - 1))
  ------------------
  |  Branch (87:9): [True: 10.2M, False: 181k]
  ------------------
   88|  10.2M|      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
   89|   181k|    else
   90|   181k|      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
   91|  10.4M|  }
   92|       |
   93|  14.5M|  coef->mcu_ctr = 0;
   94|  14.5M|  coef->MCU_vert_offset = 0;
   95|  14.5M|}
jccoefct-12.c:compress_data:
  147|   272k|{
  148|   272k|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  149|   272k|  JDIMENSION MCU_col_num;       /* index of current MCU within row */
  150|   272k|  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
  151|   272k|  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
  152|   272k|  int blkn, bi, ci, yindex, yoffset, blockcnt;
  153|   272k|  JDIMENSION ypos, xpos;
  154|   272k|  jpeg_component_info *compptr;
  155|       |
  156|       |  /* Loop to write as much as one whole iMCU row */
  157|   545k|  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
  ------------------
  |  Branch (157:41): [True: 272k, False: 272k]
  ------------------
  158|   272k|       yoffset++) {
  159|   902k|    for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col;
  ------------------
  |  Branch (159:39): [True: 630k, False: 272k]
  ------------------
  160|   630k|         MCU_col_num++) {
  161|       |      /* Determine where data comes from in input_buf and do the DCT thing.
  162|       |       * Each call on forward_DCT processes a horizontal row of DCT blocks
  163|       |       * as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks
  164|       |       * sequentially.  Dummy blocks at the right or bottom edge are filled in
  165|       |       * specially.  The data in them does not matter for image reconstruction,
  166|       |       * so we fill them with values that will encode to the smallest amount of
  167|       |       * data, viz: all zeroes in the AC entries, DC entries equal to previous
  168|       |       * block's DC value.  (Thanks to Thomas Kinsman for this idea.)
  169|       |       */
  170|   630k|      blkn = 0;
  171|  2.52M|      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (171:20): [True: 1.89M, False: 630k]
  ------------------
  172|  1.89M|        compptr = cinfo->cur_comp_info[ci];
  173|  1.89M|        blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width :
  ------------------
  |  Branch (173:20): [True: 1.07M, False: 817k]
  ------------------
  174|  1.89M|                                                  compptr->last_col_width;
  175|  1.89M|        xpos = MCU_col_num * compptr->MCU_sample_width;
  176|  1.89M|        ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */
  ------------------
  |  |   66|  1.89M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  177|  4.41M|        for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
  ------------------
  |  Branch (177:26): [True: 2.52M, False: 1.89M]
  ------------------
  178|  2.52M|          if (coef->iMCU_row_num < last_iMCU_row ||
  ------------------
  |  Branch (178:15): [True: 1.18M, False: 1.33M]
  ------------------
  179|  2.25M|              yoffset + yindex < compptr->last_row_height) {
  ------------------
  |  Branch (179:15): [True: 1.06M, False: 264k]
  ------------------
  180|  2.25M|            (*cinfo->fdct->_forward_DCT) (cinfo, compptr,
  ------------------
  |  |  138|  2.25M|#define _forward_DCT  forward_DCT_12
  ------------------
  181|  2.25M|                                          input_buf[compptr->component_index],
  182|  2.25M|                                          coef->MCU_buffer[blkn],
  183|  2.25M|                                          ypos, xpos, (JDIMENSION)blockcnt);
  184|  2.25M|            if (blockcnt < compptr->MCU_width) {
  ------------------
  |  Branch (184:17): [True: 538k, False: 1.71M]
  ------------------
  185|       |              /* Create some dummy blocks at the right edge of the image. */
  186|   538k|              jzero_far((void *)coef->MCU_buffer[blkn + blockcnt],
  187|   538k|                        (compptr->MCU_width - blockcnt) * sizeof(JBLOCK));
  188|  1.07M|              for (bi = blockcnt; bi < compptr->MCU_width; bi++) {
  ------------------
  |  Branch (188:35): [True: 538k, False: 538k]
  ------------------
  189|   538k|                coef->MCU_buffer[blkn + bi][0][0] =
  190|   538k|                  coef->MCU_buffer[blkn + bi - 1][0][0];
  191|   538k|              }
  192|   538k|            }
  193|  2.25M|          } else {
  194|       |            /* Create a row of dummy blocks at the bottom of the image. */
  195|   264k|            jzero_far((void *)coef->MCU_buffer[blkn],
  196|   264k|                      compptr->MCU_width * sizeof(JBLOCK));
  197|   792k|            for (bi = 0; bi < compptr->MCU_width; bi++) {
  ------------------
  |  Branch (197:26): [True: 528k, False: 264k]
  ------------------
  198|   528k|              coef->MCU_buffer[blkn + bi][0][0] =
  199|   528k|                coef->MCU_buffer[blkn - 1][0][0];
  200|   528k|            }
  201|   264k|          }
  202|  2.52M|          blkn += compptr->MCU_width;
  203|  2.52M|          ypos += DCTSIZE;
  ------------------
  |  |   66|  2.52M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  204|  2.52M|        }
  205|  1.89M|      }
  206|       |      /* Try to write the MCU.  In event of a suspension failure, we will
  207|       |       * re-DCT the MCU on restart (a bit inefficient, could be fixed...)
  208|       |       */
  209|       |#ifdef WITH_PROFILE
  210|       |      cinfo->master->start = getTime();
  211|       |#endif
  212|   630k|      if (!(*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
  ------------------
  |  Branch (212:11): [True: 0, False: 630k]
  ------------------
  213|       |        /* Suspension forced; update state counters and exit */
  214|      0|        coef->MCU_vert_offset = yoffset;
  215|      0|        coef->mcu_ctr = MCU_col_num;
  216|       |#ifdef WITH_PROFILE
  217|       |        cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
  218|       |        cinfo->master->entropy_mcoeffs +=
  219|       |          (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
  220|       |#endif
  221|      0|        return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  222|      0|      }
  223|       |#ifdef WITH_PROFILE
  224|       |      cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
  225|       |      cinfo->master->entropy_mcoeffs +=
  226|       |        (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
  227|       |#endif
  228|   630k|    }
  229|       |    /* Completed an MCU row, but perhaps not an iMCU row */
  230|   272k|    coef->mcu_ctr = 0;
  231|   272k|  }
  232|       |  /* Completed the iMCU row, advance counters for next one */
  233|   272k|  coef->iMCU_row_num++;
  234|   272k|  start_iMCU_row(cinfo);
  235|   272k|  return TRUE;
  ------------------
  |  |  210|   272k|#define TRUE    1
  ------------------
  236|   272k|}
jccoefct-12.c:compress_first_pass:
  264|  2.89M|{
  265|  2.89M|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  266|  2.89M|  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
  267|  2.89M|  JDIMENSION blocks_across, MCUs_across, MCUindex;
  268|  2.89M|  int bi, ci, h_samp_factor, block_row, block_rows, ndummy;
  269|  2.89M|  JCOEF lastDC;
  270|  2.89M|  jpeg_component_info *compptr;
  271|  2.89M|  JBLOCKARRAY buffer;
  272|  2.89M|  JBLOCKROW thisblockrow, lastblockrow;
  273|       |
  274|  9.85M|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (274:44): [True: 6.96M, False: 2.89M]
  ------------------
  275|  6.96M|       ci++, compptr++) {
  276|       |    /* Align the virtual buffer for this component. */
  277|  6.96M|    buffer = (*cinfo->mem->access_virt_barray)
  278|  6.96M|      ((j_common_ptr)cinfo, coef->whole_image[ci],
  279|  6.96M|       coef->iMCU_row_num * compptr->v_samp_factor,
  280|  6.96M|       (JDIMENSION)compptr->v_samp_factor, TRUE);
  ------------------
  |  |  210|  6.96M|#define TRUE    1
  ------------------
  281|       |    /* Count non-dummy DCT block rows in this iMCU row. */
  282|  6.96M|    if (coef->iMCU_row_num < last_iMCU_row)
  ------------------
  |  Branch (282:9): [True: 6.92M, False: 43.9k]
  ------------------
  283|  6.92M|      block_rows = compptr->v_samp_factor;
  284|  43.9k|    else {
  285|       |      /* NB: can't use last_row_height here, since may not be set! */
  286|  43.9k|      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
  287|  43.9k|      if (block_rows == 0) block_rows = compptr->v_samp_factor;
  ------------------
  |  Branch (287:11): [True: 39.2k, False: 4.72k]
  ------------------
  288|  43.9k|    }
  289|  6.96M|    blocks_across = compptr->width_in_blocks;
  290|  6.96M|    h_samp_factor = compptr->h_samp_factor;
  291|       |    /* Count number of dummy blocks to be added at the right margin. */
  292|  6.96M|    ndummy = (int)(blocks_across % h_samp_factor);
  293|  6.96M|    if (ndummy > 0)
  ------------------
  |  Branch (293:9): [True: 1.07M, False: 5.88M]
  ------------------
  294|  1.07M|      ndummy = h_samp_factor - ndummy;
  295|       |    /* Perform DCT for all non-dummy blocks in this iMCU row.  Each call
  296|       |     * on forward_DCT processes a complete horizontal row of DCT blocks.
  297|       |     */
  298|  14.4M|    for (block_row = 0; block_row < block_rows; block_row++) {
  ------------------
  |  Branch (298:25): [True: 7.50M, False: 6.96M]
  ------------------
  299|  7.50M|      thisblockrow = buffer[block_row];
  300|  7.50M|      (*cinfo->fdct->_forward_DCT) (cinfo, compptr,
  ------------------
  |  |  138|  7.50M|#define _forward_DCT  forward_DCT_12
  ------------------
  301|  7.50M|                                    input_buf[ci], thisblockrow,
  302|  7.50M|                                    (JDIMENSION)(block_row * DCTSIZE),
  ------------------
  |  |   66|  7.50M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  303|  7.50M|                                    (JDIMENSION)0, blocks_across);
  304|  7.50M|      if (ndummy > 0) {
  ------------------
  |  Branch (304:11): [True: 1.07M, False: 6.42M]
  ------------------
  305|       |        /* Create dummy blocks at the right edge of the image. */
  306|  1.07M|        thisblockrow += blocks_across; /* => first dummy block */
  307|  1.07M|        jzero_far((void *)thisblockrow, ndummy * sizeof(JBLOCK));
  308|  1.07M|        lastDC = thisblockrow[-1][0];
  309|  3.23M|        for (bi = 0; bi < ndummy; bi++) {
  ------------------
  |  Branch (309:22): [True: 2.15M, False: 1.07M]
  ------------------
  310|  2.15M|          thisblockrow[bi][0] = lastDC;
  311|  2.15M|        }
  312|  1.07M|      }
  313|  7.50M|    }
  314|       |    /* If at end of image, create dummy block rows as needed.
  315|       |     * The tricky part here is that within each MCU, we want the DC values
  316|       |     * of the dummy blocks to match the last real block's DC value.
  317|       |     * This squeezes a few more bytes out of the resulting file...
  318|       |     */
  319|  6.96M|    if (coef->iMCU_row_num == last_iMCU_row) {
  ------------------
  |  Branch (319:9): [True: 43.9k, False: 6.92M]
  ------------------
  320|  43.9k|      blocks_across += ndummy;  /* include lower right corner */
  321|  43.9k|      MCUs_across = blocks_across / h_samp_factor;
  322|  48.7k|      for (block_row = block_rows; block_row < compptr->v_samp_factor;
  ------------------
  |  Branch (322:36): [True: 4.72k, False: 43.9k]
  ------------------
  323|  43.9k|           block_row++) {
  324|  4.72k|        thisblockrow = buffer[block_row];
  325|  4.72k|        lastblockrow = buffer[block_row - 1];
  326|  4.72k|        jzero_far((void *)thisblockrow,
  327|  4.72k|                  (size_t)(blocks_across * sizeof(JBLOCK)));
  328|  1.05M|        for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
  ------------------
  |  Branch (328:28): [True: 1.05M, False: 4.72k]
  ------------------
  329|  1.05M|          lastDC = lastblockrow[h_samp_factor - 1][0];
  330|  2.10M|          for (bi = 0; bi < h_samp_factor; bi++) {
  ------------------
  |  Branch (330:24): [True: 1.05M, False: 1.05M]
  ------------------
  331|  1.05M|            thisblockrow[bi][0] = lastDC;
  332|  1.05M|          }
  333|  1.05M|          thisblockrow += h_samp_factor; /* advance to next MCU in row */
  334|  1.05M|          lastblockrow += h_samp_factor;
  335|  1.05M|        }
  336|  4.72k|      }
  337|  43.9k|    }
  338|  6.96M|  }
  339|       |  /* NB: compress_output will increment iMCU_row_num if successful.
  340|       |   * A suspension return will result in redoing all the work above next time.
  341|       |   */
  342|       |
  343|       |  /* Emit data to the entropy encoder, sharing code with subsequent passes */
  344|  2.89M|  return compress_output(cinfo, input_buf);
  345|  2.89M|}
jccoefct-12.c:compress_output:
  360|  14.1M|{
  361|  14.1M|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  362|  14.1M|  JDIMENSION MCU_col_num;       /* index of current MCU within row */
  363|  14.1M|  int blkn, ci, xindex, yindex, yoffset;
  364|  14.1M|  JDIMENSION start_col;
  365|  14.1M|  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
  366|  14.1M|  JBLOCKROW buffer_ptr;
  367|  14.1M|  jpeg_component_info *compptr;
  368|       |
  369|       |  /* Align the virtual buffers for the components used in this scan.
  370|       |   * NB: during first pass, this is safe only because the buffers will
  371|       |   * already be aligned properly, so jmemmgr.c won't need to do any I/O.
  372|       |   */
  373|  36.5M|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (373:16): [True: 22.3M, False: 14.1M]
  ------------------
  374|  22.3M|    compptr = cinfo->cur_comp_info[ci];
  375|  22.3M|    buffer[ci] = (*cinfo->mem->access_virt_barray)
  376|  22.3M|      ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
  377|  22.3M|       coef->iMCU_row_num * compptr->v_samp_factor,
  378|  22.3M|       (JDIMENSION)compptr->v_samp_factor, FALSE);
  ------------------
  |  |  207|  22.3M|#define FALSE   0               /* values of boolean */
  ------------------
  379|  22.3M|  }
  380|       |
  381|       |  /* Loop to process one whole iMCU row */
  382|  30.5M|  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
  ------------------
  |  Branch (382:41): [True: 16.3M, False: 14.1M]
  ------------------
  383|  16.3M|       yoffset++) {
  384|  59.8M|    for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row;
  ------------------
  |  Branch (384:39): [True: 43.5M, False: 16.3M]
  ------------------
  385|  43.5M|         MCU_col_num++) {
  386|       |      /* Construct list of pointers to DCT blocks belonging to this MCU */
  387|  43.5M|      blkn = 0;                 /* index of current DCT block within MCU */
  388|   105M|      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (388:20): [True: 62.3M, False: 43.5M]
  ------------------
  389|  62.3M|        compptr = cinfo->cur_comp_info[ci];
  390|  62.3M|        start_col = MCU_col_num * compptr->MCU_width;
  391|   128M|        for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
  ------------------
  |  Branch (391:26): [True: 66.2M, False: 62.3M]
  ------------------
  392|  66.2M|          buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
  393|   139M|          for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
  ------------------
  |  Branch (393:28): [True: 72.8M, False: 66.2M]
  ------------------
  394|  72.8M|            coef->MCU_buffer[blkn++] = buffer_ptr++;
  395|  72.8M|          }
  396|  66.2M|        }
  397|  62.3M|      }
  398|       |      /* Try to write the MCU. */
  399|       |#ifdef WITH_PROFILE
  400|       |      cinfo->master->start = getTime();
  401|       |#endif
  402|  43.5M|      if (!(*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
  ------------------
  |  Branch (402:11): [True: 0, False: 43.5M]
  ------------------
  403|       |        /* Suspension forced; update state counters and exit */
  404|      0|        coef->MCU_vert_offset = yoffset;
  405|      0|        coef->mcu_ctr = MCU_col_num;
  406|       |#ifdef WITH_PROFILE
  407|       |        cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
  408|       |        cinfo->master->entropy_mcoeffs +=
  409|       |          (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
  410|       |#endif
  411|      0|        return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  412|      0|      }
  413|       |#ifdef WITH_PROFILE
  414|       |      cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
  415|       |      cinfo->master->entropy_mcoeffs +=
  416|       |        (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
  417|       |#endif
  418|  43.5M|    }
  419|       |    /* Completed an MCU row, but perhaps not an iMCU row */
  420|  16.3M|    coef->mcu_ctr = 0;
  421|  16.3M|  }
  422|       |  /* Completed the iMCU row, advance counters for next one */
  423|  14.1M|  coef->iMCU_row_num++;
  424|  14.1M|  start_iMCU_row(cinfo);
  425|  14.1M|  return TRUE;
  ------------------
  |  |  210|  14.1M|#define TRUE    1
  ------------------
  426|  14.1M|}

jccolor-12.c:extxrgb_gray_convert:
   91|  4.33M|{
   92|  4.33M|#if BITS_IN_JSAMPLE != 16
   93|  4.33M|  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
   94|  4.33M|  register int r, g, b;
   95|  4.33M|  register JLONG *ctab = cconvert->rgb_ycc_tab;
   96|  4.33M|  register _JSAMPROW inptr;
   97|  4.33M|  register _JSAMPROW outptr;
   98|  4.33M|  register JDIMENSION col;
   99|  4.33M|  JDIMENSION num_cols = cinfo->image_width;
  100|       |
  101|  8.66M|  while (--num_rows >= 0) {
  ------------------
  |  Branch (101:10): [True: 4.33M, False: 4.33M]
  ------------------
  102|  4.33M|    inptr = *input_buf++;
  103|  4.33M|    outptr = output_buf[0][output_row];
  104|  4.33M|    output_row++;
  105|  37.1M|    for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (105:19): [True: 32.8M, False: 4.33M]
  ------------------
  106|  32.8M|      r = RANGE_LIMIT(inptr[RGB_RED]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
  107|  32.8M|      g = RANGE_LIMIT(inptr[RGB_GREEN]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
  108|  32.8M|      b = RANGE_LIMIT(inptr[RGB_BLUE]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
  109|  32.8M|      inptr += RGB_PIXELSIZE;
  ------------------
  |  |  196|  32.8M|#define RGB_PIXELSIZE  EXT_XRGB_PIXELSIZE
  |  |  ------------------
  |  |  |  |  334|  32.8M|#define EXT_XRGB_PIXELSIZE  4
  |  |  ------------------
  ------------------
  110|       |      /* Y */
  111|  32.8M|      outptr[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   81|  32.8M|#define R_Y_OFF         0                       /* offset to R => Y section */
  ------------------
                    outptr[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   82|  32.8M|#define G_Y_OFF         (1 * (_MAXJSAMPLE + 1)) /* offset to G => Y section */
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  112|  32.8M|                                ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   83|  32.8M|#define B_Y_OFF         (2 * (_MAXJSAMPLE + 1)) /* etc. */
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                              ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  32.8M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
  113|  32.8M|    }
  114|  4.33M|  }
  115|       |#else
  116|       |  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  117|       |#endif
  118|  4.33M|}
jccolor-12.c:extrgbx_rgb_convert:
  130|  2.16M|{
  131|  2.16M|  register _JSAMPROW inptr;
  132|  2.16M|  register _JSAMPROW outptr0, outptr1, outptr2;
  133|  2.16M|  register JDIMENSION col;
  134|  2.16M|  JDIMENSION num_cols = cinfo->image_width;
  135|       |
  136|  6.49M|  while (--num_rows >= 0) {
  ------------------
  |  Branch (136:10): [True: 4.33M, False: 2.16M]
  ------------------
  137|  4.33M|    inptr = *input_buf++;
  138|  4.33M|    outptr0 = output_buf[0][output_row];
  139|  4.33M|    outptr1 = output_buf[1][output_row];
  140|  4.33M|    outptr2 = output_buf[2][output_row];
  141|  4.33M|    output_row++;
  142|  37.1M|    for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (142:19): [True: 32.8M, False: 4.33M]
  ------------------
  143|  32.8M|      outptr0[col] = inptr[RGB_RED];
  ------------------
  |  |  129|  32.8M|#define RGB_RED  EXT_RGBX_RED
  |  |  ------------------
  |  |  |  |  311|  32.8M|#define EXT_RGBX_RED        0
  |  |  ------------------
  ------------------
  144|  32.8M|      outptr1[col] = inptr[RGB_GREEN];
  ------------------
  |  |  130|  32.8M|#define RGB_GREEN  EXT_RGBX_GREEN
  |  |  ------------------
  |  |  |  |  312|  32.8M|#define EXT_RGBX_GREEN      1
  |  |  ------------------
  ------------------
  145|  32.8M|      outptr2[col] = inptr[RGB_BLUE];
  ------------------
  |  |  131|  32.8M|#define RGB_BLUE  EXT_RGBX_BLUE
  |  |  ------------------
  |  |  |  |  313|  32.8M|#define EXT_RGBX_BLUE       2
  |  |  ------------------
  ------------------
  146|  32.8M|      inptr += RGB_PIXELSIZE;
  ------------------
  |  |  132|  32.8M|#define RGB_PIXELSIZE  EXT_RGBX_PIXELSIZE
  |  |  ------------------
  |  |  |  |  314|  32.8M|#define EXT_RGBX_PIXELSIZE  4
  |  |  ------------------
  ------------------
  147|  32.8M|    }
  148|  4.33M|  }
  149|  2.16M|}
jccolor-12.c:extrgb_ycc_convert:
   34|  4.33M|{
   35|  4.33M|#if BITS_IN_JSAMPLE != 16
   36|  4.33M|  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
   37|  4.33M|  register int r, g, b;
   38|  4.33M|  register JLONG *ctab = cconvert->rgb_ycc_tab;
   39|  4.33M|  register _JSAMPROW inptr;
   40|  4.33M|  register _JSAMPROW outptr0, outptr1, outptr2;
   41|  4.33M|  register JDIMENSION col;
   42|  4.33M|  JDIMENSION num_cols = cinfo->image_width;
   43|       |
   44|  8.66M|  while (--num_rows >= 0) {
  ------------------
  |  Branch (44:10): [True: 4.33M, False: 4.33M]
  ------------------
   45|  4.33M|    inptr = *input_buf++;
   46|  4.33M|    outptr0 = output_buf[0][output_row];
   47|  4.33M|    outptr1 = output_buf[1][output_row];
   48|  4.33M|    outptr2 = output_buf[2][output_row];
   49|  4.33M|    output_row++;
   50|  37.2M|    for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (50:19): [True: 32.8M, False: 4.33M]
  ------------------
   51|  32.8M|      r = RANGE_LIMIT(inptr[RGB_RED]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
   52|  32.8M|      g = RANGE_LIMIT(inptr[RGB_GREEN]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
   53|  32.8M|      b = RANGE_LIMIT(inptr[RGB_BLUE]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
   54|  32.8M|      inptr += RGB_PIXELSIZE;
  ------------------
  |  |  116|  32.8M|#define RGB_PIXELSIZE  EXT_RGB_PIXELSIZE
  |  |  ------------------
  |  |  |  |  309|  32.8M|#define EXT_RGB_PIXELSIZE   3
  |  |  ------------------
  ------------------
   55|       |      /* If the inputs are 0.._MAXJSAMPLE, the outputs of these equations
   56|       |       * must be too; we do not need an explicit range-limiting operation.
   57|       |       * Hence the value being shifted is never negative, and we don't
   58|       |       * need the general RIGHT_SHIFT macro.
   59|       |       */
   60|       |      /* Y */
   61|  32.8M|      outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   81|  32.8M|#define R_Y_OFF         0                       /* offset to R => Y section */
  ------------------
                    outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   82|  32.8M|#define G_Y_OFF         (1 * (_MAXJSAMPLE + 1)) /* offset to G => Y section */
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   62|  32.8M|                                 ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   83|  32.8M|#define B_Y_OFF         (2 * (_MAXJSAMPLE + 1)) /* etc. */
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  32.8M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
   63|       |      /* Cb */
   64|  32.8M|      outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
  ------------------
  |  |   84|  32.8M|#define R_CB_OFF        (3 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
  ------------------
  |  |   85|  32.8M|#define G_CB_OFF        (4 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   65|  32.8M|                                 ctab[b + B_CB_OFF]) >> SCALEBITS);
  ------------------
  |  |   86|  32.8M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_CB_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  32.8M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
   66|       |      /* Cr */
   67|  32.8M|      outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
  ------------------
  |  |   87|  32.8M|#define R_CR_OFF        B_CB_OFF                /* B=>Cb, R=>Cr are the same */
  |  |  ------------------
  |  |  |  |   86|  32.8M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
  ------------------
  |  |   88|  32.8M|#define G_CR_OFF        (6 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   68|  32.8M|                                 ctab[b + B_CR_OFF]) >> SCALEBITS);
  ------------------
  |  |   89|  32.8M|#define B_CR_OFF        (7 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_CR_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  32.8M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
   69|  32.8M|    }
   70|  4.33M|  }
   71|       |#else
   72|       |  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
   73|       |#endif
   74|  4.33M|}
jccolor-12.c:extbgr_ycc_convert:
   34|  4.33M|{
   35|  4.33M|#if BITS_IN_JSAMPLE != 16
   36|  4.33M|  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
   37|  4.33M|  register int r, g, b;
   38|  4.33M|  register JLONG *ctab = cconvert->rgb_ycc_tab;
   39|  4.33M|  register _JSAMPROW inptr;
   40|  4.33M|  register _JSAMPROW outptr0, outptr1, outptr2;
   41|  4.33M|  register JDIMENSION col;
   42|  4.33M|  JDIMENSION num_cols = cinfo->image_width;
   43|       |
   44|  8.66M|  while (--num_rows >= 0) {
  ------------------
  |  Branch (44:10): [True: 4.33M, False: 4.33M]
  ------------------
   45|  4.33M|    inptr = *input_buf++;
   46|  4.33M|    outptr0 = output_buf[0][output_row];
   47|  4.33M|    outptr1 = output_buf[1][output_row];
   48|  4.33M|    outptr2 = output_buf[2][output_row];
   49|  4.33M|    output_row++;
   50|  37.2M|    for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (50:19): [True: 32.8M, False: 4.33M]
  ------------------
   51|  32.8M|      r = RANGE_LIMIT(inptr[RGB_RED]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
   52|  32.8M|      g = RANGE_LIMIT(inptr[RGB_GREEN]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
   53|  32.8M|      b = RANGE_LIMIT(inptr[RGB_BLUE]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
   54|  32.8M|      inptr += RGB_PIXELSIZE;
  ------------------
  |  |  148|  32.8M|#define RGB_PIXELSIZE  EXT_BGR_PIXELSIZE
  |  |  ------------------
  |  |  |  |  319|  32.8M|#define EXT_BGR_PIXELSIZE   3
  |  |  ------------------
  ------------------
   55|       |      /* If the inputs are 0.._MAXJSAMPLE, the outputs of these equations
   56|       |       * must be too; we do not need an explicit range-limiting operation.
   57|       |       * Hence the value being shifted is never negative, and we don't
   58|       |       * need the general RIGHT_SHIFT macro.
   59|       |       */
   60|       |      /* Y */
   61|  32.8M|      outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   81|  32.8M|#define R_Y_OFF         0                       /* offset to R => Y section */
  ------------------
                    outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   82|  32.8M|#define G_Y_OFF         (1 * (_MAXJSAMPLE + 1)) /* offset to G => Y section */
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   62|  32.8M|                                 ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   83|  32.8M|#define B_Y_OFF         (2 * (_MAXJSAMPLE + 1)) /* etc. */
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  32.8M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
   63|       |      /* Cb */
   64|  32.8M|      outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
  ------------------
  |  |   84|  32.8M|#define R_CB_OFF        (3 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
  ------------------
  |  |   85|  32.8M|#define G_CB_OFF        (4 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   65|  32.8M|                                 ctab[b + B_CB_OFF]) >> SCALEBITS);
  ------------------
  |  |   86|  32.8M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_CB_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  32.8M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
   66|       |      /* Cr */
   67|  32.8M|      outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
  ------------------
  |  |   87|  32.8M|#define R_CR_OFF        B_CB_OFF                /* B=>Cb, R=>Cr are the same */
  |  |  ------------------
  |  |  |  |   86|  32.8M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
  ------------------
  |  |   88|  32.8M|#define G_CR_OFF        (6 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   68|  32.8M|                                 ctab[b + B_CR_OFF]) >> SCALEBITS);
  ------------------
  |  |   89|  32.8M|#define B_CR_OFF        (7 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_CR_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  32.8M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
   69|  32.8M|    }
   70|  4.33M|  }
   71|       |#else
   72|       |  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
   73|       |#endif
   74|  4.33M|}
jccolor-12.c:extbgrx_ycc_convert:
   34|  4.33M|{
   35|  4.33M|#if BITS_IN_JSAMPLE != 16
   36|  4.33M|  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
   37|  4.33M|  register int r, g, b;
   38|  4.33M|  register JLONG *ctab = cconvert->rgb_ycc_tab;
   39|  4.33M|  register _JSAMPROW inptr;
   40|  4.33M|  register _JSAMPROW outptr0, outptr1, outptr2;
   41|  4.33M|  register JDIMENSION col;
   42|  4.33M|  JDIMENSION num_cols = cinfo->image_width;
   43|       |
   44|  8.66M|  while (--num_rows >= 0) {
  ------------------
  |  Branch (44:10): [True: 4.33M, False: 4.33M]
  ------------------
   45|  4.33M|    inptr = *input_buf++;
   46|  4.33M|    outptr0 = output_buf[0][output_row];
   47|  4.33M|    outptr1 = output_buf[1][output_row];
   48|  4.33M|    outptr2 = output_buf[2][output_row];
   49|  4.33M|    output_row++;
   50|  37.1M|    for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (50:19): [True: 32.8M, False: 4.33M]
  ------------------
   51|  32.8M|      r = RANGE_LIMIT(inptr[RGB_RED]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
   52|  32.8M|      g = RANGE_LIMIT(inptr[RGB_GREEN]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
   53|  32.8M|      b = RANGE_LIMIT(inptr[RGB_BLUE]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
   54|  32.8M|      inptr += RGB_PIXELSIZE;
  ------------------
  |  |  164|  32.8M|#define RGB_PIXELSIZE  EXT_BGRX_PIXELSIZE
  |  |  ------------------
  |  |  |  |  324|  32.8M|#define EXT_BGRX_PIXELSIZE  4
  |  |  ------------------
  ------------------
   55|       |      /* If the inputs are 0.._MAXJSAMPLE, the outputs of these equations
   56|       |       * must be too; we do not need an explicit range-limiting operation.
   57|       |       * Hence the value being shifted is never negative, and we don't
   58|       |       * need the general RIGHT_SHIFT macro.
   59|       |       */
   60|       |      /* Y */
   61|  32.8M|      outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   81|  32.8M|#define R_Y_OFF         0                       /* offset to R => Y section */
  ------------------
                    outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   82|  32.8M|#define G_Y_OFF         (1 * (_MAXJSAMPLE + 1)) /* offset to G => Y section */
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   62|  32.8M|                                 ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   83|  32.8M|#define B_Y_OFF         (2 * (_MAXJSAMPLE + 1)) /* etc. */
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  32.8M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
   63|       |      /* Cb */
   64|  32.8M|      outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
  ------------------
  |  |   84|  32.8M|#define R_CB_OFF        (3 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
  ------------------
  |  |   85|  32.8M|#define G_CB_OFF        (4 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   65|  32.8M|                                 ctab[b + B_CB_OFF]) >> SCALEBITS);
  ------------------
  |  |   86|  32.8M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_CB_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  32.8M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
   66|       |      /* Cr */
   67|  32.8M|      outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
  ------------------
  |  |   87|  32.8M|#define R_CR_OFF        B_CB_OFF                /* B=>Cb, R=>Cr are the same */
  |  |  ------------------
  |  |  |  |   86|  32.8M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
  ------------------
  |  |   88|  32.8M|#define G_CR_OFF        (6 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   68|  32.8M|                                 ctab[b + B_CR_OFF]) >> SCALEBITS);
  ------------------
  |  |   89|  32.8M|#define B_CR_OFF        (7 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_CR_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  32.8M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
   69|  32.8M|    }
   70|  4.33M|  }
   71|       |#else
   72|       |  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
   73|       |#endif
   74|  4.33M|}

j12init_color_converter:
  418|  20.8k|{
  419|  20.8k|  my_cconvert_ptr cconvert;
  420|       |
  421|  20.8k|#ifdef C_LOSSLESS_SUPPORTED
  422|  20.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (422:7): [True: 0, False: 20.8k]
  ------------------
  423|       |#if BITS_IN_JSAMPLE == 8
  424|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  425|       |#else
  426|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (426:9): [True: 0, False: 0]
  ------------------
  427|      0|        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (427:9): [True: 0, False: 0]
  ------------------
  428|      0|#endif
  429|      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)))
  ------------------
  430|      0|  } else
  431|  20.8k|#endif
  432|  20.8k|  {
  433|  20.8k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  20.8k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (433:9): [True: 0, False: 20.8k]
  ------------------
  434|      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)))
  ------------------
  435|  20.8k|  }
  436|       |
  437|  20.8k|  cconvert = (my_cconvert_ptr)
  438|  20.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  20.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  439|  20.8k|                                sizeof(my_color_converter));
  440|  20.8k|  cinfo->cconvert = (struct jpeg_color_converter *)cconvert;
  441|       |  /* set start_pass to null method until we find out differently */
  442|  20.8k|  cconvert->pub.start_pass = null_method;
  443|       |
  444|       |  /* Make sure input_components agrees with in_color_space */
  445|  20.8k|  switch (cinfo->in_color_space) {
  446|  3.58k|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (446:3): [True: 3.58k, False: 17.2k]
  ------------------
  447|  3.58k|    if (cinfo->input_components != 1)
  ------------------
  |  Branch (447:9): [True: 0, False: 3.58k]
  ------------------
  448|      0|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  449|  3.58k|    break;
  450|       |
  451|      0|  case JCS_RGB:
  ------------------
  |  Branch (451:3): [True: 0, False: 20.8k]
  ------------------
  452|  2.95k|  case JCS_EXT_RGB:
  ------------------
  |  Branch (452:3): [True: 2.95k, False: 17.8k]
  ------------------
  453|  5.78k|  case JCS_EXT_RGBX:
  ------------------
  |  Branch (453:3): [True: 2.83k, False: 18.0k]
  ------------------
  454|  8.74k|  case JCS_EXT_BGR:
  ------------------
  |  Branch (454:3): [True: 2.95k, False: 17.8k]
  ------------------
  455|  8.74k|  case JCS_EXT_BGRX:
  ------------------
  |  Branch (455:3): [True: 0, False: 20.8k]
  ------------------
  456|  8.74k|  case JCS_EXT_XBGR:
  ------------------
  |  Branch (456:3): [True: 0, False: 20.8k]
  ------------------
  457|  11.5k|  case JCS_EXT_XRGB:
  ------------------
  |  Branch (457:3): [True: 2.83k, False: 18.0k]
  ------------------
  458|  11.5k|  case JCS_EXT_RGBA:
  ------------------
  |  Branch (458:3): [True: 0, False: 20.8k]
  ------------------
  459|  14.4k|  case JCS_EXT_BGRA:
  ------------------
  |  Branch (459:3): [True: 2.83k, False: 18.0k]
  ------------------
  460|  14.4k|  case JCS_EXT_ABGR:
  ------------------
  |  Branch (460:3): [True: 0, False: 20.8k]
  ------------------
  461|  14.4k|  case JCS_EXT_ARGB:
  ------------------
  |  Branch (461:3): [True: 0, False: 20.8k]
  ------------------
  462|  14.4k|    if (cinfo->input_components != rgb_pixelsize[cinfo->in_color_space])
  ------------------
  |  Branch (462:9): [True: 0, False: 14.4k]
  ------------------
  463|      0|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  464|  14.4k|    break;
  465|       |
  466|      0|  case JCS_YCbCr:
  ------------------
  |  Branch (466:3): [True: 0, False: 20.8k]
  ------------------
  467|      0|    if (cinfo->input_components != 3)
  ------------------
  |  Branch (467:9): [True: 0, False: 0]
  ------------------
  468|      0|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  469|      0|    break;
  470|       |
  471|  2.83k|  case JCS_CMYK:
  ------------------
  |  Branch (471:3): [True: 2.83k, False: 18.0k]
  ------------------
  472|  2.83k|  case JCS_YCCK:
  ------------------
  |  Branch (472:3): [True: 0, False: 20.8k]
  ------------------
  473|  2.83k|    if (cinfo->input_components != 4)
  ------------------
  |  Branch (473:9): [True: 0, False: 2.83k]
  ------------------
  474|      0|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  475|  2.83k|    break;
  476|       |
  477|      0|  default:                      /* JCS_UNKNOWN can be anything */
  ------------------
  |  Branch (477:3): [True: 0, False: 20.8k]
  ------------------
  478|      0|    if (cinfo->input_components < 1)
  ------------------
  |  Branch (478:9): [True: 0, False: 0]
  ------------------
  479|      0|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  480|      0|    break;
  481|  20.8k|  }
  482|       |
  483|       |  /* Check num_components, set conversion method based on requested space.
  484|       |   * NOTE: We do not allow any lossy color conversion algorithms in lossless
  485|       |   * mode.
  486|       |   */
  487|  20.8k|  switch (cinfo->jpeg_color_space) {
  488|  6.42k|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (488:3): [True: 6.42k, False: 14.4k]
  ------------------
  489|  6.42k|#ifdef C_LOSSLESS_SUPPORTED
  490|  6.42k|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (490:9): [True: 0, False: 6.42k]
  ------------------
  491|      0|        cinfo->in_color_space != cinfo->jpeg_color_space)
  ------------------
  |  Branch (491:9): [True: 0, False: 0]
  ------------------
  492|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  493|  6.42k|#endif
  494|  6.42k|    if (cinfo->num_components != 1)
  ------------------
  |  Branch (494:9): [True: 0, False: 6.42k]
  ------------------
  495|      0|      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  496|  6.42k|    if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (496:9): [True: 3.58k, False: 2.83k]
  ------------------
  497|  3.58k|      cconvert->pub._color_convert = grayscale_convert;
  ------------------
  |  |  151|  3.58k|#define _color_convert  color_convert_12
  ------------------
  498|  2.83k|    else if (IsExtRGB(cinfo->in_color_space)) {
  ------------------
  |  |   78|  2.83k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 2.83k]
  |  |  |  Branch (78:22): [True: 2.83k, False: 0]
  |  |  |  Branch (78:43): [True: 2.83k, False: 0]
  |  |  ------------------
  ------------------
  499|       |#ifdef WITH_SIMD
  500|       |      if (jsimd_set_rgb_gray(cinfo))
  501|       |        cconvert->pub._color_convert = jsimd_color_convert;
  502|       |      else
  503|       |#endif
  504|  2.83k|      {
  505|  2.83k|        cconvert->pub.start_pass = rgb_ycc_start;
  506|  2.83k|        switch (cinfo->in_color_space) {
  507|      0|        case JCS_EXT_RGB:
  ------------------
  |  Branch (507:9): [True: 0, False: 2.83k]
  ------------------
  508|      0|          cconvert->pub._color_convert = extrgb_gray_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  509|      0|          break;
  510|      0|        case JCS_EXT_RGBX:
  ------------------
  |  Branch (510:9): [True: 0, False: 2.83k]
  ------------------
  511|      0|        case JCS_EXT_RGBA:
  ------------------
  |  Branch (511:9): [True: 0, False: 2.83k]
  ------------------
  512|      0|          cconvert->pub._color_convert = extrgbx_gray_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  513|      0|          break;
  514|      0|        case JCS_EXT_BGR:
  ------------------
  |  Branch (514:9): [True: 0, False: 2.83k]
  ------------------
  515|      0|          cconvert->pub._color_convert = extbgr_gray_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  516|      0|          break;
  517|      0|        case JCS_EXT_BGRX:
  ------------------
  |  Branch (517:9): [True: 0, False: 2.83k]
  ------------------
  518|      0|        case JCS_EXT_BGRA:
  ------------------
  |  Branch (518:9): [True: 0, False: 2.83k]
  ------------------
  519|      0|          cconvert->pub._color_convert = extbgrx_gray_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  520|      0|          break;
  521|      0|        case JCS_EXT_XBGR:
  ------------------
  |  Branch (521:9): [True: 0, False: 2.83k]
  ------------------
  522|      0|        case JCS_EXT_ABGR:
  ------------------
  |  Branch (522:9): [True: 0, False: 2.83k]
  ------------------
  523|      0|          cconvert->pub._color_convert = extxbgr_gray_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  524|      0|          break;
  525|  2.83k|        case JCS_EXT_XRGB:
  ------------------
  |  Branch (525:9): [True: 2.83k, False: 0]
  ------------------
  526|  2.83k|        case JCS_EXT_ARGB:
  ------------------
  |  Branch (526:9): [True: 0, False: 2.83k]
  ------------------
  527|  2.83k|          cconvert->pub._color_convert = extxrgb_gray_convert;
  ------------------
  |  |  151|  2.83k|#define _color_convert  color_convert_12
  ------------------
  528|  2.83k|          break;
  529|      0|        default:
  ------------------
  |  Branch (529:9): [True: 0, False: 2.83k]
  ------------------
  530|      0|          cconvert->pub._color_convert = rgb_gray_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  531|  2.83k|        }
  532|  2.83k|      }
  533|  2.83k|    } else if (cinfo->in_color_space == JCS_YCbCr)
  ------------------
  |  Branch (533:16): [True: 0, False: 0]
  ------------------
  534|      0|      cconvert->pub._color_convert = grayscale_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  535|      0|    else
  536|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  537|  6.42k|    break;
  538|       |
  539|  6.42k|  case JCS_RGB:
  ------------------
  |  Branch (539:3): [True: 2.83k, False: 18.0k]
  ------------------
  540|  2.83k|#ifdef C_LOSSLESS_SUPPORTED
  541|  2.83k|    if (cinfo->master->lossless && !IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|      0|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 0]
  |  |  |  Branch (78:22): [True: 0, False: 0]
  |  |  |  Branch (78:43): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (541:9): [True: 0, False: 2.83k]
  ------------------
  542|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  543|  2.83k|#endif
  544|  2.83k|    if (cinfo->num_components != 3)
  ------------------
  |  Branch (544:9): [True: 0, False: 2.83k]
  ------------------
  545|      0|      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  546|  2.83k|    if (rgb_red[cinfo->in_color_space] == 0 &&
  ------------------
  |  Branch (546:9): [True: 2.83k, False: 0]
  ------------------
  547|  2.83k|        rgb_green[cinfo->in_color_space] == 1 &&
  ------------------
  |  Branch (547:9): [True: 2.83k, False: 0]
  ------------------
  548|  2.83k|        rgb_blue[cinfo->in_color_space] == 2 &&
  ------------------
  |  Branch (548:9): [True: 2.83k, False: 0]
  ------------------
  549|  2.83k|        rgb_pixelsize[cinfo->in_color_space] == 3) {
  ------------------
  |  Branch (549:9): [True: 0, False: 2.83k]
  ------------------
  550|      0|      cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  551|  2.83k|    } else if (IsExtRGB(cinfo->in_color_space)) {
  ------------------
  |  |   78|  2.83k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 2.83k]
  |  |  |  Branch (78:22): [True: 2.83k, False: 0]
  |  |  |  Branch (78:43): [True: 2.83k, False: 0]
  |  |  ------------------
  ------------------
  552|  2.83k|      switch (cinfo->in_color_space) {
  553|      0|      case JCS_EXT_RGB:
  ------------------
  |  Branch (553:7): [True: 0, False: 2.83k]
  ------------------
  554|      0|        cconvert->pub._color_convert = extrgb_rgb_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  555|      0|        break;
  556|  2.83k|      case JCS_EXT_RGBX:
  ------------------
  |  Branch (556:7): [True: 2.83k, False: 0]
  ------------------
  557|  2.83k|      case JCS_EXT_RGBA:
  ------------------
  |  Branch (557:7): [True: 0, False: 2.83k]
  ------------------
  558|  2.83k|        cconvert->pub._color_convert = extrgbx_rgb_convert;
  ------------------
  |  |  151|  2.83k|#define _color_convert  color_convert_12
  ------------------
  559|  2.83k|        break;
  560|      0|      case JCS_EXT_BGR:
  ------------------
  |  Branch (560:7): [True: 0, False: 2.83k]
  ------------------
  561|      0|        cconvert->pub._color_convert = extbgr_rgb_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  562|      0|        break;
  563|      0|      case JCS_EXT_BGRX:
  ------------------
  |  Branch (563:7): [True: 0, False: 2.83k]
  ------------------
  564|      0|      case JCS_EXT_BGRA:
  ------------------
  |  Branch (564:7): [True: 0, False: 2.83k]
  ------------------
  565|      0|        cconvert->pub._color_convert = extbgrx_rgb_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  566|      0|        break;
  567|      0|      case JCS_EXT_XBGR:
  ------------------
  |  Branch (567:7): [True: 0, False: 2.83k]
  ------------------
  568|      0|      case JCS_EXT_ABGR:
  ------------------
  |  Branch (568:7): [True: 0, False: 2.83k]
  ------------------
  569|      0|        cconvert->pub._color_convert = extxbgr_rgb_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  570|      0|        break;
  571|      0|      case JCS_EXT_XRGB:
  ------------------
  |  Branch (571:7): [True: 0, False: 2.83k]
  ------------------
  572|      0|      case JCS_EXT_ARGB:
  ------------------
  |  Branch (572:7): [True: 0, False: 2.83k]
  ------------------
  573|      0|        cconvert->pub._color_convert = extxrgb_rgb_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  574|      0|        break;
  575|      0|      default:
  ------------------
  |  Branch (575:7): [True: 0, False: 2.83k]
  ------------------
  576|      0|        cconvert->pub._color_convert = rgb_rgb_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  577|  2.83k|      }
  578|  2.83k|    } else
  579|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  580|  2.83k|    break;
  581|       |
  582|  8.74k|  case JCS_YCbCr:
  ------------------
  |  Branch (582:3): [True: 8.74k, False: 12.1k]
  ------------------
  583|  8.74k|#ifdef C_LOSSLESS_SUPPORTED
  584|  8.74k|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (584:9): [True: 0, False: 8.74k]
  ------------------
  585|      0|        cinfo->in_color_space != cinfo->jpeg_color_space)
  ------------------
  |  Branch (585:9): [True: 0, False: 0]
  ------------------
  586|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  587|  8.74k|#endif
  588|  8.74k|    if (cinfo->num_components != 3)
  ------------------
  |  Branch (588:9): [True: 0, False: 8.74k]
  ------------------
  589|      0|      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  590|  8.74k|    if (IsExtRGB(cinfo->in_color_space)) {
  ------------------
  |  |   78|  8.74k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 8.74k]
  |  |  |  Branch (78:22): [True: 8.74k, False: 0]
  |  |  |  Branch (78:43): [True: 8.74k, False: 0]
  |  |  ------------------
  ------------------
  591|       |#ifdef WITH_SIMD
  592|       |      if (jsimd_set_rgb_ycc(cinfo))
  593|       |        cconvert->pub._color_convert = jsimd_color_convert;
  594|       |      else
  595|       |#endif
  596|  8.74k|      {
  597|  8.74k|        cconvert->pub.start_pass = rgb_ycc_start;
  598|  8.74k|        switch (cinfo->in_color_space) {
  599|  2.95k|        case JCS_EXT_RGB:
  ------------------
  |  Branch (599:9): [True: 2.95k, False: 5.78k]
  ------------------
  600|  2.95k|          cconvert->pub._color_convert = extrgb_ycc_convert;
  ------------------
  |  |  151|  2.95k|#define _color_convert  color_convert_12
  ------------------
  601|  2.95k|          break;
  602|      0|        case JCS_EXT_RGBX:
  ------------------
  |  Branch (602:9): [True: 0, False: 8.74k]
  ------------------
  603|      0|        case JCS_EXT_RGBA:
  ------------------
  |  Branch (603:9): [True: 0, False: 8.74k]
  ------------------
  604|      0|          cconvert->pub._color_convert = extrgbx_ycc_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  605|      0|          break;
  606|  2.95k|        case JCS_EXT_BGR:
  ------------------
  |  Branch (606:9): [True: 2.95k, False: 5.78k]
  ------------------
  607|  2.95k|          cconvert->pub._color_convert = extbgr_ycc_convert;
  ------------------
  |  |  151|  2.95k|#define _color_convert  color_convert_12
  ------------------
  608|  2.95k|          break;
  609|      0|        case JCS_EXT_BGRX:
  ------------------
  |  Branch (609:9): [True: 0, False: 8.74k]
  ------------------
  610|  2.83k|        case JCS_EXT_BGRA:
  ------------------
  |  Branch (610:9): [True: 2.83k, False: 5.90k]
  ------------------
  611|  2.83k|          cconvert->pub._color_convert = extbgrx_ycc_convert;
  ------------------
  |  |  151|  2.83k|#define _color_convert  color_convert_12
  ------------------
  612|  2.83k|          break;
  613|      0|        case JCS_EXT_XBGR:
  ------------------
  |  Branch (613:9): [True: 0, False: 8.74k]
  ------------------
  614|      0|        case JCS_EXT_ABGR:
  ------------------
  |  Branch (614:9): [True: 0, False: 8.74k]
  ------------------
  615|      0|          cconvert->pub._color_convert = extxbgr_ycc_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  616|      0|          break;
  617|      0|        case JCS_EXT_XRGB:
  ------------------
  |  Branch (617:9): [True: 0, False: 8.74k]
  ------------------
  618|      0|        case JCS_EXT_ARGB:
  ------------------
  |  Branch (618:9): [True: 0, False: 8.74k]
  ------------------
  619|      0|          cconvert->pub._color_convert = extxrgb_ycc_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  620|      0|          break;
  621|      0|        default:
  ------------------
  |  Branch (621:9): [True: 0, False: 8.74k]
  ------------------
  622|      0|          cconvert->pub._color_convert = rgb_ycc_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  623|  8.74k|        }
  624|  8.74k|      }
  625|  8.74k|    } else if (cinfo->in_color_space == JCS_YCbCr) {
  ------------------
  |  Branch (625:16): [True: 0, False: 0]
  ------------------
  626|      0|      cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  627|      0|    } else
  628|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  629|  8.74k|    break;
  630|       |
  631|  8.74k|  case JCS_CMYK:
  ------------------
  |  Branch (631:3): [True: 0, False: 20.8k]
  ------------------
  632|      0|#ifdef C_LOSSLESS_SUPPORTED
  633|      0|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (633:9): [True: 0, False: 0]
  ------------------
  634|      0|        cinfo->in_color_space != cinfo->jpeg_color_space)
  ------------------
  |  Branch (634:9): [True: 0, False: 0]
  ------------------
  635|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  636|      0|#endif
  637|      0|    if (cinfo->num_components != 4)
  ------------------
  |  Branch (637:9): [True: 0, False: 0]
  ------------------
  638|      0|      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  639|      0|    if (cinfo->in_color_space == JCS_CMYK) {
  ------------------
  |  Branch (639:9): [True: 0, False: 0]
  ------------------
  640|      0|      cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  641|      0|    } else
  642|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  643|      0|    break;
  644|       |
  645|  2.83k|  case JCS_YCCK:
  ------------------
  |  Branch (645:3): [True: 2.83k, False: 18.0k]
  ------------------
  646|  2.83k|#ifdef C_LOSSLESS_SUPPORTED
  647|  2.83k|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (647:9): [True: 0, False: 2.83k]
  ------------------
  648|      0|        cinfo->in_color_space != cinfo->jpeg_color_space)
  ------------------
  |  Branch (648:9): [True: 0, False: 0]
  ------------------
  649|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  650|  2.83k|#endif
  651|  2.83k|    if (cinfo->num_components != 4)
  ------------------
  |  Branch (651:9): [True: 0, False: 2.83k]
  ------------------
  652|      0|      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  653|  2.83k|    if (cinfo->in_color_space == JCS_CMYK) {
  ------------------
  |  Branch (653:9): [True: 2.83k, False: 0]
  ------------------
  654|  2.83k|      cconvert->pub.start_pass = rgb_ycc_start;
  655|  2.83k|      cconvert->pub._color_convert = cmyk_ycck_convert;
  ------------------
  |  |  151|  2.83k|#define _color_convert  color_convert_12
  ------------------
  656|  2.83k|    } else if (cinfo->in_color_space == JCS_YCCK) {
  ------------------
  |  Branch (656:16): [True: 0, False: 0]
  ------------------
  657|      0|      cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  658|      0|    } else
  659|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  660|  2.83k|    break;
  661|       |
  662|      0|  default:                      /* allow null conversion of JCS_UNKNOWN */
  ------------------
  |  Branch (662:3): [True: 0, False: 20.8k]
  ------------------
  663|      0|    if (cinfo->jpeg_color_space != cinfo->in_color_space ||
  ------------------
  |  Branch (663:9): [True: 0, False: 0]
  ------------------
  664|      0|        cinfo->num_components != cinfo->input_components)
  ------------------
  |  Branch (664:9): [True: 0, False: 0]
  ------------------
  665|      0|      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  666|      0|    cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  667|      0|    break;
  668|  20.8k|  }
  669|  20.8k|}
jccolor-12.c:null_method:
  407|  6.42k|{
  408|       |  /* no work needed */
  409|  6.42k|}
jccolor-12.c:grayscale_convert:
  319|  3.58M|{
  320|  3.58M|  register _JSAMPROW inptr;
  321|  3.58M|  register _JSAMPROW outptr;
  322|  3.58M|  register JDIMENSION col;
  323|  3.58M|  JDIMENSION num_cols = cinfo->image_width;
  324|  3.58M|  int instride = cinfo->input_components;
  325|       |
  326|  7.16M|  while (--num_rows >= 0) {
  ------------------
  |  Branch (326:10): [True: 3.58M, False: 3.58M]
  ------------------
  327|  3.58M|    inptr = *input_buf++;
  328|  3.58M|    outptr = output_buf[0][output_row];
  329|  3.58M|    output_row++;
  330|  23.6M|    for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (330:19): [True: 20.0M, False: 3.58M]
  ------------------
  331|  20.0M|      outptr[col] = inptr[0];
  332|  20.0M|      inptr += instride;
  333|  20.0M|    }
  334|  3.58M|  }
  335|  3.58M|}
jccolor-12.c:rgb_ycc_start:
  216|  14.4k|{
  217|  14.4k|#if BITS_IN_JSAMPLE != 16
  218|  14.4k|  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
  219|  14.4k|  JLONG *rgb_ycc_tab;
  220|  14.4k|  JLONG i;
  221|       |
  222|       |  /* Allocate and fill in the conversion tables. */
  223|  14.4k|  cconvert->rgb_ycc_tab = rgb_ycc_tab = (JLONG *)
  224|  14.4k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  14.4k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  225|  14.4k|                                (TABLE_SIZE * sizeof(JLONG)));
  ------------------
  |  |   90|  14.4k|#define TABLE_SIZE      (8 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  14.4k|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  14.4k|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  226|       |
  227|  59.0M|  for (i = 0; i <= _MAXJSAMPLE; i++) {
  ------------------
  |  |  110|  59.0M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  ------------------
  |  |  |  |   60|  59.0M|#define MAXJ12SAMPLE     4095
  |  |  ------------------
  ------------------
  |  Branch (227:15): [True: 59.0M, False: 14.4k]
  ------------------
  228|  59.0M|    rgb_ycc_tab[i + R_Y_OFF] = FIX(0.29900) * i;
  ------------------
  |  |   81|  59.0M|#define R_Y_OFF         0                       /* offset to R => Y section */
  ------------------
                  rgb_ycc_tab[i + R_Y_OFF] = FIX(0.29900) * i;
  ------------------
  |  |   73|  59.0M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  59.0M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  229|  59.0M|    rgb_ycc_tab[i + G_Y_OFF] = FIX(0.58700) * i;
  ------------------
  |  |   82|  59.0M|#define G_Y_OFF         (1 * (_MAXJSAMPLE + 1)) /* offset to G => Y section */
  |  |  ------------------
  |  |  |  |  110|  59.0M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  59.0M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + G_Y_OFF] = FIX(0.58700) * i;
  ------------------
  |  |   73|  59.0M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  59.0M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  230|  59.0M|    rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i   + ONE_HALF;
  ------------------
  |  |   83|  59.0M|#define B_Y_OFF         (2 * (_MAXJSAMPLE + 1)) /* etc. */
  |  |  ------------------
  |  |  |  |  110|  59.0M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  59.0M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i   + ONE_HALF;
  ------------------
  |  |   73|  59.0M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  59.0M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i   + ONE_HALF;
  ------------------
  |  |   72|  59.0M|#define ONE_HALF        ((JLONG)1 << (SCALEBITS - 1))
  |  |  ------------------
  |  |  |  |   70|  59.0M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  231|  59.0M|    rgb_ycc_tab[i + R_CB_OFF] = (-FIX(0.16874)) * i;
  ------------------
  |  |   84|  59.0M|#define R_CB_OFF        (3 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  59.0M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  59.0M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + R_CB_OFF] = (-FIX(0.16874)) * i;
  ------------------
  |  |   73|  59.0M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  59.0M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  232|  59.0M|    rgb_ycc_tab[i + G_CB_OFF] = (-FIX(0.33126)) * i;
  ------------------
  |  |   85|  59.0M|#define G_CB_OFF        (4 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  59.0M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  59.0M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + G_CB_OFF] = (-FIX(0.33126)) * i;
  ------------------
  |  |   73|  59.0M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  59.0M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  233|       |    /* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr.
  234|       |     * This ensures that the maximum output will round to _MAXJSAMPLE
  235|       |     * not _MAXJSAMPLE+1, and thus that we don't have to range-limit.
  236|       |     */
  237|  59.0M|    rgb_ycc_tab[i + B_CB_OFF] = FIX(0.50000) * i  + CBCR_OFFSET + ONE_HALF - 1;
  ------------------
  |  |   86|  59.0M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  59.0M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  59.0M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_CB_OFF] = FIX(0.50000) * i  + CBCR_OFFSET + ONE_HALF - 1;
  ------------------
  |  |   73|  59.0M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  59.0M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_CB_OFF] = FIX(0.50000) * i  + CBCR_OFFSET + ONE_HALF - 1;
  ------------------
  |  |   71|  59.0M|#define CBCR_OFFSET     ((JLONG)_CENTERJSAMPLE << SCALEBITS)
  |  |  ------------------
  |  |  |  |  111|  59.0M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  59.0M|#define CENTERJ12SAMPLE  2048
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define CBCR_OFFSET     ((JLONG)_CENTERJSAMPLE << SCALEBITS)
  |  |  ------------------
  |  |  |  |   70|  59.0M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_CB_OFF] = FIX(0.50000) * i  + CBCR_OFFSET + ONE_HALF - 1;
  ------------------
  |  |   72|  59.0M|#define ONE_HALF        ((JLONG)1 << (SCALEBITS - 1))
  |  |  ------------------
  |  |  |  |   70|  59.0M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  238|       |/*  B=>Cb and R=>Cr tables are the same
  239|       |    rgb_ycc_tab[i + R_CR_OFF] = FIX(0.50000) * i  + CBCR_OFFSET + ONE_HALF - 1;
  240|       |*/
  241|  59.0M|    rgb_ycc_tab[i + G_CR_OFF] = (-FIX(0.41869)) * i;
  ------------------
  |  |   88|  59.0M|#define G_CR_OFF        (6 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  59.0M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  59.0M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + G_CR_OFF] = (-FIX(0.41869)) * i;
  ------------------
  |  |   73|  59.0M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  59.0M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  242|  59.0M|    rgb_ycc_tab[i + B_CR_OFF] = (-FIX(0.08131)) * i;
  ------------------
  |  |   89|  59.0M|#define B_CR_OFF        (7 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  59.0M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  59.0M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_CR_OFF] = (-FIX(0.08131)) * i;
  ------------------
  |  |   73|  59.0M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  59.0M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  243|  59.0M|  }
  244|       |#else
  245|       |  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  246|       |#endif
  247|  14.4k|}
jccolor-12.c:cmyk_ycck_convert:
  264|  2.16M|{
  265|  2.16M|#if BITS_IN_JSAMPLE != 16
  266|  2.16M|  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
  267|  2.16M|  register int r, g, b;
  268|  2.16M|  register JLONG *ctab = cconvert->rgb_ycc_tab;
  269|  2.16M|  register _JSAMPROW inptr;
  270|  2.16M|  register _JSAMPROW outptr0, outptr1, outptr2, outptr3;
  271|  2.16M|  register JDIMENSION col;
  272|  2.16M|  JDIMENSION num_cols = cinfo->image_width;
  273|       |
  274|  6.49M|  while (--num_rows >= 0) {
  ------------------
  |  Branch (274:10): [True: 4.33M, False: 2.16M]
  ------------------
  275|  4.33M|    inptr = *input_buf++;
  276|  4.33M|    outptr0 = output_buf[0][output_row];
  277|  4.33M|    outptr1 = output_buf[1][output_row];
  278|  4.33M|    outptr2 = output_buf[2][output_row];
  279|  4.33M|    outptr3 = output_buf[3][output_row];
  280|  4.33M|    output_row++;
  281|  37.1M|    for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (281:19): [True: 32.8M, False: 4.33M]
  ------------------
  282|  32.8M|      r = _MAXJSAMPLE - RANGE_LIMIT(inptr[0]);
  ------------------
  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  ------------------
  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  ------------------
  ------------------
                    r = _MAXJSAMPLE - RANGE_LIMIT(inptr[0]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
  283|  32.8M|      g = _MAXJSAMPLE - RANGE_LIMIT(inptr[1]);
  ------------------
  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  ------------------
  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  ------------------
  ------------------
                    g = _MAXJSAMPLE - RANGE_LIMIT(inptr[1]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
  284|  32.8M|      b = _MAXJSAMPLE - RANGE_LIMIT(inptr[2]);
  ------------------
  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  ------------------
  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  ------------------
  ------------------
                    b = _MAXJSAMPLE - RANGE_LIMIT(inptr[2]);
  ------------------
  |  |   99|  32.8M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
  285|       |      /* K passes through as-is */
  286|  32.8M|      outptr3[col] = inptr[3];
  287|  32.8M|      inptr += 4;
  288|       |      /* If the inputs are 0.._MAXJSAMPLE, the outputs of these equations
  289|       |       * must be too; we do not need an explicit range-limiting operation.
  290|       |       * Hence the value being shifted is never negative, and we don't
  291|       |       * need the general RIGHT_SHIFT macro.
  292|       |       */
  293|       |      /* Y */
  294|  32.8M|      outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   81|  32.8M|#define R_Y_OFF         0                       /* offset to R => Y section */
  ------------------
                    outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   82|  32.8M|#define G_Y_OFF         (1 * (_MAXJSAMPLE + 1)) /* offset to G => Y section */
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  295|  32.8M|                                 ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   83|  32.8M|#define B_Y_OFF         (2 * (_MAXJSAMPLE + 1)) /* etc. */
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  32.8M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
  296|       |      /* Cb */
  297|  32.8M|      outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
  ------------------
  |  |   84|  32.8M|#define R_CB_OFF        (3 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
  ------------------
  |  |   85|  32.8M|#define G_CB_OFF        (4 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  298|  32.8M|                                 ctab[b + B_CB_OFF]) >> SCALEBITS);
  ------------------
  |  |   86|  32.8M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_CB_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  32.8M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
  299|       |      /* Cr */
  300|  32.8M|      outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
  ------------------
  |  |   87|  32.8M|#define R_CR_OFF        B_CB_OFF                /* B=>Cb, R=>Cr are the same */
  |  |  ------------------
  |  |  |  |   86|  32.8M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
  ------------------
  |  |   88|  32.8M|#define G_CR_OFF        (6 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  301|  32.8M|                                 ctab[b + B_CR_OFF]) >> SCALEBITS);
  ------------------
  |  |   89|  32.8M|#define B_CR_OFF        (7 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  32.8M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  32.8M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_CR_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  32.8M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
  302|  32.8M|    }
  303|  4.33M|  }
  304|       |#else
  305|       |  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  306|       |#endif
  307|  2.16M|}

j12init_forward_dct:
  672|  20.8k|{
  673|  20.8k|  my_fdct_ptr fdct;
  674|  20.8k|  int i;
  675|       |
  676|  20.8k|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  20.8k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (676:7): [True: 0, False: 20.8k]
  ------------------
  677|      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)))
  ------------------
  678|       |
  679|  20.8k|  fdct = (my_fdct_ptr)
  680|  20.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  20.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  681|  20.8k|                                sizeof(my_fdct_controller));
  682|  20.8k|  cinfo->fdct = (struct jpeg_forward_dct *)fdct;
  683|  20.8k|  fdct->pub.start_pass = start_pass_fdctmgr;
  684|       |
  685|       |  /* First determine the DCT... */
  686|  20.8k|  switch (cinfo->dct_method) {
  687|      0|#ifdef DCT_ISLOW_SUPPORTED
  688|  17.8k|  case JDCT_ISLOW:
  ------------------
  |  Branch (688:3): [True: 17.8k, False: 2.95k]
  ------------------
  689|  17.8k|    fdct->pub._forward_DCT = forward_DCT;
  ------------------
  |  |  138|  17.8k|#define _forward_DCT  forward_DCT_12
  ------------------
  690|       |#ifdef WITH_SIMD
  691|       |    if (!jsimd_set_fdct_islow(cinfo, &fdct->dct))
  692|       |#endif
  693|  17.8k|      fdct->dct = _jpeg_fdct_islow;
  ------------------
  |  |  184|  17.8k|#define _jpeg_fdct_islow  jpeg12_fdct_islow
  ------------------
  694|  17.8k|    break;
  695|      0|#endif
  696|      0|#ifdef DCT_IFAST_SUPPORTED
  697|  2.95k|  case JDCT_IFAST:
  ------------------
  |  Branch (697:3): [True: 2.95k, False: 17.8k]
  ------------------
  698|  2.95k|    fdct->pub._forward_DCT = forward_DCT;
  ------------------
  |  |  138|  2.95k|#define _forward_DCT  forward_DCT_12
  ------------------
  699|       |#ifdef WITH_SIMD
  700|       |    if (!jsimd_set_fdct_ifast(cinfo, &fdct->dct))
  701|       |#endif
  702|  2.95k|      fdct->dct = _jpeg_fdct_ifast;
  ------------------
  |  |  185|  2.95k|#define _jpeg_fdct_ifast  jpeg12_fdct_ifast
  ------------------
  703|  2.95k|    break;
  704|      0|#endif
  705|      0|#ifdef DCT_FLOAT_SUPPORTED
  706|      0|  case JDCT_FLOAT:
  ------------------
  |  Branch (706:3): [True: 0, False: 20.8k]
  ------------------
  707|      0|    fdct->pub._forward_DCT = forward_DCT_float;
  ------------------
  |  |  138|      0|#define _forward_DCT  forward_DCT_12
  ------------------
  708|       |#ifdef WITH_SIMD
  709|       |    if (!jsimd_set_fdct_float(cinfo, &fdct->float_dct))
  710|       |#endif
  711|      0|      fdct->float_dct = jpeg_fdct_float;
  712|      0|    break;
  713|      0|#endif
  714|      0|  default:
  ------------------
  |  Branch (714:3): [True: 0, False: 20.8k]
  ------------------
  715|      0|    ERREXIT(cinfo, JERR_NOT_COMPILED);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  716|      0|    break;
  717|  20.8k|  }
  718|       |
  719|       |  /* ...then the supporting stages. */
  720|  20.8k|  switch (cinfo->dct_method) {
  721|      0|#ifdef DCT_ISLOW_SUPPORTED
  722|  17.8k|  case JDCT_ISLOW:
  ------------------
  |  Branch (722:3): [True: 17.8k, False: 2.95k]
  ------------------
  723|  17.8k|#endif
  724|  17.8k|#ifdef DCT_IFAST_SUPPORTED
  725|  20.8k|  case JDCT_IFAST:
  ------------------
  |  Branch (725:3): [True: 2.95k, False: 17.8k]
  ------------------
  726|  20.8k|#endif
  727|  20.8k|#if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED)
  728|       |#ifdef WITH_SIMD
  729|       |    if (!jsimd_set_convsamp(cinfo, &fdct->convsamp))
  730|       |#endif
  731|  20.8k|      fdct->convsamp = convsamp;
  732|       |#ifdef WITH_SIMD
  733|       |    if (!jsimd_set_quantize(cinfo, &fdct->quantize))
  734|       |#endif
  735|  20.8k|      fdct->quantize = quantize;
  736|  20.8k|    break;
  737|      0|#endif
  738|      0|#ifdef DCT_FLOAT_SUPPORTED
  739|      0|  case JDCT_FLOAT:
  ------------------
  |  Branch (739:3): [True: 0, False: 20.8k]
  ------------------
  740|       |#ifdef WITH_SIMD
  741|       |    if (!jsimd_set_convsamp_float(cinfo, &fdct->float_convsamp))
  742|       |#endif
  743|      0|      fdct->float_convsamp = convsamp_float;
  744|       |#ifdef WITH_SIMD
  745|       |    if (!jsimd_set_quantize_float(cinfo, &fdct->float_quantize))
  746|       |#endif
  747|      0|      fdct->float_quantize = quantize_float;
  748|      0|    break;
  749|      0|#endif
  750|      0|  default:
  ------------------
  |  Branch (750:3): [True: 0, False: 20.8k]
  ------------------
  751|      0|    ERREXIT(cinfo, JERR_NOT_COMPILED);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  752|      0|    break;
  753|  20.8k|  }
  754|       |
  755|       |  /* Allocate workspace memory */
  756|  20.8k|#ifdef DCT_FLOAT_SUPPORTED
  757|  20.8k|  if (cinfo->dct_method == JDCT_FLOAT)
  ------------------
  |  Branch (757:7): [True: 0, False: 20.8k]
  ------------------
  758|      0|    fdct->float_workspace = (FAST_FLOAT *)
  759|      0|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      0|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  760|      0|                                  sizeof(FAST_FLOAT) * DCTSIZE2);
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  761|  20.8k|  else
  762|  20.8k|#endif
  763|  20.8k|    fdct->workspace = (DCTELEM *)
  764|  20.8k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  20.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  765|  20.8k|                                  sizeof(DCTELEM) * DCTSIZE2);
  ------------------
  |  |   67|  20.8k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  766|       |
  767|       |  /* Mark divisor tables unallocated */
  768|   104k|  for (i = 0; i < NUM_QUANT_TBLS; i++) {
  ------------------
  |  |   68|   104k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (768:15): [True: 83.3k, False: 20.8k]
  ------------------
  769|  83.3k|    fdct->divisors[i] = NULL;
  770|  83.3k|#ifdef DCT_FLOAT_SUPPORTED
  771|       |    fdct->float_divisors[i] = NULL;
  772|  83.3k|#endif
  773|  83.3k|  }
  774|  20.8k|}
jcdctmgr-12.c:start_pass_fdctmgr:
  235|  20.8k|{
  236|  20.8k|  my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
  237|  20.8k|  int ci, qtblno, i;
  238|  20.8k|  jpeg_component_info *compptr;
  239|  20.8k|  JQUANT_TBL *qtbl;
  240|  20.8k|  DCTELEM *dtbl;
  241|       |
  242|  73.3k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (242:44): [True: 52.5k, False: 20.8k]
  ------------------
  243|  52.5k|       ci++, compptr++) {
  244|  52.5k|    qtblno = compptr->quant_tbl_no;
  245|       |    /* Make sure specified quantization table is present */
  246|  52.5k|    if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
  ------------------
  |  |   68|   105k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (246:9): [True: 0, False: 52.5k]
  |  Branch (246:23): [True: 0, False: 52.5k]
  ------------------
  247|  52.5k|        cinfo->quant_tbl_ptrs[qtblno] == NULL)
  ------------------
  |  Branch (247:9): [True: 0, False: 52.5k]
  ------------------
  248|      0|      ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
  ------------------
  |  |  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)))
  ------------------
  249|  52.5k|    qtbl = cinfo->quant_tbl_ptrs[qtblno];
  250|       |    /* Compute divisors for this quant table */
  251|       |    /* We may do this more than once for same table, but it's not a big deal */
  252|  52.5k|    switch (cinfo->dct_method) {
  253|      0|#ifdef DCT_ISLOW_SUPPORTED
  254|  43.6k|    case JDCT_ISLOW:
  ------------------
  |  Branch (254:5): [True: 43.6k, False: 8.85k]
  ------------------
  255|       |      /* For LL&M IDCT method, divisors are equal to raw quantization
  256|       |       * coefficients multiplied by 8 (to counteract scaling).
  257|       |       */
  258|  43.6k|      if (fdct->divisors[qtblno] == NULL) {
  ------------------
  |  Branch (258:11): [True: 26.5k, False: 17.1k]
  ------------------
  259|  26.5k|        fdct->divisors[qtblno] = (DCTELEM *)
  260|  26.5k|          (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  26.5k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  261|  26.5k|                                      (DCTSIZE2 * 4) * sizeof(DCTELEM));
  ------------------
  |  |   67|  26.5k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  262|  26.5k|      }
  263|  43.6k|      dtbl = fdct->divisors[qtblno];
  264|  2.83M|      for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  2.83M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (264:19): [True: 2.79M, False: 43.6k]
  ------------------
  265|       |#if BITS_IN_JSAMPLE == 8
  266|       |#ifdef WITH_SIMD
  267|       |        if (!compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]) &&
  268|       |            fdct->quantize != quantize)
  269|       |          fdct->quantize = quantize;
  270|       |#else
  271|       |        compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]);
  272|       |#endif
  273|       |#else
  274|  2.79M|        dtbl[i] = ((DCTELEM)qtbl->quantval[i]) << 3;
  275|  2.79M|#endif
  276|  2.79M|      }
  277|  43.6k|      break;
  278|      0|#endif
  279|      0|#ifdef DCT_IFAST_SUPPORTED
  280|  8.85k|    case JDCT_IFAST:
  ------------------
  |  Branch (280:5): [True: 8.85k, False: 43.6k]
  ------------------
  281|  8.85k|      {
  282|       |        /* For AA&N IDCT method, divisors are equal to quantization
  283|       |         * coefficients scaled by scalefactor[row]*scalefactor[col], where
  284|       |         *   scalefactor[0] = 1
  285|       |         *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
  286|       |         * We apply a further scale factor of 8.
  287|       |         */
  288|  8.85k|#define CONST_BITS  14
  289|  8.85k|        static const INT16 aanscales[DCTSIZE2] = {
  290|       |          /* precomputed values scaled up by 14 bits */
  291|  8.85k|          16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
  292|  8.85k|          22725, 31521, 29692, 26722, 22725, 17855, 12299,  6270,
  293|  8.85k|          21407, 29692, 27969, 25172, 21407, 16819, 11585,  5906,
  294|  8.85k|          19266, 26722, 25172, 22654, 19266, 15137, 10426,  5315,
  295|  8.85k|          16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
  296|  8.85k|          12873, 17855, 16819, 15137, 12873, 10114,  6967,  3552,
  297|  8.85k|           8867, 12299, 11585, 10426,  8867,  6967,  4799,  2446,
  298|  8.85k|           4520,  6270,  5906,  5315,  4520,  3552,  2446,  1247
  299|  8.85k|        };
  300|  8.85k|        SHIFT_TEMPS
  301|       |
  302|  8.85k|        if (fdct->divisors[qtblno] == NULL) {
  ------------------
  |  Branch (302:13): [True: 5.90k, False: 2.95k]
  ------------------
  303|  5.90k|          fdct->divisors[qtblno] = (DCTELEM *)
  304|  5.90k|            (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  5.90k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  305|  5.90k|                                        (DCTSIZE2 * 4) * sizeof(DCTELEM));
  ------------------
  |  |   67|  5.90k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  306|  5.90k|        }
  307|  8.85k|        dtbl = fdct->divisors[qtblno];
  308|   575k|        for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|   575k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (308:21): [True: 566k, False: 8.85k]
  ------------------
  309|       |#if BITS_IN_JSAMPLE == 8
  310|       |#ifdef WITH_SIMD
  311|       |          if (!compute_reciprocal(
  312|       |                DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
  313|       |                                      (JLONG)aanscales[i]),
  314|       |                        CONST_BITS - 3), &dtbl[i]) &&
  315|       |              fdct->quantize != quantize)
  316|       |            fdct->quantize = quantize;
  317|       |#else
  318|       |          compute_reciprocal(
  319|       |            DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
  320|       |                                  (JLONG)aanscales[i]),
  321|       |                    CONST_BITS-3), &dtbl[i]);
  322|       |#endif
  323|       |#else
  324|   566k|          dtbl[i] = (DCTELEM)
  325|   566k|            DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
  ------------------
  |  |  216|   566k|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   566k|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  326|   566k|                                  (JLONG)aanscales[i]),
  327|   566k|                    CONST_BITS - 3);
  328|   566k|#endif
  329|   566k|        }
  330|  8.85k|      }
  331|  8.85k|      break;
  332|      0|#endif
  333|      0|#ifdef DCT_FLOAT_SUPPORTED
  334|      0|    case JDCT_FLOAT:
  ------------------
  |  Branch (334:5): [True: 0, False: 52.5k]
  ------------------
  335|      0|      {
  336|       |        /* For float AA&N IDCT method, divisors are equal to quantization
  337|       |         * coefficients scaled by scalefactor[row]*scalefactor[col], where
  338|       |         *   scalefactor[0] = 1
  339|       |         *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
  340|       |         * We apply a further scale factor of 8.
  341|       |         * What's actually stored is 1/divisor so that the inner loop can
  342|       |         * use a multiplication rather than a division.
  343|       |         */
  344|      0|        FAST_FLOAT *fdtbl;
  ------------------
  |  |  386|      0|#define FAST_FLOAT  float
  ------------------
  345|      0|        int row, col;
  346|      0|        static const double aanscalefactor[DCTSIZE] = {
  347|      0|          1.0, 1.387039845, 1.306562965, 1.175875602,
  348|      0|          1.0, 0.785694958, 0.541196100, 0.275899379
  349|      0|        };
  350|       |
  351|      0|        if (fdct->float_divisors[qtblno] == NULL) {
  ------------------
  |  Branch (351:13): [True: 0, False: 0]
  ------------------
  352|      0|          fdct->float_divisors[qtblno] = (FAST_FLOAT *)
  353|      0|            (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      0|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  354|      0|                                        DCTSIZE2 * sizeof(FAST_FLOAT));
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  355|      0|        }
  356|      0|        fdtbl = fdct->float_divisors[qtblno];
  357|      0|        i = 0;
  358|      0|        for (row = 0; row < DCTSIZE; row++) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (358:23): [True: 0, False: 0]
  ------------------
  359|      0|          for (col = 0; col < DCTSIZE; col++) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (359:25): [True: 0, False: 0]
  ------------------
  360|      0|            fdtbl[i] = (FAST_FLOAT)
  361|      0|              (1.0 / (((double)qtbl->quantval[i] *
  362|      0|                       aanscalefactor[row] * aanscalefactor[col] * 8.0)));
  363|      0|            i++;
  364|      0|          }
  365|      0|        }
  366|      0|      }
  367|      0|      break;
  368|      0|#endif
  369|      0|    default:
  ------------------
  |  Branch (369:5): [True: 0, False: 52.5k]
  ------------------
  370|      0|      ERREXIT(cinfo, JERR_NOT_COMPILED);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  371|      0|      break;
  372|  52.5k|    }
  373|  52.5k|  }
  374|  20.8k|}
jcdctmgr-12.c:forward_DCT:
  503|  9.76M|{
  504|       |  /* This routine is heavily used, so it's worth coding it tightly. */
  505|  9.76M|  my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
  506|  9.76M|  DCTELEM *divisors = fdct->divisors[compptr->quant_tbl_no];
  507|  9.76M|  DCTELEM *workspace;
  508|  9.76M|  JDIMENSION bi;
  509|       |
  510|       |  /* Make sure the compiler doesn't look up these every pass */
  511|  9.76M|  forward_DCT_method_ptr do_dct = fdct->dct;
  512|  9.76M|  convsamp_method_ptr do_convsamp = fdct->convsamp;
  513|  9.76M|  quantize_method_ptr do_quantize = fdct->quantize;
  514|  9.76M|  workspace = fdct->workspace;
  515|       |
  516|  9.76M|  sample_data += start_row;     /* fold in the vertical offset once */
  517|       |
  518|  30.7M|  for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {
  ------------------
  |  |   66|  20.9M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (518:16): [True: 20.9M, False: 9.76M]
  ------------------
  519|       |    /* Load data into workspace, applying unsigned->signed conversion */
  520|       |#ifdef WITH_PROFILE
  521|       |    cinfo->master->start = getTime();
  522|       |#endif
  523|  20.9M|    (*do_convsamp) (sample_data, start_col, workspace);
  524|       |#ifdef WITH_PROFILE
  525|       |    cinfo->master->convsamp_elapsed += getTime() - cinfo->master->start;
  526|       |    cinfo->master->convsamp_msamples += (double)DCTSIZE2 / 1000000.;
  527|       |#endif
  528|       |
  529|       |    /* Perform the DCT */
  530|       |#ifdef WITH_PROFILE
  531|       |    cinfo->master->start = getTime();
  532|       |#endif
  533|  20.9M|    (*do_dct) (workspace);
  534|       |#ifdef WITH_PROFILE
  535|       |    cinfo->master->fdct_elapsed += getTime() - cinfo->master->start;
  536|       |    cinfo->master->fdct_mcoeffs += (double)DCTSIZE2 / 1000000.;
  537|       |#endif
  538|       |
  539|       |    /* Quantize/descale the coefficients, and store into coef_blocks[] */
  540|       |#ifdef WITH_PROFILE
  541|       |    cinfo->master->start = getTime();
  542|       |#endif
  543|  20.9M|    (*do_quantize) (coef_blocks[bi], divisors, workspace);
  544|       |#ifdef WITH_PROFILE
  545|       |    cinfo->master->quantize_elapsed += getTime() - cinfo->master->start;
  546|       |    cinfo->master->quantize_mcoeffs += (double)DCTSIZE2 / 1000000.;
  547|       |#endif
  548|  20.9M|  }
  549|  9.76M|}
jcdctmgr-12.c:convsamp:
  383|  20.9M|{
  384|  20.9M|  register DCTELEM *workspaceptr;
  385|  20.9M|  register _JSAMPROW elemptr;
  386|  20.9M|  register int elemr;
  387|       |
  388|  20.9M|  workspaceptr = workspace;
  389|   188M|  for (elemr = 0; elemr < DCTSIZE; elemr++) {
  ------------------
  |  |   66|   188M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (389:19): [True: 167M, False: 20.9M]
  ------------------
  390|   167M|    elemptr = sample_data[elemr] + start_col;
  391|       |
  392|   167M|#if DCTSIZE == 8                /* unroll the inner loop */
  393|   167M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   167M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   167M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  394|   167M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   167M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   167M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  395|   167M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   167M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   167M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  396|   167M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   167M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   167M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  397|   167M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   167M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   167M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  398|   167M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   167M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   167M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  399|   167M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   167M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   167M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  400|   167M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   167M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   167M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  401|       |#else
  402|       |    {
  403|       |      register int elemc;
  404|       |      for (elemc = DCTSIZE; elemc > 0; elemc--)
  405|       |        *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  406|       |    }
  407|       |#endif
  408|   167M|  }
  409|  20.9M|}
jcdctmgr-12.c:quantize:
  418|  20.9M|{
  419|  20.9M|  int i;
  420|  20.9M|  DCTELEM temp;
  421|  20.9M|  JCOEFPTR output_ptr = coef_block;
  422|       |
  423|       |#if BITS_IN_JSAMPLE == 8
  424|       |
  425|       |  UDCTELEM recip, corr;
  426|       |  int shift;
  427|       |  UDCTELEM2 product;
  428|       |
  429|       |  for (i = 0; i < DCTSIZE2; i++) {
  430|       |    temp = workspace[i];
  431|       |    recip = divisors[i + DCTSIZE2 * 0];
  432|       |    corr =  divisors[i + DCTSIZE2 * 1];
  433|       |    shift = divisors[i + DCTSIZE2 * 3];
  434|       |
  435|       |    if (temp < 0) {
  436|       |      temp = -temp;
  437|       |      product = (UDCTELEM2)(temp + corr) * recip;
  438|       |      product >>= shift + sizeof(DCTELEM) * 8;
  439|       |      temp = (DCTELEM)product;
  440|       |      temp = -temp;
  441|       |    } else {
  442|       |      product = (UDCTELEM2)(temp + corr) * recip;
  443|       |      product >>= shift + sizeof(DCTELEM) * 8;
  444|       |      temp = (DCTELEM)product;
  445|       |    }
  446|       |    output_ptr[i] = (JCOEF)temp;
  447|       |  }
  448|       |
  449|       |#else
  450|       |
  451|  20.9M|  register DCTELEM qval;
  452|       |
  453|  1.36G|  for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  1.36G|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (453:15): [True: 1.34G, False: 20.9M]
  ------------------
  454|  1.34G|    qval = divisors[i];
  455|  1.34G|    temp = workspace[i];
  456|       |    /* Divide the coefficient value by qval, ensuring proper rounding.
  457|       |     * Since C does not specify the direction of rounding for negative
  458|       |     * quotients, we have to force the dividend positive for portability.
  459|       |     *
  460|       |     * In most files, at least half of the output values will be zero
  461|       |     * (at default quantization settings, more like three-quarters...)
  462|       |     * so we should ensure that this case is fast.  On many machines,
  463|       |     * a comparison is enough cheaper than a divide to make a special test
  464|       |     * a win.  Since both inputs will be nonnegative, we need only test
  465|       |     * for a < b to discover whether a/b is 0.
  466|       |     * If your machine's division is fast enough, define FAST_DIVIDE.
  467|       |     */
  468|       |#ifdef FAST_DIVIDE
  469|       |#define DIVIDE_BY(a, b)  a /= b
  470|       |#else
  471|  1.34G|#define DIVIDE_BY(a, b)  if (a >= b) a /= b;  else a = 0
  472|  1.34G|#endif
  473|  1.34G|    if (temp < 0) {
  ------------------
  |  Branch (473:9): [True: 196M, False: 1.14G]
  ------------------
  474|   196M|      temp = -temp;
  475|   196M|      temp += qval >> 1;        /* for rounding */
  476|   196M|      DIVIDE_BY(temp, qval);
  ------------------
  |  |  471|   196M|#define DIVIDE_BY(a, b)  if (a >= b) a /= b;  else a = 0
  |  |  ------------------
  |  |  |  Branch (471:30): [True: 174M, False: 22.4M]
  |  |  ------------------
  ------------------
  477|   196M|      temp = -temp;
  478|  1.14G|    } else {
  479|  1.14G|      temp += qval >> 1;        /* for rounding */
  480|  1.14G|      DIVIDE_BY(temp, qval);
  ------------------
  |  |  471|  1.14G|#define DIVIDE_BY(a, b)  if (a >= b) a /= b;  else a = 0
  |  |  ------------------
  |  |  |  Branch (471:30): [True: 159M, False: 987M]
  |  |  ------------------
  ------------------
  481|  1.14G|    }
  482|  1.34G|    output_ptr[i] = (JCOEF)temp;
  483|  1.34G|  }
  484|       |
  485|  20.9M|#endif
  486|       |
  487|  20.9M|}

jpeg_make_c_derived_tbl:
  224|  76.0k|{
  225|  76.0k|  JHUFF_TBL *htbl;
  226|  76.0k|  c_derived_tbl *dtbl;
  227|  76.0k|  int p, i, l, lastp, si, maxsymbol;
  228|  76.0k|  char huffsize[257];
  229|  76.0k|  unsigned int huffcode[257];
  230|  76.0k|  unsigned int code;
  231|       |
  232|       |  /* Note that huffsize[] and huffcode[] are filled in code-length order,
  233|       |   * paralleling the order of the symbols themselves in htbl->huffval[].
  234|       |   */
  235|       |
  236|       |  /* Find the input Huffman table */
  237|  76.0k|  if (tblno < 0 || tblno >= NUM_HUFF_TBLS)
  ------------------
  |  |   69|  76.0k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (237:7): [True: 0, False: 76.0k]
  |  Branch (237:20): [True: 0, False: 76.0k]
  ------------------
  238|      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)))
  ------------------
  239|  76.0k|  htbl =
  240|  76.0k|    isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
  ------------------
  |  Branch (240:5): [True: 32.6k, False: 43.4k]
  ------------------
  241|  76.0k|  if (htbl == NULL)
  ------------------
  |  Branch (241:7): [True: 0, False: 76.0k]
  ------------------
  242|      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)))
  ------------------
  243|       |
  244|       |  /* Allocate a workspace if we haven't already done so. */
  245|  76.0k|  if (*pdtbl == NULL)
  ------------------
  |  Branch (245:7): [True: 44.2k, False: 31.8k]
  ------------------
  246|  44.2k|    *pdtbl = (c_derived_tbl *)
  247|  44.2k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  44.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  248|  44.2k|                                  sizeof(c_derived_tbl));
  249|  76.0k|  dtbl = *pdtbl;
  250|       |
  251|       |  /* Figure C.1: make table of Huffman code length for each symbol */
  252|       |
  253|  76.0k|  p = 0;
  254|  1.29M|  for (l = 1; l <= 16; l++) {
  ------------------
  |  Branch (254:15): [True: 1.21M, False: 76.0k]
  ------------------
  255|  1.21M|    i = (int)htbl->bits[l];
  256|  1.21M|    if (i < 0 || p + i > 256)   /* protect against table overrun */
  ------------------
  |  Branch (256:9): [True: 0, False: 1.21M]
  |  Branch (256:18): [True: 0, False: 1.21M]
  ------------------
  257|      0|      ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  258|  1.87M|    while (i--)
  ------------------
  |  Branch (258:12): [True: 660k, False: 1.21M]
  ------------------
  259|   660k|      huffsize[p++] = (char)l;
  260|  1.21M|  }
  261|  76.0k|  huffsize[p] = 0;
  262|  76.0k|  lastp = p;
  263|       |
  264|       |  /* Figure C.2: generate the codes themselves */
  265|       |  /* We also validate that the counts represent a legal Huffman code tree. */
  266|       |
  267|  76.0k|  code = 0;
  268|  76.0k|  si = huffsize[0];
  269|  76.0k|  p = 0;
  270|   366k|  while (huffsize[p]) {
  ------------------
  |  Branch (270:10): [True: 290k, False: 76.0k]
  ------------------
  271|   950k|    while (((int)huffsize[p]) == si) {
  ------------------
  |  Branch (271:12): [True: 660k, False: 290k]
  ------------------
  272|   660k|      huffcode[p++] = code;
  273|   660k|      code++;
  274|   660k|    }
  275|       |    /* code is now 1 more than the last code used for codelength si; but
  276|       |     * it must still fit in si bits, since no code is allowed to be all ones.
  277|       |     */
  278|   290k|    if (((JLONG)code) >= (((JLONG)1) << si))
  ------------------
  |  Branch (278:9): [True: 0, False: 290k]
  ------------------
  279|      0|      ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  280|   290k|    code <<= 1;
  281|   290k|    si++;
  282|   290k|  }
  283|       |
  284|       |  /* Figure C.3: generate encoding tables */
  285|       |  /* These are code and size indexed by symbol value */
  286|       |
  287|       |  /* Set all codeless symbols to have code length 0;
  288|       |   * this lets us detect duplicate VAL entries here, and later
  289|       |   * allows emit_bits to detect any attempt to emit such symbols.
  290|       |   */
  291|  76.0k|  memset(dtbl->ehufco, 0, sizeof(dtbl->ehufco));
  292|  76.0k|  memset(dtbl->ehufsi, 0, sizeof(dtbl->ehufsi));
  293|       |
  294|       |  /* This is also a convenient place to check for out-of-range and duplicated
  295|       |   * VAL entries.  We allow 0..255 for AC symbols but only 0..15 for DC in
  296|       |   * lossy mode and 0..16 for DC in lossless mode.  (We could constrain them
  297|       |   * further based on data depth and mode, but this seems enough.)
  298|       |   */
  299|  76.0k|  maxsymbol = isDC ? (cinfo->master->lossless ? 16 : 15) : 255;
  ------------------
  |  Branch (299:15): [True: 32.6k, False: 43.4k]
  |  Branch (299:23): [True: 0, False: 32.6k]
  ------------------
  300|       |
  301|   736k|  for (p = 0; p < lastp; p++) {
  ------------------
  |  Branch (301:15): [True: 660k, False: 76.0k]
  ------------------
  302|   660k|    i = htbl->huffval[p];
  303|   660k|    if (i < 0 || i > maxsymbol || dtbl->ehufsi[i])
  ------------------
  |  Branch (303:9): [True: 0, False: 660k]
  |  Branch (303:18): [True: 0, False: 660k]
  |  Branch (303:35): [True: 0, False: 660k]
  ------------------
  304|      0|      ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  305|   660k|    dtbl->ehufco[i] = huffcode[p];
  306|   660k|    dtbl->ehufsi[i] = huffsize[p];
  307|   660k|  }
  308|  76.0k|}
jpeg_gen_optimal_table:
  931|  58.5k|{
  932|  58.5k|#define MAX_CLEN  32            /* assumed maximum initial code length */
  933|       |  /* The array length is MAX_CLEN + 2 rather than MAX_CLEN + 1 to work around a
  934|       |   * -Wstringop-overflow false positive with GCC 12 and later.
  935|       |   */
  936|  58.5k|  UINT8 bits[MAX_CLEN + 2];     /* bits[k] = # of symbols with code length k */
  937|  58.5k|  int bit_pos[MAX_CLEN + 1];    /* # of symbols with smaller code length */
  938|  58.5k|  int codesize[257];            /* codesize[k] = code length of symbol k */
  939|  58.5k|  int nz_index[257];            /* index of nonzero symbol in the original freq
  940|       |                                   array */
  941|  58.5k|  int others[257];              /* next symbol in current branch of tree */
  942|  58.5k|  int c1, c2;
  943|  58.5k|  int p, i, j;
  944|  58.5k|  int num_nz_symbols;
  945|  58.5k|  long v, v2;
  946|       |
  947|       |  /* This algorithm is explained in section K.2 of the JPEG standard */
  948|       |
  949|  58.5k|  memset(bits, 0, sizeof(bits));
  950|  58.5k|  memset(codesize, 0, sizeof(codesize));
  951|  15.1M|  for (i = 0; i < 257; i++)
  ------------------
  |  Branch (951:15): [True: 15.0M, False: 58.5k]
  ------------------
  952|  15.0M|    others[i] = -1;             /* init links to empty */
  953|       |
  954|  58.5k|  freq[256] = 1;                /* make sure 256 has a nonzero count */
  955|       |  /* Including the pseudo-symbol 256 in the Huffman procedure guarantees
  956|       |   * that no real symbol is given code-value of all ones, because 256
  957|       |   * will be placed last in the largest codeword category.
  958|       |   */
  959|       |
  960|       |  /* Group nonzero frequencies together so we can more easily find the
  961|       |   * smallest.
  962|       |   */
  963|  58.5k|  num_nz_symbols = 0;
  964|  15.1M|  for (i = 0; i < 257; i++) {
  ------------------
  |  Branch (964:15): [True: 15.0M, False: 58.5k]
  ------------------
  965|  15.0M|    if (freq[i]) {
  ------------------
  |  Branch (965:9): [True: 596k, False: 14.4M]
  ------------------
  966|   596k|      nz_index[num_nz_symbols] = i;
  967|   596k|      freq[num_nz_symbols] = freq[i];
  968|   596k|      num_nz_symbols++;
  969|   596k|    }
  970|  15.0M|  }
  971|       |
  972|       |  /* Huffman's basic algorithm to assign optimal code lengths to symbols */
  973|       |
  974|   596k|  for (;;) {
  975|       |    /* Find the two smallest nonzero frequencies; set c1, c2 = their symbols */
  976|       |    /* In case of ties, take the larger symbol number.  Since we have grouped
  977|       |     * the nonzero symbols together, checking for zero symbols is not
  978|       |     * necessary.
  979|       |     */
  980|   596k|    c1 = -1;
  981|   596k|    c2 = -1;
  982|   596k|    v = 1000000000L;
  983|   596k|    v2 = 1000000000L;
  984|  16.3M|    for (i = 0; i < num_nz_symbols; i++) {
  ------------------
  |  Branch (984:17): [True: 15.7M, False: 596k]
  ------------------
  985|  15.7M|      if (freq[i] <= v2) {
  ------------------
  |  Branch (985:11): [True: 3.63M, False: 12.1M]
  ------------------
  986|  3.63M|        if (freq[i] <= v) {
  ------------------
  |  Branch (986:13): [True: 2.38M, False: 1.25M]
  ------------------
  987|  2.38M|          c2 = c1;
  988|  2.38M|          v2 = v;
  989|  2.38M|          v = freq[i];
  990|  2.38M|          c1 = i;
  991|  2.38M|        } else {
  992|  1.25M|          v2 = freq[i];
  993|  1.25M|          c2 = i;
  994|  1.25M|        }
  995|  3.63M|      }
  996|  15.7M|    }
  997|       |
  998|       |    /* Done if we've merged everything into one frequency */
  999|   596k|    if (c2 < 0)
  ------------------
  |  Branch (999:9): [True: 58.5k, False: 538k]
  ------------------
 1000|  58.5k|      break;
 1001|       |
 1002|       |    /* Else merge the two counts/trees */
 1003|   538k|    freq[c1] += freq[c2];
 1004|       |    /* Set the frequency to a very high value instead of zero, so we don't have
 1005|       |     * to check for zero values.
 1006|       |     */
 1007|   538k|    freq[c2] = 1000000001L;
 1008|       |
 1009|       |    /* Increment the codesize of everything in c1's tree branch */
 1010|   538k|    codesize[c1]++;
 1011|  1.63M|    while (others[c1] >= 0) {
  ------------------
  |  Branch (1011:12): [True: 1.09M, False: 538k]
  ------------------
 1012|  1.09M|      c1 = others[c1];
 1013|  1.09M|      codesize[c1]++;
 1014|  1.09M|    }
 1015|       |
 1016|   538k|    others[c1] = c2;            /* chain c2 onto c1's tree branch */
 1017|       |
 1018|       |    /* Increment the codesize of everything in c2's tree branch */
 1019|   538k|    codesize[c2]++;
 1020|  1.75M|    while (others[c2] >= 0) {
  ------------------
  |  Branch (1020:12): [True: 1.22M, False: 538k]
  ------------------
 1021|  1.22M|      c2 = others[c2];
 1022|  1.22M|      codesize[c2]++;
 1023|  1.22M|    }
 1024|   538k|  }
 1025|       |
 1026|       |  /* Now count the number of symbols of each code length */
 1027|   655k|  for (i = 0; i < num_nz_symbols; i++) {
  ------------------
  |  Branch (1027:15): [True: 596k, False: 58.5k]
  ------------------
 1028|       |    /* The JPEG standard seems to think that this can't happen, */
 1029|       |    /* but I'm paranoid... */
 1030|   596k|    if (codesize[i] > MAX_CLEN)
  ------------------
  |  |  932|   596k|#define MAX_CLEN  32            /* assumed maximum initial code length */
  ------------------
  |  Branch (1030:9): [True: 0, False: 596k]
  ------------------
 1031|      0|      ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
 1032|       |
 1033|   596k|    bits[codesize[i]]++;
 1034|   596k|  }
 1035|       |
 1036|       |  /* Count the number of symbols with a length smaller than i bits, so we can
 1037|       |   * construct the symbol table more efficiently.  Note that this includes the
 1038|       |   * pseudo-symbol 256, but since it is the last symbol, it will not affect the
 1039|       |   * table.
 1040|       |   */
 1041|  58.5k|  p = 0;
 1042|  1.93M|  for (i = 1; i <= MAX_CLEN; i++) {
  ------------------
  |  |  932|  1.93M|#define MAX_CLEN  32            /* assumed maximum initial code length */
  ------------------
  |  Branch (1042:15): [True: 1.87M, False: 58.5k]
  ------------------
 1043|  1.87M|    bit_pos[i] = p;
 1044|  1.87M|    p += bits[i];
 1045|  1.87M|  }
 1046|       |
 1047|       |  /* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure
 1048|       |   * Huffman procedure assigned any such lengths, we must adjust the coding.
 1049|       |   * Here is what Rec. ITU-T T.81 | ISO/IEC 10918-1 says about how this next
 1050|       |   * bit works: Since symbols are paired for the longest Huffman code, the
 1051|       |   * symbols are removed from this length category two at a time.  The prefix
 1052|       |   * for the pair (which is one bit shorter) is allocated to one of the pair;
 1053|       |   * then, skipping the BITS entry for that prefix length, a code word from the
 1054|       |   * next shortest nonzero BITS entry is converted into a prefix for two code
 1055|       |   * words one bit longer.
 1056|       |   */
 1057|       |
 1058|   995k|  for (i = MAX_CLEN; i > 16; i--) {
  ------------------
  |  |  932|  58.5k|#define MAX_CLEN  32            /* assumed maximum initial code length */
  ------------------
  |  Branch (1058:22): [True: 937k, False: 58.5k]
  ------------------
 1059|   943k|    while (bits[i] > 0) {
  ------------------
  |  Branch (1059:12): [True: 6.77k, False: 937k]
  ------------------
 1060|  6.77k|      j = i - 2;                /* find length of new prefix to be used */
 1061|  8.66k|      while (bits[j] == 0)
  ------------------
  |  Branch (1061:14): [True: 1.88k, False: 6.77k]
  ------------------
 1062|  1.88k|        j--;
 1063|       |
 1064|  6.77k|      bits[i] -= 2;             /* remove two symbols */
 1065|  6.77k|      bits[i - 1]++;            /* one goes in this length */
 1066|  6.77k|      bits[j + 1] += 2;         /* two new symbols in this length */
 1067|  6.77k|      bits[j]--;                /* symbol of this length is now a prefix */
 1068|  6.77k|    }
 1069|   937k|  }
 1070|       |
 1071|       |  /* Remove the count for the pseudo-symbol 256 from the largest codelength */
 1072|   733k|  while (bits[i] == 0)          /* find largest codelength still in use */
  ------------------
  |  Branch (1072:10): [True: 674k, False: 58.5k]
  ------------------
 1073|   674k|    i--;
 1074|  58.5k|  bits[i]--;
 1075|       |
 1076|       |  /* Return final symbol counts (only for lengths 0..16) */
 1077|  58.5k|  memcpy(htbl->bits, bits, sizeof(htbl->bits));
 1078|       |
 1079|       |  /* Return a list of the symbols sorted by code length */
 1080|       |  /* It's not real clear to me why we don't need to consider the codelength
 1081|       |   * changes made above, but Rec. ITU-T T.81 | ISO/IEC 10918-1 seems to think
 1082|       |   * this works.
 1083|       |   */
 1084|   596k|  for (i = 0; i < num_nz_symbols - 1; i++) {
  ------------------
  |  Branch (1084:15): [True: 538k, False: 58.5k]
  ------------------
 1085|   538k|    htbl->huffval[bit_pos[codesize[i]]] = (UINT8)nz_index[i];
 1086|   538k|    bit_pos[codesize[i]]++;
 1087|   538k|  }
 1088|       |
 1089|       |  /* Set sent_table FALSE so updated table will be written to JPEG file. */
 1090|  58.5k|  htbl->sent_table = FALSE;
  ------------------
  |  |  207|  58.5k|#define FALSE   0               /* values of boolean */
  ------------------
 1091|  58.5k|}
jinit_huff_encoder:
 1145|  11.5k|{
 1146|  11.5k|  huff_entropy_ptr entropy;
 1147|  11.5k|  int i;
 1148|       |
 1149|  11.5k|  entropy = (huff_entropy_ptr)
 1150|  11.5k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  11.5k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
 1151|  11.5k|                                sizeof(huff_entropy_encoder));
 1152|  11.5k|  cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
 1153|  11.5k|  entropy->pub.start_pass = start_pass_huff;
 1154|       |
 1155|       |  /* Mark tables unallocated */
 1156|  57.8k|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|  57.8k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (1156:15): [True: 46.3k, False: 11.5k]
  ------------------
 1157|  46.3k|    entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;
 1158|  46.3k|#ifdef ENTROPY_OPT_SUPPORTED
 1159|       |    entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL;
 1160|  46.3k|#endif
 1161|  46.3k|  }
 1162|  11.5k|}
jchuff.c:start_pass_huff:
  138|  23.1k|{
  139|  23.1k|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  140|  23.1k|  int ci, dctbl, actbl;
  141|  23.1k|  jpeg_component_info *compptr;
  142|       |
  143|  23.1k|  if (gather_statistics) {
  ------------------
  |  Branch (143:7): [True: 11.5k, False: 11.5k]
  ------------------
  144|  11.5k|#ifdef ENTROPY_OPT_SUPPORTED
  145|  11.5k|    entropy->pub.encode_mcu = encode_mcu_gather;
  146|  11.5k|    entropy->pub.finish_pass = finish_pass_gather;
  147|       |#else
  148|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  149|       |#endif
  150|  11.5k|  } else {
  151|  11.5k|    entropy->pub.encode_mcu = encode_mcu_huff;
  152|  11.5k|    entropy->pub.finish_pass = finish_pass_huff;
  153|  11.5k|  }
  154|       |
  155|  23.1k|#ifdef WITH_SIMD
  156|  23.1k|  entropy->simd = jsimd_set_huff_encode_one_block(cinfo);
  157|  23.1k|#endif
  158|       |
  159|  81.2k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (159:16): [True: 58.1k, False: 23.1k]
  ------------------
  160|  58.1k|    compptr = cinfo->cur_comp_info[ci];
  161|  58.1k|    dctbl = compptr->dc_tbl_no;
  162|  58.1k|    actbl = compptr->ac_tbl_no;
  163|  58.1k|    if (gather_statistics) {
  ------------------
  |  Branch (163:9): [True: 29.0k, False: 29.0k]
  ------------------
  164|  29.0k|#ifdef ENTROPY_OPT_SUPPORTED
  165|       |      /* Check for invalid table indexes */
  166|       |      /* (make_c_derived_tbl does this in the other path) */
  167|  29.0k|      if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS)
  ------------------
  |  |   69|  29.0k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (167:11): [True: 0, False: 29.0k]
  |  Branch (167:24): [True: 0, False: 29.0k]
  ------------------
  168|      0|        ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl);
  ------------------
  |  |  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)))
  ------------------
  169|  29.0k|      if (actbl < 0 || actbl >= NUM_HUFF_TBLS)
  ------------------
  |  |   69|  29.0k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (169:11): [True: 0, False: 29.0k]
  |  Branch (169:24): [True: 0, False: 29.0k]
  ------------------
  170|      0|        ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl);
  ------------------
  |  |  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)))
  ------------------
  171|       |      /* Allocate and zero the statistics tables */
  172|       |      /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
  173|  29.0k|      if (entropy->dc_count_ptrs[dctbl] == NULL)
  ------------------
  |  Branch (173:11): [True: 20.3k, False: 8.74k]
  ------------------
  174|  20.3k|        entropy->dc_count_ptrs[dctbl] = (long *)
  175|  20.3k|          (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  20.3k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  176|  20.3k|                                      257 * sizeof(long));
  177|  29.0k|      memset(entropy->dc_count_ptrs[dctbl], 0, 257 * sizeof(long));
  178|  29.0k|      if (entropy->ac_count_ptrs[actbl] == NULL)
  ------------------
  |  Branch (178:11): [True: 20.3k, False: 8.74k]
  ------------------
  179|  20.3k|        entropy->ac_count_ptrs[actbl] = (long *)
  180|  20.3k|          (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  20.3k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  181|  20.3k|                                      257 * sizeof(long));
  182|  29.0k|      memset(entropy->ac_count_ptrs[actbl], 0, 257 * sizeof(long));
  183|  29.0k|#endif
  184|  29.0k|    } else {
  185|       |      /* Compute derived values for Huffman tables */
  186|       |      /* We may do this more than once for a table, but it's not expensive */
  187|  29.0k|      jpeg_make_c_derived_tbl(cinfo, TRUE, dctbl,
  ------------------
  |  |  210|  29.0k|#define TRUE    1
  ------------------
  188|  29.0k|                              &entropy->dc_derived_tbls[dctbl]);
  189|  29.0k|      jpeg_make_c_derived_tbl(cinfo, FALSE, actbl,
  ------------------
  |  |  207|  29.0k|#define FALSE   0               /* values of boolean */
  ------------------
  190|  29.0k|                              &entropy->ac_derived_tbls[actbl]);
  191|  29.0k|    }
  192|       |    /* Initialize DC predictions to 0 */
  193|  58.1k|    entropy->saved.last_dc_val[ci] = 0;
  194|  58.1k|  }
  195|       |
  196|       |  /* Initialize bit buffer to empty */
  197|  23.1k|#ifdef WITH_SIMD
  198|  23.1k|  if (entropy->simd) {
  ------------------
  |  Branch (198:7): [True: 23.1k, False: 0]
  ------------------
  199|  23.1k|    entropy->saved.put_buffer.simd = 0;
  200|  23.1k|    entropy->saved.free_bits = SIMD_BIT_BUF_SIZE;
  ------------------
  |  |   67|  23.1k|#define SIMD_BIT_BUF_SIZE  (sizeof(simd_bit_buf_type) * 8)
  ------------------
  201|  23.1k|  } else
  202|      0|#endif
  203|      0|  {
  204|      0|    entropy->saved.put_buffer.c = 0;
  205|      0|    entropy->saved.free_bits = BIT_BUF_SIZE;
  ------------------
  |  |   61|      0|#define BIT_BUF_SIZE  64
  ------------------
  206|      0|  }
  207|       |
  208|       |  /* Initialize restart stuff */
  209|  23.1k|  entropy->restarts_to_go = cinfo->restart_interval;
  210|  23.1k|  entropy->next_restart_num = 0;
  211|  23.1k|}
jchuff.c:encode_mcu_gather:
  870|  4.67M|{
  871|  4.67M|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  872|  4.67M|  int blkn, ci;
  873|  4.67M|  jpeg_component_info *compptr;
  874|       |
  875|       |  /* Take care of restart intervals if needed */
  876|  4.67M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (876:7): [True: 0, False: 4.67M]
  ------------------
  877|      0|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (877:9): [True: 0, False: 0]
  ------------------
  878|       |      /* Re-initialize DC predictions to 0 */
  879|      0|      for (ci = 0; ci < cinfo->comps_in_scan; ci++)
  ------------------
  |  Branch (879:20): [True: 0, False: 0]
  ------------------
  880|      0|        entropy->saved.last_dc_val[ci] = 0;
  881|       |      /* Update restart state */
  882|      0|      entropy->restarts_to_go = cinfo->restart_interval;
  883|      0|    }
  884|      0|    entropy->restarts_to_go--;
  885|      0|  }
  886|       |
  887|  19.0M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (887:18): [True: 14.4M, False: 4.67M]
  ------------------
  888|  14.4M|    ci = cinfo->MCU_membership[blkn];
  889|  14.4M|    compptr = cinfo->cur_comp_info[ci];
  890|  14.4M|    htest_one_block(cinfo, MCU_data[blkn][0], entropy->saved.last_dc_val[ci],
  891|  14.4M|                    entropy->dc_count_ptrs[compptr->dc_tbl_no],
  892|  14.4M|                    entropy->ac_count_ptrs[compptr->ac_tbl_no]);
  893|  14.4M|    entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0];
  894|  14.4M|  }
  895|       |
  896|  4.67M|  return TRUE;
  ------------------
  |  |  210|  4.67M|#define TRUE    1
  ------------------
  897|  4.67M|}
jchuff.c:htest_one_block:
  797|  14.4M|{
  798|  14.4M|  register int temp;
  799|  14.4M|  register int nbits;
  800|  14.4M|  register int k, r;
  801|  14.4M|  int max_coef_bits = cinfo->data_precision + 2;
  802|       |
  803|       |  /* Encode the DC coefficient difference per section F.1.2.1 */
  804|       |
  805|  14.4M|  temp = block[0] - last_dc_val;
  806|  14.4M|  if (temp < 0)
  ------------------
  |  Branch (806:7): [True: 2.25M, False: 12.1M]
  ------------------
  807|  2.25M|    temp = -temp;
  808|       |
  809|       |  /* Find the number of bits needed for the magnitude of the coefficient */
  810|  14.4M|  nbits = 0;
  811|  53.5M|  while (temp) {
  ------------------
  |  Branch (811:10): [True: 39.1M, False: 14.4M]
  ------------------
  812|  39.1M|    nbits++;
  813|  39.1M|    temp >>= 1;
  814|  39.1M|  }
  815|       |  /* Check for out-of-range coefficient values.
  816|       |   * Since we're encoding a difference, the range limit is twice as much.
  817|       |   */
  818|  14.4M|  if (nbits > max_coef_bits + 1)
  ------------------
  |  Branch (818:7): [True: 0, False: 14.4M]
  ------------------
  819|      0|    ERREXIT(cinfo, JERR_BAD_DCT_COEF);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  820|       |
  821|       |  /* Count the Huffman symbol for the number of bits */
  822|  14.4M|  dc_counts[nbits]++;
  823|       |
  824|       |  /* Encode the AC coefficients per section F.1.2.2 */
  825|       |
  826|  14.4M|  r = 0;                        /* r = run length of zeros */
  827|       |
  828|   921M|  for (k = 1; k < DCTSIZE2; k++) {
  ------------------
  |  |   67|   921M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (828:15): [True: 907M, False: 14.4M]
  ------------------
  829|   907M|    if ((temp = block[jpeg_natural_order[k]]) == 0) {
  ------------------
  |  Branch (829:9): [True: 712M, False: 195M]
  ------------------
  830|   712M|      r++;
  831|   712M|    } else {
  832|       |      /* if run length > 15, must emit special run-length-16 codes (0xF0) */
  833|   195M|      while (r > 15) {
  ------------------
  |  Branch (833:14): [True: 3.45k, False: 195M]
  ------------------
  834|  3.45k|        ac_counts[0xF0]++;
  835|  3.45k|        r -= 16;
  836|  3.45k|      }
  837|       |
  838|       |      /* Find the number of bits needed for the magnitude of the coefficient */
  839|   195M|      if (temp < 0)
  ------------------
  |  Branch (839:11): [True: 98.5M, False: 96.6M]
  ------------------
  840|  98.5M|        temp = -temp;
  841|       |
  842|       |      /* Find the number of bits needed for the magnitude of the coefficient */
  843|   195M|      nbits = 1;                /* there must be at least one 1 bit */
  844|  1.09G|      while ((temp >>= 1))
  ------------------
  |  Branch (844:14): [True: 899M, False: 195M]
  ------------------
  845|   899M|        nbits++;
  846|       |      /* Check for out-of-range coefficient values */
  847|   195M|      if (nbits > max_coef_bits)
  ------------------
  |  Branch (847:11): [True: 0, False: 195M]
  ------------------
  848|      0|        ERREXIT(cinfo, JERR_BAD_DCT_COEF);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  849|       |
  850|       |      /* Count Huffman symbol for run length / number of bits */
  851|   195M|      ac_counts[(r << 4) + nbits]++;
  852|       |
  853|   195M|      r = 0;
  854|   195M|    }
  855|   907M|  }
  856|       |
  857|       |  /* If the last coef(s) were zero, emit an end-of-block code */
  858|  14.4M|  if (r > 0)
  ------------------
  |  Branch (858:7): [True: 11.7M, False: 2.67M]
  ------------------
  859|  11.7M|    ac_counts[0]++;
  860|  14.4M|}
jchuff.c:finish_pass_gather:
 1100|  11.5k|{
 1101|  11.5k|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
 1102|  11.5k|  int ci, dctbl, actbl;
 1103|  11.5k|  jpeg_component_info *compptr;
 1104|  11.5k|  JHUFF_TBL **htblptr;
 1105|  11.5k|  boolean did_dc[NUM_HUFF_TBLS];
 1106|  11.5k|  boolean did_ac[NUM_HUFF_TBLS];
 1107|       |
 1108|       |  /* It's important not to apply jpeg_gen_optimal_table more than once
 1109|       |   * per table, because it clobbers the input frequency counts!
 1110|       |   */
 1111|  11.5k|  memset(did_dc, 0, sizeof(did_dc));
 1112|  11.5k|  memset(did_ac, 0, sizeof(did_ac));
 1113|       |
 1114|  40.6k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (1114:16): [True: 29.0k, False: 11.5k]
  ------------------
 1115|  29.0k|    compptr = cinfo->cur_comp_info[ci];
 1116|  29.0k|    dctbl = compptr->dc_tbl_no;
 1117|  29.0k|    actbl = compptr->ac_tbl_no;
 1118|  29.0k|    if (!did_dc[dctbl]) {
  ------------------
  |  Branch (1118:9): [True: 20.3k, False: 8.74k]
  ------------------
 1119|  20.3k|      htblptr = &cinfo->dc_huff_tbl_ptrs[dctbl];
 1120|  20.3k|      if (*htblptr == NULL)
  ------------------
  |  Branch (1120:11): [True: 0, False: 20.3k]
  ------------------
 1121|      0|        *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
 1122|  20.3k|      jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[dctbl]);
 1123|  20.3k|      did_dc[dctbl] = TRUE;
  ------------------
  |  |  210|  20.3k|#define TRUE    1
  ------------------
 1124|  20.3k|    }
 1125|  29.0k|    if (!did_ac[actbl]) {
  ------------------
  |  Branch (1125:9): [True: 20.3k, False: 8.74k]
  ------------------
 1126|  20.3k|      htblptr = &cinfo->ac_huff_tbl_ptrs[actbl];
 1127|  20.3k|      if (*htblptr == NULL)
  ------------------
  |  Branch (1127:11): [True: 0, False: 20.3k]
  ------------------
 1128|      0|        *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
 1129|  20.3k|      jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[actbl]);
 1130|  20.3k|      did_ac[actbl] = TRUE;
  ------------------
  |  |  210|  20.3k|#define TRUE    1
  ------------------
 1131|  20.3k|    }
 1132|  29.0k|  }
 1133|  11.5k|}
jchuff.c:encode_mcu_huff:
  677|  4.67M|{
  678|  4.67M|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  679|  4.67M|  working_state state;
  680|  4.67M|  int blkn, ci;
  681|  4.67M|  jpeg_component_info *compptr;
  682|       |
  683|       |  /* Load up working state */
  684|  4.67M|  state.next_output_byte = cinfo->dest->next_output_byte;
  685|  4.67M|  state.free_in_buffer = cinfo->dest->free_in_buffer;
  686|  4.67M|  state.cur = entropy->saved;
  687|  4.67M|  state.cinfo = cinfo;
  688|  4.67M|#ifdef WITH_SIMD
  689|  4.67M|  state.simd = entropy->simd;
  690|  4.67M|#endif
  691|       |
  692|       |  /* Emit restart marker if needed */
  693|  4.67M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (693:7): [True: 0, False: 4.67M]
  ------------------
  694|      0|    if (entropy->restarts_to_go == 0)
  ------------------
  |  Branch (694:9): [True: 0, False: 0]
  ------------------
  695|      0|      if (!emit_restart(&state, entropy->next_restart_num))
  ------------------
  |  Branch (695:11): [True: 0, False: 0]
  ------------------
  696|      0|        return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  697|      0|  }
  698|       |
  699|       |  /* Encode the MCU data blocks */
  700|  4.67M|#ifdef WITH_SIMD
  701|  4.67M|  if (entropy->simd) {
  ------------------
  |  Branch (701:7): [True: 4.67M, False: 0]
  ------------------
  702|  19.0M|    for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (702:20): [True: 14.4M, False: 4.67M]
  ------------------
  703|  14.4M|      ci = cinfo->MCU_membership[blkn];
  704|  14.4M|      compptr = cinfo->cur_comp_info[ci];
  705|  14.4M|      if (!encode_one_block_simd(&state,
  ------------------
  |  Branch (705:11): [True: 0, False: 14.4M]
  ------------------
  706|  14.4M|                                 MCU_data[blkn][0], state.cur.last_dc_val[ci],
  707|  14.4M|                                 entropy->dc_derived_tbls[compptr->dc_tbl_no],
  708|  14.4M|                                 entropy->ac_derived_tbls[compptr->ac_tbl_no]))
  709|      0|        return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  710|       |      /* Update last_dc_val */
  711|  14.4M|      state.cur.last_dc_val[ci] = MCU_data[blkn][0][0];
  712|  14.4M|    }
  713|  4.67M|  } else
  714|      0|#endif
  715|      0|  {
  716|      0|    for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (716:20): [True: 0, False: 0]
  ------------------
  717|      0|      ci = cinfo->MCU_membership[blkn];
  718|      0|      compptr = cinfo->cur_comp_info[ci];
  719|      0|      if (!encode_one_block(&state,
  ------------------
  |  Branch (719:11): [True: 0, False: 0]
  ------------------
  720|      0|                            MCU_data[blkn][0], state.cur.last_dc_val[ci],
  721|      0|                            entropy->dc_derived_tbls[compptr->dc_tbl_no],
  722|      0|                            entropy->ac_derived_tbls[compptr->ac_tbl_no]))
  723|      0|        return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  724|       |      /* Update last_dc_val */
  725|      0|      state.cur.last_dc_val[ci] = MCU_data[blkn][0][0];
  726|      0|    }
  727|      0|  }
  728|       |
  729|       |  /* Completed MCU, so update state */
  730|  4.67M|  cinfo->dest->next_output_byte = state.next_output_byte;
  731|  4.67M|  cinfo->dest->free_in_buffer = state.free_in_buffer;
  732|  4.67M|  entropy->saved = state.cur;
  733|       |
  734|       |  /* Update restart-interval state too */
  735|  4.67M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (735:7): [True: 0, False: 4.67M]
  ------------------
  736|      0|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (736:9): [True: 0, False: 0]
  ------------------
  737|      0|      entropy->restarts_to_go = cinfo->restart_interval;
  738|      0|      entropy->next_restart_num++;
  739|      0|      entropy->next_restart_num &= 7;
  740|      0|    }
  741|      0|    entropy->restarts_to_go--;
  742|      0|  }
  743|       |
  744|  4.67M|  return TRUE;
  ------------------
  |  |  210|  4.67M|#define TRUE    1
  ------------------
  745|  4.67M|}
jchuff.c:flush_bits:
  471|  11.5k|{
  472|  11.5k|  JOCTET _buffer[BUFSIZE], *buffer, temp;
  473|  11.5k|  simd_bit_buf_type put_buffer;  int put_bits;
  474|  11.5k|  int localbuf = 0;
  475|       |
  476|  11.5k|#ifdef WITH_SIMD
  477|  11.5k|  if (state->simd) {
  ------------------
  |  Branch (477:7): [True: 11.5k, False: 0]
  ------------------
  478|  11.5k|    put_bits = SIMD_BIT_BUF_SIZE - state->cur.free_bits;
  ------------------
  |  |   67|  11.5k|#define SIMD_BIT_BUF_SIZE  (sizeof(simd_bit_buf_type) * 8)
  ------------------
  479|  11.5k|    put_buffer = state->cur.put_buffer.simd;
  480|  11.5k|  } else
  481|      0|#endif
  482|      0|  {
  483|      0|    put_bits = BIT_BUF_SIZE - state->cur.free_bits;
  ------------------
  |  |   61|      0|#define BIT_BUF_SIZE  64
  ------------------
  484|      0|    put_buffer = state->cur.put_buffer.c;
  485|      0|  }
  486|       |
  487|  11.5k|  LOAD_BUFFER()
  ------------------
  |  |  439|  11.5k|#define LOAD_BUFFER() { \
  |  |  440|  11.5k|  if (state->free_in_buffer < BUFSIZE) { \
  |  |  ------------------
  |  |  |  |  437|  11.5k|#define BUFSIZE  (DCTSIZE2 * 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   67|  11.5k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (440:7): [True: 151, False: 11.4k]
  |  |  ------------------
  |  |  441|    151|    localbuf = 1; \
  |  |  442|    151|    buffer = _buffer; \
  |  |  443|    151|  } else \
  |  |  444|  11.5k|    buffer = state->next_output_byte; \
  |  |  445|  11.5k|}
  ------------------
  488|       |
  489|  50.3k|  while (put_bits >= 8) {
  ------------------
  |  Branch (489:10): [True: 38.7k, False: 11.5k]
  ------------------
  490|  38.7k|    put_bits -= 8;
  491|  38.7k|    temp = (JOCTET)(put_buffer >> put_bits);
  492|  38.7k|    EMIT_BYTE(temp)
  ------------------
  |  |  344|  38.7k|#define EMIT_BYTE(b) { \
  |  |  345|  38.7k|  buffer[0] = (JOCTET)(b); \
  |  |  346|  38.7k|  buffer[1] = 0; \
  |  |  347|  38.7k|  buffer -= -2 + ((JOCTET)(b) < 0xFF); \
  |  |  348|  38.7k|}
  ------------------
  493|  38.7k|  }
  494|  11.5k|  if (put_bits) {
  ------------------
  |  Branch (494:7): [True: 10.1k, False: 1.45k]
  ------------------
  495|       |    /* fill partial byte with ones */
  496|  10.1k|    temp = (JOCTET)((put_buffer << (8 - put_bits)) | (0xFF >> put_bits));
  497|  10.1k|    EMIT_BYTE(temp)
  ------------------
  |  |  344|  10.1k|#define EMIT_BYTE(b) { \
  |  |  345|  10.1k|  buffer[0] = (JOCTET)(b); \
  |  |  346|  10.1k|  buffer[1] = 0; \
  |  |  347|  10.1k|  buffer -= -2 + ((JOCTET)(b) < 0xFF); \
  |  |  348|  10.1k|}
  ------------------
  498|  10.1k|  }
  499|       |
  500|  11.5k|#ifdef WITH_SIMD
  501|  11.5k|  if (state->simd) {                    /* and reset bit buffer to empty */
  ------------------
  |  Branch (501:7): [True: 11.5k, False: 0]
  ------------------
  502|  11.5k|    state->cur.put_buffer.simd = 0;
  503|  11.5k|    state->cur.free_bits = SIMD_BIT_BUF_SIZE;
  ------------------
  |  |   67|  11.5k|#define SIMD_BIT_BUF_SIZE  (sizeof(simd_bit_buf_type) * 8)
  ------------------
  504|  11.5k|  } else
  505|      0|#endif
  506|      0|  {
  507|      0|    state->cur.put_buffer.c = 0;
  508|      0|    state->cur.free_bits = BIT_BUF_SIZE;
  ------------------
  |  |   61|      0|#define BIT_BUF_SIZE  64
  ------------------
  509|      0|  }
  510|  11.5k|  STORE_BUFFER()
  ------------------
  |  |  447|  11.5k|#define STORE_BUFFER() { \
  |  |  448|  11.5k|  if (localbuf) { \
  |  |  ------------------
  |  |  |  Branch (448:7): [True: 151, False: 11.4k]
  |  |  ------------------
  |  |  449|    151|    size_t bytes, bytestocopy; \
  |  |  450|    151|    bytes = buffer - _buffer; \
  |  |  451|    151|    buffer = _buffer; \
  |  |  452|    310|    while (bytes > 0) { \
  |  |  ------------------
  |  |  |  Branch (452:12): [True: 159, False: 151]
  |  |  ------------------
  |  |  453|    159|      bytestocopy = MIN(bytes, state->free_in_buffer); \
  |  |  ------------------
  |  |  |  |  515|    159|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (515:26): [True: 148, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  454|    159|      memcpy(state->next_output_byte, buffer, bytestocopy); \
  |  |  455|    159|      state->next_output_byte += bytestocopy; \
  |  |  456|    159|      buffer += bytestocopy; \
  |  |  457|    159|      state->free_in_buffer -= bytestocopy; \
  |  |  458|    159|      if (state->free_in_buffer == 0) \
  |  |  ------------------
  |  |  |  Branch (458:11): [True: 11, False: 148]
  |  |  ------------------
  |  |  459|    159|        if (!dump_buffer(state)) return FALSE; \
  |  |  ------------------
  |  |  |  |  207|      0|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  |  Branch (459:13): [True: 0, False: 11]
  |  |  ------------------
  |  |  460|    159|      bytes -= bytestocopy; \
  |  |  461|    159|    } \
  |  |  462|  11.4k|  } else { \
  |  |  463|  11.4k|    state->free_in_buffer -= (buffer - state->next_output_byte); \
  |  |  464|  11.4k|    state->next_output_byte = buffer; \
  |  |  465|  11.4k|  } \
  |  |  466|  11.5k|}
  ------------------
  511|       |
  512|  11.5k|  return TRUE;
  ------------------
  |  |  210|  11.5k|#define TRUE    1
  ------------------
  513|  11.5k|}
jchuff.c:dump_buffer:
  325|  4.05k|{
  326|  4.05k|  struct jpeg_destination_mgr *dest = state->cinfo->dest;
  327|       |
  328|  4.05k|  if (!(*dest->empty_output_buffer) (state->cinfo))
  ------------------
  |  Branch (328:7): [True: 0, False: 4.05k]
  ------------------
  329|      0|    return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  330|       |  /* After a successful buffer dump, must reset buffer pointers */
  331|  4.05k|  state->next_output_byte = dest->next_output_byte;
  332|  4.05k|  state->free_in_buffer = dest->free_in_buffer;
  333|  4.05k|  return TRUE;
  ------------------
  |  |  210|  4.05k|#define TRUE    1
  ------------------
  334|  4.05k|}
jchuff.c:encode_one_block_simd:
  523|  14.4M|{
  524|  14.4M|  JOCTET _buffer[BUFSIZE], *buffer;
  525|  14.4M|  int localbuf = 0;
  526|       |
  527|       |#ifdef ZERO_BUFFERS
  528|       |  memset(_buffer, 0, sizeof(_buffer));
  529|       |#endif
  530|       |
  531|  14.4M|  LOAD_BUFFER()
  ------------------
  |  |  439|  14.4M|#define LOAD_BUFFER() { \
  |  |  440|  14.4M|  if (state->free_in_buffer < BUFSIZE) { \
  |  |  ------------------
  |  |  |  |  437|  14.4M|#define BUFSIZE  (DCTSIZE2 * 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   67|  14.4M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (440:7): [True: 451k, False: 13.9M]
  |  |  ------------------
  |  |  441|   451k|    localbuf = 1; \
  |  |  442|   451k|    buffer = _buffer; \
  |  |  443|   451k|  } else \
  |  |  444|  14.4M|    buffer = state->next_output_byte; \
  |  |  445|  14.4M|}
  ------------------
  532|       |
  533|  14.4M|  buffer = state->cinfo->entropy->huff_encode_one_block_simd(state, buffer,
  534|  14.4M|                                                             block,
  535|  14.4M|                                                             last_dc_val,
  536|  14.4M|                                                             dctbl, actbl);
  537|       |
  538|  14.4M|  STORE_BUFFER()
  ------------------
  |  |  447|  14.4M|#define STORE_BUFFER() { \
  |  |  448|  14.4M|  if (localbuf) { \
  |  |  ------------------
  |  |  |  Branch (448:7): [True: 451k, False: 13.9M]
  |  |  ------------------
  |  |  449|   451k|    size_t bytes, bytestocopy; \
  |  |  450|   451k|    bytes = buffer - _buffer; \
  |  |  451|   451k|    buffer = _buffer; \
  |  |  452|   545k|    while (bytes > 0) { \
  |  |  ------------------
  |  |  |  Branch (452:12): [True: 94.4k, False: 451k]
  |  |  ------------------
  |  |  453|  94.4k|      bytestocopy = MIN(bytes, state->free_in_buffer); \
  |  |  ------------------
  |  |  |  |  515|  94.4k|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (515:26): [True: 90.4k, False: 4.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  454|  94.4k|      memcpy(state->next_output_byte, buffer, bytestocopy); \
  |  |  455|  94.4k|      state->next_output_byte += bytestocopy; \
  |  |  456|  94.4k|      buffer += bytestocopy; \
  |  |  457|  94.4k|      state->free_in_buffer -= bytestocopy; \
  |  |  458|  94.4k|      if (state->free_in_buffer == 0) \
  |  |  ------------------
  |  |  |  Branch (458:11): [True: 4.04k, False: 90.4k]
  |  |  ------------------
  |  |  459|  94.4k|        if (!dump_buffer(state)) return FALSE; \
  |  |  ------------------
  |  |  |  |  207|      0|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  |  Branch (459:13): [True: 0, False: 4.04k]
  |  |  ------------------
  |  |  460|  94.4k|      bytes -= bytestocopy; \
  |  |  461|  94.4k|    } \
  |  |  462|  13.9M|  } else { \
  |  |  463|  13.9M|    state->free_in_buffer -= (buffer - state->next_output_byte); \
  |  |  464|  13.9M|    state->next_output_byte = buffer; \
  |  |  465|  13.9M|  } \
  |  |  466|  14.4M|}
  ------------------
  539|       |
  540|  14.4M|  return TRUE;
  ------------------
  |  |  210|  14.4M|#define TRUE    1
  ------------------
  541|  14.4M|}
jchuff.c:finish_pass_huff:
  754|  11.5k|{
  755|  11.5k|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  756|  11.5k|  working_state state;
  757|       |
  758|       |  /* Load up working state ... flush_bits needs it */
  759|  11.5k|  state.next_output_byte = cinfo->dest->next_output_byte;
  760|  11.5k|  state.free_in_buffer = cinfo->dest->free_in_buffer;
  761|  11.5k|  state.cur = entropy->saved;
  762|  11.5k|  state.cinfo = cinfo;
  763|  11.5k|#ifdef WITH_SIMD
  764|  11.5k|  state.simd = entropy->simd;
  765|  11.5k|#endif
  766|       |
  767|       |  /* Flush out the last data */
  768|  11.5k|  if (!flush_bits(&state))
  ------------------
  |  Branch (768:7): [True: 0, False: 11.5k]
  ------------------
  769|      0|    ERREXIT(cinfo, JERR_CANT_SUSPEND);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  770|       |
  771|       |  /* Update state */
  772|  11.5k|  cinfo->dest->next_output_byte = state.next_output_byte;
  773|  11.5k|  cinfo->dest->free_in_buffer = state.free_in_buffer;
  774|  11.5k|  entropy->saved = state.cur;
  775|  11.5k|}

jpeg_write_icc_profile:
   51|  17.7k|{
   52|  17.7k|  unsigned int num_markers;     /* total number of markers we'll write */
   53|  17.7k|  int cur_marker = 1;           /* per spec, counting starts at 1 */
   54|  17.7k|  unsigned int length;          /* number of bytes to write in this marker */
   55|       |
   56|  17.7k|  if (icc_data_ptr == NULL || icc_data_len == 0)
  ------------------
  |  Branch (56:7): [True: 0, False: 17.7k]
  |  Branch (56:31): [True: 0, False: 17.7k]
  ------------------
   57|      0|    ERREXIT(cinfo, JERR_BUFFER_SIZE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   58|  17.7k|  if (cinfo->global_state < CSTATE_SCANNING)
  ------------------
  |  |   45|  17.7k|#define CSTATE_SCANNING  101    /* start_compress done, write_scanlines OK */
  ------------------
  |  Branch (58:7): [True: 0, False: 17.7k]
  ------------------
   59|      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)))
  ------------------
   60|       |
   61|       |  /* Calculate the number of markers we'll need, rounding up of course */
   62|  17.7k|  num_markers = icc_data_len / MAX_DATA_BYTES_IN_MARKER;
  ------------------
  |  |   38|  17.7k|#define MAX_DATA_BYTES_IN_MARKER  (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN)
  |  |  ------------------
  |  |  |  |   37|  17.7k|#define MAX_BYTES_IN_MARKER  65533      /* maximum data len of a JPEG marker */
  |  |  ------------------
  |  |               #define MAX_DATA_BYTES_IN_MARKER  (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN)
  |  |  ------------------
  |  |  |  |   36|  17.7k|#define ICC_OVERHEAD_LEN  14            /* size of non-profile data in APP2 */
  |  |  ------------------
  ------------------
   63|  17.7k|  if (num_markers * MAX_DATA_BYTES_IN_MARKER != icc_data_len)
  ------------------
  |  |   38|  17.7k|#define MAX_DATA_BYTES_IN_MARKER  (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN)
  |  |  ------------------
  |  |  |  |   37|  17.7k|#define MAX_BYTES_IN_MARKER  65533      /* maximum data len of a JPEG marker */
  |  |  ------------------
  |  |               #define MAX_DATA_BYTES_IN_MARKER  (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN)
  |  |  ------------------
  |  |  |  |   36|  17.7k|#define ICC_OVERHEAD_LEN  14            /* size of non-profile data in APP2 */
  |  |  ------------------
  ------------------
  |  Branch (63:7): [True: 17.7k, False: 0]
  ------------------
   64|  17.7k|    num_markers++;
   65|       |
   66|  35.5k|  while (icc_data_len > 0) {
  ------------------
  |  Branch (66:10): [True: 17.7k, False: 17.7k]
  ------------------
   67|       |    /* length of profile to put in this marker */
   68|  17.7k|    length = icc_data_len;
   69|  17.7k|    if (length > MAX_DATA_BYTES_IN_MARKER)
  ------------------
  |  |   38|  17.7k|#define MAX_DATA_BYTES_IN_MARKER  (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN)
  |  |  ------------------
  |  |  |  |   37|  17.7k|#define MAX_BYTES_IN_MARKER  65533      /* maximum data len of a JPEG marker */
  |  |  ------------------
  |  |               #define MAX_DATA_BYTES_IN_MARKER  (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN)
  |  |  ------------------
  |  |  |  |   36|  17.7k|#define ICC_OVERHEAD_LEN  14            /* size of non-profile data in APP2 */
  |  |  ------------------
  ------------------
  |  Branch (69:9): [True: 0, False: 17.7k]
  ------------------
   70|      0|      length = MAX_DATA_BYTES_IN_MARKER;
  ------------------
  |  |   38|      0|#define MAX_DATA_BYTES_IN_MARKER  (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN)
  |  |  ------------------
  |  |  |  |   37|      0|#define MAX_BYTES_IN_MARKER  65533      /* maximum data len of a JPEG marker */
  |  |  ------------------
  |  |               #define MAX_DATA_BYTES_IN_MARKER  (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN)
  |  |  ------------------
  |  |  |  |   36|      0|#define ICC_OVERHEAD_LEN  14            /* size of non-profile data in APP2 */
  |  |  ------------------
  ------------------
   71|  17.7k|    icc_data_len -= length;
   72|       |
   73|       |    /* Write the JPEG marker header (APP2 code and marker length) */
   74|  17.7k|    jpeg_write_m_header(cinfo, ICC_MARKER,
  ------------------
  |  |   35|  17.7k|#define ICC_MARKER  (JPEG_APP0 + 2)     /* JPEG marker code for ICC */
  |  |  ------------------
  |  |  |  | 1168|  17.7k|#define JPEG_APP0       0xE0    /* APP0 marker code */
  |  |  ------------------
  ------------------
   75|  17.7k|                        (unsigned int)(length + ICC_OVERHEAD_LEN));
  ------------------
  |  |   36|  17.7k|#define ICC_OVERHEAD_LEN  14            /* size of non-profile data in APP2 */
  ------------------
   76|       |
   77|       |    /* Write the marker identifying string "ICC_PROFILE" (null-terminated).  We
   78|       |     * code it in this less-than-transparent way so that the code works even if
   79|       |     * the local character set is not ASCII.
   80|       |     */
   81|  17.7k|    jpeg_write_m_byte(cinfo, 0x49);
   82|  17.7k|    jpeg_write_m_byte(cinfo, 0x43);
   83|  17.7k|    jpeg_write_m_byte(cinfo, 0x43);
   84|  17.7k|    jpeg_write_m_byte(cinfo, 0x5F);
   85|  17.7k|    jpeg_write_m_byte(cinfo, 0x50);
   86|  17.7k|    jpeg_write_m_byte(cinfo, 0x52);
   87|  17.7k|    jpeg_write_m_byte(cinfo, 0x4F);
   88|  17.7k|    jpeg_write_m_byte(cinfo, 0x46);
   89|  17.7k|    jpeg_write_m_byte(cinfo, 0x49);
   90|  17.7k|    jpeg_write_m_byte(cinfo, 0x4C);
   91|  17.7k|    jpeg_write_m_byte(cinfo, 0x45);
   92|  17.7k|    jpeg_write_m_byte(cinfo, 0x0);
   93|       |
   94|       |    /* Add the sequencing info */
   95|  17.7k|    jpeg_write_m_byte(cinfo, cur_marker);
   96|  17.7k|    jpeg_write_m_byte(cinfo, (int)num_markers);
   97|       |
   98|       |    /* Add the profile data */
   99|   587k|    while (length--) {
  ------------------
  |  Branch (99:12): [True: 569k, False: 17.7k]
  ------------------
  100|   569k|      jpeg_write_m_byte(cinfo, *icc_data_ptr);
  101|   569k|      icc_data_ptr++;
  102|   569k|    }
  103|  17.7k|    cur_marker++;
  104|  17.7k|  }
  105|  17.7k|}

jinit_compress_master:
   37|  20.8k|{
   38|       |  /* Initialize master control (includes parameter checking/processing) */
   39|  20.8k|  jinit_c_master_control(cinfo, FALSE /* full compression */);
  ------------------
  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  ------------------
   40|       |
   41|       |  /* Preprocessing */
   42|  20.8k|  if (!cinfo->raw_data_in) {
  ------------------
  |  Branch (42:7): [True: 20.8k, False: 0]
  ------------------
   43|  20.8k|    if (cinfo->data_precision <= 8) {
  ------------------
  |  Branch (43:9): [True: 0, False: 20.8k]
  ------------------
   44|      0|      jinit_color_converter(cinfo);
   45|      0|      jinit_downsampler(cinfo);
   46|      0|      jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
   47|  20.8k|    } else if (cinfo->data_precision <= 12) {
  ------------------
  |  Branch (47:16): [True: 20.8k, False: 0]
  ------------------
   48|  20.8k|      j12init_color_converter(cinfo);
   49|  20.8k|      j12init_downsampler(cinfo);
   50|  20.8k|      j12init_c_prep_controller(cinfo,
   51|  20.8k|                                FALSE /* never need full buffer here */);
  ------------------
  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  ------------------
   52|  20.8k|    } else {
   53|      0|#ifdef C_LOSSLESS_SUPPORTED
   54|      0|      j16init_color_converter(cinfo);
   55|      0|      j16init_downsampler(cinfo);
   56|      0|      j16init_c_prep_controller(cinfo,
   57|      0|                                FALSE /* never need full buffer here */);
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
   58|       |#else
   59|       |      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
   60|       |#endif
   61|      0|    }
   62|  20.8k|  }
   63|       |
   64|  20.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (64:7): [True: 0, False: 20.8k]
  ------------------
   65|      0|#ifdef C_LOSSLESS_SUPPORTED
   66|       |    /* Prediction, sample differencing, and point transform */
   67|      0|    if (cinfo->data_precision <= 8)
  ------------------
  |  Branch (67:9): [True: 0, False: 0]
  ------------------
   68|      0|      jinit_lossless_compressor(cinfo);
   69|      0|    else if (cinfo->data_precision <= 12)
  ------------------
  |  Branch (69:14): [True: 0, False: 0]
  ------------------
   70|      0|      j12init_lossless_compressor(cinfo);
   71|      0|    else
   72|      0|      j16init_lossless_compressor(cinfo);
   73|       |    /* Entropy encoding: either Huffman or arithmetic coding. */
   74|      0|    if (cinfo->arith_code) {
  ------------------
  |  Branch (74:9): [True: 0, False: 0]
  ------------------
   75|      0|      ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   76|      0|    } else {
   77|      0|      jinit_lhuff_encoder(cinfo);
   78|      0|    }
   79|       |
   80|       |    /* Need a full-image difference buffer in any multi-pass mode. */
   81|      0|    if (cinfo->data_precision <= 8)
  ------------------
  |  Branch (81:9): [True: 0, False: 0]
  ------------------
   82|      0|      jinit_c_diff_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
  ------------------
  |  Branch (82:48): [True: 0, False: 0]
  ------------------
   83|      0|                                               cinfo->optimize_coding));
  ------------------
  |  Branch (83:48): [True: 0, False: 0]
  ------------------
   84|      0|    else if (cinfo->data_precision <= 12)
  ------------------
  |  Branch (84:14): [True: 0, False: 0]
  ------------------
   85|      0|      j12init_c_diff_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
  ------------------
  |  Branch (85:50): [True: 0, False: 0]
  ------------------
   86|      0|                                                 cinfo->optimize_coding));
  ------------------
  |  Branch (86:50): [True: 0, False: 0]
  ------------------
   87|      0|    else
   88|      0|      j16init_c_diff_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
  ------------------
  |  Branch (88:50): [True: 0, False: 0]
  ------------------
   89|      0|                                                 cinfo->optimize_coding));
  ------------------
  |  Branch (89:50): [True: 0, False: 0]
  ------------------
   90|       |#else
   91|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
   92|       |#endif
   93|  20.8k|  } else {
   94|  20.8k|#if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED) || \
   95|  20.8k|    defined(DCT_FLOAT_SUPPORTED)
   96|       |    /* Forward DCT */
   97|  20.8k|    if (cinfo->data_precision == 8)
  ------------------
  |  Branch (97:9): [True: 0, False: 20.8k]
  ------------------
   98|      0|      jinit_forward_dct(cinfo);
   99|  20.8k|    else if (cinfo->data_precision == 12)
  ------------------
  |  Branch (99:14): [True: 20.8k, False: 0]
  ------------------
  100|  20.8k|      j12init_forward_dct(cinfo);
  101|      0|    else
  102|      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)))
  ------------------
  103|       |    /* Entropy encoding: either Huffman or arithmetic coding. */
  104|  20.8k|    if (cinfo->arith_code) {
  ------------------
  |  Branch (104:9): [True: 5.67k, False: 15.1k]
  ------------------
  105|  5.67k|#ifdef C_ARITH_CODING_SUPPORTED
  106|  5.67k|      jinit_arith_encoder(cinfo);
  107|       |#else
  108|       |      ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
  109|       |#endif
  110|  15.1k|    } else {
  111|  15.1k|      if (cinfo->progressive_mode) {
  ------------------
  |  Branch (111:11): [True: 3.58k, False: 11.5k]
  ------------------
  112|  3.58k|#ifdef C_PROGRESSIVE_SUPPORTED
  113|  3.58k|        jinit_phuff_encoder(cinfo);
  114|       |#else
  115|       |        ERREXIT(cinfo, JERR_NOT_COMPILED);
  116|       |#endif
  117|  3.58k|      } else
  118|  11.5k|        jinit_huff_encoder(cinfo);
  119|  15.1k|    }
  120|       |
  121|       |    /* Need a full-image coefficient buffer in any multi-pass mode. */
  122|  20.8k|    if (cinfo->data_precision == 12)
  ------------------
  |  Branch (122:9): [True: 20.8k, False: 0]
  ------------------
  123|  20.8k|      j12init_c_coef_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
  ------------------
  |  Branch (123:50): [True: 6.42k, False: 14.4k]
  ------------------
  124|  14.4k|                                                 cinfo->optimize_coding));
  ------------------
  |  Branch (124:50): [True: 11.5k, False: 2.83k]
  ------------------
  125|      0|    else
  126|      0|      jinit_c_coef_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
  ------------------
  |  Branch (126:48): [True: 0, False: 0]
  ------------------
  127|      0|                                               cinfo->optimize_coding));
  ------------------
  |  Branch (127:48): [True: 0, False: 0]
  ------------------
  128|       |#else
  129|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  130|       |#endif
  131|  20.8k|  }
  132|       |
  133|  20.8k|  if (cinfo->data_precision <= 8)
  ------------------
  |  Branch (133:7): [True: 0, False: 20.8k]
  ------------------
  134|      0|    jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  135|  20.8k|  else if (cinfo->data_precision <= 12)
  ------------------
  |  Branch (135:12): [True: 20.8k, False: 0]
  ------------------
  136|  20.8k|    j12init_c_main_controller(cinfo, FALSE /* never need full buffer here */);
  ------------------
  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  ------------------
  137|      0|  else
  138|      0|#ifdef C_LOSSLESS_SUPPORTED
  139|      0|    j16init_c_main_controller(cinfo, FALSE /* never need full buffer here */);
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  140|       |#else
  141|       |    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  142|       |#endif
  143|       |
  144|  20.8k|  jinit_marker_writer(cinfo);
  145|       |
  146|       |  /* We can now tell the memory manager to allocate virtual arrays. */
  147|  20.8k|  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
  148|       |
  149|       |  /* Write the datastream header (SOI) immediately.
  150|       |   * Frame and scan headers are postponed till later.
  151|       |   * This lets application insert special markers after the SOI.
  152|       |   */
  153|  20.8k|  (*cinfo->marker->write_file_header) (cinfo);
  154|  20.8k|}

j12init_c_main_controller:
  137|  20.8k|{
  138|  20.8k|  my_main_ptr main_ptr;
  139|  20.8k|  int ci;
  140|  20.8k|  jpeg_component_info *compptr;
  141|  20.8k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  20.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (141:19): [True: 0, False: 20.8k]
  ------------------
  142|       |
  143|  20.8k|#ifdef C_LOSSLESS_SUPPORTED
  144|  20.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (144:7): [True: 0, False: 20.8k]
  ------------------
  145|       |#if BITS_IN_JSAMPLE == 8
  146|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  147|       |#else
  148|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (148:9): [True: 0, False: 0]
  ------------------
  149|      0|        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (149:9): [True: 0, False: 0]
  ------------------
  150|      0|#endif
  151|      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)))
  ------------------
  152|      0|  } else
  153|  20.8k|#endif
  154|  20.8k|  {
  155|  20.8k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  20.8k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (155:9): [True: 0, False: 20.8k]
  ------------------
  156|      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)))
  ------------------
  157|  20.8k|  }
  158|       |
  159|  20.8k|  main_ptr = (my_main_ptr)
  160|  20.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  20.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  161|  20.8k|                                sizeof(my_main_controller));
  162|  20.8k|  memset(main_ptr, 0, sizeof(my_main_controller));
  163|  20.8k|  cinfo->main = (struct jpeg_c_main_controller *)main_ptr;
  164|  20.8k|  main_ptr->pub.start_pass = start_pass_main;
  165|       |
  166|       |  /* We don't need to create a buffer in raw-data mode. */
  167|  20.8k|  if (cinfo->raw_data_in)
  ------------------
  |  Branch (167:7): [True: 0, False: 20.8k]
  ------------------
  168|      0|    return;
  169|       |
  170|       |  /* Create the buffer.  It holds downsampled data, so each component
  171|       |   * may be of a different size.
  172|       |   */
  173|  20.8k|  if (need_full_buffer) {
  ------------------
  |  Branch (173:7): [True: 0, False: 20.8k]
  ------------------
  174|      0|    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  175|  20.8k|  } else {
  176|       |    /* Allocate a strip buffer for each component */
  177|  73.3k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (177:46): [True: 52.5k, False: 20.8k]
  ------------------
  178|  52.5k|         ci++, compptr++) {
  179|  52.5k|      main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  180|  52.5k|        ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  52.5k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  181|  52.5k|         compptr->width_in_blocks * data_unit,
  182|  52.5k|         (JDIMENSION)(compptr->v_samp_factor * data_unit));
  183|  52.5k|    }
  184|  20.8k|  }
  185|  20.8k|}
jcmainct-12.c:start_pass_main:
   59|  20.8k|{
   60|  20.8k|  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
   61|       |
   62|       |  /* Do nothing in raw-data mode. */
   63|  20.8k|  if (cinfo->raw_data_in)
  ------------------
  |  Branch (63:7): [True: 0, False: 20.8k]
  ------------------
   64|      0|    return;
   65|       |
   66|  20.8k|  if (pass_mode != JBUF_PASS_THRU)
  ------------------
  |  Branch (66:7): [True: 0, False: 20.8k]
  ------------------
   67|      0|    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   68|       |
   69|  20.8k|  main_ptr->cur_iMCU_row = 0;   /* initialize counters */
   70|  20.8k|  main_ptr->rowgroup_ctr = 0;
   71|  20.8k|  main_ptr->suspended = FALSE;
  ------------------
  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  ------------------
   72|  20.8k|  main_ptr->pass_mode = pass_mode;      /* save mode for use by process_data */
   73|  20.8k|  main_ptr->pub._process_data = process_data_simple_main;
  ------------------
  |  |  140|  20.8k|#define _process_data  process_data_12
  ------------------
   74|  20.8k|}
jcmainct-12.c:process_data_simple_main:
   86|  20.8k|{
   87|  20.8k|  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
   88|  20.8k|  JDIMENSION data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  41.6k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (88:26): [True: 0, False: 20.8k]
  ------------------
   89|       |
   90|  3.18M|  while (main_ptr->cur_iMCU_row < cinfo->total_iMCU_rows) {
  ------------------
  |  Branch (90:10): [True: 3.16M, False: 20.8k]
  ------------------
   91|       |    /* Read input data if we haven't filled the main buffer yet */
   92|  3.16M|    if (main_ptr->rowgroup_ctr < data_unit)
  ------------------
  |  Branch (92:9): [True: 3.16M, False: 0]
  ------------------
   93|  3.16M|      (*cinfo->prep->_pre_process_data) (cinfo, input_buf, in_row_ctr,
  ------------------
  |  |  130|  3.16M|#define _pre_process_data  pre_process_data_12
  ------------------
   94|  3.16M|                                         in_rows_avail, main_ptr->buffer,
   95|  3.16M|                                         &main_ptr->rowgroup_ctr, data_unit);
   96|       |
   97|       |    /* If we don't have a full iMCU row buffered, return to application for
   98|       |     * more data.  Note that preprocessor will always pad to fill the iMCU row
   99|       |     * at the bottom of the image.
  100|       |     */
  101|  3.16M|    if (main_ptr->rowgroup_ctr != data_unit)
  ------------------
  |  Branch (101:9): [True: 0, False: 3.16M]
  ------------------
  102|      0|      return;
  103|       |
  104|       |    /* Send the completed row to the compressor */
  105|  3.16M|    if (!(*cinfo->coef->_compress_data) (cinfo, main_ptr->buffer)) {
  ------------------
  |  |  132|  3.16M|#define _compress_data  compress_data_12
  ------------------
  |  Branch (105:9): [True: 0, False: 3.16M]
  ------------------
  106|       |      /* If compressor did not consume the whole row, then we must need to
  107|       |       * suspend processing and return to the application.  In this situation
  108|       |       * we pretend we didn't yet consume the last input row; otherwise, if
  109|       |       * it happened to be the last row of the image, the application would
  110|       |       * think we were done.
  111|       |       */
  112|      0|      if (!main_ptr->suspended) {
  ------------------
  |  Branch (112:11): [True: 0, False: 0]
  ------------------
  113|      0|        (*in_row_ctr)--;
  114|      0|        main_ptr->suspended = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  115|      0|      }
  116|      0|      return;
  117|      0|    }
  118|       |    /* We did finish the row.  Undo our little suspension hack if a previous
  119|       |     * call suspended; then mark the main buffer empty.
  120|       |     */
  121|  3.16M|    if (main_ptr->suspended) {
  ------------------
  |  Branch (121:9): [True: 0, False: 3.16M]
  ------------------
  122|      0|      (*in_row_ctr)++;
  123|      0|      main_ptr->suspended = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  124|      0|    }
  125|  3.16M|    main_ptr->rowgroup_ctr = 0;
  126|  3.16M|    main_ptr->cur_iMCU_row++;
  127|  3.16M|  }
  128|  20.8k|}

jinit_marker_writer:
  652|  20.8k|{
  653|  20.8k|  my_marker_ptr marker;
  654|       |
  655|       |  /* Create the subobject */
  656|  20.8k|  marker = (my_marker_ptr)
  657|  20.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  20.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  658|  20.8k|                                sizeof(my_marker_writer));
  659|  20.8k|  cinfo->marker = (struct jpeg_marker_writer *)marker;
  660|       |  /* Initialize method pointers */
  661|  20.8k|  marker->pub.write_file_header = write_file_header;
  662|  20.8k|  marker->pub.write_frame_header = write_frame_header;
  663|  20.8k|  marker->pub.write_scan_header = write_scan_header;
  664|  20.8k|  marker->pub.write_file_trailer = write_file_trailer;
  665|  20.8k|  marker->pub.write_tables_only = write_tables_only;
  666|  20.8k|  marker->pub.write_marker_header = write_marker_header;
  667|  20.8k|  marker->pub.write_marker_byte = write_marker_byte;
  668|       |  /* Initialize private state */
  669|  20.8k|  marker->last_restart_interval = 0;
  670|  20.8k|}
jcmarker.c:write_file_header:
  476|  20.8k|{
  477|  20.8k|  my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
  478|       |
  479|  20.8k|  emit_marker(cinfo, M_SOI);    /* first the SOI */
  480|       |
  481|       |  /* SOI is defined to reset restart interval to 0 */
  482|  20.8k|  marker->last_restart_interval = 0;
  483|       |
  484|  20.8k|  if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */
  ------------------
  |  Branch (484:7): [True: 15.1k, False: 5.67k]
  ------------------
  485|  15.1k|    emit_jfif_app0(cinfo);
  486|  20.8k|  if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */
  ------------------
  |  Branch (486:7): [True: 5.67k, False: 15.1k]
  ------------------
  487|  5.67k|    emit_adobe_app14(cinfo);
  488|  20.8k|}
jcmarker.c:emit_marker:
  131|   335k|{
  132|   335k|  emit_byte(cinfo, 0xFF);
  133|   335k|  emit_byte(cinfo, (int)mark);
  134|   335k|}
jcmarker.c:emit_byte:
  117|  7.01M|{
  118|  7.01M|  struct jpeg_destination_mgr *dest = cinfo->dest;
  119|       |
  120|  7.01M|  *(dest->next_output_byte)++ = (JOCTET)val;
  121|  7.01M|  if (--dest->free_in_buffer == 0) {
  ------------------
  |  Branch (121:7): [True: 111, False: 7.01M]
  ------------------
  122|    111|    if (!(*dest->empty_output_buffer) (cinfo))
  ------------------
  |  Branch (122:9): [True: 0, False: 111]
  ------------------
  123|      0|      ERREXIT(cinfo, JERR_CANT_SUSPEND);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  124|    111|  }
  125|  7.01M|}
jcmarker.c:emit_jfif_app0:
  357|  15.1k|{
  358|       |  /*
  359|       |   * Length of APP0 block       (2 bytes)
  360|       |   * Block ID                   (4 bytes - ASCII "JFIF")
  361|       |   * Zero byte                  (1 byte to terminate the ID string)
  362|       |   * Version Major, Minor       (2 bytes - major first)
  363|       |   * Units                      (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm)
  364|       |   * Xdpu                       (2 bytes - dots per unit horizontal)
  365|       |   * Ydpu                       (2 bytes - dots per unit vertical)
  366|       |   * Thumbnail X size           (1 byte)
  367|       |   * Thumbnail Y size           (1 byte)
  368|       |   */
  369|       |
  370|  15.1k|  emit_marker(cinfo, M_APP0);
  371|       |
  372|  15.1k|  emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */
  373|       |
  374|  15.1k|  emit_byte(cinfo, 0x4A);       /* Identifier: ASCII "JFIF" */
  375|  15.1k|  emit_byte(cinfo, 0x46);
  376|  15.1k|  emit_byte(cinfo, 0x49);
  377|  15.1k|  emit_byte(cinfo, 0x46);
  378|  15.1k|  emit_byte(cinfo, 0);
  379|  15.1k|  emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */
  380|  15.1k|  emit_byte(cinfo, cinfo->JFIF_minor_version);
  381|  15.1k|  emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */
  382|  15.1k|  emit_2bytes(cinfo, (int)cinfo->X_density);
  383|  15.1k|  emit_2bytes(cinfo, (int)cinfo->Y_density);
  384|  15.1k|  emit_byte(cinfo, 0);          /* No thumbnail image */
  385|  15.1k|  emit_byte(cinfo, 0);
  386|  15.1k|}
jcmarker.c:emit_2bytes:
  140|   388k|{
  141|   388k|  emit_byte(cinfo, (value >> 8) & 0xFF);
  142|   388k|  emit_byte(cinfo, value & 0xFF);
  143|   388k|}
jcmarker.c:emit_adobe_app14:
  392|  5.67k|{
  393|       |  /*
  394|       |   * Length of APP14 block      (2 bytes)
  395|       |   * Block ID                   (5 bytes - ASCII "Adobe")
  396|       |   * Version Number             (2 bytes - currently 100)
  397|       |   * Flags0                     (2 bytes - currently 0)
  398|       |   * Flags1                     (2 bytes - currently 0)
  399|       |   * Color transform            (1 byte)
  400|       |   *
  401|       |   * Although Adobe TN 5116 mentions Version = 101, all the Adobe files
  402|       |   * now in circulation seem to use Version = 100, so that's what we write.
  403|       |   *
  404|       |   * We write the color transform byte as 1 if the JPEG color space is
  405|       |   * YCbCr, 2 if it's YCCK, 0 otherwise.  Adobe's definition has to do with
  406|       |   * whether the encoder performed a transformation, which is pretty useless.
  407|       |   */
  408|       |
  409|  5.67k|  emit_marker(cinfo, M_APP14);
  410|       |
  411|  5.67k|  emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */
  412|       |
  413|  5.67k|  emit_byte(cinfo, 0x41);       /* Identifier: ASCII "Adobe" */
  414|  5.67k|  emit_byte(cinfo, 0x64);
  415|  5.67k|  emit_byte(cinfo, 0x6F);
  416|  5.67k|  emit_byte(cinfo, 0x62);
  417|  5.67k|  emit_byte(cinfo, 0x65);
  418|  5.67k|  emit_2bytes(cinfo, 100);      /* Version */
  419|  5.67k|  emit_2bytes(cinfo, 0);        /* Flags0 */
  420|  5.67k|  emit_2bytes(cinfo, 0);        /* Flags1 */
  421|  5.67k|  switch (cinfo->jpeg_color_space) {
  422|      0|  case JCS_YCbCr:
  ------------------
  |  Branch (422:3): [True: 0, False: 5.67k]
  ------------------
  423|      0|    emit_byte(cinfo, 1);        /* Color transform = 1 */
  424|      0|    break;
  425|  2.83k|  case JCS_YCCK:
  ------------------
  |  Branch (425:3): [True: 2.83k, False: 2.83k]
  ------------------
  426|  2.83k|    emit_byte(cinfo, 2);        /* Color transform = 2 */
  427|  2.83k|    break;
  428|  2.83k|  default:
  ------------------
  |  Branch (428:3): [True: 2.83k, False: 2.83k]
  ------------------
  429|  2.83k|    emit_byte(cinfo, 0);        /* Color transform = 0 */
  430|  2.83k|    break;
  431|  5.67k|  }
  432|  5.67k|}
jcmarker.c:write_frame_header:
  501|  20.8k|{
  502|  20.8k|  int ci, prec = 0;
  503|  20.8k|  boolean is_baseline;
  504|  20.8k|  jpeg_component_info *compptr;
  505|       |
  506|  20.8k|  if (!cinfo->master->lossless) {
  ------------------
  |  Branch (506:7): [True: 20.8k, False: 0]
  ------------------
  507|       |    /* Emit DQT for each quantization table.
  508|       |     * Note that emit_dqt() suppresses any duplicate tables.
  509|       |     */
  510|  73.3k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (510:46): [True: 52.5k, False: 20.8k]
  ------------------
  511|  52.5k|         ci++, compptr++) {
  512|  52.5k|      prec += emit_dqt(cinfo, compptr->quant_tbl_no);
  513|  52.5k|    }
  514|       |    /* now prec is nonzero iff there are any 16-bit quant tables. */
  515|  20.8k|  }
  516|       |
  517|       |  /* Check for a non-baseline specification.
  518|       |   * Note we assume that Huffman table numbers won't be changed later.
  519|       |   */
  520|  20.8k|  if (cinfo->arith_code || cinfo->progressive_mode ||
  ------------------
  |  Branch (520:7): [True: 5.67k, False: 15.1k]
  |  Branch (520:28): [True: 3.58k, False: 11.5k]
  ------------------
  521|  20.8k|      cinfo->master->lossless || cinfo->data_precision != 8) {
  ------------------
  |  Branch (521:7): [True: 0, False: 11.5k]
  |  Branch (521:34): [True: 11.5k, False: 0]
  ------------------
  522|  20.8k|    is_baseline = FALSE;
  ------------------
  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  ------------------
  523|  20.8k|  } else {
  524|      0|    is_baseline = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  525|      0|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (525:46): [True: 0, False: 0]
  ------------------
  526|      0|         ci++, compptr++) {
  527|      0|      if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1)
  ------------------
  |  Branch (527:11): [True: 0, False: 0]
  |  Branch (527:37): [True: 0, False: 0]
  ------------------
  528|      0|        is_baseline = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  529|      0|    }
  530|      0|    if (prec && is_baseline) {
  ------------------
  |  Branch (530:9): [True: 0, False: 0]
  |  Branch (530:17): [True: 0, False: 0]
  ------------------
  531|      0|      is_baseline = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  532|       |      /* If it's baseline except for quantizer size, warn the user */
  533|      0|      TRACEMS(cinfo, 0, JTRC_16BIT_TABLES);
  ------------------
  |  |  297|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  298|      0|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  534|      0|    }
  535|      0|  }
  536|       |
  537|       |  /* Emit the proper SOF marker */
  538|  20.8k|  if (cinfo->arith_code) {
  ------------------
  |  Branch (538:7): [True: 5.67k, False: 15.1k]
  ------------------
  539|  5.67k|    if (cinfo->progressive_mode)
  ------------------
  |  Branch (539:9): [True: 2.83k, False: 2.83k]
  ------------------
  540|  2.83k|      emit_sof(cinfo, M_SOF10); /* SOF code for progressive arithmetic */
  541|  2.83k|    else
  542|  2.83k|      emit_sof(cinfo, M_SOF9);  /* SOF code for sequential arithmetic */
  543|  15.1k|  } else {
  544|  15.1k|    if (cinfo->progressive_mode)
  ------------------
  |  Branch (544:9): [True: 3.58k, False: 11.5k]
  ------------------
  545|  3.58k|      emit_sof(cinfo, M_SOF2);  /* SOF code for progressive Huffman */
  546|  11.5k|    else if (cinfo->master->lossless)
  ------------------
  |  Branch (546:14): [True: 0, False: 11.5k]
  ------------------
  547|      0|      emit_sof(cinfo, M_SOF3);  /* SOF code for lossless Huffman */
  548|  11.5k|    else if (is_baseline)
  ------------------
  |  Branch (548:14): [True: 0, False: 11.5k]
  ------------------
  549|      0|      emit_sof(cinfo, M_SOF0);  /* SOF code for baseline implementation */
  550|  11.5k|    else
  551|  11.5k|      emit_sof(cinfo, M_SOF1);  /* SOF code for non-baseline Huffman file */
  552|  15.1k|  }
  553|  20.8k|}
jcmarker.c:emit_dqt:
  154|  52.5k|{
  155|  52.5k|  JQUANT_TBL *qtbl = cinfo->quant_tbl_ptrs[index];
  156|  52.5k|  int prec;
  157|  52.5k|  int i;
  158|       |
  159|  52.5k|  if (qtbl == NULL)
  ------------------
  |  Branch (159:7): [True: 0, False: 52.5k]
  ------------------
  160|      0|    ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index);
  ------------------
  |  |  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|       |
  162|  52.5k|  prec = 0;
  163|  3.41M|  for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  3.41M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (163:15): [True: 3.36M, False: 52.5k]
  ------------------
  164|  3.36M|    if (qtbl->quantval[i] > 255)
  ------------------
  |  Branch (164:9): [True: 0, False: 3.36M]
  ------------------
  165|      0|      prec = 1;
  166|  3.36M|  }
  167|       |
  168|  52.5k|  if (!qtbl->sent_table) {
  ------------------
  |  Branch (168:7): [True: 32.4k, False: 20.0k]
  ------------------
  169|  32.4k|    emit_marker(cinfo, M_DQT);
  170|       |
  171|  32.4k|    emit_2bytes(cinfo, prec ? DCTSIZE2 * 2 + 1 + 2 : DCTSIZE2 + 1 + 2);
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
                  emit_2bytes(cinfo, prec ? DCTSIZE2 * 2 + 1 + 2 : DCTSIZE2 + 1 + 2);
  ------------------
  |  |   67|  32.4k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (171:24): [True: 0, False: 32.4k]
  ------------------
  172|       |
  173|  32.4k|    emit_byte(cinfo, index + (prec << 4));
  174|       |
  175|  2.10M|    for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  2.10M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (175:17): [True: 2.07M, False: 32.4k]
  ------------------
  176|       |      /* The table entries must be emitted in zigzag order. */
  177|  2.07M|      unsigned int qval = qtbl->quantval[jpeg_natural_order[i]];
  178|  2.07M|      if (prec)
  ------------------
  |  Branch (178:11): [True: 0, False: 2.07M]
  ------------------
  179|      0|        emit_byte(cinfo, (int)(qval >> 8));
  180|  2.07M|      emit_byte(cinfo, (int)(qval & 0xFF));
  181|  2.07M|    }
  182|       |
  183|  32.4k|    qtbl->sent_table = TRUE;
  ------------------
  |  |  210|  32.4k|#define TRUE    1
  ------------------
  184|  32.4k|  }
  185|       |
  186|  52.5k|  return prec;
  187|  52.5k|}
jcmarker.c:emit_sof:
  292|  20.8k|{
  293|  20.8k|  int ci;
  294|  20.8k|  jpeg_component_info *compptr;
  295|       |
  296|  20.8k|  emit_marker(cinfo, code);
  297|       |
  298|  20.8k|  emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */
  299|       |
  300|       |  /* Make sure image isn't bigger than SOF field can handle */
  301|  20.8k|  if ((long)cinfo->_jpeg_height > 65535L || (long)cinfo->_jpeg_width > 65535L)
  ------------------
  |  |   31|  20.8k|#define _jpeg_height  image_height
  ------------------
                if ((long)cinfo->_jpeg_height > 65535L || (long)cinfo->_jpeg_width > 65535L)
  ------------------
  |  |   30|  20.8k|#define _jpeg_width  image_width
  ------------------
  |  Branch (301:7): [True: 0, False: 20.8k]
  |  Branch (301:45): [True: 0, False: 20.8k]
  ------------------
  302|      0|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)65535);
  ------------------
  |  |  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)))
  ------------------
  303|       |
  304|  20.8k|  emit_byte(cinfo, cinfo->data_precision);
  305|  20.8k|  emit_2bytes(cinfo, (int)cinfo->_jpeg_height);
  ------------------
  |  |   31|  20.8k|#define _jpeg_height  image_height
  ------------------
  306|  20.8k|  emit_2bytes(cinfo, (int)cinfo->_jpeg_width);
  ------------------
  |  |   30|  20.8k|#define _jpeg_width  image_width
  ------------------
  307|       |
  308|  20.8k|  emit_byte(cinfo, cinfo->num_components);
  309|       |
  310|  73.3k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (310:44): [True: 52.5k, False: 20.8k]
  ------------------
  311|  52.5k|       ci++, compptr++) {
  312|  52.5k|    emit_byte(cinfo, compptr->component_id);
  313|  52.5k|    emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor);
  314|  52.5k|    emit_byte(cinfo, compptr->quant_tbl_no);
  315|  52.5k|  }
  316|  20.8k|}
jcmarker.c:write_scan_header:
  564|  87.0k|{
  565|  87.0k|  my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
  566|  87.0k|  int i;
  567|  87.0k|  jpeg_component_info *compptr;
  568|       |
  569|  87.0k|  if (cinfo->arith_code) {
  ------------------
  |  Branch (569:7): [True: 53.9k, False: 33.1k]
  ------------------
  570|       |    /* Emit arith conditioning info.  We may have some duplication
  571|       |     * if the file has multiple scans, but it's so small it's hardly
  572|       |     * worth worrying about.
  573|       |     */
  574|  53.9k|    emit_dac(cinfo);
  575|  53.9k|  } else {
  576|       |    /* Emit Huffman tables.
  577|       |     * Note that emit_dht() suppresses any duplicate tables.
  578|       |     */
  579|  83.6k|    for (i = 0; i < cinfo->comps_in_scan; i++) {
  ------------------
  |  Branch (579:17): [True: 50.5k, False: 33.1k]
  ------------------
  580|  50.5k|      compptr = cinfo->cur_comp_info[i];
  581|       |      /* DC needs no table for refinement scan */
  582|  50.5k|      if ((cinfo->Ss == 0 && cinfo->Ah == 0) || cinfo->master->lossless)
  ------------------
  |  Branch (582:12): [True: 36.2k, False: 14.3k]
  |  Branch (582:30): [True: 32.6k, False: 3.58k]
  |  Branch (582:49): [True: 0, False: 17.9k]
  ------------------
  583|  32.6k|        emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
  ------------------
  |  |  207|  32.6k|#define FALSE   0               /* values of boolean */
  ------------------
  584|       |      /* AC needs no table when not present, and lossless mode uses only DC
  585|       |         tables. */
  586|  50.5k|      if (cinfo->Se && !cinfo->master->lossless)
  ------------------
  |  Branch (586:11): [True: 43.4k, False: 7.17k]
  |  Branch (586:24): [True: 43.4k, False: 0]
  ------------------
  587|  43.4k|        emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
  ------------------
  |  |  210|  43.4k|#define TRUE    1
  ------------------
  588|  50.5k|    }
  589|  33.1k|  }
  590|       |
  591|       |  /* Emit DRI if required --- note that DRI value could change for each scan.
  592|       |   * We avoid wasting space with unnecessary DRIs, however.
  593|       |   */
  594|  87.0k|  if (cinfo->restart_interval != marker->last_restart_interval) {
  ------------------
  |  Branch (594:7): [True: 5.67k, False: 81.3k]
  ------------------
  595|  5.67k|    emit_dri(cinfo);
  596|  5.67k|    marker->last_restart_interval = cinfo->restart_interval;
  597|  5.67k|  }
  598|       |
  599|  87.0k|  emit_sos(cinfo);
  600|  87.0k|}
jcmarker.c:emit_dac:
  233|  53.9k|{
  234|  53.9k|#ifdef C_ARITH_CODING_SUPPORTED
  235|  53.9k|  char dc_in_use[NUM_ARITH_TBLS];
  236|  53.9k|  char ac_in_use[NUM_ARITH_TBLS];
  237|  53.9k|  int length, i;
  238|  53.9k|  jpeg_component_info *compptr;
  239|       |
  240|   916k|  for (i = 0; i < NUM_ARITH_TBLS; i++)
  ------------------
  |  |   70|   916k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (240:15): [True: 862k, False: 53.9k]
  ------------------
  241|   862k|    dc_in_use[i] = ac_in_use[i] = 0;
  242|       |
  243|   130k|  for (i = 0; i < cinfo->comps_in_scan; i++) {
  ------------------
  |  Branch (243:15): [True: 76.6k, False: 53.9k]
  ------------------
  244|  76.6k|    compptr = cinfo->cur_comp_info[i];
  245|       |    /* DC needs no table for refinement scan */
  246|  76.6k|    if (cinfo->Ss == 0 && cinfo->Ah == 0)
  ------------------
  |  Branch (246:9): [True: 31.2k, False: 45.4k]
  |  Branch (246:27): [True: 19.8k, False: 11.3k]
  ------------------
  247|  19.8k|      dc_in_use[compptr->dc_tbl_no] = 1;
  248|       |    /* AC needs no table when not present */
  249|  76.6k|    if (cinfo->Se)
  ------------------
  |  Branch (249:9): [True: 53.9k, False: 22.7k]
  ------------------
  250|  53.9k|      ac_in_use[compptr->ac_tbl_no] = 1;
  251|  76.6k|  }
  252|       |
  253|  53.9k|  length = 0;
  254|   916k|  for (i = 0; i < NUM_ARITH_TBLS; i++)
  ------------------
  |  |   70|   916k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (254:15): [True: 862k, False: 53.9k]
  ------------------
  255|   862k|    length += dc_in_use[i] + ac_in_use[i];
  256|       |
  257|  53.9k|  if (length) {
  ------------------
  |  Branch (257:7): [True: 51.0k, False: 2.83k]
  ------------------
  258|  51.0k|    emit_marker(cinfo, M_DAC);
  259|       |
  260|  51.0k|    emit_2bytes(cinfo, length * 2 + 2);
  261|       |
  262|   868k|    for (i = 0; i < NUM_ARITH_TBLS; i++) {
  ------------------
  |  |   70|   868k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (262:17): [True: 817k, False: 51.0k]
  ------------------
  263|   817k|      if (dc_in_use[i]) {
  ------------------
  |  Branch (263:11): [True: 8.51k, False: 808k]
  ------------------
  264|  8.51k|        emit_byte(cinfo, i);
  265|  8.51k|        emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i] << 4));
  266|  8.51k|      }
  267|   817k|      if (ac_in_use[i]) {
  ------------------
  |  Branch (267:11): [True: 48.2k, False: 769k]
  ------------------
  268|  48.2k|        emit_byte(cinfo, i + 0x10);
  269|  48.2k|        emit_byte(cinfo, cinfo->arith_ac_K[i]);
  270|  48.2k|      }
  271|   817k|    }
  272|  51.0k|  }
  273|  53.9k|#endif /* C_ARITH_CODING_SUPPORTED */
  274|  53.9k|}
jcmarker.c:emit_dht:
  193|  76.0k|{
  194|  76.0k|  JHUFF_TBL *htbl;
  195|  76.0k|  int length, i;
  196|       |
  197|  76.0k|  if (is_ac) {
  ------------------
  |  Branch (197:7): [True: 43.4k, False: 32.6k]
  ------------------
  198|  43.4k|    htbl = cinfo->ac_huff_tbl_ptrs[index];
  199|  43.4k|    index += 0x10;              /* output index has AC bit set */
  200|  43.4k|  } else {
  201|  32.6k|    htbl = cinfo->dc_huff_tbl_ptrs[index];
  202|  32.6k|  }
  203|       |
  204|  76.0k|  if (htbl == NULL)
  ------------------
  |  Branch (204:7): [True: 0, False: 76.0k]
  ------------------
  205|      0|    ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index);
  ------------------
  |  |  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)))
  ------------------
  206|       |
  207|  76.0k|  if (!htbl->sent_table) {
  ------------------
  |  Branch (207:7): [True: 58.5k, False: 17.4k]
  ------------------
  208|  58.5k|    emit_marker(cinfo, M_DHT);
  209|       |
  210|  58.5k|    length = 0;
  211|   995k|    for (i = 1; i <= 16; i++)
  ------------------
  |  Branch (211:17): [True: 937k, False: 58.5k]
  ------------------
  212|   937k|      length += htbl->bits[i];
  213|       |
  214|  58.5k|    emit_2bytes(cinfo, length + 2 + 1 + 16);
  215|  58.5k|    emit_byte(cinfo, index);
  216|       |
  217|   995k|    for (i = 1; i <= 16; i++)
  ------------------
  |  Branch (217:17): [True: 937k, False: 58.5k]
  ------------------
  218|   937k|      emit_byte(cinfo, htbl->bits[i]);
  219|       |
  220|   596k|    for (i = 0; i < length; i++)
  ------------------
  |  Branch (220:17): [True: 538k, False: 58.5k]
  ------------------
  221|   538k|      emit_byte(cinfo, htbl->huffval[i]);
  222|       |
  223|  58.5k|    htbl->sent_table = TRUE;
  ------------------
  |  |  210|  58.5k|#define TRUE    1
  ------------------
  224|  58.5k|  }
  225|  76.0k|}
jcmarker.c:emit_dri:
  280|  5.67k|{
  281|  5.67k|  emit_marker(cinfo, M_DRI);
  282|       |
  283|  5.67k|  emit_2bytes(cinfo, 4);        /* fixed length */
  284|       |
  285|  5.67k|  emit_2bytes(cinfo, (int)cinfo->restart_interval);
  286|  5.67k|}
jcmarker.c:emit_sos:
  322|  87.0k|{
  323|  87.0k|  int i, td, ta;
  324|  87.0k|  jpeg_component_info *compptr;
  325|       |
  326|  87.0k|  emit_marker(cinfo, M_SOS);
  327|       |
  328|  87.0k|  emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */
  329|       |
  330|  87.0k|  emit_byte(cinfo, cinfo->comps_in_scan);
  331|       |
  332|   214k|  for (i = 0; i < cinfo->comps_in_scan; i++) {
  ------------------
  |  Branch (332:15): [True: 127k, False: 87.0k]
  ------------------
  333|   127k|    compptr = cinfo->cur_comp_info[i];
  334|   127k|    emit_byte(cinfo, compptr->component_id);
  335|       |
  336|       |    /* We emit 0 for unused field(s); this is recommended by the P&M text
  337|       |     * but does not seem to be specified in the standard.
  338|       |     */
  339|       |
  340|       |    /* DC needs no table for refinement scan */
  341|   127k|    td = cinfo->Ss == 0 && cinfo->Ah == 0 ? compptr->dc_tbl_no : 0;
  ------------------
  |  Branch (341:10): [True: 67.4k, False: 59.7k]
  |  Branch (341:28): [True: 52.5k, False: 14.9k]
  ------------------
  342|       |    /* AC needs no table when not present */
  343|   127k|    ta = cinfo->Se ? compptr->ac_tbl_no : 0;
  ------------------
  |  Branch (343:10): [True: 97.3k, False: 29.8k]
  ------------------
  344|       |
  345|   127k|    emit_byte(cinfo, (td << 4) + ta);
  346|   127k|  }
  347|       |
  348|  87.0k|  emit_byte(cinfo, cinfo->Ss);
  349|  87.0k|  emit_byte(cinfo, cinfo->Se);
  350|  87.0k|  emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al);
  351|  87.0k|}
jcmarker.c:write_file_trailer:
  609|  20.8k|{
  610|  20.8k|  emit_marker(cinfo, M_EOI);
  611|  20.8k|}
jcmarker.c:write_marker_header:
  446|  17.7k|{
  447|  17.7k|  if (datalen > (unsigned int)65533)            /* safety check */
  ------------------
  |  Branch (447:7): [True: 0, False: 17.7k]
  ------------------
  448|      0|    ERREXIT(cinfo, JERR_BAD_LENGTH);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  449|       |
  450|  17.7k|  emit_marker(cinfo, (JPEG_MARKER)marker);
  451|       |
  452|  17.7k|  emit_2bytes(cinfo, (int)(datalen + 2));       /* total length */
  453|  17.7k|}
jcmarker.c:write_marker_byte:
  458|   818k|{
  459|   818k|  emit_byte(cinfo, val);
  460|   818k|}

jinit_c_master_control:
  722|  20.8k|{
  723|  20.8k|  my_master_ptr master = (my_master_ptr)cinfo->master;
  724|  20.8k|  boolean empty_huff_tables = TRUE;
  ------------------
  |  |  210|  20.8k|#define TRUE    1
  ------------------
  725|  20.8k|  int i;
  726|       |
  727|       |#ifdef WITH_PROFILE
  728|       |  master->pub.total_start = getTime();
  729|       |#endif
  730|       |
  731|  20.8k|  master->pub.prepare_for_pass = prepare_for_pass;
  732|  20.8k|  master->pub.pass_startup = pass_startup;
  733|  20.8k|  master->pub.finish_pass = finish_pass_master;
  734|  20.8k|  master->pub.is_last_pass = FALSE;
  ------------------
  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  ------------------
  735|       |
  736|  20.8k|  if (cinfo->scan_info != NULL) {
  ------------------
  |  Branch (736:7): [True: 6.42k, False: 14.4k]
  ------------------
  737|  6.42k|#ifdef NEED_SCAN_SCRIPT
  738|  6.42k|    validate_script(cinfo);
  739|       |#else
  740|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  741|       |#endif
  742|  14.4k|  } else {
  743|  14.4k|    cinfo->progressive_mode = FALSE;
  ------------------
  |  |  207|  14.4k|#define FALSE   0               /* values of boolean */
  ------------------
  744|  14.4k|    cinfo->num_scans = 1;
  745|  14.4k|  }
  746|       |
  747|  20.8k|#ifdef C_LOSSLESS_SUPPORTED
  748|       |  /* Disable smoothing and subsampling in lossless mode, since those are lossy
  749|       |   * algorithms.  Set the JPEG colorspace to the input colorspace.  Disable raw
  750|       |   * (downsampled) data input, because it isn't particularly useful without
  751|       |   * subsampling and has not been tested in lossless mode.
  752|       |   */
  753|  20.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (753:7): [True: 0, False: 20.8k]
  ------------------
  754|      0|    int ci;
  755|      0|    jpeg_component_info *compptr;
  756|       |
  757|      0|    cinfo->raw_data_in = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  758|      0|    cinfo->smoothing_factor = 0;
  759|      0|    jpeg_default_colorspace(cinfo);
  760|      0|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (760:46): [True: 0, False: 0]
  ------------------
  761|      0|         ci++, compptr++)
  762|      0|      compptr->h_samp_factor = compptr->v_samp_factor = 1;
  763|      0|  }
  764|  20.8k|#endif
  765|       |
  766|       |  /* Validate parameters, determine derived values */
  767|  20.8k|  initial_setup(cinfo, transcode_only);
  768|       |
  769|  20.8k|  if (cinfo->arith_code)
  ------------------
  |  Branch (769:7): [True: 5.67k, False: 15.1k]
  ------------------
  770|  5.67k|    cinfo->optimize_coding = FALSE;
  ------------------
  |  |  207|  5.67k|#define FALSE   0               /* values of boolean */
  ------------------
  771|  15.1k|  else {
  772|  15.1k|    if (cinfo->master->lossless ||      /*  TEMPORARY HACK ??? */
  ------------------
  |  Branch (772:9): [True: 0, False: 15.1k]
  ------------------
  773|  15.1k|        cinfo->progressive_mode)
  ------------------
  |  Branch (773:9): [True: 3.58k, False: 11.5k]
  ------------------
  774|  3.58k|      cinfo->optimize_coding = TRUE; /* assume default tables no good for
  ------------------
  |  |  210|  3.58k|#define TRUE    1
  ------------------
  775|       |                                        progressive mode or lossless mode */
  776|  15.1k|    for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|  15.1k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (776:17): [True: 15.1k, False: 0]
  ------------------
  777|  15.1k|      if (cinfo->dc_huff_tbl_ptrs[i] != NULL ||
  ------------------
  |  Branch (777:11): [True: 15.1k, False: 0]
  ------------------
  778|  15.1k|          cinfo->ac_huff_tbl_ptrs[i] != NULL) {
  ------------------
  |  Branch (778:11): [True: 0, False: 0]
  ------------------
  779|  15.1k|        empty_huff_tables = FALSE;
  ------------------
  |  |  207|  15.1k|#define FALSE   0               /* values of boolean */
  ------------------
  780|  15.1k|        break;
  781|  15.1k|      }
  782|  15.1k|    }
  783|  15.1k|    if (cinfo->data_precision == 12 && !cinfo->optimize_coding &&
  ------------------
  |  Branch (783:9): [True: 15.1k, False: 0]
  |  Branch (783:40): [True: 0, False: 15.1k]
  ------------------
  784|      0|        (empty_huff_tables || using_std_huff_tables(cinfo)))
  ------------------
  |  Branch (784:10): [True: 0, False: 0]
  |  Branch (784:31): [True: 0, False: 0]
  ------------------
  785|      0|      cinfo->optimize_coding = TRUE; /* assume default tables no good for
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  786|       |                                        12-bit data precision */
  787|  15.1k|  }
  788|       |
  789|       |  /* Initialize my private state */
  790|  20.8k|  if (transcode_only) {
  ------------------
  |  Branch (790:7): [True: 0, False: 20.8k]
  ------------------
  791|       |    /* no main pass in transcoding */
  792|      0|    if (cinfo->optimize_coding)
  ------------------
  |  Branch (792:9): [True: 0, False: 0]
  ------------------
  793|      0|      master->pass_type = huff_opt_pass;
  794|      0|    else
  795|      0|      master->pass_type = output_pass;
  796|  20.8k|  } else {
  797|       |    /* for normal compression, first pass is always this type: */
  798|  20.8k|    master->pass_type = main_pass;
  799|  20.8k|  }
  800|  20.8k|  master->scan_number = 0;
  801|  20.8k|  master->pass_number = 0;
  802|  20.8k|  if (cinfo->optimize_coding)
  ------------------
  |  Branch (802:7): [True: 15.1k, False: 5.67k]
  ------------------
  803|  15.1k|    master->total_passes = cinfo->num_scans * 2;
  804|  5.67k|  else
  805|  5.67k|    master->total_passes = cinfo->num_scans;
  806|       |
  807|  20.8k|  master->jpeg_version = PACKAGE_NAME " version " VERSION " (build " BUILD ")";
  ------------------
  |  |   17|  20.8k|#define PACKAGE_NAME  "libjpeg-turbo"
  ------------------
  808|  20.8k|}
jcmaster.c:prepare_for_pass:
  579|   116k|{
  580|   116k|  my_master_ptr master = (my_master_ptr)cinfo->master;
  581|       |
  582|   116k|  switch (master->pass_type) {
  583|  20.8k|  case main_pass:
  ------------------
  |  Branch (583:3): [True: 20.8k, False: 95.7k]
  ------------------
  584|       |    /* Initial pass: will collect input data, and do either Huffman
  585|       |     * optimization or data output for the first scan.
  586|       |     */
  587|  20.8k|    select_scan_parameters(cinfo);
  588|  20.8k|    per_scan_setup(cinfo);
  589|  20.8k|    if (!cinfo->raw_data_in) {
  ------------------
  |  Branch (589:9): [True: 20.8k, False: 0]
  ------------------
  590|  20.8k|      (*cinfo->cconvert->start_pass) (cinfo);
  591|  20.8k|      (*cinfo->downsample->start_pass) (cinfo);
  592|  20.8k|      (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU);
  593|  20.8k|    }
  594|  20.8k|    (*cinfo->fdct->start_pass) (cinfo);
  595|  20.8k|    (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding);
  596|  20.8k|    (*cinfo->coef->start_pass) (cinfo,
  597|  20.8k|                                (master->total_passes > 1 ?
  ------------------
  |  Branch (597:34): [True: 18.0k, False: 2.83k]
  ------------------
  598|  18.0k|                                 JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
  599|  20.8k|    (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
  600|  20.8k|    if (cinfo->optimize_coding) {
  ------------------
  |  Branch (600:9): [True: 15.1k, False: 5.67k]
  ------------------
  601|       |      /* No immediate data output; postpone writing frame/scan headers */
  602|  15.1k|      master->pub.call_pass_startup = FALSE;
  ------------------
  |  |  207|  15.1k|#define FALSE   0               /* values of boolean */
  ------------------
  603|  15.1k|    } else {
  604|       |      /* Will write frame/scan headers at first jpeg_write_scanlines call */
  605|  5.67k|      master->pub.call_pass_startup = TRUE;
  ------------------
  |  |  210|  5.67k|#define TRUE    1
  ------------------
  606|  5.67k|    }
  607|  20.8k|    break;
  608|      0|#ifdef ENTROPY_OPT_SUPPORTED
  609|  17.9k|  case huff_opt_pass:
  ------------------
  |  Branch (609:3): [True: 17.9k, False: 98.6k]
  ------------------
  610|       |    /* Do Huffman optimization for a scan after the first one. */
  611|  17.9k|    select_scan_parameters(cinfo);
  612|  17.9k|    per_scan_setup(cinfo);
  613|  17.9k|    if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code ||
  ------------------
  |  Branch (613:9): [True: 14.3k, False: 3.58k]
  |  Branch (613:27): [True: 0, False: 3.58k]
  |  Branch (613:45): [True: 0, False: 3.58k]
  ------------------
  614|  14.3k|        cinfo->master->lossless) {
  ------------------
  |  Branch (614:9): [True: 0, False: 3.58k]
  ------------------
  615|  14.3k|      (*cinfo->entropy->start_pass) (cinfo, TRUE);
  ------------------
  |  |  210|  14.3k|#define TRUE    1
  ------------------
  616|  14.3k|      (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
  617|  14.3k|      master->pub.call_pass_startup = FALSE;
  ------------------
  |  |  207|  14.3k|#define FALSE   0               /* values of boolean */
  ------------------
  618|  14.3k|      break;
  619|  14.3k|    }
  620|       |    /* Special case: Huffman DC refinement scans need no Huffman table
  621|       |     * and therefore we can skip the optimization pass for them.
  622|       |     */
  623|  3.58k|    master->pass_type = output_pass;
  624|  3.58k|    master->pass_number++;
  625|  3.58k|    FALLTHROUGH                 /*FALLTHROUGH*/
  ------------------
  |  |   41|  3.58k|#define FALLTHROUGH  __attribute__((fallthrough));
  ------------------
  626|  3.58k|#endif
  627|  81.3k|  case output_pass:
  ------------------
  |  Branch (627:3): [True: 77.7k, False: 38.7k]
  ------------------
  628|       |    /* Do a data-output pass. */
  629|       |    /* We need not repeat per-scan setup if prior optimization pass did it. */
  630|  81.3k|    if (!cinfo->optimize_coding) {
  ------------------
  |  Branch (630:9): [True: 48.2k, False: 33.1k]
  ------------------
  631|  48.2k|      select_scan_parameters(cinfo);
  632|  48.2k|      per_scan_setup(cinfo);
  633|  48.2k|    }
  634|  81.3k|    (*cinfo->entropy->start_pass) (cinfo, FALSE);
  ------------------
  |  |  207|  81.3k|#define FALSE   0               /* values of boolean */
  ------------------
  635|  81.3k|    (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
  636|       |    /* We emit frame/scan headers now */
  637|  81.3k|    if (master->scan_number == 0)
  ------------------
  |  Branch (637:9): [True: 15.1k, False: 66.1k]
  ------------------
  638|  15.1k|      (*cinfo->marker->write_frame_header) (cinfo);
  639|  81.3k|    (*cinfo->marker->write_scan_header) (cinfo);
  640|  81.3k|    master->pub.call_pass_startup = FALSE;
  ------------------
  |  |  207|  81.3k|#define FALSE   0               /* values of boolean */
  ------------------
  641|  81.3k|    break;
  642|      0|  default:
  ------------------
  |  Branch (642:3): [True: 0, False: 116k]
  ------------------
  643|      0|    ERREXIT(cinfo, JERR_NOT_COMPILED);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  644|   116k|  }
  645|       |
  646|   116k|  master->pub.is_last_pass = (master->pass_number == master->total_passes - 1);
  647|       |
  648|       |  /* Set up progress monitor's pass info if present */
  649|   116k|  if (cinfo->progress != NULL) {
  ------------------
  |  Branch (649:7): [True: 0, False: 116k]
  ------------------
  650|      0|    cinfo->progress->completed_passes = master->pass_number;
  651|      0|    cinfo->progress->total_passes = master->total_passes;
  652|      0|  }
  653|   116k|}
jcmaster.c:select_scan_parameters:
  444|  87.0k|{
  445|  87.0k|  int ci;
  446|       |
  447|  87.0k|#ifdef NEED_SCAN_SCRIPT
  448|  87.0k|  if (cinfo->scan_info != NULL) {
  ------------------
  |  Branch (448:7): [True: 72.6k, False: 14.4k]
  ------------------
  449|       |    /* Prepare for current scan --- the script is already validated */
  450|  72.6k|    my_master_ptr master = (my_master_ptr)cinfo->master;
  451|  72.6k|    const jpeg_scan_info *scanptr = cinfo->scan_info + master->scan_number;
  452|       |
  453|  72.6k|    cinfo->comps_in_scan = scanptr->comps_in_scan;
  454|   162k|    for (ci = 0; ci < scanptr->comps_in_scan; ci++) {
  ------------------
  |  Branch (454:18): [True: 89.6k, False: 72.6k]
  ------------------
  455|  89.6k|      cinfo->cur_comp_info[ci] =
  456|  89.6k|        &cinfo->comp_info[scanptr->component_index[ci]];
  457|  89.6k|    }
  458|  72.6k|    cinfo->Ss = scanptr->Ss;
  459|  72.6k|    cinfo->Se = scanptr->Se;
  460|  72.6k|    cinfo->Ah = scanptr->Ah;
  461|  72.6k|    cinfo->Al = scanptr->Al;
  462|  72.6k|  } else
  463|  14.4k|#endif
  464|  14.4k|  {
  465|       |    /* Prepare for single sequential-JPEG scan containing all components */
  466|  14.4k|    if (cinfo->num_components > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  14.4k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (466:9): [True: 0, False: 14.4k]
  ------------------
  467|      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)))
  ------------------
  468|  14.4k|               MAX_COMPS_IN_SCAN);
  469|  14.4k|    cinfo->comps_in_scan = cinfo->num_components;
  470|  51.9k|    for (ci = 0; ci < cinfo->num_components; ci++) {
  ------------------
  |  Branch (470:18): [True: 37.5k, False: 14.4k]
  ------------------
  471|  37.5k|      cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
  472|  37.5k|    }
  473|  14.4k|    if (!cinfo->master->lossless) {
  ------------------
  |  Branch (473:9): [True: 14.4k, False: 0]
  ------------------
  474|  14.4k|      cinfo->Ss = 0;
  475|  14.4k|      cinfo->Se = DCTSIZE2 - 1;
  ------------------
  |  |   67|  14.4k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  476|  14.4k|      cinfo->Ah = 0;
  477|  14.4k|      cinfo->Al = 0;
  478|  14.4k|    }
  479|  14.4k|  }
  480|  87.0k|}
jcmaster.c:per_scan_setup:
  487|  87.0k|{
  488|  87.0k|  int ci, mcublks, tmp;
  489|  87.0k|  jpeg_component_info *compptr;
  490|  87.0k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  87.0k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (490:19): [True: 0, False: 87.0k]
  ------------------
  491|       |
  492|  87.0k|  if (cinfo->comps_in_scan == 1) {
  ------------------
  |  Branch (492:7): [True: 69.7k, False: 17.2k]
  ------------------
  493|       |
  494|       |    /* Noninterleaved (single-component) scan */
  495|  69.7k|    compptr = cinfo->cur_comp_info[0];
  496|       |
  497|       |    /* Overall image size in MCUs */
  498|  69.7k|    cinfo->MCUs_per_row = compptr->width_in_blocks;
  499|  69.7k|    cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
  500|       |
  501|       |    /* For noninterleaved scan, always one block per MCU */
  502|  69.7k|    compptr->MCU_width = 1;
  503|  69.7k|    compptr->MCU_height = 1;
  504|  69.7k|    compptr->MCU_blocks = 1;
  505|  69.7k|    compptr->MCU_sample_width = data_unit;
  506|  69.7k|    compptr->last_col_width = 1;
  507|       |    /* For noninterleaved scans, it is convenient to define last_row_height
  508|       |     * as the number of block rows present in the last iMCU row.
  509|       |     */
  510|  69.7k|    tmp = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
  511|  69.7k|    if (tmp == 0) tmp = compptr->v_samp_factor;
  ------------------
  |  Branch (511:9): [True: 50.8k, False: 18.8k]
  ------------------
  512|  69.7k|    compptr->last_row_height = tmp;
  513|       |
  514|       |    /* Prepare array describing MCU composition */
  515|  69.7k|    cinfo->blocks_in_MCU = 1;
  516|  69.7k|    cinfo->MCU_membership[0] = 0;
  517|       |
  518|  69.7k|  } else {
  519|       |
  520|       |    /* Interleaved (multi-component) scan */
  521|  17.2k|    if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  17.2k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (521:9): [True: 0, False: 17.2k]
  |  Branch (521:38): [True: 0, False: 17.2k]
  ------------------
  522|      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)))
  ------------------
  523|  17.2k|               MAX_COMPS_IN_SCAN);
  524|       |
  525|       |    /* Overall image size in MCUs */
  526|  17.2k|    cinfo->MCUs_per_row = (JDIMENSION)
  527|  17.2k|      jdiv_round_up((long)cinfo->_jpeg_width,
  ------------------
  |  |   30|  17.2k|#define _jpeg_width  image_width
  ------------------
  528|  17.2k|                    (long)(cinfo->max_h_samp_factor * data_unit));
  529|  17.2k|    cinfo->MCU_rows_in_scan = (JDIMENSION)
  530|  17.2k|      jdiv_round_up((long)cinfo->_jpeg_height,
  ------------------
  |  |   31|  17.2k|#define _jpeg_height  image_height
  ------------------
  531|  17.2k|                    (long)(cinfo->max_v_samp_factor * data_unit));
  532|       |
  533|  17.2k|    cinfo->blocks_in_MCU = 0;
  534|       |
  535|  74.6k|    for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (535:18): [True: 57.4k, False: 17.2k]
  ------------------
  536|  57.4k|      compptr = cinfo->cur_comp_info[ci];
  537|       |      /* Sampling factors give # of blocks of component in each MCU */
  538|  57.4k|      compptr->MCU_width = compptr->h_samp_factor;
  539|  57.4k|      compptr->MCU_height = compptr->v_samp_factor;
  540|  57.4k|      compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
  541|  57.4k|      compptr->MCU_sample_width = compptr->MCU_width * data_unit;
  542|       |      /* Figure number of non-dummy blocks in last MCU column & row */
  543|  57.4k|      tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
  544|  57.4k|      if (tmp == 0) tmp = compptr->MCU_width;
  ------------------
  |  Branch (544:11): [True: 49.6k, False: 7.78k]
  ------------------
  545|  57.4k|      compptr->last_col_width = tmp;
  546|  57.4k|      tmp = (int)(compptr->height_in_blocks % compptr->MCU_height);
  547|  57.4k|      if (tmp == 0) tmp = compptr->MCU_height;
  ------------------
  |  Branch (547:11): [True: 45.6k, False: 11.8k]
  ------------------
  548|  57.4k|      compptr->last_row_height = tmp;
  549|       |      /* Prepare array describing MCU composition */
  550|  57.4k|      mcublks = compptr->MCU_blocks;
  551|  57.4k|      if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU)
  ------------------
  |  |   80|  57.4k|#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on data units/MCU */
  ------------------
  |  Branch (551:11): [True: 0, False: 57.4k]
  ------------------
  552|      0|        ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  553|   146k|      while (mcublks-- > 0) {
  ------------------
  |  Branch (553:14): [True: 88.7k, False: 57.4k]
  ------------------
  554|  88.7k|        cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
  555|  88.7k|      }
  556|  57.4k|    }
  557|       |
  558|  17.2k|  }
  559|       |
  560|       |  /* Convert restart specified in rows to actual MCU count. */
  561|       |  /* Note that count must fit in 16 bits, so we provide limiting. */
  562|  87.0k|  if (cinfo->restart_in_rows > 0) {
  ------------------
  |  Branch (562:7): [True: 53.9k, False: 33.1k]
  ------------------
  563|  53.9k|    long nominal = (long)cinfo->restart_in_rows * (long)cinfo->MCUs_per_row;
  564|  53.9k|    cinfo->restart_interval = (unsigned int)MIN(nominal, 65535L);
  ------------------
  |  |  515|  53.9k|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 53.9k, False: 0]
  |  |  ------------------
  ------------------
  565|  53.9k|  }
  566|  87.0k|}
jcmaster.c:pass_startup:
  668|  5.67k|{
  669|  5.67k|  cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */
  ------------------
  |  |  207|  5.67k|#define FALSE   0               /* values of boolean */
  ------------------
  670|       |
  671|  5.67k|  (*cinfo->marker->write_frame_header) (cinfo);
  672|  5.67k|  (*cinfo->marker->write_scan_header) (cinfo);
  673|  5.67k|}
jcmaster.c:finish_pass_master:
  682|   116k|{
  683|   116k|  my_master_ptr master = (my_master_ptr)cinfo->master;
  684|       |
  685|       |  /* The entropy coder always needs an end-of-pass call,
  686|       |   * either to analyze statistics or to flush its output buffer.
  687|       |   */
  688|   116k|  (*cinfo->entropy->finish_pass) (cinfo);
  689|       |
  690|       |  /* Update state for next pass */
  691|   116k|  switch (master->pass_type) {
  ------------------
  |  Branch (691:11): [True: 116k, False: 0]
  ------------------
  692|  20.8k|  case main_pass:
  ------------------
  |  Branch (692:3): [True: 20.8k, False: 95.7k]
  ------------------
  693|       |    /* next pass is either output of scan 0 (after optimization)
  694|       |     * or output of scan 1 (if no optimization).
  695|       |     */
  696|  20.8k|    master->pass_type = output_pass;
  697|  20.8k|    if (!cinfo->optimize_coding)
  ------------------
  |  Branch (697:9): [True: 5.67k, False: 15.1k]
  ------------------
  698|  5.67k|      master->scan_number++;
  699|  20.8k|    break;
  700|  14.3k|  case huff_opt_pass:
  ------------------
  |  Branch (700:3): [True: 14.3k, False: 102k]
  ------------------
  701|       |    /* next pass is always output of current scan */
  702|  14.3k|    master->pass_type = output_pass;
  703|  14.3k|    break;
  704|  81.3k|  case output_pass:
  ------------------
  |  Branch (704:3): [True: 81.3k, False: 35.1k]
  ------------------
  705|       |    /* next pass is either optimization or output of next scan */
  706|  81.3k|    if (cinfo->optimize_coding)
  ------------------
  |  Branch (706:9): [True: 33.1k, False: 48.2k]
  ------------------
  707|  33.1k|      master->pass_type = huff_opt_pass;
  708|  81.3k|    master->scan_number++;
  709|  81.3k|    break;
  710|   116k|  }
  711|       |
  712|   116k|  master->pass_number++;
  713|   116k|}
jcmaster.c:validate_script:
  280|  6.42k|{
  281|  6.42k|  const jpeg_scan_info *scanptr;
  282|  6.42k|  int scanno, ncomps, ci, thisi;
  283|  6.42k|  int Ss, Se, Ah, Al;
  284|  6.42k|  boolean component_sent[MAX_COMPONENTS];
  285|  6.42k|#ifdef C_PROGRESSIVE_SUPPORTED
  286|  6.42k|  int coefi, *last_bitpos_ptr;
  287|  6.42k|  int last_bitpos[MAX_COMPONENTS][DCTSIZE2];
  288|       |  /* -1 until that coefficient has been seen; then last Al for it */
  289|  6.42k|#endif
  290|       |
  291|  6.42k|  if (cinfo->num_scans <= 0)
  ------------------
  |  Branch (291:7): [True: 0, False: 6.42k]
  ------------------
  292|      0|    ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 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)))
  ------------------
  293|       |
  294|       |#ifndef C_MULTISCAN_FILES_SUPPORTED
  295|       |  if (cinfo->num_scans > 1)
  296|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  297|       |#endif
  298|       |
  299|  6.42k|  scanptr = cinfo->scan_info;
  300|  6.42k|  if (scanptr->Ss != 0 && scanptr->Se == 0) {
  ------------------
  |  Branch (300:7): [True: 0, False: 6.42k]
  |  Branch (300:27): [True: 0, False: 0]
  ------------------
  301|      0|#ifdef C_LOSSLESS_SUPPORTED
  302|      0|    cinfo->master->lossless = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  303|      0|    cinfo->progressive_mode = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  304|      0|    for (ci = 0; ci < cinfo->num_components; ci++)
  ------------------
  |  Branch (304:18): [True: 0, False: 0]
  ------------------
  305|      0|      component_sent[ci] = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  306|       |#else
  307|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  308|       |#endif
  309|      0|  }
  310|       |  /* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1;
  311|       |   * for progressive JPEG, no scan can have this.
  312|       |   */
  313|  6.42k|  else if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2 - 1) {
  ------------------
  |  |   67|  6.42k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (313:12): [True: 0, False: 6.42k]
  |  Branch (313:32): [True: 6.42k, False: 0]
  ------------------
  314|  6.42k|#ifdef C_PROGRESSIVE_SUPPORTED
  315|  6.42k|    cinfo->progressive_mode = TRUE;
  ------------------
  |  |  210|  6.42k|#define TRUE    1
  ------------------
  316|  6.42k|    cinfo->master->lossless = FALSE;
  ------------------
  |  |  207|  6.42k|#define FALSE   0               /* values of boolean */
  ------------------
  317|  6.42k|    last_bitpos_ptr = &last_bitpos[0][0];
  318|  21.3k|    for (ci = 0; ci < cinfo->num_components; ci++)
  ------------------
  |  Branch (318:18): [True: 14.9k, False: 6.42k]
  ------------------
  319|   971k|      for (coefi = 0; coefi < DCTSIZE2; coefi++)
  ------------------
  |  |   67|   971k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (319:23): [True: 956k, False: 14.9k]
  ------------------
  320|   956k|        *last_bitpos_ptr++ = -1;
  321|       |#else
  322|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  323|       |#endif
  324|  6.42k|  } else {
  325|      0|    cinfo->progressive_mode = cinfo->master->lossless = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  326|      0|    for (ci = 0; ci < cinfo->num_components; ci++)
  ------------------
  |  Branch (326:18): [True: 0, False: 0]
  ------------------
  327|      0|      component_sent[ci] = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  328|      0|  }
  329|       |
  330|  79.0k|  for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) {
  ------------------
  |  Branch (330:20): [True: 72.6k, False: 6.42k]
  ------------------
  331|       |    /* Validate component indexes */
  332|  72.6k|    ncomps = scanptr->comps_in_scan;
  333|  72.6k|    if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  72.6k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (333:9): [True: 0, False: 72.6k]
  |  Branch (333:24): [True: 0, False: 72.6k]
  ------------------
  334|      0|      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_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)))
  ------------------
  335|   162k|    for (ci = 0; ci < ncomps; ci++) {
  ------------------
  |  Branch (335:18): [True: 89.6k, False: 72.6k]
  ------------------
  336|  89.6k|      thisi = scanptr->component_index[ci];
  337|  89.6k|      if (thisi < 0 || thisi >= cinfo->num_components)
  ------------------
  |  Branch (337:11): [True: 0, False: 89.6k]
  |  Branch (337:24): [True: 0, False: 89.6k]
  ------------------
  338|      0|        ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
  ------------------
  |  |  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)))
  ------------------
  339|       |      /* Components must appear in SOF order within each scan */
  340|  89.6k|      if (ci > 0 && thisi <= scanptr->component_index[ci - 1])
  ------------------
  |  Branch (340:11): [True: 17.0k, False: 72.6k]
  |  Branch (340:21): [True: 0, False: 17.0k]
  ------------------
  341|      0|        ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
  ------------------
  |  |  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|  89.6k|    }
  343|       |    /* Validate progression parameters */
  344|  72.6k|    Ss = scanptr->Ss;
  345|  72.6k|    Se = scanptr->Se;
  346|  72.6k|    Ah = scanptr->Ah;
  347|  72.6k|    Al = scanptr->Al;
  348|  72.6k|    if (cinfo->progressive_mode) {
  ------------------
  |  Branch (348:9): [True: 72.6k, False: 0]
  ------------------
  349|  72.6k|#ifdef C_PROGRESSIVE_SUPPORTED
  350|       |      /* Rec. ITU-T T.81 | ISO/IEC 10918-1 simply gives the ranges 0..13 for Ah
  351|       |       * and Al, but that seems wrong: the upper bound ought to depend on data
  352|       |       * precision.  Perhaps they really meant 0..N+1 for N-bit precision.
  353|       |       * Here we allow 0..10 for 8-bit data; Al larger than 10 results in
  354|       |       * out-of-range reconstructed DC values during the first DC scan,
  355|       |       * which might cause problems for some decoders.
  356|       |       */
  357|  72.6k|      int max_Ah_Al = cinfo->data_precision == 12 ? 13 : 10;
  ------------------
  |  Branch (357:23): [True: 72.6k, False: 0]
  ------------------
  358|       |
  359|  72.6k|      if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
  ------------------
  |  |   67|   145k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
                    if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
  ------------------
  |  |   67|   145k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (359:11): [True: 0, False: 72.6k]
  |  Branch (359:21): [True: 0, False: 72.6k]
  |  Branch (359:39): [True: 0, False: 72.6k]
  |  Branch (359:50): [True: 0, False: 72.6k]
  ------------------
  360|  72.6k|          Ah < 0 || Ah > max_Ah_Al || Al < 0 || Al > max_Ah_Al)
  ------------------
  |  Branch (360:11): [True: 0, False: 72.6k]
  |  Branch (360:21): [True: 0, False: 72.6k]
  |  Branch (360:39): [True: 0, False: 72.6k]
  |  Branch (360:49): [True: 0, False: 72.6k]
  ------------------
  361|      0|        ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
  ------------------
  |  |  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|  72.6k|      if (Ss == 0) {
  ------------------
  |  Branch (362:11): [True: 12.8k, False: 59.7k]
  ------------------
  363|  12.8k|        if (Se != 0)            /* DC and AC together not OK */
  ------------------
  |  Branch (363:13): [True: 0, False: 12.8k]
  ------------------
  364|      0|          ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
  ------------------
  |  |  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)))
  ------------------
  365|  59.7k|      } else {
  366|  59.7k|        if (ncomps != 1)        /* AC scans must be for only one component */
  ------------------
  |  Branch (366:13): [True: 0, False: 59.7k]
  ------------------
  367|      0|          ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
  ------------------
  |  |  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)))
  ------------------
  368|  59.7k|      }
  369|   162k|      for (ci = 0; ci < ncomps; ci++) {
  ------------------
  |  Branch (369:20): [True: 89.6k, False: 72.6k]
  ------------------
  370|  89.6k|        last_bitpos_ptr = &last_bitpos[scanptr->component_index[ci]][0];
  371|  89.6k|        if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */
  ------------------
  |  Branch (371:13): [True: 59.7k, False: 29.8k]
  |  Branch (371:24): [True: 0, False: 59.7k]
  ------------------
  372|      0|          ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
  ------------------
  |  |  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)))
  ------------------
  373|  2.94M|        for (coefi = Ss; coefi <= Se; coefi++) {
  ------------------
  |  Branch (373:26): [True: 2.85M, False: 89.6k]
  ------------------
  374|  2.85M|          if (last_bitpos_ptr[coefi] < 0) {
  ------------------
  |  Branch (374:15): [True: 956k, False: 1.89M]
  ------------------
  375|       |            /* first scan of this coefficient */
  376|   956k|            if (Ah != 0)
  ------------------
  |  Branch (376:17): [True: 0, False: 956k]
  ------------------
  377|      0|              ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
  ------------------
  |  |  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)))
  ------------------
  378|  1.89M|          } else {
  379|       |            /* not first scan */
  380|  1.89M|            if (Ah != last_bitpos_ptr[coefi] || Al != Ah - 1)
  ------------------
  |  Branch (380:17): [True: 0, False: 1.89M]
  |  Branch (380:49): [True: 0, False: 1.89M]
  ------------------
  381|      0|              ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
  ------------------
  |  |  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)))
  ------------------
  382|  1.89M|          }
  383|  2.85M|          last_bitpos_ptr[coefi] = Al;
  384|  2.85M|        }
  385|  89.6k|      }
  386|  72.6k|#endif
  387|  72.6k|    } else {
  388|      0|#ifdef C_LOSSLESS_SUPPORTED
  389|      0|      if (cinfo->master->lossless) {
  ------------------
  |  Branch (389:11): [True: 0, False: 0]
  ------------------
  390|       |        /* The JPEG spec simply gives the range 0..15 for Al (Pt), but that
  391|       |         * seems wrong: the upper bound ought to depend on data precision.
  392|       |         * Perhaps they really meant 0..N-1 for N-bit precision, which is what
  393|       |         * we allow here.  Values greater than or equal to the data precision
  394|       |         * will result in a blank image.
  395|       |         */
  396|      0|        if (Ss < 1 || Ss > 7 ||         /* predictor selection value */
  ------------------
  |  Branch (396:13): [True: 0, False: 0]
  |  Branch (396:23): [True: 0, False: 0]
  ------------------
  397|      0|            Se != 0 || Ah != 0 ||
  ------------------
  |  Branch (397:13): [True: 0, False: 0]
  |  Branch (397:24): [True: 0, False: 0]
  ------------------
  398|      0|            Al < 0 || Al >= cinfo->data_precision) /* point transform */
  ------------------
  |  Branch (398:13): [True: 0, False: 0]
  |  Branch (398:23): [True: 0, False: 0]
  ------------------
  399|      0|          ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
  ------------------
  |  |  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)))
  ------------------
  400|      0|      } else
  401|      0|#endif
  402|      0|      {
  403|       |        /* For sequential JPEG, all progression parameters must be these: */
  404|      0|        if (Ss != 0 || Se != DCTSIZE2 - 1 || Ah != 0 || Al != 0)
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (404:13): [True: 0, False: 0]
  |  Branch (404:24): [True: 0, False: 0]
  |  Branch (404:46): [True: 0, False: 0]
  |  Branch (404:57): [True: 0, False: 0]
  ------------------
  405|      0|          ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
  ------------------
  |  |  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)))
  ------------------
  406|      0|      }
  407|       |      /* Make sure components are not sent twice */
  408|      0|      for (ci = 0; ci < ncomps; ci++) {
  ------------------
  |  Branch (408:20): [True: 0, False: 0]
  ------------------
  409|      0|        thisi = scanptr->component_index[ci];
  410|      0|        if (component_sent[thisi])
  ------------------
  |  Branch (410:13): [True: 0, False: 0]
  ------------------
  411|      0|          ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
  ------------------
  |  |  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)))
  ------------------
  412|      0|        component_sent[thisi] = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  413|      0|      }
  414|      0|    }
  415|  72.6k|  }
  416|       |
  417|       |  /* Now verify that everything got sent. */
  418|  6.42k|  if (cinfo->progressive_mode) {
  ------------------
  |  Branch (418:7): [True: 6.42k, False: 0]
  ------------------
  419|  6.42k|#ifdef C_PROGRESSIVE_SUPPORTED
  420|       |    /* For progressive mode, we only check that at least some DC data
  421|       |     * got sent for each component; the spec does not require that all bits
  422|       |     * of all coefficients be transmitted.  Would it be wiser to enforce
  423|       |     * transmission of all coefficient bits??
  424|       |     */
  425|  21.3k|    for (ci = 0; ci < cinfo->num_components; ci++) {
  ------------------
  |  Branch (425:18): [True: 14.9k, False: 6.42k]
  ------------------
  426|  14.9k|      if (last_bitpos[ci][0] < 0)
  ------------------
  |  Branch (426:11): [True: 0, False: 14.9k]
  ------------------
  427|      0|        ERREXIT(cinfo, JERR_MISSING_DATA);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  428|  14.9k|    }
  429|  6.42k|#endif
  430|  6.42k|  } else {
  431|      0|    for (ci = 0; ci < cinfo->num_components; ci++) {
  ------------------
  |  Branch (431:18): [True: 0, False: 0]
  ------------------
  432|      0|      if (!component_sent[ci])
  ------------------
  |  Branch (432:11): [True: 0, False: 0]
  ------------------
  433|      0|        ERREXIT(cinfo, JERR_MISSING_DATA);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  434|      0|    }
  435|      0|  }
  436|  6.42k|}
jcmaster.c:initial_setup:
  166|  20.8k|{
  167|  20.8k|  int ci;
  168|  20.8k|  jpeg_component_info *compptr;
  169|  20.8k|  long samplesperrow;
  170|  20.8k|  JDIMENSION jd_samplesperrow;
  171|  20.8k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  20.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (171:19): [True: 0, False: 20.8k]
  ------------------
  172|       |
  173|       |#if JPEG_LIB_VERSION >= 70
  174|       |#if JPEG_LIB_VERSION >= 80
  175|       |  if (!transcode_only)
  176|       |#endif
  177|       |    jpeg_calc_jpeg_dimensions(cinfo);
  178|       |#endif
  179|       |
  180|       |  /* Sanity check on image dimensions */
  181|  20.8k|  if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0 ||
  ------------------
  |  |   31|  20.8k|#define _jpeg_height  image_height
  ------------------
                if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0 ||
  ------------------
  |  |   30|  20.8k|#define _jpeg_width  image_width
  ------------------
  |  Branch (181:7): [True: 0, False: 20.8k]
  |  Branch (181:35): [True: 0, False: 20.8k]
  ------------------
  182|  20.8k|      cinfo->num_components <= 0 || cinfo->input_components <= 0)
  ------------------
  |  Branch (182:7): [True: 0, False: 20.8k]
  |  Branch (182:37): [True: 0, False: 20.8k]
  ------------------
  183|      0|    ERREXIT(cinfo, JERR_EMPTY_IMAGE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  184|       |
  185|       |  /* Make sure image isn't bigger than I can handle */
  186|  20.8k|  if ((long)cinfo->_jpeg_height > (long)JPEG_MAX_DIMENSION ||
  ------------------
  |  |   31|  20.8k|#define _jpeg_height  image_height
  ------------------
                if ((long)cinfo->_jpeg_height > (long)JPEG_MAX_DIMENSION ||
  ------------------
  |  |  158|  41.6k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (186:7): [True: 0, False: 20.8k]
  ------------------
  187|  20.8k|      (long)cinfo->_jpeg_width > (long)JPEG_MAX_DIMENSION)
  ------------------
  |  |   30|  20.8k|#define _jpeg_width  image_width
  ------------------
                    (long)cinfo->_jpeg_width > (long)JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  20.8k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (187:7): [True: 0, False: 20.8k]
  ------------------
  188|      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)))
  ------------------
  189|       |
  190|       |  /* Width of an input scanline must be representable as JDIMENSION. */
  191|  20.8k|  samplesperrow = (long)cinfo->image_width * (long)cinfo->input_components;
  192|  20.8k|  jd_samplesperrow = (JDIMENSION)samplesperrow;
  193|  20.8k|  if ((long)jd_samplesperrow != samplesperrow)
  ------------------
  |  Branch (193:7): [True: 0, False: 20.8k]
  ------------------
  194|      0|    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  195|       |
  196|       |  /* Lossy JPEG images must have 8 or 12 bits per sample.  Lossless JPEG images
  197|       |   * can have 2 to 16 bits per sample.
  198|       |   */
  199|  20.8k|#ifdef C_LOSSLESS_SUPPORTED
  200|  20.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (200:7): [True: 0, False: 20.8k]
  ------------------
  201|      0|    if (cinfo->data_precision < 2 || cinfo->data_precision > 16)
  ------------------
  |  Branch (201:9): [True: 0, False: 0]
  |  Branch (201:38): [True: 0, False: 0]
  ------------------
  202|      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)))
  ------------------
  203|      0|  } else
  204|  20.8k|#endif
  205|  20.8k|  {
  206|  20.8k|    if (cinfo->data_precision != 8 && cinfo->data_precision != 12)
  ------------------
  |  Branch (206:9): [True: 20.8k, False: 0]
  |  Branch (206:39): [True: 0, False: 20.8k]
  ------------------
  207|      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)))
  ------------------
  208|  20.8k|  }
  209|       |
  210|       |  /* Check that number of components won't exceed internal array sizes */
  211|  20.8k|  if (cinfo->num_components > MAX_COMPONENTS)
  ------------------
  |  |   30|  20.8k|#define MAX_COMPONENTS  10      /* maximum number of image components */
  ------------------
  |  Branch (211:7): [True: 0, False: 20.8k]
  ------------------
  212|      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)))
  ------------------
  213|  20.8k|             MAX_COMPONENTS);
  214|       |
  215|       |  /* Compute maximum sampling factors; check factor validity */
  216|  20.8k|  cinfo->max_h_samp_factor = 1;
  217|  20.8k|  cinfo->max_v_samp_factor = 1;
  218|  73.3k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (218:44): [True: 52.5k, False: 20.8k]
  ------------------
  219|  52.5k|       ci++, compptr++) {
  220|  52.5k|    if (compptr->h_samp_factor <= 0 ||
  ------------------
  |  Branch (220:9): [True: 0, False: 52.5k]
  ------------------
  221|  52.5k|        compptr->h_samp_factor > MAX_SAMP_FACTOR ||
  ------------------
  |  |   72|   105k|#define MAX_SAMP_FACTOR     4   /* JPEG limit on sampling factors */
  ------------------
  |  Branch (221:9): [True: 0, False: 52.5k]
  ------------------
  222|  52.5k|        compptr->v_samp_factor <= 0 ||
  ------------------
  |  Branch (222:9): [True: 0, False: 52.5k]
  ------------------
  223|  52.5k|        compptr->v_samp_factor > MAX_SAMP_FACTOR)
  ------------------
  |  |   72|  52.5k|#define MAX_SAMP_FACTOR     4   /* JPEG limit on sampling factors */
  ------------------
  |  Branch (223:9): [True: 0, False: 52.5k]
  ------------------
  224|      0|      ERREXIT(cinfo, JERR_BAD_SAMPLING);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  225|  52.5k|    cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
  ------------------
  |  |  513|  52.5k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 17.2k, False: 35.2k]
  |  |  ------------------
  ------------------
  226|  52.5k|                                   compptr->h_samp_factor);
  227|  52.5k|    cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
  ------------------
  |  |  513|  52.5k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 11.3k, False: 41.1k]
  |  |  ------------------
  ------------------
  228|  52.5k|                                   compptr->v_samp_factor);
  229|  52.5k|  }
  230|       |
  231|       |  /* Compute dimensions of components */
  232|  73.3k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (232:44): [True: 52.5k, False: 20.8k]
  ------------------
  233|  52.5k|       ci++, compptr++) {
  234|       |    /* Fill in the correct component_index value; don't rely on application */
  235|  52.5k|    compptr->component_index = ci;
  236|       |    /* For compression, we never do DCT scaling. */
  237|       |#if JPEG_LIB_VERSION >= 70
  238|       |    compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = data_unit;
  239|       |#else
  240|  52.5k|    compptr->DCT_scaled_size = data_unit;
  241|  52.5k|#endif
  242|       |    /* Size in data units */
  243|  52.5k|    compptr->width_in_blocks = (JDIMENSION)
  244|  52.5k|      jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
  ------------------
  |  |   30|  52.5k|#define _jpeg_width  image_width
  ------------------
  245|  52.5k|                    (long)(cinfo->max_h_samp_factor * data_unit));
  246|  52.5k|    compptr->height_in_blocks = (JDIMENSION)
  247|  52.5k|      jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
  ------------------
  |  |   31|  52.5k|#define _jpeg_height  image_height
  ------------------
  248|  52.5k|                    (long)(cinfo->max_v_samp_factor * data_unit));
  249|       |    /* Size in samples */
  250|  52.5k|    compptr->downsampled_width = (JDIMENSION)
  251|  52.5k|      jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
  ------------------
  |  |   30|  52.5k|#define _jpeg_width  image_width
  ------------------
  252|  52.5k|                    (long)cinfo->max_h_samp_factor);
  253|  52.5k|    compptr->downsampled_height = (JDIMENSION)
  254|  52.5k|      jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
  ------------------
  |  |   31|  52.5k|#define _jpeg_height  image_height
  ------------------
  255|  52.5k|                    (long)cinfo->max_v_samp_factor);
  256|       |    /* Mark component needed (this flag isn't actually used for compression) */
  257|  52.5k|    compptr->component_needed = TRUE;
  ------------------
  |  |  210|  52.5k|#define TRUE    1
  ------------------
  258|  52.5k|  }
  259|       |
  260|       |  /* Compute number of fully interleaved MCU rows (number of times that
  261|       |   * main controller will call coefficient or difference controller).
  262|       |   */
  263|  20.8k|  cinfo->total_iMCU_rows = (JDIMENSION)
  264|  20.8k|    jdiv_round_up((long)cinfo->_jpeg_height,
  ------------------
  |  |   31|  20.8k|#define _jpeg_height  image_height
  ------------------
  265|  20.8k|                  (long)(cinfo->max_v_samp_factor * data_unit));
  266|  20.8k|}

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

jpeg_add_quant_table:
   38|  83.3k|{
   39|  83.3k|  JQUANT_TBL **qtblptr;
   40|  83.3k|  int i;
   41|  83.3k|  long temp;
   42|       |
   43|       |  /* Safety check to ensure start_compress not called yet. */
   44|  83.3k|  if (cinfo->global_state != CSTATE_START)
  ------------------
  |  |   44|  83.3k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (44:7): [True: 0, False: 83.3k]
  ------------------
   45|      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)))
  ------------------
   46|       |
   47|  83.3k|  if (which_tbl < 0 || which_tbl >= NUM_QUANT_TBLS)
  ------------------
  |  |   68|  83.3k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (47:7): [True: 0, False: 83.3k]
  |  Branch (47:24): [True: 0, False: 83.3k]
  ------------------
   48|      0|    ERREXIT1(cinfo, JERR_DQT_INDEX, which_tbl);
  ------------------
  |  |  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)))
  ------------------
   49|       |
   50|  83.3k|  qtblptr = &cinfo->quant_tbl_ptrs[which_tbl];
   51|       |
   52|  83.3k|  if (*qtblptr == NULL)
  ------------------
  |  Branch (52:7): [True: 7.54k, False: 75.8k]
  ------------------
   53|  7.54k|    *qtblptr = jpeg_alloc_quant_table((j_common_ptr)cinfo);
   54|       |
   55|  5.41M|  for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  5.41M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (55:15): [True: 5.33M, False: 83.3k]
  ------------------
   56|  5.33M|    temp = ((long)basic_table[i] * scale_factor + 50L) / 100L;
   57|       |    /* limit the values to the valid range */
   58|  5.33M|    if (temp <= 0L) temp = 1L;
  ------------------
  |  Branch (58:9): [True: 377k, False: 4.95M]
  ------------------
   59|  5.33M|    if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */
  ------------------
  |  Branch (59:9): [True: 0, False: 5.33M]
  ------------------
   60|  5.33M|    if (force_baseline && temp > 255L)
  ------------------
  |  Branch (60:9): [True: 5.33M, False: 0]
  |  Branch (60:27): [True: 686k, False: 4.64M]
  ------------------
   61|   686k|      temp = 255L;              /* limit to baseline range if requested */
   62|  5.33M|    (*qtblptr)->quantval[i] = (UINT16)temp;
   63|  5.33M|  }
   64|       |
   65|       |  /* Initialize sent_table FALSE so table will be written to JPEG file. */
   66|  83.3k|  (*qtblptr)->sent_table = FALSE;
  ------------------
  |  |  207|  83.3k|#define FALSE   0               /* values of boolean */
  ------------------
   67|  83.3k|}
jpeg_set_linear_quality:
  122|  41.6k|{
  123|       |  /* Set up two quantization tables using the specified scaling */
  124|  41.6k|  jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
  125|  41.6k|                       scale_factor, force_baseline);
  126|  41.6k|  jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
  127|  41.6k|                       scale_factor, force_baseline);
  128|  41.6k|}
jpeg_quality_scaling:
  137|  41.6k|{
  138|       |  /* Safety limit on quality factor.  Convert 0 to 1 to avoid zero divide. */
  139|  41.6k|  if (quality <= 0) quality = 1;
  ------------------
  |  Branch (139:7): [True: 0, False: 41.6k]
  ------------------
  140|  41.6k|  if (quality > 100) quality = 100;
  ------------------
  |  Branch (140:7): [True: 0, False: 41.6k]
  ------------------
  141|       |
  142|       |  /* The basic table is used as-is (scaling 100) for a quality of 50.
  143|       |   * Qualities 50..100 are converted to scaling percentage 200 - 2*Q;
  144|       |   * note that at Q=100 the scaling is 0, which will cause jpeg_add_quant_table
  145|       |   * to make all the table entries 1 (hence, minimum quantization loss).
  146|       |   * Qualities 1..50 are converted to scaling percentage 5000/Q.
  147|       |   */
  148|  41.6k|  if (quality < 50)
  ------------------
  |  Branch (148:7): [True: 9.26k, False: 32.4k]
  ------------------
  149|  9.26k|    quality = 5000 / quality;
  150|  32.4k|  else
  151|  32.4k|    quality = 200 - quality * 2;
  152|       |
  153|  41.6k|  return quality;
  154|  41.6k|}
jpeg_set_quality:
  164|  41.6k|{
  165|       |  /* Convert user 0-100 rating to percentage scaling */
  166|  41.6k|  quality = jpeg_quality_scaling(quality);
  167|       |
  168|       |  /* Set up standard quality tables */
  169|  41.6k|  jpeg_set_linear_quality(cinfo, quality, force_baseline);
  170|  41.6k|}
jpeg_set_defaults:
  185|  20.8k|{
  186|  20.8k|  int i;
  187|       |
  188|       |  /* Safety check to ensure start_compress not called yet. */
  189|  20.8k|  if (cinfo->global_state != CSTATE_START)
  ------------------
  |  |   44|  20.8k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (189:7): [True: 0, False: 20.8k]
  ------------------
  190|      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)))
  ------------------
  191|       |
  192|       |  /* Allocate comp_info array large enough for maximum component count.
  193|       |   * Array is made permanent in case application wants to compress
  194|       |   * multiple images at same param settings.
  195|       |   */
  196|  20.8k|  if (cinfo->comp_info == NULL)
  ------------------
  |  Branch (196:7): [True: 3.77k, False: 17.0k]
  ------------------
  197|  3.77k|    cinfo->comp_info = (jpeg_component_info *)
  198|  3.77k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  3.77k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  199|  3.77k|                                  MAX_COMPONENTS * sizeof(jpeg_component_info));
  ------------------
  |  |   30|  3.77k|#define MAX_COMPONENTS  10      /* maximum number of image components */
  ------------------
  200|       |
  201|       |  /* Initialize everything not dependent on the color space */
  202|       |
  203|       |#if JPEG_LIB_VERSION >= 70
  204|       |  cinfo->scale_num = 1;         /* 1:1 scaling */
  205|       |  cinfo->scale_denom = 1;
  206|       |#endif
  207|       |  /* Set up two quantization tables using default quality of 75 */
  208|  20.8k|  jpeg_set_quality(cinfo, 75, TRUE);
  ------------------
  |  |  210|  20.8k|#define TRUE    1
  ------------------
  209|       |  /* Set up two Huffman tables */
  210|  20.8k|  std_huff_tables((j_common_ptr)cinfo);
  211|       |
  212|       |  /* Initialize default arithmetic coding conditioning */
  213|   354k|  for (i = 0; i < NUM_ARITH_TBLS; i++) {
  ------------------
  |  |   70|   354k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (213:15): [True: 333k, False: 20.8k]
  ------------------
  214|   333k|    cinfo->arith_dc_L[i] = 0;
  215|   333k|    cinfo->arith_dc_U[i] = 1;
  216|   333k|    cinfo->arith_ac_K[i] = 5;
  217|   333k|  }
  218|       |
  219|       |  /* Default is no multiple-scan output */
  220|  20.8k|  cinfo->scan_info = NULL;
  221|  20.8k|  cinfo->num_scans = 0;
  222|       |
  223|       |  /* Default is lossy output */
  224|  20.8k|  cinfo->master->lossless = FALSE;
  ------------------
  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  ------------------
  225|       |
  226|       |  /* Expect normal source image, not raw downsampled data */
  227|  20.8k|  cinfo->raw_data_in = FALSE;
  ------------------
  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  ------------------
  228|       |
  229|       |  /* Use Huffman coding, not arithmetic coding, by default */
  230|  20.8k|  cinfo->arith_code = FALSE;
  ------------------
  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  ------------------
  231|       |
  232|       |  /* By default, don't do extra passes to optimize entropy coding */
  233|  20.8k|  cinfo->optimize_coding = FALSE;
  ------------------
  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  ------------------
  234|       |  /* The standard Huffman tables are only valid for 8-bit data precision.
  235|       |   * If the precision is higher, force optimization on so that usable
  236|       |   * tables will be computed.  This test can be removed if default tables
  237|       |   * are supplied that are valid for the desired precision.
  238|       |   */
  239|  20.8k|  if (cinfo->data_precision == 12)
  ------------------
  |  Branch (239:7): [True: 20.8k, False: 0]
  ------------------
  240|  20.8k|    cinfo->optimize_coding = TRUE;
  ------------------
  |  |  210|  20.8k|#define TRUE    1
  ------------------
  241|       |
  242|       |  /* By default, use the simpler non-cosited sampling alignment */
  243|  20.8k|  cinfo->CCIR601_sampling = FALSE;
  ------------------
  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  ------------------
  244|       |
  245|       |#if JPEG_LIB_VERSION >= 70
  246|       |  /* By default, apply fancy downsampling */
  247|       |  cinfo->do_fancy_downsampling = TRUE;
  248|       |#endif
  249|       |
  250|       |  /* No input smoothing */
  251|  20.8k|  cinfo->smoothing_factor = 0;
  252|       |
  253|       |  /* DCT algorithm preference */
  254|  20.8k|  cinfo->dct_method = JDCT_DEFAULT;
  ------------------
  |  |  301|  20.8k|#define JDCT_DEFAULT  JDCT_ISLOW
  ------------------
  255|       |
  256|       |  /* No restart markers */
  257|  20.8k|  cinfo->restart_interval = 0;
  258|  20.8k|  cinfo->restart_in_rows = 0;
  259|       |
  260|       |  /* Fill in default JFIF marker parameters.  Note that whether the marker
  261|       |   * will actually be written is determined by jpeg_set_colorspace.
  262|       |   *
  263|       |   * By default, the library emits JFIF version code 1.01.
  264|       |   * An application that wants to emit JFIF 1.02 extension markers should set
  265|       |   * JFIF_minor_version to 2.  We could probably get away with just defaulting
  266|       |   * to 1.02, but there may still be some decoders in use that will complain
  267|       |   * about that; saying 1.01 should minimize compatibility problems.
  268|       |   */
  269|  20.8k|  cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */
  270|  20.8k|  cinfo->JFIF_minor_version = 1;
  271|  20.8k|  cinfo->density_unit = 0;      /* Pixel size is unknown by default */
  272|  20.8k|  cinfo->X_density = 1;         /* Pixel aspect ratio is square by default */
  273|  20.8k|  cinfo->Y_density = 1;
  274|       |
  275|       |  /* Choose JPEG colorspace based on input space, set defaults accordingly */
  276|       |
  277|  20.8k|  jpeg_default_colorspace(cinfo);
  278|  20.8k|}
jpeg_default_colorspace:
  287|  20.8k|{
  288|  20.8k|  switch (cinfo->in_color_space) {
  289|  3.58k|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (289:3): [True: 3.58k, False: 17.2k]
  ------------------
  290|  3.58k|    jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
  291|  3.58k|    break;
  292|      0|  case JCS_RGB:
  ------------------
  |  Branch (292:3): [True: 0, False: 20.8k]
  ------------------
  293|  2.95k|  case JCS_EXT_RGB:
  ------------------
  |  Branch (293:3): [True: 2.95k, False: 17.8k]
  ------------------
  294|  5.78k|  case JCS_EXT_RGBX:
  ------------------
  |  Branch (294:3): [True: 2.83k, False: 18.0k]
  ------------------
  295|  8.74k|  case JCS_EXT_BGR:
  ------------------
  |  Branch (295:3): [True: 2.95k, False: 17.8k]
  ------------------
  296|  8.74k|  case JCS_EXT_BGRX:
  ------------------
  |  Branch (296:3): [True: 0, False: 20.8k]
  ------------------
  297|  8.74k|  case JCS_EXT_XBGR:
  ------------------
  |  Branch (297:3): [True: 0, False: 20.8k]
  ------------------
  298|  11.5k|  case JCS_EXT_XRGB:
  ------------------
  |  Branch (298:3): [True: 2.83k, False: 18.0k]
  ------------------
  299|  11.5k|  case JCS_EXT_RGBA:
  ------------------
  |  Branch (299:3): [True: 0, False: 20.8k]
  ------------------
  300|  14.4k|  case JCS_EXT_BGRA:
  ------------------
  |  Branch (300:3): [True: 2.83k, False: 18.0k]
  ------------------
  301|  14.4k|  case JCS_EXT_ABGR:
  ------------------
  |  Branch (301:3): [True: 0, False: 20.8k]
  ------------------
  302|  14.4k|  case JCS_EXT_ARGB:
  ------------------
  |  Branch (302:3): [True: 0, False: 20.8k]
  ------------------
  303|  14.4k|#ifdef C_LOSSLESS_SUPPORTED
  304|  14.4k|    if (cinfo->master->lossless)
  ------------------
  |  Branch (304:9): [True: 0, False: 14.4k]
  ------------------
  305|      0|      jpeg_set_colorspace(cinfo, JCS_RGB);
  306|  14.4k|    else
  307|  14.4k|#endif
  308|  14.4k|      jpeg_set_colorspace(cinfo, JCS_YCbCr);
  309|  14.4k|    break;
  310|      0|  case JCS_YCbCr:
  ------------------
  |  Branch (310:3): [True: 0, False: 20.8k]
  ------------------
  311|      0|    jpeg_set_colorspace(cinfo, JCS_YCbCr);
  312|      0|    break;
  313|  2.83k|  case JCS_CMYK:
  ------------------
  |  Branch (313:3): [True: 2.83k, False: 18.0k]
  ------------------
  314|  2.83k|    jpeg_set_colorspace(cinfo, JCS_CMYK); /* By default, no translation */
  315|  2.83k|    break;
  316|      0|  case JCS_YCCK:
  ------------------
  |  Branch (316:3): [True: 0, False: 20.8k]
  ------------------
  317|      0|    jpeg_set_colorspace(cinfo, JCS_YCCK);
  318|      0|    break;
  319|      0|  case JCS_UNKNOWN:
  ------------------
  |  Branch (319:3): [True: 0, False: 20.8k]
  ------------------
  320|      0|    jpeg_set_colorspace(cinfo, JCS_UNKNOWN);
  321|      0|    break;
  322|      0|  default:
  ------------------
  |  Branch (322:3): [True: 0, False: 20.8k]
  ------------------
  323|      0|    ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  324|  20.8k|  }
  325|  20.8k|}
jpeg_set_colorspace:
  334|  41.6k|{
  335|  41.6k|  jpeg_component_info *compptr;
  336|  41.6k|  int ci;
  337|       |
  338|  41.6k|#define SET_COMP(index, id, hsamp, vsamp, quant, dctbl, actbl) \
  339|  41.6k|  (compptr = &cinfo->comp_info[index], \
  340|  41.6k|   compptr->component_id = (id), \
  341|  41.6k|   compptr->h_samp_factor = (hsamp), \
  342|  41.6k|   compptr->v_samp_factor = (vsamp), \
  343|  41.6k|   compptr->quant_tbl_no = (quant), \
  344|  41.6k|   compptr->dc_tbl_no = (dctbl), \
  345|  41.6k|   compptr->ac_tbl_no = (actbl) )
  346|       |
  347|       |  /* Safety check to ensure start_compress not called yet. */
  348|  41.6k|  if (cinfo->global_state != CSTATE_START)
  ------------------
  |  |   44|  41.6k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (348:7): [True: 0, False: 41.6k]
  ------------------
  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|       |
  351|       |  /* For all colorspaces, we use Q and Huff tables 0 for luminance components,
  352|       |   * tables 1 for chrominance components.
  353|       |   */
  354|       |
  355|  41.6k|  cinfo->jpeg_color_space = colorspace;
  356|       |
  357|  41.6k|  cinfo->write_JFIF_header = FALSE; /* No marker for non-JFIF colorspaces */
  ------------------
  |  |  207|  41.6k|#define FALSE   0               /* values of boolean */
  ------------------
  358|  41.6k|  cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */
  ------------------
  |  |  207|  41.6k|#define FALSE   0               /* values of boolean */
  ------------------
  359|       |
  360|  41.6k|  switch (colorspace) {
  361|  10.0k|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (361:3): [True: 10.0k, False: 31.6k]
  ------------------
  362|  10.0k|    cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
  ------------------
  |  |  210|  10.0k|#define TRUE    1
  ------------------
  363|  10.0k|    cinfo->num_components = 1;
  364|       |    /* JFIF specifies component ID 1 */
  365|  10.0k|    SET_COMP(0, 1, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  10.0k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  10.0k|   compptr->component_id = (id), \
  |  |  341|  10.0k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  10.0k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  10.0k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  10.0k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  10.0k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  366|  10.0k|    break;
  367|  2.83k|  case JCS_RGB:
  ------------------
  |  Branch (367:3): [True: 2.83k, False: 38.8k]
  ------------------
  368|  2.83k|    cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */
  ------------------
  |  |  210|  2.83k|#define TRUE    1
  ------------------
  369|  2.83k|    cinfo->num_components = 3;
  370|  2.83k|    SET_COMP(0, 0x52 /* 'R' */, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  2.83k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.83k|   compptr->component_id = (id), \
  |  |  341|  2.83k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.83k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.83k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.83k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.83k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  371|  2.83k|    SET_COMP(1, 0x47 /* 'G' */, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  2.83k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.83k|   compptr->component_id = (id), \
  |  |  341|  2.83k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.83k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.83k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.83k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.83k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  372|  2.83k|    SET_COMP(2, 0x42 /* 'B' */, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  2.83k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.83k|   compptr->component_id = (id), \
  |  |  341|  2.83k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.83k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.83k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.83k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.83k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  373|  2.83k|    break;
  374|  23.1k|  case JCS_YCbCr:
  ------------------
  |  Branch (374:3): [True: 23.1k, False: 18.5k]
  ------------------
  375|  23.1k|    cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
  ------------------
  |  |  210|  23.1k|#define TRUE    1
  ------------------
  376|  23.1k|    cinfo->num_components = 3;
  377|       |    /* JFIF specifies component IDs 1,2,3 */
  378|       |    /* We default to 2x2 subsamples of chrominance */
  379|  23.1k|    SET_COMP(0, 1, 2, 2, 0, 0, 0);
  ------------------
  |  |  339|  23.1k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  23.1k|   compptr->component_id = (id), \
  |  |  341|  23.1k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  23.1k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  23.1k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  23.1k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  23.1k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  380|  23.1k|    SET_COMP(1, 2, 1, 1, 1, 1, 1);
  ------------------
  |  |  339|  23.1k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  23.1k|   compptr->component_id = (id), \
  |  |  341|  23.1k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  23.1k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  23.1k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  23.1k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  23.1k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  381|  23.1k|    SET_COMP(2, 3, 1, 1, 1, 1, 1);
  ------------------
  |  |  339|  23.1k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  23.1k|   compptr->component_id = (id), \
  |  |  341|  23.1k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  23.1k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  23.1k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  23.1k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  23.1k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  382|  23.1k|    break;
  383|  2.83k|  case JCS_CMYK:
  ------------------
  |  Branch (383:3): [True: 2.83k, False: 38.8k]
  ------------------
  384|  2.83k|    cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */
  ------------------
  |  |  210|  2.83k|#define TRUE    1
  ------------------
  385|  2.83k|    cinfo->num_components = 4;
  386|  2.83k|    SET_COMP(0, 0x43 /* 'C' */, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  2.83k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.83k|   compptr->component_id = (id), \
  |  |  341|  2.83k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.83k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.83k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.83k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.83k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  387|  2.83k|    SET_COMP(1, 0x4D /* 'M' */, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  2.83k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.83k|   compptr->component_id = (id), \
  |  |  341|  2.83k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.83k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.83k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.83k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.83k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  388|  2.83k|    SET_COMP(2, 0x59 /* 'Y' */, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  2.83k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.83k|   compptr->component_id = (id), \
  |  |  341|  2.83k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.83k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.83k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.83k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.83k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  389|  2.83k|    SET_COMP(3, 0x4B /* 'K' */, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  2.83k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.83k|   compptr->component_id = (id), \
  |  |  341|  2.83k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.83k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.83k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.83k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.83k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  390|  2.83k|    break;
  391|  2.83k|  case JCS_YCCK:
  ------------------
  |  Branch (391:3): [True: 2.83k, False: 38.8k]
  ------------------
  392|  2.83k|    cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */
  ------------------
  |  |  210|  2.83k|#define TRUE    1
  ------------------
  393|  2.83k|    cinfo->num_components = 4;
  394|  2.83k|    SET_COMP(0, 1, 2, 2, 0, 0, 0);
  ------------------
  |  |  339|  2.83k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.83k|   compptr->component_id = (id), \
  |  |  341|  2.83k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.83k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.83k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.83k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.83k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  395|  2.83k|    SET_COMP(1, 2, 1, 1, 1, 1, 1);
  ------------------
  |  |  339|  2.83k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.83k|   compptr->component_id = (id), \
  |  |  341|  2.83k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.83k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.83k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.83k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.83k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  396|  2.83k|    SET_COMP(2, 3, 1, 1, 1, 1, 1);
  ------------------
  |  |  339|  2.83k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.83k|   compptr->component_id = (id), \
  |  |  341|  2.83k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.83k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.83k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.83k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.83k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  397|  2.83k|    SET_COMP(3, 4, 2, 2, 0, 0, 0);
  ------------------
  |  |  339|  2.83k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.83k|   compptr->component_id = (id), \
  |  |  341|  2.83k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.83k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.83k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.83k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.83k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  398|  2.83k|    break;
  399|      0|  case JCS_UNKNOWN:
  ------------------
  |  Branch (399:3): [True: 0, False: 41.6k]
  ------------------
  400|      0|    cinfo->num_components = cinfo->input_components;
  401|      0|    if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS)
  ------------------
  |  |   30|      0|#define MAX_COMPONENTS  10      /* maximum number of image components */
  ------------------
  |  Branch (401:9): [True: 0, False: 0]
  |  Branch (401:38): [True: 0, False: 0]
  ------------------
  402|      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)))
  ------------------
  403|      0|               MAX_COMPONENTS);
  404|      0|    for (ci = 0; ci < cinfo->num_components; ci++) {
  ------------------
  |  Branch (404:18): [True: 0, False: 0]
  ------------------
  405|      0|      SET_COMP(ci, ci, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|      0|  (compptr = &cinfo->comp_info[index], \
  |  |  340|      0|   compptr->component_id = (id), \
  |  |  341|      0|   compptr->h_samp_factor = (hsamp), \
  |  |  342|      0|   compptr->v_samp_factor = (vsamp), \
  |  |  343|      0|   compptr->quant_tbl_no = (quant), \
  |  |  344|      0|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|      0|   compptr->ac_tbl_no = (actbl) )
  ------------------
  406|      0|    }
  407|      0|    break;
  408|      0|  default:
  ------------------
  |  Branch (408:3): [True: 0, False: 41.6k]
  ------------------
  409|      0|    ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  410|  41.6k|  }
  411|  41.6k|}
jpeg_simple_progression:
  478|  6.42k|{
  479|  6.42k|  int ncomps = cinfo->num_components;
  480|  6.42k|  int nscans;
  481|  6.42k|  jpeg_scan_info *scanptr;
  482|       |
  483|       |  /* Safety check to ensure start_compress not called yet. */
  484|  6.42k|  if (cinfo->global_state != CSTATE_START)
  ------------------
  |  |   44|  6.42k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (484:7): [True: 0, False: 6.42k]
  ------------------
  485|      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)))
  ------------------
  486|       |
  487|  6.42k|#ifdef C_LOSSLESS_SUPPORTED
  488|  6.42k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (488:7): [True: 0, False: 6.42k]
  ------------------
  489|      0|    cinfo->master->lossless = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  490|      0|    jpeg_default_colorspace(cinfo);
  491|      0|  }
  492|  6.42k|#endif
  493|       |
  494|       |  /* Figure space needed for script.  Calculation must match code below! */
  495|  6.42k|  if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
  ------------------
  |  Branch (495:7): [True: 0, False: 6.42k]
  |  Branch (495:22): [True: 0, False: 0]
  ------------------
  496|       |    /* Custom script for YCbCr color images. */
  497|      0|    nscans = 10;
  498|  6.42k|  } else {
  499|       |    /* All-purpose script for other color spaces. */
  500|  6.42k|    if (ncomps > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  6.42k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (500:9): [True: 0, False: 6.42k]
  ------------------
  501|      0|      nscans = 6 * ncomps;      /* 2 DC + 4 AC scans per component */
  502|  6.42k|    else
  503|  6.42k|      nscans = 2 + 4 * ncomps;  /* 2 DC scans; 4 AC scans per component */
  504|  6.42k|  }
  505|       |
  506|       |  /* Allocate space for script.
  507|       |   * We need to put it in the permanent pool in case the application performs
  508|       |   * multiple compressions without changing the settings.  To avoid a memory
  509|       |   * leak if jpeg_simple_progression is called repeatedly for the same JPEG
  510|       |   * object, we try to re-use previously allocated space, and we allocate
  511|       |   * enough space to handle YCbCr even if initially asked for grayscale.
  512|       |   */
  513|  6.42k|  if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) {
  ------------------
  |  Branch (513:7): [True: 3.77k, False: 2.65k]
  |  Branch (513:38): [True: 2.65k, False: 0]
  ------------------
  514|  6.42k|    cinfo->script_space_size = MAX(nscans, 10);
  ------------------
  |  |  513|  6.42k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 2.83k, False: 3.58k]
  |  |  ------------------
  ------------------
  515|  6.42k|    cinfo->script_space = (jpeg_scan_info *)
  516|  6.42k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  6.42k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  517|  6.42k|                        cinfo->script_space_size * sizeof(jpeg_scan_info));
  518|  6.42k|  }
  519|  6.42k|  scanptr = cinfo->script_space;
  520|  6.42k|  cinfo->scan_info = scanptr;
  521|  6.42k|  cinfo->num_scans = nscans;
  522|       |
  523|  6.42k|  if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
  ------------------
  |  Branch (523:7): [True: 0, False: 6.42k]
  |  Branch (523:22): [True: 0, False: 0]
  ------------------
  524|       |    /* Custom script for YCbCr color images. */
  525|       |    /* Initial DC scan */
  526|      0|    scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
  527|       |    /* Initial AC scan: get some luma data out in a hurry */
  528|      0|    scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2);
  529|       |    /* Chroma data is too small to be worth expending many scans on */
  530|      0|    scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1);
  531|      0|    scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1);
  532|       |    /* Complete spectral selection for luma AC */
  533|      0|    scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2);
  534|       |    /* Refine next bit of luma AC */
  535|      0|    scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1);
  536|       |    /* Finish DC successive approximation */
  537|      0|    scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
  538|       |    /* Finish AC successive approximation */
  539|      0|    scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0);
  540|      0|    scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0);
  541|       |    /* Luma bottom bit comes last since it's usually largest scan */
  542|      0|    scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0);
  543|  6.42k|  } else {
  544|       |    /* All-purpose script for other color spaces. */
  545|       |    /* Successive approximation first pass */
  546|  6.42k|    scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
  547|  6.42k|    scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2);
  548|  6.42k|    scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2);
  549|       |    /* Successive approximation second pass */
  550|  6.42k|    scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1);
  551|       |    /* Successive approximation final pass */
  552|  6.42k|    scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
  553|  6.42k|    scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
  554|  6.42k|  }
  555|  6.42k|}
jcparam.c:fill_dc_scans:
  451|  12.8k|{
  452|  12.8k|  int ci;
  453|       |
  454|  12.8k|  if (ncomps <= MAX_COMPS_IN_SCAN) {
  ------------------
  |  |   71|  12.8k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (454:7): [True: 12.8k, False: 0]
  ------------------
  455|       |    /* Single interleaved DC scan */
  456|  12.8k|    scanptr->comps_in_scan = ncomps;
  457|  42.7k|    for (ci = 0; ci < ncomps; ci++)
  ------------------
  |  Branch (457:18): [True: 29.8k, False: 12.8k]
  ------------------
  458|  29.8k|      scanptr->component_index[ci] = ci;
  459|  12.8k|    scanptr->Ss = scanptr->Se = 0;
  460|  12.8k|    scanptr->Ah = Ah;
  461|  12.8k|    scanptr->Al = Al;
  462|  12.8k|    scanptr++;
  463|  12.8k|  } else {
  464|       |    /* Noninterleaved DC scan for each component */
  465|      0|    scanptr = fill_scans(scanptr, ncomps, 0, 0, Ah, Al);
  466|      0|  }
  467|  12.8k|  return scanptr;
  468|  12.8k|}
jcparam.c:fill_scans:
  433|  25.7k|{
  434|  25.7k|  int ci;
  435|       |
  436|  85.4k|  for (ci = 0; ci < ncomps; ci++) {
  ------------------
  |  Branch (436:16): [True: 59.7k, False: 25.7k]
  ------------------
  437|  59.7k|    scanptr->comps_in_scan = 1;
  438|  59.7k|    scanptr->component_index[0] = ci;
  439|  59.7k|    scanptr->Ss = Ss;
  440|  59.7k|    scanptr->Se = Se;
  441|  59.7k|    scanptr->Ah = Ah;
  442|  59.7k|    scanptr->Al = Al;
  443|  59.7k|    scanptr++;
  444|  59.7k|  }
  445|  25.7k|  return scanptr;
  446|  25.7k|}

jinit_phuff_encoder:
 1081|  3.58k|{
 1082|  3.58k|  phuff_entropy_ptr entropy;
 1083|  3.58k|  int i;
 1084|       |
 1085|  3.58k|  entropy = (phuff_entropy_ptr)
 1086|  3.58k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  3.58k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
 1087|  3.58k|                                sizeof(phuff_entropy_encoder));
 1088|  3.58k|  cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
 1089|  3.58k|  entropy->pub.start_pass = start_pass_phuff;
 1090|       |
 1091|       |  /* Mark tables unallocated */
 1092|  17.9k|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|  17.9k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (1092:15): [True: 14.3k, False: 3.58k]
  ------------------
 1093|  14.3k|    entropy->derived_tbls[i] = NULL;
 1094|  14.3k|    entropy->count_ptrs[i] = NULL;
 1095|  14.3k|  }
 1096|       |  entropy->bit_buffer = NULL;   /* needed only in AC refinement scan */
 1097|  3.58k|}
jcphuff.c:start_pass_phuff:
  179|  39.4k|{
  180|  39.4k|  phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
  181|  39.4k|  boolean is_DC_band;
  182|  39.4k|  int ci, tbl;
  183|  39.4k|  jpeg_component_info *compptr;
  184|       |
  185|  39.4k|  entropy->cinfo = cinfo;
  186|  39.4k|  entropy->gather_statistics = gather_statistics;
  187|       |
  188|  39.4k|  is_DC_band = (cinfo->Ss == 0);
  189|       |
  190|       |  /* We assume jcmaster.c already validated the scan parameters. */
  191|       |
  192|       |  /* Select execution routines */
  193|  39.4k|  if (cinfo->Ah == 0) {
  ------------------
  |  Branch (193:7): [True: 21.5k, False: 17.9k]
  ------------------
  194|  21.5k|    if (is_DC_band)
  ------------------
  |  Branch (194:9): [True: 7.17k, False: 14.3k]
  ------------------
  195|  7.17k|      entropy->pub.encode_mcu = encode_mcu_DC_first;
  196|  14.3k|    else
  197|  14.3k|      entropy->pub.encode_mcu = encode_mcu_AC_first;
  198|  21.5k|#ifdef WITH_SIMD
  199|  21.5k|    if (!jsimd_set_encode_mcu_AC_first_prepare(cinfo,
  ------------------
  |  Branch (199:9): [True: 0, False: 21.5k]
  ------------------
  200|  21.5k|                                               &entropy->AC_first_prepare))
  201|      0|#endif
  202|      0|      entropy->AC_first_prepare = encode_mcu_AC_first_prepare;
  203|  21.5k|  } else {
  204|  17.9k|    if (is_DC_band)
  ------------------
  |  Branch (204:9): [True: 3.58k, False: 14.3k]
  ------------------
  205|  3.58k|      entropy->pub.encode_mcu = encode_mcu_DC_refine;
  206|  14.3k|    else {
  207|  14.3k|      entropy->pub.encode_mcu = encode_mcu_AC_refine;
  208|  14.3k|#ifdef WITH_SIMD
  209|  14.3k|      if (!jsimd_set_encode_mcu_AC_refine_prepare(cinfo,
  ------------------
  |  Branch (209:11): [True: 0, False: 14.3k]
  ------------------
  210|  14.3k|                                                  &entropy->AC_refine_prepare))
  211|      0|#endif
  212|      0|        entropy->AC_refine_prepare = encode_mcu_AC_refine_prepare;
  213|       |      /* AC refinement needs a correction bit buffer */
  214|  14.3k|      if (entropy->bit_buffer == NULL)
  ------------------
  |  Branch (214:11): [True: 3.58k, False: 10.7k]
  ------------------
  215|  3.58k|        entropy->bit_buffer = (char *)
  216|  3.58k|          (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  3.58k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  217|  3.58k|                                      MAX_CORR_BITS);
  ------------------
  |  |  106|  3.58k|#define MAX_CORR_BITS  1000     /* Max # of correction bits I can buffer */
  ------------------
  218|  14.3k|    }
  219|  17.9k|  }
  220|  39.4k|  if (gather_statistics)
  ------------------
  |  Branch (220:7): [True: 17.9k, False: 21.5k]
  ------------------
  221|  17.9k|    entropy->pub.finish_pass = finish_pass_gather_phuff;
  222|  21.5k|  else
  223|  21.5k|    entropy->pub.finish_pass = finish_pass_phuff;
  224|       |
  225|       |  /* Only DC coefficients may be interleaved, so cinfo->comps_in_scan = 1
  226|       |   * for AC coefficients.
  227|       |   */
  228|  78.9k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (228:16): [True: 39.4k, False: 39.4k]
  ------------------
  229|  39.4k|    compptr = cinfo->cur_comp_info[ci];
  230|       |    /* Initialize DC predictions to 0 */
  231|  39.4k|    entropy->last_dc_val[ci] = 0;
  232|       |    /* Get table index */
  233|  39.4k|    if (is_DC_band) {
  ------------------
  |  Branch (233:9): [True: 10.7k, False: 28.7k]
  ------------------
  234|  10.7k|      if (cinfo->Ah != 0)       /* DC refinement needs no table */
  ------------------
  |  Branch (234:11): [True: 3.58k, False: 7.17k]
  ------------------
  235|  3.58k|        continue;
  236|  7.17k|      tbl = compptr->dc_tbl_no;
  237|  28.7k|    } else {
  238|  28.7k|      entropy->ac_tbl_no = tbl = compptr->ac_tbl_no;
  239|  28.7k|    }
  240|  35.8k|    if (gather_statistics) {
  ------------------
  |  Branch (240:9): [True: 17.9k, False: 17.9k]
  ------------------
  241|       |      /* Check for invalid table index */
  242|       |      /* (make_c_derived_tbl does this in the other path) */
  243|  17.9k|      if (tbl < 0 || tbl >= NUM_HUFF_TBLS)
  ------------------
  |  |   69|  17.9k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (243:11): [True: 0, False: 17.9k]
  |  Branch (243:22): [True: 0, False: 17.9k]
  ------------------
  244|      0|        ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
  ------------------
  |  |  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)))
  ------------------
  245|       |      /* Allocate and zero the statistics tables */
  246|       |      /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
  247|  17.9k|      if (entropy->count_ptrs[tbl] == NULL)
  ------------------
  |  Branch (247:11): [True: 3.58k, False: 14.3k]
  ------------------
  248|  3.58k|        entropy->count_ptrs[tbl] = (long *)
  249|  3.58k|          (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  3.58k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  250|  3.58k|                                      257 * sizeof(long));
  251|  17.9k|      memset(entropy->count_ptrs[tbl], 0, 257 * sizeof(long));
  252|  17.9k|    } else {
  253|       |      /* Compute derived values for Huffman table */
  254|       |      /* We may do this more than once for a table, but it's not expensive */
  255|  17.9k|      jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl,
  256|  17.9k|                              &entropy->derived_tbls[tbl]);
  257|  17.9k|    }
  258|  35.8k|  }
  259|       |
  260|       |  /* Initialize AC stuff */
  261|  39.4k|  entropy->EOBRUN = 0;
  262|  39.4k|  entropy->BE = 0;
  263|       |
  264|       |  /* Initialize bit buffer to empty */
  265|  39.4k|  entropy->put_buffer = 0;
  266|  39.4k|  entropy->put_bits = 0;
  267|       |
  268|       |  /* Initialize restart stuff */
  269|  39.4k|  entropy->restarts_to_go = cinfo->restart_interval;
  270|  39.4k|  entropy->next_restart_num = 0;
  271|  39.4k|}
jcphuff.c:encode_mcu_DC_first:
  457|  2.30M|{
  458|  2.30M|  phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
  459|  2.30M|  register int temp, temp2, temp3;
  460|  2.30M|  register int nbits;
  461|  2.30M|  int blkn, ci;
  462|  2.30M|  int Al = cinfo->Al;
  463|  2.30M|  JBLOCKROW block;
  464|  2.30M|  jpeg_component_info *compptr;
  465|  2.30M|  ISHIFT_TEMPS
  466|  2.30M|  int max_coef_bits = cinfo->data_precision + 2;
  467|       |
  468|  2.30M|  entropy->next_output_byte = cinfo->dest->next_output_byte;
  469|  2.30M|  entropy->free_in_buffer = cinfo->dest->free_in_buffer;
  470|       |
  471|       |  /* Emit restart marker if needed */
  472|  2.30M|  if (cinfo->restart_interval)
  ------------------
  |  Branch (472:7): [True: 0, False: 2.30M]
  ------------------
  473|      0|    if (entropy->restarts_to_go == 0)
  ------------------
  |  Branch (473:9): [True: 0, False: 0]
  ------------------
  474|      0|      emit_restart(entropy, entropy->next_restart_num);
  475|       |
  476|       |  /* Encode the MCU data blocks */
  477|  4.60M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (477:18): [True: 2.30M, False: 2.30M]
  ------------------
  478|  2.30M|    block = MCU_data[blkn];
  479|  2.30M|    ci = cinfo->MCU_membership[blkn];
  480|  2.30M|    compptr = cinfo->cur_comp_info[ci];
  481|       |
  482|       |    /* Compute the DC value after the required point transform by Al.
  483|       |     * This is simply an arithmetic right shift.
  484|       |     */
  485|  2.30M|    temp2 = IRIGHT_SHIFT((int)((*block)[0]), Al);
  ------------------
  |  |  121|  2.30M|#define IRIGHT_SHIFT(x, shft)   ((x) >> (shft))
  ------------------
  486|       |
  487|       |    /* DC differences are figured on the point-transformed values. */
  488|  2.30M|    temp = temp2 - entropy->last_dc_val[ci];
  489|  2.30M|    entropy->last_dc_val[ci] = temp2;
  490|       |
  491|       |    /* Encode the DC coefficient difference per section G.1.2.1 */
  492|       |
  493|       |    /* This is a well-known technique for obtaining the absolute value without
  494|       |     * a branch.  It is derived from an assembly language technique presented
  495|       |     * in "How to Optimize for the Pentium Processors", Copyright (c) 1996,
  496|       |     * 1997 by Agner Fog.
  497|       |     */
  498|  2.30M|    temp3 = temp >> (CHAR_BIT * sizeof(int) - 1);
  499|  2.30M|    temp ^= temp3;
  500|  2.30M|    temp -= temp3;              /* temp is abs value of input */
  501|       |    /* For a negative input, want temp2 = bitwise complement of abs(input) */
  502|  2.30M|    temp2 = temp ^ temp3;
  503|       |
  504|       |    /* Find the number of bits needed for the magnitude of the coefficient */
  505|  2.30M|    nbits = JPEG_NBITS(temp);
  ------------------
  |  |   41|  2.30M|#define JPEG_NBITS(x)          (jpeg_nbits_table[x])
  ------------------
  506|       |    /* Check for out-of-range coefficient values.
  507|       |     * Since we're encoding a difference, the range limit is twice as much.
  508|       |     */
  509|  2.30M|    if (nbits > max_coef_bits + 1)
  ------------------
  |  Branch (509:9): [True: 0, False: 2.30M]
  ------------------
  510|      0|      ERREXIT(cinfo, JERR_BAD_DCT_COEF);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  511|       |
  512|       |    /* Count/emit the Huffman-coded symbol for the number of bits */
  513|  2.30M|    emit_symbol(entropy, compptr->dc_tbl_no, nbits);
  514|       |
  515|       |    /* Emit that number of bits of the value, if positive, */
  516|       |    /* or the complement of its magnitude, if negative. */
  517|  2.30M|    if (nbits)                  /* emit_bits rejects calls with size 0 */
  ------------------
  |  Branch (517:9): [True: 1.15M, False: 1.14M]
  ------------------
  518|  1.15M|      emit_bits(entropy, (unsigned int)temp2, nbits);
  519|  2.30M|  }
  520|       |
  521|  2.30M|  cinfo->dest->next_output_byte = entropy->next_output_byte;
  522|  2.30M|  cinfo->dest->free_in_buffer = entropy->free_in_buffer;
  523|       |
  524|       |  /* Update restart-interval state too */
  525|  2.30M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (525:7): [True: 0, False: 2.30M]
  ------------------
  526|      0|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (526:9): [True: 0, False: 0]
  ------------------
  527|      0|      entropy->restarts_to_go = cinfo->restart_interval;
  528|      0|      entropy->next_restart_num++;
  529|      0|      entropy->next_restart_num &= 7;
  530|      0|    }
  531|      0|    entropy->restarts_to_go--;
  532|      0|  }
  533|       |
  534|  2.30M|  return TRUE;
  ------------------
  |  |  210|  2.30M|#define TRUE    1
  ------------------
  535|  2.30M|}
jcphuff.c:emit_eobrun:
  398|  22.8M|{
  399|  22.8M|  register int temp, nbits;
  400|       |
  401|  22.8M|  if (entropy->EOBRUN > 0) {    /* if there is any pending EOBRUN */
  ------------------
  |  Branch (401:7): [True: 2.86M, False: 19.9M]
  ------------------
  402|  2.86M|    temp = entropy->EOBRUN;
  403|  2.86M|    nbits = JPEG_NBITS_NONZERO(temp) - 1;
  ------------------
  |  |   42|  2.86M|#define JPEG_NBITS_NONZERO(x)  JPEG_NBITS(x)
  |  |  ------------------
  |  |  |  |   41|  2.86M|#define JPEG_NBITS(x)          (jpeg_nbits_table[x])
  |  |  ------------------
  ------------------
  404|       |    /* safety check: shouldn't happen given limited correction-bit buffer */
  405|  2.86M|    if (nbits > 14)
  ------------------
  |  Branch (405:9): [True: 0, False: 2.86M]
  ------------------
  406|      0|      ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  407|       |
  408|  2.86M|    emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4);
  409|  2.86M|    if (nbits)
  ------------------
  |  Branch (409:9): [True: 396k, False: 2.46M]
  ------------------
  410|   396k|      emit_bits(entropy, entropy->EOBRUN, nbits);
  411|       |
  412|  2.86M|    entropy->EOBRUN = 0;
  413|       |
  414|       |    /* Emit any buffered correction bits */
  415|  2.86M|    emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE);
  416|  2.86M|    entropy->BE = 0;
  417|  2.86M|  }
  418|  22.8M|}
jcphuff.c:emit_buffered_bits:
  380|  24.2M|{
  381|  24.2M|  if (entropy->gather_statistics)
  ------------------
  |  Branch (381:7): [True: 12.1M, False: 12.1M]
  ------------------
  382|  12.1M|    return;                     /* no real work */
  383|       |
  384|  37.4M|  while (nbits > 0) {
  ------------------
  |  Branch (384:10): [True: 25.2M, False: 12.1M]
  ------------------
  385|  25.2M|    emit_bits(entropy, (unsigned int)(*bufstart), 1);
  386|  25.2M|    bufstart++;
  387|  25.2M|    nbits--;
  388|  25.2M|  }
  389|  12.1M|}
jcphuff.c:flush_bits:
  350|  21.5k|{
  351|  21.5k|  emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */
  352|  21.5k|  entropy->put_buffer = 0;     /* and reset bit-buffer to empty */
  353|  21.5k|  entropy->put_bits = 0;
  354|  21.5k|}
jcphuff.c:dump_buffer:
  290|    638|{
  291|    638|  struct jpeg_destination_mgr *dest = entropy->cinfo->dest;
  292|       |
  293|    638|  if (!(*dest->empty_output_buffer) (entropy->cinfo))
  ------------------
  |  Branch (293:7): [True: 0, False: 638]
  ------------------
  294|      0|    ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  295|       |  /* After a successful buffer dump, must reset buffer pointers */
  296|    638|  entropy->next_output_byte = dest->next_output_byte;
  297|    638|  entropy->free_in_buffer = dest->free_in_buffer;
  298|    638|}
jcphuff.c:emit_symbol:
  363|  46.3M|{
  364|  46.3M|  if (entropy->gather_statistics)
  ------------------
  |  Branch (364:7): [True: 23.1M, False: 23.1M]
  ------------------
  365|  23.1M|    entropy->count_ptrs[tbl_no][symbol]++;
  366|  23.1M|  else {
  367|  23.1M|    c_derived_tbl *tbl = entropy->derived_tbls[tbl_no];
  368|  23.1M|    emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]);
  369|  23.1M|  }
  370|  46.3M|}
jcphuff.c:emit_bits:
  312|  92.2M|{
  313|       |  /* This routine is heavily used, so it's worth coding tightly. */
  314|  92.2M|  register size_t put_buffer = (size_t)code;
  315|  92.2M|  register int put_bits = entropy->put_bits;
  316|       |
  317|       |  /* if size is 0, caller used an invalid Huffman table entry */
  318|  92.2M|  if (size == 0)
  ------------------
  |  Branch (318:7): [True: 0, False: 92.2M]
  ------------------
  319|      0|    ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  320|       |
  321|  92.2M|  if (entropy->gather_statistics)
  ------------------
  |  Branch (321:7): [True: 21.2M, False: 70.9M]
  ------------------
  322|  21.2M|    return;                     /* do nothing if we're only getting stats */
  323|       |
  324|  70.9M|  put_buffer &= (((size_t)1) << size) - 1; /* mask off any extra bits in code */
  325|       |
  326|  70.9M|  put_bits += size;             /* new number of bits in buffer */
  327|       |
  328|  70.9M|  put_buffer <<= 24 - put_bits; /* align incoming bits */
  329|       |
  330|  70.9M|  put_buffer |= entropy->put_buffer; /* and merge with old buffer contents */
  331|       |
  332|  86.5M|  while (put_bits >= 8) {
  ------------------
  |  Branch (332:10): [True: 15.5M, False: 70.9M]
  ------------------
  333|  15.5M|    int c = (int)((put_buffer >> 16) & 0xFF);
  334|       |
  335|  15.5M|    emit_byte(entropy, c);
  ------------------
  |  |  280|  15.5M|#define emit_byte(entropy, val) { \
  |  |  281|  15.5M|  *(entropy)->next_output_byte++ = (JOCTET)(val); \
  |  |  282|  15.5M|  if (--(entropy)->free_in_buffer == 0) \
  |  |  ------------------
  |  |  |  Branch (282:7): [True: 630, False: 15.5M]
  |  |  ------------------
  |  |  283|  15.5M|    dump_buffer(entropy); \
  |  |  284|  15.5M|}
  ------------------
  336|  15.5M|    if (c == 0xFF) {            /* need to stuff a zero byte? */
  ------------------
  |  Branch (336:9): [True: 105k, False: 15.4M]
  ------------------
  337|   105k|      emit_byte(entropy, 0);
  ------------------
  |  |  280|   105k|#define emit_byte(entropy, val) { \
  |  |  281|   105k|  *(entropy)->next_output_byte++ = (JOCTET)(val); \
  |  |  282|   105k|  if (--(entropy)->free_in_buffer == 0) \
  |  |  ------------------
  |  |  |  Branch (282:7): [True: 8, False: 105k]
  |  |  ------------------
  |  |  283|   105k|    dump_buffer(entropy); \
  |  |  284|   105k|}
  ------------------
  338|   105k|    }
  339|  15.5M|    put_buffer <<= 8;
  340|  15.5M|    put_bits -= 8;
  341|  15.5M|  }
  342|       |
  343|  70.9M|  entropy->put_buffer = put_buffer; /* update variables */
  344|  70.9M|  entropy->put_bits = put_bits;
  345|  70.9M|}
jcphuff.c:encode_mcu_AC_first:
  637|  4.60M|{
  638|  4.60M|  phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
  639|  4.60M|  register int temp, temp2;
  640|  4.60M|  register int nbits, r;
  641|  4.60M|  int Sl = cinfo->Se - cinfo->Ss + 1;
  642|  4.60M|  int Al = cinfo->Al;
  643|  4.60M|  UJCOEF values_unaligned[2 * DCTSIZE2 + 15];
  644|  4.60M|  UJCOEF *values;
  645|  4.60M|  const UJCOEF *cvalue;
  646|  4.60M|  size_t zerobits;
  647|  4.60M|  size_t bits[8 / SIZEOF_SIZE_T];
  648|  4.60M|  int max_coef_bits = cinfo->data_precision + 2;
  649|       |
  650|       |#ifdef ZERO_BUFFERS
  651|       |  memset(values_unaligned, 0, sizeof(values_unaligned));
  652|       |  memset(bits, 0, sizeof(bits));
  653|       |#endif
  654|       |
  655|  4.60M|  entropy->next_output_byte = cinfo->dest->next_output_byte;
  656|  4.60M|  entropy->free_in_buffer = cinfo->dest->free_in_buffer;
  657|       |
  658|       |  /* Emit restart marker if needed */
  659|  4.60M|  if (cinfo->restart_interval)
  ------------------
  |  Branch (659:7): [True: 0, False: 4.60M]
  ------------------
  660|      0|    if (entropy->restarts_to_go == 0)
  ------------------
  |  Branch (660:9): [True: 0, False: 0]
  ------------------
  661|      0|      emit_restart(entropy, entropy->next_restart_num);
  662|       |
  663|  4.60M|#ifdef WITH_SIMD
  664|  4.60M|  cvalue = values = (UJCOEF *)PAD((JUINTPTR)values_unaligned, 16);
  ------------------
  |  |  124|  4.60M|#define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
  ------------------
  665|       |#else
  666|       |  /* Not using SIMD, so alignment is not needed */
  667|       |  cvalue = values = values_unaligned;
  668|       |#endif
  669|       |
  670|       |  /* Prepare data */
  671|  4.60M|  entropy->AC_first_prepare(MCU_data[0][0], jpeg_natural_order + cinfo->Ss,
  672|  4.60M|                            Sl, Al, values, bits);
  673|       |
  674|  4.60M|  zerobits = bits[0];
  675|       |#if SIZEOF_SIZE_T == 4
  676|       |  zerobits |= bits[1];
  677|       |#endif
  678|       |
  679|       |  /* Emit any pending EOBRUN */
  680|  4.60M|  if (zerobits && (entropy->EOBRUN > 0))
  ------------------
  |  Branch (680:7): [True: 2.27M, False: 2.32M]
  |  Branch (680:19): [True: 1.43M, False: 846k]
  ------------------
  681|  1.43M|    emit_eobrun(entropy);
  682|       |
  683|       |#if SIZEOF_SIZE_T == 4
  684|       |  zerobits = bits[0];
  685|       |#endif
  686|       |
  687|       |  /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */
  688|       |
  689|  4.60M|  ENCODE_COEFS_AC_FIRST((void)0;);
  ------------------
  |  |  603|  4.60M|#define ENCODE_COEFS_AC_FIRST(label) { \
  |  |  604|  24.4M|  while (zerobits) { \
  |  |  ------------------
  |  |  |  Branch (604:10): [True: 19.8M, False: 4.60M]
  |  |  ------------------
  |  |  605|  19.8M|    r = count_zeroes(&zerobits); \
  |  |  606|  19.8M|    cvalue += r; \
  |  |  607|  19.8M|label \
  |  |  608|  19.8M|    temp  = cvalue[0]; \
  |  |  609|  19.8M|    temp2 = cvalue[DCTSIZE2]; \
  |  |  ------------------
  |  |  |  |   67|  19.8M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  |  |  ------------------
  |  |  610|  19.8M|    \
  |  |  611|  19.8M|    /* if run length > 15, must emit special run-length-16 codes (0xF0) */ \
  |  |  612|  19.8M|    while (r > 15) { \
  |  |  ------------------
  |  |  |  Branch (612:12): [True: 24.1k, False: 19.8M]
  |  |  ------------------
  |  |  613|  24.1k|      emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); \
  |  |  614|  24.1k|      r -= 16; \
  |  |  615|  24.1k|    } \
  |  |  616|  19.8M|    \
  |  |  617|  19.8M|    /* Find the number of bits needed for the magnitude of the coefficient */ \
  |  |  618|  19.8M|    nbits = JPEG_NBITS_NONZERO(temp);  /* there must be at least one 1 bit */ \
  |  |  ------------------
  |  |  |  |   42|  19.8M|#define JPEG_NBITS_NONZERO(x)  JPEG_NBITS(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  19.8M|#define JPEG_NBITS(x)          (jpeg_nbits_table[x])
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  619|  19.8M|    /* Check for out-of-range coefficient values */ \
  |  |  620|  19.8M|    if (nbits > max_coef_bits) \
  |  |  ------------------
  |  |  |  Branch (620:9): [True: 0, False: 19.8M]
  |  |  ------------------
  |  |  621|  19.8M|      ERREXIT(cinfo, JERR_BAD_DCT_COEF); \
  |  |  ------------------
  |  |  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  |  |  ------------------
  |  |  622|  19.8M|    \
  |  |  623|  19.8M|    /* Count/emit Huffman symbol for run length / number of bits */ \
  |  |  624|  19.8M|    emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); \
  |  |  625|  19.8M|    \
  |  |  626|  19.8M|    /* Emit that number of bits of the value, if positive, */ \
  |  |  627|  19.8M|    /* or the complement of its magnitude, if negative. */ \
  |  |  628|  19.8M|    emit_bits(entropy, (unsigned int)temp2, nbits); \
  |  |  629|  19.8M|    \
  |  |  630|  19.8M|    cvalue++; \
  |  |  631|  19.8M|    zerobits >>= 1; \
  |  |  632|  19.8M|  } \
  |  |  633|  4.60M|}
  ------------------
  690|       |
  691|       |#if SIZEOF_SIZE_T == 4
  692|       |  zerobits = bits[1];
  693|       |  if (zerobits) {
  694|       |    int diff = ((values + DCTSIZE2 / 2) - cvalue);
  695|       |    r = count_zeroes(&zerobits);
  696|       |    r += diff;
  697|       |    cvalue += r;
  698|       |    goto first_iter_ac_first;
  699|       |  }
  700|       |
  701|       |  ENCODE_COEFS_AC_FIRST(first_iter_ac_first:);
  702|       |#endif
  703|       |
  704|  4.60M|  if (cvalue < (values + Sl)) { /* If there are trailing zeroes, */
  ------------------
  |  Branch (704:7): [True: 3.71M, False: 885k]
  ------------------
  705|  3.71M|    entropy->EOBRUN++;          /* count an EOB */
  706|  3.71M|    if (entropy->EOBRUN == 0x7FFF)
  ------------------
  |  Branch (706:9): [True: 0, False: 3.71M]
  ------------------
  707|      0|      emit_eobrun(entropy);     /* force it out to avoid overflow */
  708|  3.71M|  }
  709|       |
  710|  4.60M|  cinfo->dest->next_output_byte = entropy->next_output_byte;
  711|  4.60M|  cinfo->dest->free_in_buffer = entropy->free_in_buffer;
  712|       |
  713|       |  /* Update restart-interval state too */
  714|  4.60M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (714:7): [True: 0, False: 4.60M]
  ------------------
  715|      0|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (715:9): [True: 0, False: 0]
  ------------------
  716|      0|      entropy->restarts_to_go = cinfo->restart_interval;
  717|      0|      entropy->next_restart_num++;
  718|      0|      entropy->next_restart_num &= 7;
  719|      0|    }
  720|      0|    entropy->restarts_to_go--;
  721|      0|  }
  722|       |
  723|  4.60M|  return TRUE;
  ------------------
  |  |  210|  4.60M|#define TRUE    1
  ------------------
  724|  4.60M|}
jcphuff.c:count_zeroes:
  149|  91.5M|{
  150|  91.5M|#if defined(HAVE_BUILTIN_CTZL)
  151|  91.5M|  int result;
  152|  91.5M|  result = __builtin_ctzl(*x);
  153|  91.5M|  *x >>= result;
  154|       |#elif defined(HAVE_BITSCANFORWARD64)
  155|       |  unsigned long result;
  156|       |  _BitScanForward64(&result, *x);
  157|       |  *x >>= result;
  158|       |#elif defined(HAVE_BITSCANFORWARD)
  159|       |  unsigned long result;
  160|       |  _BitScanForward(&result, *x);
  161|       |  *x >>= result;
  162|       |#else
  163|       |  int result = 0;
  164|       |  while ((*x & 1) == 0) {
  165|       |    ++result;
  166|       |    *x >>= 1;
  167|       |  }
  168|       |#endif
  169|  91.5M|  return (int)result;
  170|  91.5M|}
jcphuff.c:encode_mcu_DC_refine:
  735|  1.15M|{
  736|  1.15M|  phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
  737|  1.15M|  register int temp;
  738|  1.15M|  int blkn;
  739|  1.15M|  int Al = cinfo->Al;
  740|  1.15M|  JBLOCKROW block;
  741|       |
  742|  1.15M|  entropy->next_output_byte = cinfo->dest->next_output_byte;
  743|  1.15M|  entropy->free_in_buffer = cinfo->dest->free_in_buffer;
  744|       |
  745|       |  /* Emit restart marker if needed */
  746|  1.15M|  if (cinfo->restart_interval)
  ------------------
  |  Branch (746:7): [True: 0, False: 1.15M]
  ------------------
  747|      0|    if (entropy->restarts_to_go == 0)
  ------------------
  |  Branch (747:9): [True: 0, False: 0]
  ------------------
  748|      0|      emit_restart(entropy, entropy->next_restart_num);
  749|       |
  750|       |  /* Encode the MCU data blocks */
  751|  2.30M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (751:18): [True: 1.15M, False: 1.15M]
  ------------------
  752|  1.15M|    block = MCU_data[blkn];
  753|       |
  754|       |    /* We simply emit the Al'th bit of the DC coefficient value. */
  755|  1.15M|    temp = (*block)[0];
  756|  1.15M|    emit_bits(entropy, (unsigned int)(temp >> Al), 1);
  757|  1.15M|  }
  758|       |
  759|  1.15M|  cinfo->dest->next_output_byte = entropy->next_output_byte;
  760|  1.15M|  cinfo->dest->free_in_buffer = entropy->free_in_buffer;
  761|       |
  762|       |  /* Update restart-interval state too */
  763|  1.15M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (763:7): [True: 0, False: 1.15M]
  ------------------
  764|      0|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (764:9): [True: 0, False: 0]
  ------------------
  765|      0|      entropy->restarts_to_go = cinfo->restart_interval;
  766|      0|      entropy->next_restart_num++;
  767|      0|      entropy->next_restart_num &= 7;
  768|      0|    }
  769|      0|    entropy->restarts_to_go--;
  770|      0|  }
  771|       |
  772|  1.15M|  return TRUE;
  ------------------
  |  |  210|  1.15M|#define TRUE    1
  ------------------
  773|  1.15M|}
jcphuff.c:encode_mcu_AC_refine:
  907|  4.60M|{
  908|  4.60M|  phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
  909|  4.60M|  register int temp, r, idx;
  910|  4.60M|  char *BR_buffer;
  911|  4.60M|  unsigned int BR;
  912|  4.60M|  int Sl = cinfo->Se - cinfo->Ss + 1;
  913|  4.60M|  int Al = cinfo->Al;
  914|  4.60M|  UJCOEF absvalues_unaligned[DCTSIZE2 + 15];
  915|  4.60M|  UJCOEF *absvalues;
  916|  4.60M|  const UJCOEF *cabsvalue, *EOBPTR;
  917|  4.60M|  size_t zerobits, signbits;
  918|  4.60M|  size_t bits[16 / SIZEOF_SIZE_T];
  919|       |
  920|       |#ifdef ZERO_BUFFERS
  921|       |  memset(absvalues_unaligned, 0, sizeof(absvalues_unaligned));
  922|       |  memset(bits, 0, sizeof(bits));
  923|       |#endif
  924|       |
  925|  4.60M|  entropy->next_output_byte = cinfo->dest->next_output_byte;
  926|  4.60M|  entropy->free_in_buffer = cinfo->dest->free_in_buffer;
  927|       |
  928|       |  /* Emit restart marker if needed */
  929|  4.60M|  if (cinfo->restart_interval)
  ------------------
  |  Branch (929:7): [True: 0, False: 4.60M]
  ------------------
  930|      0|    if (entropy->restarts_to_go == 0)
  ------------------
  |  Branch (930:9): [True: 0, False: 0]
  ------------------
  931|      0|      emit_restart(entropy, entropy->next_restart_num);
  932|       |
  933|  4.60M|#ifdef WITH_SIMD
  934|  4.60M|  cabsvalue = absvalues = (UJCOEF *)PAD((JUINTPTR)absvalues_unaligned, 16);
  ------------------
  |  |  124|  4.60M|#define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
  ------------------
  935|       |#else
  936|       |  /* Not using SIMD, so alignment is not needed */
  937|       |  cabsvalue = absvalues = absvalues_unaligned;
  938|       |#endif
  939|       |
  940|       |  /* Prepare data */
  941|  4.60M|  EOBPTR = absvalues +
  942|  4.60M|    entropy->AC_refine_prepare(MCU_data[0][0], jpeg_natural_order + cinfo->Ss,
  943|  4.60M|                               Sl, Al, absvalues, bits);
  944|       |
  945|       |  /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */
  946|       |
  947|  4.60M|  r = 0;                        /* r = run length of zeros */
  948|  4.60M|  BR = 0;                       /* BR = count of buffered bits added now */
  949|  4.60M|  BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */
  950|       |
  951|  4.60M|  zerobits = bits[0];
  952|  4.60M|#if SIZEOF_SIZE_T == 8
  953|  4.60M|  signbits = bits[1];
  954|       |#else
  955|       |  signbits = bits[2];
  956|       |#endif
  957|  4.60M|  ENCODE_COEFS_AC_REFINE((void)0;);
  ------------------
  |  |  850|  4.60M|#define ENCODE_COEFS_AC_REFINE(label) { \
  |  |  851|  76.3M|  while (zerobits) { \
  |  |  ------------------
  |  |  |  Branch (851:10): [True: 71.7M, False: 4.60M]
  |  |  ------------------
  |  |  852|  71.7M|    idx = count_zeroes(&zerobits); \
  |  |  853|  71.7M|    r += idx; \
  |  |  854|  71.7M|    cabsvalue += idx; \
  |  |  855|  71.7M|    signbits >>= idx; \
  |  |  856|  71.7M|label \
  |  |  857|  71.7M|    /* Emit any required ZRLs, but not if they can be folded into EOB */ \
  |  |  858|  71.9M|    while (r > 15 && (cabsvalue <= EOBPTR)) { \
  |  |  ------------------
  |  |  |  Branch (858:12): [True: 1.03M, False: 70.9M]
  |  |  |  Branch (858:22): [True: 147k, False: 883k]
  |  |  ------------------
  |  |  859|   147k|      /* emit any pending EOBRUN and the BE correction bits */ \
  |  |  860|   147k|      emit_eobrun(entropy); \
  |  |  861|   147k|      /* Emit ZRL */ \
  |  |  862|   147k|      emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); \
  |  |  863|   147k|      r -= 16; \
  |  |  864|   147k|      /* Emit buffered correction bits that must be associated with ZRL */ \
  |  |  865|   147k|      emit_buffered_bits(entropy, BR_buffer, BR); \
  |  |  866|   147k|      BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ \
  |  |  867|   147k|      BR = 0; \
  |  |  868|   147k|    } \
  |  |  869|  71.7M|    \
  |  |  870|  71.7M|    temp = *cabsvalue++; \
  |  |  871|  71.7M|    \
  |  |  872|  71.7M|    /* If the coef was previously nonzero, it only needs a correction bit. \
  |  |  873|  71.7M|     * NOTE: a straight translation of the spec's figure G.7 would suggest \
  |  |  874|  71.7M|     * that we also need to test r > 15.  But if r > 15, we can only get here \
  |  |  875|  71.7M|     * if k > EOB, which implies that this coefficient is not 1. \
  |  |  876|  71.7M|     */ \
  |  |  877|  71.7M|    if (temp > 1) { \
  |  |  ------------------
  |  |  |  Branch (877:9): [True: 50.5M, False: 21.2M]
  |  |  ------------------
  |  |  878|  50.5M|      /* The correction bit is the next bit of the absolute value. */ \
  |  |  879|  50.5M|      BR_buffer[BR++] = (char)(temp & 1); \
  |  |  880|  50.5M|      signbits >>= 1; \
  |  |  881|  50.5M|      zerobits >>= 1; \
  |  |  882|  50.5M|      continue; \
  |  |  883|  50.5M|    } \
  |  |  884|  71.7M|    \
  |  |  885|  71.7M|    /* Emit any pending EOBRUN and the BE correction bits */ \
  |  |  886|  71.7M|    emit_eobrun(entropy); \
  |  |  887|  21.2M|    \
  |  |  888|  21.2M|    /* Count/emit Huffman symbol for run length / number of bits */ \
  |  |  889|  21.2M|    emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); \
  |  |  890|  21.2M|    \
  |  |  891|  21.2M|    /* Emit output bit for newly-nonzero coef */ \
  |  |  892|  21.2M|    temp = signbits & 1; /* ((*block)[jpeg_natural_order_start[k]] < 0) ? 0 : 1 */ \
  |  |  893|  21.2M|    emit_bits(entropy, (unsigned int)temp, 1); \
  |  |  894|  21.2M|    \
  |  |  895|  21.2M|    /* Emit buffered correction bits that must be associated with this code */ \
  |  |  896|  21.2M|    emit_buffered_bits(entropy, BR_buffer, BR); \
  |  |  897|  21.2M|    BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ \
  |  |  898|  21.2M|    BR = 0; \
  |  |  899|  21.2M|    r = 0;                      /* reset zero run length */ \
  |  |  900|  21.2M|    signbits >>= 1; \
  |  |  901|  21.2M|    zerobits >>= 1; \
  |  |  902|  21.2M|  } \
  |  |  903|  4.60M|}
  ------------------
  958|       |
  959|       |#if SIZEOF_SIZE_T == 4
  960|       |  zerobits = bits[1];
  961|       |  signbits = bits[3];
  962|       |
  963|       |  if (zerobits) {
  964|       |    int diff = ((absvalues + DCTSIZE2 / 2) - cabsvalue);
  965|       |    idx = count_zeroes(&zerobits);
  966|       |    signbits >>= idx;
  967|       |    idx += diff;
  968|       |    r += idx;
  969|       |    cabsvalue += idx;
  970|       |    goto first_iter_ac_refine;
  971|       |  }
  972|       |
  973|       |  ENCODE_COEFS_AC_REFINE(first_iter_ac_refine:);
  974|       |#endif
  975|       |
  976|  4.60M|  r |= (int)((absvalues + Sl) - cabsvalue);
  977|       |
  978|  4.60M|  if (r > 0 || BR > 0) {        /* If there are trailing zeroes, */
  ------------------
  |  Branch (978:7): [True: 4.10M, False: 498k]
  |  Branch (978:16): [True: 152k, False: 345k]
  ------------------
  979|  4.25M|    entropy->EOBRUN++;          /* count an EOB */
  980|  4.25M|    entropy->BE += BR;          /* concat my correction bits to older ones */
  981|       |    /* We force out the EOB if we risk either:
  982|       |     * 1. overflow of the EOB counter;
  983|       |     * 2. overflow of the correction bit buffer during the next MCU.
  984|       |     */
  985|  4.25M|    if (entropy->EOBRUN == 0x7FFF ||
  ------------------
  |  Branch (985:9): [True: 0, False: 4.25M]
  ------------------
  986|  4.25M|        entropy->BE > (MAX_CORR_BITS - DCTSIZE2 + 1))
  ------------------
  |  |  106|  4.25M|#define MAX_CORR_BITS  1000     /* Max # of correction bits I can buffer */
  ------------------
                      entropy->BE > (MAX_CORR_BITS - DCTSIZE2 + 1))
  ------------------
  |  |   67|  4.25M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (986:9): [True: 590, False: 4.25M]
  ------------------
  987|    590|      emit_eobrun(entropy);
  988|  4.25M|  }
  989|       |
  990|  4.60M|  cinfo->dest->next_output_byte = entropy->next_output_byte;
  991|  4.60M|  cinfo->dest->free_in_buffer = entropy->free_in_buffer;
  992|       |
  993|       |  /* Update restart-interval state too */
  994|  4.60M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (994:7): [True: 0, False: 4.60M]
  ------------------
  995|      0|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (995:9): [True: 0, False: 0]
  ------------------
  996|      0|      entropy->restarts_to_go = cinfo->restart_interval;
  997|      0|      entropy->next_restart_num++;
  998|      0|      entropy->next_restart_num &= 7;
  999|      0|    }
 1000|      0|    entropy->restarts_to_go--;
 1001|      0|  }
 1002|       |
 1003|  4.60M|  return TRUE;
  ------------------
  |  |  210|  4.60M|#define TRUE    1
  ------------------
 1004|  4.60M|}
jcphuff.c:finish_pass_gather_phuff:
 1034|  17.9k|{
 1035|  17.9k|  phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
 1036|  17.9k|  boolean is_DC_band;
 1037|  17.9k|  int ci, tbl;
 1038|  17.9k|  jpeg_component_info *compptr;
 1039|  17.9k|  JHUFF_TBL **htblptr;
 1040|  17.9k|  boolean did[NUM_HUFF_TBLS];
 1041|       |
 1042|       |  /* Flush out buffered data (all we care about is counting the EOB symbol) */
 1043|  17.9k|  emit_eobrun(entropy);
 1044|       |
 1045|  17.9k|  is_DC_band = (cinfo->Ss == 0);
 1046|       |
 1047|       |  /* It's important not to apply jpeg_gen_optimal_table more than once
 1048|       |   * per table, because it clobbers the input frequency counts!
 1049|       |   */
 1050|  17.9k|  memset(did, 0, sizeof(did));
 1051|       |
 1052|  35.8k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (1052:16): [True: 17.9k, False: 17.9k]
  ------------------
 1053|  17.9k|    compptr = cinfo->cur_comp_info[ci];
 1054|  17.9k|    if (is_DC_band) {
  ------------------
  |  Branch (1054:9): [True: 3.58k, False: 14.3k]
  ------------------
 1055|  3.58k|      if (cinfo->Ah != 0)       /* DC refinement needs no table */
  ------------------
  |  Branch (1055:11): [True: 0, False: 3.58k]
  ------------------
 1056|      0|        continue;
 1057|  3.58k|      tbl = compptr->dc_tbl_no;
 1058|  14.3k|    } else {
 1059|  14.3k|      tbl = compptr->ac_tbl_no;
 1060|  14.3k|    }
 1061|  17.9k|    if (!did[tbl]) {
  ------------------
  |  Branch (1061:9): [True: 17.9k, False: 0]
  ------------------
 1062|  17.9k|      if (is_DC_band)
  ------------------
  |  Branch (1062:11): [True: 3.58k, False: 14.3k]
  ------------------
 1063|  3.58k|        htblptr = &cinfo->dc_huff_tbl_ptrs[tbl];
 1064|  14.3k|      else
 1065|  14.3k|        htblptr = &cinfo->ac_huff_tbl_ptrs[tbl];
 1066|  17.9k|      if (*htblptr == NULL)
  ------------------
  |  Branch (1066:11): [True: 0, False: 17.9k]
  ------------------
 1067|      0|        *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
 1068|  17.9k|      jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]);
 1069|  17.9k|      did[tbl] = TRUE;
  ------------------
  |  |  210|  17.9k|#define TRUE    1
  ------------------
 1070|  17.9k|    }
 1071|  17.9k|  }
 1072|  17.9k|}
jcphuff.c:finish_pass_phuff:
 1013|  21.5k|{
 1014|  21.5k|  phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
 1015|       |
 1016|  21.5k|  entropy->next_output_byte = cinfo->dest->next_output_byte;
 1017|  21.5k|  entropy->free_in_buffer = cinfo->dest->free_in_buffer;
 1018|       |
 1019|       |  /* Flush out any buffered data */
 1020|  21.5k|  emit_eobrun(entropy);
 1021|  21.5k|  flush_bits(entropy);
 1022|       |
 1023|  21.5k|  cinfo->dest->next_output_byte = entropy->next_output_byte;
 1024|  21.5k|  cinfo->dest->free_in_buffer = entropy->free_in_buffer;
 1025|  21.5k|}

j12init_c_prep_controller:
  356|  20.8k|{
  357|  20.8k|  my_prep_ptr prep;
  358|  20.8k|  int ci;
  359|  20.8k|  jpeg_component_info *compptr;
  360|  20.8k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  20.8k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (360:19): [True: 0, False: 20.8k]
  ------------------
  361|       |
  362|  20.8k|#ifdef C_LOSSLESS_SUPPORTED
  363|  20.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (363:7): [True: 0, False: 20.8k]
  ------------------
  364|       |#if BITS_IN_JSAMPLE == 8
  365|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  366|       |#else
  367|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (367:9): [True: 0, False: 0]
  ------------------
  368|      0|        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (368:9): [True: 0, False: 0]
  ------------------
  369|      0|#endif
  370|      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)))
  ------------------
  371|      0|  } else
  372|  20.8k|#endif
  373|  20.8k|  {
  374|  20.8k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  20.8k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (374:9): [True: 0, False: 20.8k]
  ------------------
  375|      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)))
  ------------------
  376|  20.8k|  }
  377|       |
  378|  20.8k|  if (need_full_buffer)         /* safety check */
  ------------------
  |  Branch (378:7): [True: 0, False: 20.8k]
  ------------------
  379|      0|    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  380|       |
  381|  20.8k|  prep = (my_prep_ptr)
  382|  20.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  20.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  383|  20.8k|                                sizeof(my_prep_controller));
  384|  20.8k|  cinfo->prep = (struct jpeg_c_prep_controller *)prep;
  385|  20.8k|  prep->pub.start_pass = start_pass_prep;
  386|       |
  387|       |  /* Allocate the color conversion buffer.
  388|       |   * We make the buffer wide enough to allow the downsampler to edge-expand
  389|       |   * horizontally within the buffer, if it so chooses.
  390|       |   */
  391|  20.8k|  if (cinfo->downsample->need_context_rows) {
  ------------------
  |  Branch (391:7): [True: 0, False: 20.8k]
  ------------------
  392|       |    /* Set up to provide context rows */
  393|      0|#ifdef CONTEXT_ROWS_SUPPORTED
  394|      0|    prep->pub._pre_process_data = pre_process_context;
  ------------------
  |  |  130|      0|#define _pre_process_data  pre_process_data_12
  ------------------
  395|      0|    create_context_buffer(cinfo);
  396|       |#else
  397|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  398|       |#endif
  399|  20.8k|  } else {
  400|       |    /* No context, just make it tall enough for one row group */
  401|  20.8k|    prep->pub._pre_process_data = pre_process_data;
  ------------------
  |  |  130|  20.8k|#define _pre_process_data  pre_process_data_12
  ------------------
  402|  73.3k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (402:46): [True: 52.5k, False: 20.8k]
  ------------------
  403|  52.5k|         ci++, compptr++) {
  404|  52.5k|      prep->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  405|  52.5k|        ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  52.5k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  406|  52.5k|         (JDIMENSION)(((long)compptr->width_in_blocks * data_unit *
  407|  52.5k|                       cinfo->max_h_samp_factor) / compptr->h_samp_factor),
  408|  52.5k|         (JDIMENSION)cinfo->max_v_samp_factor);
  409|  52.5k|    }
  410|  20.8k|  }
  411|  20.8k|}
jcprepct-12.c:start_pass_prep:
   90|  20.8k|{
   91|  20.8k|  my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
   92|       |
   93|  20.8k|  if (pass_mode != JBUF_PASS_THRU)
  ------------------
  |  Branch (93:7): [True: 0, False: 20.8k]
  ------------------
   94|      0|    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   95|       |
   96|       |  /* Initialize total-height counter for detecting bottom of image */
   97|  20.8k|  prep->rows_to_go = cinfo->image_height;
   98|       |  /* Mark the conversion buffer empty */
   99|  20.8k|  prep->next_buf_row = 0;
  100|  20.8k|#ifdef CONTEXT_ROWS_SUPPORTED
  101|       |  /* Preset additional state variables for context mode.
  102|       |   * These aren't used in non-context mode, so we needn't test which mode.
  103|       |   */
  104|  20.8k|  prep->this_row_group = 0;
  105|       |  /* Set next_buf_stop to stop after two row groups have been read in. */
  106|  20.8k|  prep->next_buf_stop = 2 * cinfo->max_v_samp_factor;
  107|  20.8k|#endif
  108|  20.8k|}
jcprepct-12.c:expand_bottom_edge:
  119|  43.2k|{
  120|  43.2k|  register int row;
  121|       |
  122|   278k|  for (row = input_rows; row < output_rows; row++) {
  ------------------
  |  Branch (122:26): [True: 235k, False: 43.2k]
  ------------------
  123|   235k|    _jcopy_sample_rows(image_data, input_rows - 1, image_data, row, 1,
  ------------------
  |  |  181|   235k|#define _jcopy_sample_rows  j12copy_sample_rows
  ------------------
  124|   235k|                       num_cols);
  125|   235k|  }
  126|  43.2k|}
jcprepct-12.c:pre_process_data:
  143|  3.16M|{
  144|  3.16M|  my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
  145|  3.16M|  int numrows, ci;
  146|  3.16M|  JDIMENSION inrows;
  147|  3.16M|  jpeg_component_info *compptr;
  148|  3.16M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  3.16M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (148:19): [True: 0, False: 3.16M]
  ------------------
  149|       |
  150|  28.4M|  while (*in_row_ctr < in_rows_avail &&
  ------------------
  |  Branch (150:10): [True: 28.3M, False: 7.68k]
  ------------------
  151|  28.3M|         *out_row_group_ctr < out_row_groups_avail) {
  ------------------
  |  Branch (151:10): [True: 25.2M, False: 3.14M]
  ------------------
  152|       |    /* Do color conversion to fill the conversion buffer. */
  153|  25.2M|    inrows = in_rows_avail - *in_row_ctr;
  154|  25.2M|    numrows = cinfo->max_v_samp_factor - prep->next_buf_row;
  155|  25.2M|    numrows = (int)MIN((JDIMENSION)numrows, inrows);
  ------------------
  |  |  515|  25.2M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 25.2M, False: 20.8k]
  |  |  ------------------
  ------------------
  156|       |#ifdef WITH_PROFILE
  157|       |    cinfo->master->start = getTime();
  158|       |#endif
  159|  25.2M|    (*cinfo->cconvert->_color_convert) (cinfo, input_buf + *in_row_ctr,
  ------------------
  |  |  151|  25.2M|#define _color_convert  color_convert_12
  ------------------
  160|  25.2M|                                        prep->color_buf,
  161|  25.2M|                                        (JDIMENSION)prep->next_buf_row,
  162|  25.2M|                                        numrows);
  163|       |#ifdef WITH_PROFILE
  164|       |    cinfo->master->cconvert_elapsed += getTime() - cinfo->master->start;
  165|       |    cinfo->master->cconvert_mpixels +=
  166|       |      (double)cinfo->image_width * numrows / 1000000.;
  167|       |#endif
  168|  25.2M|    *in_row_ctr += numrows;
  169|  25.2M|    prep->next_buf_row += numrows;
  170|  25.2M|    prep->rows_to_go -= numrows;
  171|       |    /* If at bottom of image, pad to fill the conversion buffer. */
  172|  25.2M|    if (prep->rows_to_go == 0 &&
  ------------------
  |  Branch (172:9): [True: 20.8k, False: 25.2M]
  ------------------
  173|  20.8k|        prep->next_buf_row < cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (173:9): [True: 2.01k, False: 18.8k]
  ------------------
  174|  9.08k|      for (ci = 0; ci < cinfo->num_components; ci++) {
  ------------------
  |  Branch (174:20): [True: 7.06k, False: 2.01k]
  ------------------
  175|  7.06k|        expand_bottom_edge(prep->color_buf[ci], cinfo->image_width,
  176|  7.06k|                           prep->next_buf_row, cinfo->max_v_samp_factor);
  177|  7.06k|      }
  178|  2.01k|      prep->next_buf_row = cinfo->max_v_samp_factor;
  179|  2.01k|    }
  180|       |    /* If we've filled the conversion buffer, empty it. */
  181|  25.2M|    if (prep->next_buf_row == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (181:9): [True: 25.2M, False: 0]
  ------------------
  182|       |#ifdef WITH_PROFILE
  183|       |      cinfo->master->start = getTime();
  184|       |#endif
  185|  25.2M|      (*cinfo->downsample->_downsample) (cinfo,
  ------------------
  |  |  136|  25.2M|#define _downsample  downsample_12
  ------------------
  186|  25.2M|                                         prep->color_buf, (JDIMENSION)0,
  187|  25.2M|                                         output_buf, *out_row_group_ctr);
  188|       |#ifdef WITH_PROFILE
  189|       |      cinfo->master->downsample_elapsed += getTime() - cinfo->master->start;
  190|       |      cinfo->master->downsample_msamples +=
  191|       |        (double)cinfo->image_width * cinfo->max_v_samp_factor / 1000000.;
  192|       |#endif
  193|  25.2M|      prep->next_buf_row = 0;
  194|  25.2M|      (*out_row_group_ctr)++;
  195|  25.2M|    }
  196|       |    /* If at bottom of image, pad the output to a full iMCU height.
  197|       |     * Note we assume the caller is providing a one-iMCU-height output buffer!
  198|       |     */
  199|  25.2M|    if (prep->rows_to_go == 0 && *out_row_group_ctr < out_row_groups_avail) {
  ------------------
  |  Branch (199:9): [True: 20.8k, False: 25.2M]
  |  Branch (199:34): [True: 13.1k, False: 7.68k]
  ------------------
  200|  49.3k|      for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (200:48): [True: 36.1k, False: 13.1k]
  ------------------
  201|  36.1k|           ci++, compptr++) {
  202|  36.1k|        expand_bottom_edge(output_buf[ci],
  203|  36.1k|                           compptr->width_in_blocks * data_unit,
  204|  36.1k|                           (int)(*out_row_group_ctr * compptr->v_samp_factor),
  205|  36.1k|                           (int)(out_row_groups_avail * compptr->v_samp_factor));
  206|  36.1k|      }
  207|  13.1k|      *out_row_group_ctr = out_row_groups_avail;
  208|  13.1k|      break;                    /* can exit outer loop without test */
  209|  13.1k|    }
  210|  25.2M|  }
  211|  3.16M|}

j12init_downsampler:
  468|  20.8k|{
  469|  20.8k|  my_downsample_ptr downsample;
  470|  20.8k|  int ci;
  471|  20.8k|  jpeg_component_info *compptr;
  472|  20.8k|#ifdef INPUT_SMOOTHING_SUPPORTED
  473|  20.8k|  boolean smoothok = TRUE;
  ------------------
  |  |  210|  20.8k|#define TRUE    1
  ------------------
  474|  20.8k|#endif
  475|       |
  476|  20.8k|#ifdef C_LOSSLESS_SUPPORTED
  477|  20.8k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (477:7): [True: 0, False: 20.8k]
  ------------------
  478|       |#if BITS_IN_JSAMPLE == 8
  479|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  480|       |#else
  481|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (481:9): [True: 0, False: 0]
  ------------------
  482|      0|        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (482:9): [True: 0, False: 0]
  ------------------
  483|      0|#endif
  484|      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)))
  ------------------
  485|      0|  } else
  486|  20.8k|#endif
  487|  20.8k|  {
  488|  20.8k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  20.8k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (488:9): [True: 0, False: 20.8k]
  ------------------
  489|      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)))
  ------------------
  490|  20.8k|  }
  491|       |
  492|  20.8k|  downsample = (my_downsample_ptr)
  493|  20.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  20.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  494|  20.8k|                                sizeof(my_downsampler));
  495|  20.8k|  cinfo->downsample = (struct jpeg_downsampler *)downsample;
  496|  20.8k|  downsample->pub.start_pass = start_pass_downsample;
  497|  20.8k|  downsample->pub._downsample = sep_downsample;
  ------------------
  |  |  136|  20.8k|#define _downsample  downsample_12
  ------------------
  498|  20.8k|  downsample->pub.need_context_rows = FALSE;
  ------------------
  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  ------------------
  499|       |
  500|  20.8k|  if (cinfo->CCIR601_sampling)
  ------------------
  |  Branch (500:7): [True: 0, False: 20.8k]
  ------------------
  501|      0|    ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  502|       |
  503|       |  /* Verify we can handle the sampling factors, and set up method pointers */
  504|  73.3k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (504:44): [True: 52.5k, False: 20.8k]
  ------------------
  505|  52.5k|       ci++, compptr++) {
  506|  52.5k|    if (compptr->h_samp_factor == cinfo->max_h_samp_factor &&
  ------------------
  |  Branch (506:9): [True: 35.2k, False: 17.2k]
  ------------------
  507|  35.2k|        compptr->v_samp_factor == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (507:9): [True: 29.5k, False: 5.67k]
  ------------------
  508|  29.5k|#ifdef INPUT_SMOOTHING_SUPPORTED
  509|  29.5k|      if (cinfo->smoothing_factor) {
  ------------------
  |  Branch (509:11): [True: 0, False: 29.5k]
  ------------------
  510|      0|        downsample->methods[ci] = fullsize_smooth_downsample;
  511|      0|        downsample->pub.need_context_rows = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  512|      0|      } else
  513|  29.5k|#endif
  514|  29.5k|        downsample->methods[ci] = fullsize_downsample;
  515|  29.5k|    } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
  ------------------
  |  Branch (515:16): [True: 11.5k, False: 11.3k]
  ------------------
  516|  11.5k|               compptr->v_samp_factor == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (516:16): [True: 5.90k, False: 5.67k]
  ------------------
  517|  5.90k|#ifdef INPUT_SMOOTHING_SUPPORTED
  518|  5.90k|      smoothok = FALSE;
  ------------------
  |  |  207|  5.90k|#define FALSE   0               /* values of boolean */
  ------------------
  519|  5.90k|#endif
  520|       |#ifdef WITH_SIMD
  521|       |      if (jsimd_set_h2v1_downsample(cinfo))
  522|       |        downsample->methods[ci] = jsimd_h2v1_downsample;
  523|       |      else
  524|       |#endif
  525|  5.90k|        downsample->methods[ci] = h2v1_downsample;
  526|  17.0k|    } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
  ------------------
  |  Branch (526:16): [True: 5.67k, False: 11.3k]
  ------------------
  527|  5.67k|               compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (527:16): [True: 5.67k, False: 0]
  ------------------
  528|  5.67k|#ifdef INPUT_SMOOTHING_SUPPORTED
  529|  5.67k|      if (cinfo->smoothing_factor) {
  ------------------
  |  Branch (529:11): [True: 0, False: 5.67k]
  ------------------
  530|      0|        downsample->methods[ci] = h2v2_smooth_downsample;
  531|      0|        downsample->pub.need_context_rows = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  532|      0|      } else
  533|  5.67k|#endif
  534|  5.67k|      {
  535|       |#ifdef WITH_SIMD
  536|       |        if (jsimd_set_h2v2_downsample(cinfo))
  537|       |          downsample->methods[ci] = jsimd_h2v2_downsample;
  538|       |        else
  539|       |#endif
  540|  5.67k|          downsample->methods[ci] = h2v2_downsample;
  541|  5.67k|      }
  542|  11.3k|    } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 &&
  ------------------
  |  Branch (542:16): [True: 11.3k, False: 0]
  ------------------
  543|  11.3k|               (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) {
  ------------------
  |  Branch (543:16): [True: 11.3k, False: 0]
  ------------------
  544|  11.3k|#ifdef INPUT_SMOOTHING_SUPPORTED
  545|  11.3k|      smoothok = FALSE;
  ------------------
  |  |  207|  11.3k|#define FALSE   0               /* values of boolean */
  ------------------
  546|  11.3k|#endif
  547|  11.3k|      downsample->methods[ci] = int_downsample;
  548|  11.3k|    } else
  549|      0|      ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  550|  52.5k|  }
  551|       |
  552|  20.8k|#ifdef INPUT_SMOOTHING_SUPPORTED
  553|  20.8k|  if (cinfo->smoothing_factor && !smoothok)
  ------------------
  |  Branch (553:7): [True: 0, False: 20.8k]
  |  Branch (553:34): [True: 0, False: 0]
  ------------------
  554|      0|    TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL);
  ------------------
  |  |  297|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  298|      0|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  555|  20.8k|#endif
  556|  20.8k|}
jcsample-12.c:start_pass_downsample:
   89|  20.8k|{
   90|       |  /* no work for now */
   91|  20.8k|}
jcsample-12.c:sep_downsample:
  130|  25.2M|{
  131|  25.2M|  my_downsample_ptr downsample = (my_downsample_ptr)cinfo->downsample;
  132|  25.2M|  int ci;
  133|  25.2M|  jpeg_component_info *compptr;
  134|  25.2M|  _JSAMPARRAY in_ptr, out_ptr;
  ------------------
  |  |  114|  25.2M|#define _JSAMPARRAY  J12SAMPARRAY
  ------------------
  135|       |
  136|  87.3M|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (136:44): [True: 62.0M, False: 25.2M]
  ------------------
  137|  62.0M|       ci++, compptr++) {
  138|  62.0M|    in_ptr = input_buf[ci] + in_row_index;
  139|  62.0M|    out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor);
  140|  62.0M|    (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr);
  141|  62.0M|  }
  142|  25.2M|}
jcsample-12.c:expand_right_edge:
  102|  62.0M|{
  103|  62.0M|  register _JSAMPROW ptr;
  104|  62.0M|  register _JSAMPLE pixval;
  105|  62.0M|  register int count;
  106|  62.0M|  int row;
  107|  62.0M|  int numcols = (int)(output_cols - input_cols);
  108|       |
  109|  62.0M|  if (numcols > 0) {
  ------------------
  |  Branch (109:7): [True: 61.6M, False: 430k]
  ------------------
  110|   138M|    for (row = 0; row < num_rows; row++) {
  ------------------
  |  Branch (110:19): [True: 76.7M, False: 61.6M]
  ------------------
  111|  76.7M|      ptr = image_data[row] + input_cols;
  112|  76.7M|      pixval = ptr[-1];
  113|   900M|      for (count = numcols; count > 0; count--)
  ------------------
  |  Branch (113:29): [True: 823M, False: 76.7M]
  ------------------
  114|   823M|        *ptr++ = pixval;
  115|  76.7M|    }
  116|  61.6M|  }
  117|  62.0M|}
jcsample-12.c:fullsize_downsample:
  203|  36.0M|{
  204|  36.0M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  36.0M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (204:19): [True: 0, False: 36.0M]
  ------------------
  205|       |
  206|       |  /* Copy the data */
  207|  36.0M|  _jcopy_sample_rows(input_data, 0, output_data, 0, cinfo->max_v_samp_factor,
  ------------------
  |  |  181|  36.0M|#define _jcopy_sample_rows  j12copy_sample_rows
  ------------------
  208|  36.0M|                     cinfo->image_width);
  209|       |  /* Edge-expand */
  210|  36.0M|  expand_right_edge(output_data, cinfo->max_v_samp_factor, cinfo->image_width,
  211|  36.0M|                    compptr->width_in_blocks * data_unit);
  212|  36.0M|}
jcsample-12.c:h2v1_downsample:
  230|  8.66M|{
  231|  8.66M|  int outrow;
  232|  8.66M|  JDIMENSION outcol;
  233|  8.66M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  8.66M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (233:19): [True: 0, False: 8.66M]
  ------------------
  234|  8.66M|  JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
  235|  8.66M|  register _JSAMPROW inptr, outptr;
  236|  8.66M|  register int bias;
  237|       |
  238|       |  /* Expand input data enough to let all the output samples be generated
  239|       |   * by the standard loop.  Special-casing padded output would be more
  240|       |   * efficient.
  241|       |   */
  242|  8.66M|  expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
  243|  8.66M|                    output_cols * 2);
  244|       |
  245|  17.3M|  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  ------------------
  |  Branch (245:20): [True: 8.66M, False: 8.66M]
  ------------------
  246|  8.66M|    outptr = output_data[outrow];
  247|  8.66M|    inptr = input_data[outrow];
  248|  8.66M|    bias = 0;                   /* bias = 0,1,0,1,... for successive samples */
  249|   102M|    for (outcol = 0; outcol < output_cols; outcol++) {
  ------------------
  |  Branch (249:22): [True: 94.0M, False: 8.66M]
  ------------------
  250|  94.0M|      *outptr++ = (_JSAMPLE)((inptr[0] + inptr[1] + bias) >> 1);
  251|  94.0M|      bias ^= 1;                /* 0=>1, 1=>0 */
  252|  94.0M|      inptr += 2;
  253|  94.0M|    }
  254|  8.66M|  }
  255|  8.66M|}
jcsample-12.c:h2v2_downsample:
  267|  4.33M|{
  268|  4.33M|  int inrow, outrow;
  269|  4.33M|  JDIMENSION outcol;
  270|  4.33M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  4.33M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (270:19): [True: 0, False: 4.33M]
  ------------------
  271|  4.33M|  JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
  272|  4.33M|  register _JSAMPROW inptr0, inptr1, outptr;
  273|  4.33M|  register int bias;
  274|       |
  275|       |  /* Expand input data enough to let all the output samples be generated
  276|       |   * by the standard loop.  Special-casing padded output would be more
  277|       |   * efficient.
  278|       |   */
  279|  4.33M|  expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
  280|  4.33M|                    output_cols * 2);
  281|       |
  282|  4.33M|  inrow = 0;
  283|  8.66M|  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  ------------------
  |  Branch (283:20): [True: 4.33M, False: 4.33M]
  ------------------
  284|  4.33M|    outptr = output_data[outrow];
  285|  4.33M|    inptr0 = input_data[inrow];
  286|  4.33M|    inptr1 = input_data[inrow + 1];
  287|  4.33M|    bias = 1;                   /* bias = 1,2,1,2,... for successive samples */
  288|  52.7M|    for (outcol = 0; outcol < output_cols; outcol++) {
  ------------------
  |  Branch (288:22): [True: 48.4M, False: 4.33M]
  ------------------
  289|  48.4M|      *outptr++ = (_JSAMPLE)
  290|  48.4M|        ((inptr0[0] + inptr0[1] + inptr1[0] + inptr1[1] + bias) >> 2);
  291|  48.4M|      bias ^= 3;                /* 1=>2, 2=>1 */
  292|  48.4M|      inptr0 += 2;  inptr1 += 2;
  293|  48.4M|    }
  294|  4.33M|    inrow += 2;
  295|  4.33M|  }
  296|  4.33M|}
jcsample-12.c:int_downsample:
  155|  12.9M|{
  156|  12.9M|  int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v;
  157|  12.9M|  JDIMENSION outcol, outcol_h;  /* outcol_h == outcol*h_expand */
  158|  12.9M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  12.9M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (158:19): [True: 0, False: 12.9M]
  ------------------
  159|  12.9M|  JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
  160|  12.9M|  _JSAMPROW inptr, outptr;
  ------------------
  |  |  113|  12.9M|#define _JSAMPROW  J12SAMPROW
  ------------------
  161|  12.9M|  JLONG outvalue;
  162|       |
  163|  12.9M|  h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor;
  164|  12.9M|  v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor;
  165|  12.9M|  numpix = h_expand * v_expand;
  166|  12.9M|  numpix2 = numpix / 2;
  167|       |
  168|       |  /* Expand input data enough to let all the output samples be generated
  169|       |   * by the standard loop.  Special-casing padded output would be more
  170|       |   * efficient.
  171|       |   */
  172|  12.9M|  expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
  173|  12.9M|                    output_cols * h_expand);
  174|       |
  175|  12.9M|  inrow = 0;
  176|  25.9M|  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  ------------------
  |  Branch (176:20): [True: 12.9M, False: 12.9M]
  ------------------
  177|  12.9M|    outptr = output_data[outrow];
  178|   156M|    for (outcol = 0, outcol_h = 0; outcol < output_cols;
  ------------------
  |  Branch (178:36): [True: 143M, False: 12.9M]
  ------------------
  179|   143M|         outcol++, outcol_h += h_expand) {
  180|   143M|      outvalue = 0;
  181|   349M|      for (v = 0; v < v_expand; v++) {
  ------------------
  |  Branch (181:19): [True: 206M, False: 143M]
  ------------------
  182|   206M|        inptr = input_data[inrow + v] + outcol_h;
  183|   656M|        for (h = 0; h < h_expand; h++) {
  ------------------
  |  Branch (183:21): [True: 450M, False: 206M]
  ------------------
  184|   450M|          outvalue += (JLONG)(*inptr++);
  185|   450M|        }
  186|   206M|      }
  187|   143M|      *outptr++ = (_JSAMPLE)((outvalue + numpix2) / numpix);
  188|   143M|    }
  189|  12.9M|    inrow += v_expand;
  190|  12.9M|  }
  191|  12.9M|}

jpeg_mem_dest_tj:
  164|  73.6k|{
  165|  73.6k|  boolean reused = FALSE;
  ------------------
  |  |  207|  73.6k|#define FALSE   0               /* values of boolean */
  ------------------
  166|  73.6k|  my_mem_dest_ptr dest;
  167|       |
  168|  73.6k|  if (outbuffer == NULL || outsize == NULL)     /* sanity check */
  ------------------
  |  Branch (168:7): [True: 0, False: 73.6k]
  |  Branch (168:28): [True: 0, False: 73.6k]
  ------------------
  169|      0|    ERREXIT(cinfo, JERR_BUFFER_SIZE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  170|       |
  171|       |  /* The destination object is made permanent so that multiple JPEG images
  172|       |   * can be written to the same buffer without re-executing jpeg_mem_dest.
  173|       |   */
  174|  73.6k|  if (cinfo->dest == NULL) {    /* first time for this JPEG object? */
  ------------------
  |  Branch (174:7): [True: 52.8k, False: 20.8k]
  ------------------
  175|  52.8k|    cinfo->dest = (struct jpeg_destination_mgr *)
  176|  52.8k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  52.8k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  177|  52.8k|                                  sizeof(my_mem_destination_mgr));
  178|  52.8k|    dest = (my_mem_dest_ptr)cinfo->dest;
  179|  52.8k|    dest->newbuffer = NULL;
  180|  52.8k|    dest->buffer = NULL;
  181|  52.8k|  } else if (cinfo->dest->init_destination != init_mem_destination) {
  ------------------
  |  Branch (181:14): [True: 0, False: 20.8k]
  ------------------
  182|       |    /* It is unsafe to reuse the existing destination manager unless it was
  183|       |     * created by this function.
  184|       |     */
  185|      0|    ERREXIT(cinfo, JERR_BUFFER_SIZE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  186|      0|  }
  187|       |
  188|  73.6k|  dest = (my_mem_dest_ptr)cinfo->dest;
  189|  73.6k|  dest->pub.init_destination = init_mem_destination;
  190|  73.6k|  dest->pub.empty_output_buffer = empty_mem_output_buffer;
  191|  73.6k|  dest->pub.term_destination = term_mem_destination;
  192|  73.6k|  if (dest->buffer == *outbuffer && *outbuffer != NULL && alloc)
  ------------------
  |  Branch (192:7): [True: 0, False: 73.6k]
  |  Branch (192:37): [True: 0, False: 0]
  |  Branch (192:59): [True: 0, False: 0]
  ------------------
  193|      0|    reused = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  194|  73.6k|  dest->outbuffer = outbuffer;
  195|  73.6k|  dest->outsize = outsize;
  196|  73.6k|  dest->alloc = alloc;
  197|       |
  198|  73.6k|  if (*outbuffer == NULL || (*outsize == 0 && !reused)) {
  ------------------
  |  Branch (198:7): [True: 17.8k, False: 55.7k]
  |  Branch (198:30): [True: 0, False: 55.7k]
  |  Branch (198:47): [True: 0, False: 0]
  ------------------
  199|  17.8k|    if (alloc) {
  ------------------
  |  Branch (199:9): [True: 17.8k, False: 0]
  ------------------
  200|       |      /* Allocate initial buffer */
  201|  17.8k|      dest->newbuffer = *outbuffer = (unsigned char *)MALLOC(OUTPUT_BUF_SIZE);
  ------------------
  |  |  520|  17.8k|#define MALLOC(size)  malloc(size)
  ------------------
  202|  17.8k|      if (dest->newbuffer == NULL)
  ------------------
  |  Branch (202:11): [True: 0, False: 17.8k]
  ------------------
  203|      0|        ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
  ------------------
  |  |  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)))
  ------------------
  204|  17.8k|      *outsize = OUTPUT_BUF_SIZE;
  ------------------
  |  |   34|  17.8k|#define OUTPUT_BUF_SIZE  4096   /* choose an efficiently fwrite'able size */
  ------------------
  205|  17.8k|    } else
  206|      0|      ERREXIT(cinfo, JERR_BUFFER_SIZE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  207|  17.8k|  } else
  208|  55.7k|    dest->newbuffer = *outbuffer;
  209|       |
  210|  73.6k|  dest->pub.next_output_byte = dest->buffer = *outbuffer;
  211|  73.6k|  if (!reused)
  ------------------
  |  Branch (211:7): [True: 73.6k, False: 0]
  ------------------
  212|  73.6k|    dest->bufsize = *outsize;
  213|  73.6k|  dest->pub.free_in_buffer = dest->bufsize;
  214|  73.6k|}
jdatadst-tj.c:init_mem_destination:
   60|  20.8k|{
   61|       |  /* no work necessary here */
   62|  20.8k|}
jdatadst-tj.c:empty_mem_output_buffer:
   90|  8.40k|{
   91|  8.40k|  size_t nextsize;
   92|  8.40k|  JOCTET *nextbuffer;
   93|  8.40k|  my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
   94|       |
   95|  8.40k|  if (!dest->alloc) ERREXIT(cinfo, JERR_BUFFER_SIZE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  |  Branch (95:7): [True: 0, False: 8.40k]
  ------------------
   96|       |
   97|       |  /* Try to allocate new buffer with double size
   98|       |   *
   99|       |   * NOTE: The following check isn't actually necessary.  On 64-bit systems,
  100|       |   * the maximum theoretical JPEG size is
  101|       |   * 65500 * 65500 * cinfo->num_components * sizeof(DCTELEM) bytes, which is of
  102|       |   * course much less than 8 exabytes (SIZE_MAX / 2).  On 32-bit systems,
  103|       |   * malloc() will never return a buffer >= 2 GB, so the malloc() call will
  104|       |   * fail before 32-bit integer overflow/wraparound can occur.  The sole
  105|       |   * purpose of this code is to shut up automated code analysis tools.
  106|       |   */
  107|  8.40k|  if (dest->bufsize > SIZE_MAX / 2)
  ------------------
  |  Branch (107:7): [True: 0, False: 8.40k]
  ------------------
  108|      0|    ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 13);
  ------------------
  |  |  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)))
  ------------------
  109|  8.40k|  nextsize = dest->bufsize * 2;
  110|  8.40k|  nextbuffer = (JOCTET *)MALLOC(nextsize);
  ------------------
  |  |  520|  8.40k|#define MALLOC(size)  malloc(size)
  ------------------
  111|       |
  112|  8.40k|  if (nextbuffer == NULL)
  ------------------
  |  Branch (112:7): [True: 0, False: 8.40k]
  ------------------
  113|      0|    ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 12);
  ------------------
  |  |  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)))
  ------------------
  114|       |
  115|  8.40k|  memcpy(nextbuffer, dest->buffer, dest->bufsize);
  116|       |
  117|  8.40k|  free(dest->newbuffer);
  118|       |
  119|  8.40k|  dest->newbuffer = nextbuffer;
  120|       |
  121|  8.40k|  dest->pub.next_output_byte = nextbuffer + dest->bufsize;
  122|  8.40k|  dest->pub.free_in_buffer = dest->bufsize;
  123|       |
  124|  8.40k|  dest->buffer = nextbuffer;
  125|  8.40k|  dest->bufsize = nextsize;
  126|       |
  127|  8.40k|  return TRUE;
  ------------------
  |  |  210|  8.40k|#define TRUE    1
  ------------------
  128|  8.40k|}
jdatadst-tj.c:term_mem_destination:
  142|  20.8k|{
  143|  20.8k|  my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
  144|       |
  145|  20.8k|  if (dest->alloc) *dest->outbuffer = dest->buffer;
  ------------------
  |  Branch (145:7): [True: 17.8k, False: 2.95k]
  ------------------
  146|  20.8k|  *dest->outsize = dest->bufsize - dest->pub.free_in_buffer;
  147|  20.8k|}

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

jpeg12_fdct_ifast:
  118|  4.36M|{
  119|  4.36M|  DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
  120|  4.36M|  DCTELEM tmp10, tmp11, tmp12, tmp13;
  121|  4.36M|  DCTELEM z1, z2, z3, z4, z5, z11, z13;
  122|  4.36M|  DCTELEM *dataptr;
  123|  4.36M|  int ctr;
  124|  4.36M|  SHIFT_TEMPS
  125|       |
  126|       |  /* Pass 1: process rows. */
  127|       |
  128|  4.36M|  dataptr = data;
  129|  39.2M|  for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
  ------------------
  |  |   66|  4.36M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (129:27): [True: 34.8M, False: 4.36M]
  ------------------
  130|  34.8M|    tmp0 = dataptr[0] + dataptr[7];
  131|  34.8M|    tmp7 = dataptr[0] - dataptr[7];
  132|  34.8M|    tmp1 = dataptr[1] + dataptr[6];
  133|  34.8M|    tmp6 = dataptr[1] - dataptr[6];
  134|  34.8M|    tmp2 = dataptr[2] + dataptr[5];
  135|  34.8M|    tmp5 = dataptr[2] - dataptr[5];
  136|  34.8M|    tmp3 = dataptr[3] + dataptr[4];
  137|  34.8M|    tmp4 = dataptr[3] - dataptr[4];
  138|       |
  139|       |    /* Even part */
  140|       |
  141|  34.8M|    tmp10 = tmp0 + tmp3;        /* phase 2 */
  142|  34.8M|    tmp13 = tmp0 - tmp3;
  143|  34.8M|    tmp11 = tmp1 + tmp2;
  144|  34.8M|    tmp12 = tmp1 - tmp2;
  145|       |
  146|  34.8M|    dataptr[0] = tmp10 + tmp11; /* phase 3 */
  147|  34.8M|    dataptr[4] = tmp10 - tmp11;
  148|       |
  149|  34.8M|    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */
  ------------------
  |  |  109|  34.8M|#define MULTIPLY(var, const)  ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
  |  |  ------------------
  |  |  |  |  101|  34.8M|#define DESCALE(x, n)  RIGHT_SHIFT(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  542|  34.8M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  150|  34.8M|    dataptr[2] = tmp13 + z1;    /* phase 5 */
  151|  34.8M|    dataptr[6] = tmp13 - z1;
  152|       |
  153|       |    /* Odd part */
  154|       |
  155|  34.8M|    tmp10 = tmp4 + tmp5;        /* phase 2 */
  156|  34.8M|    tmp11 = tmp5 + tmp6;
  157|  34.8M|    tmp12 = tmp6 + tmp7;
  158|       |
  159|       |    /* The rotator is modified from fig 4-8 to avoid extra negations. */
  160|  34.8M|    z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */
  ------------------
  |  |  109|  34.8M|#define MULTIPLY(var, const)  ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
  |  |  ------------------
  |  |  |  |  101|  34.8M|#define DESCALE(x, n)  RIGHT_SHIFT(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  542|  34.8M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  161|  34.8M|    z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */
  ------------------
  |  |  109|  34.8M|#define MULTIPLY(var, const)  ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
  |  |  ------------------
  |  |  |  |  101|  34.8M|#define DESCALE(x, n)  RIGHT_SHIFT(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  542|  34.8M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|  34.8M|    z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */
  ------------------
  |  |  109|  34.8M|#define MULTIPLY(var, const)  ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
  |  |  ------------------
  |  |  |  |  101|  34.8M|#define DESCALE(x, n)  RIGHT_SHIFT(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  542|  34.8M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  163|  34.8M|    z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */
  ------------------
  |  |  109|  34.8M|#define MULTIPLY(var, const)  ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
  |  |  ------------------
  |  |  |  |  101|  34.8M|#define DESCALE(x, n)  RIGHT_SHIFT(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  542|  34.8M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  164|       |
  165|  34.8M|    z11 = tmp7 + z3;            /* phase 5 */
  166|  34.8M|    z13 = tmp7 - z3;
  167|       |
  168|  34.8M|    dataptr[5] = z13 + z2;      /* phase 6 */
  169|  34.8M|    dataptr[3] = z13 - z2;
  170|  34.8M|    dataptr[1] = z11 + z4;
  171|  34.8M|    dataptr[7] = z11 - z4;
  172|       |
  173|  34.8M|    dataptr += DCTSIZE;         /* advance pointer to next row */
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  174|  34.8M|  }
  175|       |
  176|       |  /* Pass 2: process columns. */
  177|       |
  178|  4.36M|  dataptr = data;
  179|  39.2M|  for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
  ------------------
  |  |   66|  4.36M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (179:27): [True: 34.8M, False: 4.36M]
  ------------------
  180|  34.8M|    tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  181|  34.8M|    tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  182|  34.8M|    tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  183|  34.8M|    tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  184|  34.8M|    tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  185|  34.8M|    tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  186|  34.8M|    tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  187|  34.8M|    tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  188|       |
  189|       |    /* Even part */
  190|       |
  191|  34.8M|    tmp10 = tmp0 + tmp3;        /* phase 2 */
  192|  34.8M|    tmp13 = tmp0 - tmp3;
  193|  34.8M|    tmp11 = tmp1 + tmp2;
  194|  34.8M|    tmp12 = tmp1 - tmp2;
  195|       |
  196|  34.8M|    dataptr[DCTSIZE * 0] = tmp10 + tmp11; /* phase 3 */
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  197|  34.8M|    dataptr[DCTSIZE * 4] = tmp10 - tmp11;
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  198|       |
  199|  34.8M|    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */
  ------------------
  |  |  109|  34.8M|#define MULTIPLY(var, const)  ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
  |  |  ------------------
  |  |  |  |  101|  34.8M|#define DESCALE(x, n)  RIGHT_SHIFT(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  542|  34.8M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  200|  34.8M|    dataptr[DCTSIZE * 2] = tmp13 + z1; /* phase 5 */
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  201|  34.8M|    dataptr[DCTSIZE * 6] = tmp13 - z1;
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  202|       |
  203|       |    /* Odd part */
  204|       |
  205|  34.8M|    tmp10 = tmp4 + tmp5;        /* phase 2 */
  206|  34.8M|    tmp11 = tmp5 + tmp6;
  207|  34.8M|    tmp12 = tmp6 + tmp7;
  208|       |
  209|       |    /* The rotator is modified from fig 4-8 to avoid extra negations. */
  210|  34.8M|    z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */
  ------------------
  |  |  109|  34.8M|#define MULTIPLY(var, const)  ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
  |  |  ------------------
  |  |  |  |  101|  34.8M|#define DESCALE(x, n)  RIGHT_SHIFT(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  542|  34.8M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  211|  34.8M|    z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */
  ------------------
  |  |  109|  34.8M|#define MULTIPLY(var, const)  ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
  |  |  ------------------
  |  |  |  |  101|  34.8M|#define DESCALE(x, n)  RIGHT_SHIFT(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  542|  34.8M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  212|  34.8M|    z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */
  ------------------
  |  |  109|  34.8M|#define MULTIPLY(var, const)  ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
  |  |  ------------------
  |  |  |  |  101|  34.8M|#define DESCALE(x, n)  RIGHT_SHIFT(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  542|  34.8M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  213|  34.8M|    z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */
  ------------------
  |  |  109|  34.8M|#define MULTIPLY(var, const)  ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
  |  |  ------------------
  |  |  |  |  101|  34.8M|#define DESCALE(x, n)  RIGHT_SHIFT(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  542|  34.8M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  214|       |
  215|  34.8M|    z11 = tmp7 + z3;            /* phase 5 */
  216|  34.8M|    z13 = tmp7 - z3;
  217|       |
  218|  34.8M|    dataptr[DCTSIZE * 5] = z13 + z2; /* phase 6 */
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  219|  34.8M|    dataptr[DCTSIZE * 3] = z13 - z2;
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  220|  34.8M|    dataptr[DCTSIZE * 1] = z11 + z4;
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  221|  34.8M|    dataptr[DCTSIZE * 7] = z11 - z4;
  ------------------
  |  |   66|  34.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  222|       |
  223|  34.8M|    dataptr++;                  /* advance pointer to next column */
  224|  34.8M|  }
  225|  4.36M|}

jpeg12_fdct_islow:
  144|  16.6M|{
  145|  16.6M|  JLONG tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
  146|  16.6M|  JLONG tmp10, tmp11, tmp12, tmp13;
  147|  16.6M|  JLONG z1, z2, z3, z4, z5;
  148|  16.6M|  DCTELEM *dataptr;
  149|  16.6M|  int ctr;
  150|  16.6M|  SHIFT_TEMPS
  151|       |
  152|       |  /* Pass 1: process rows. */
  153|       |  /* Note results are scaled up by sqrt(8) compared to a true DCT; */
  154|       |  /* furthermore, we scale the results by 2**PASS1_BITS. */
  155|       |
  156|  16.6M|  dataptr = data;
  157|   149M|  for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
  ------------------
  |  |   66|  16.6M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (157:27): [True: 133M, False: 16.6M]
  ------------------
  158|   133M|    tmp0 = dataptr[0] + dataptr[7];
  159|   133M|    tmp7 = dataptr[0] - dataptr[7];
  160|   133M|    tmp1 = dataptr[1] + dataptr[6];
  161|   133M|    tmp6 = dataptr[1] - dataptr[6];
  162|   133M|    tmp2 = dataptr[2] + dataptr[5];
  163|   133M|    tmp5 = dataptr[2] - dataptr[5];
  164|   133M|    tmp3 = dataptr[3] + dataptr[4];
  165|   133M|    tmp4 = dataptr[3] - dataptr[4];
  166|       |
  167|       |    /* Even part per LL&M figure 1 --- note that published figure is faulty;
  168|       |     * rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
  169|       |     */
  170|       |
  171|   133M|    tmp10 = tmp0 + tmp3;
  172|   133M|    tmp13 = tmp0 - tmp3;
  173|   133M|    tmp11 = tmp1 + tmp2;
  174|   133M|    tmp12 = tmp1 - tmp2;
  175|       |
  176|   133M|    dataptr[0] = (DCTELEM)LEFT_SHIFT(tmp10 + tmp11, PASS1_BITS);
  ------------------
  |  |   85|   133M|#define LEFT_SHIFT(a, b)  ((JLONG)((unsigned long)(a) << (b)))
  ------------------
  177|   133M|    dataptr[4] = (DCTELEM)LEFT_SHIFT(tmp10 - tmp11, PASS1_BITS);
  ------------------
  |  |   85|   133M|#define LEFT_SHIFT(a, b)  ((JLONG)((unsigned long)(a) << (b)))
  ------------------
  178|       |
  179|   133M|    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  180|   133M|    dataptr[2] = (DCTELEM)DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
  ------------------
  |  |  216|   133M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   133M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  181|   133M|                                  CONST_BITS - PASS1_BITS);
  182|   133M|    dataptr[6] = (DCTELEM)DESCALE(z1 + MULTIPLY(tmp12, -FIX_1_847759065),
  ------------------
  |  |  216|   133M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   133M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  183|   133M|                                  CONST_BITS - PASS1_BITS);
  184|       |
  185|       |    /* Odd part per figure 8 --- note paper omits factor of sqrt(2).
  186|       |     * cK represents cos(K*pi/16).
  187|       |     * i0..i3 in the paper are tmp4..tmp7 here.
  188|       |     */
  189|       |
  190|   133M|    z1 = tmp4 + tmp7;
  191|   133M|    z2 = tmp5 + tmp6;
  192|   133M|    z3 = tmp4 + tmp6;
  193|   133M|    z4 = tmp5 + tmp7;
  194|   133M|    z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  195|       |
  196|   133M|    tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  197|   133M|    tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  198|   133M|    tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  199|   133M|    tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  200|   133M|    z1 = MULTIPLY(z1, -FIX_0_899976223); /* sqrt(2) * ( c7-c3) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  201|   133M|    z2 = MULTIPLY(z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  202|   133M|    z3 = MULTIPLY(z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  203|   133M|    z4 = MULTIPLY(z4, -FIX_0_390180644); /* sqrt(2) * ( c5-c3) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  204|       |
  205|   133M|    z3 += z5;
  206|   133M|    z4 += z5;
  207|       |
  208|   133M|    dataptr[7] = (DCTELEM)DESCALE(tmp4 + z1 + z3, CONST_BITS - PASS1_BITS);
  ------------------
  |  |  216|   133M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   133M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  209|   133M|    dataptr[5] = (DCTELEM)DESCALE(tmp5 + z2 + z4, CONST_BITS - PASS1_BITS);
  ------------------
  |  |  216|   133M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   133M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  210|   133M|    dataptr[3] = (DCTELEM)DESCALE(tmp6 + z2 + z3, CONST_BITS - PASS1_BITS);
  ------------------
  |  |  216|   133M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   133M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  211|   133M|    dataptr[1] = (DCTELEM)DESCALE(tmp7 + z1 + z4, CONST_BITS - PASS1_BITS);
  ------------------
  |  |  216|   133M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   133M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  212|       |
  213|   133M|    dataptr += DCTSIZE;         /* advance pointer to next row */
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  214|   133M|  }
  215|       |
  216|       |  /* Pass 2: process columns.
  217|       |   * We remove the PASS1_BITS scaling, but leave the results scaled up
  218|       |   * by an overall factor of 8.
  219|       |   */
  220|       |
  221|  16.6M|  dataptr = data;
  222|   149M|  for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
  ------------------
  |  |   66|  16.6M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (222:27): [True: 133M, False: 16.6M]
  ------------------
  223|   133M|    tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  224|   133M|    tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  225|   133M|    tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  226|   133M|    tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  227|   133M|    tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  228|   133M|    tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  229|   133M|    tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  230|   133M|    tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  231|       |
  232|       |    /* Even part per LL&M figure 1 --- note that published figure is faulty;
  233|       |     * rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
  234|       |     */
  235|       |
  236|   133M|    tmp10 = tmp0 + tmp3;
  237|   133M|    tmp13 = tmp0 - tmp3;
  238|   133M|    tmp11 = tmp1 + tmp2;
  239|   133M|    tmp12 = tmp1 - tmp2;
  240|       |
  241|   133M|    dataptr[DCTSIZE * 0] = (DCTELEM)DESCALE(tmp10 + tmp11, PASS1_BITS);
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  dataptr[DCTSIZE * 0] = (DCTELEM)DESCALE(tmp10 + tmp11, PASS1_BITS);
  ------------------
  |  |  216|   133M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   133M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  242|   133M|    dataptr[DCTSIZE * 4] = (DCTELEM)DESCALE(tmp10 - tmp11, PASS1_BITS);
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  dataptr[DCTSIZE * 4] = (DCTELEM)DESCALE(tmp10 - tmp11, PASS1_BITS);
  ------------------
  |  |  216|   133M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   133M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  243|       |
  244|   133M|    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  245|   133M|    dataptr[DCTSIZE * 2] =
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  246|   133M|      (DCTELEM)DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
  ------------------
  |  |  216|   133M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   133M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  247|   133M|                       CONST_BITS + PASS1_BITS);
  248|   133M|    dataptr[DCTSIZE * 6] =
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  249|   133M|      (DCTELEM)DESCALE(z1 + MULTIPLY(tmp12, -FIX_1_847759065),
  ------------------
  |  |  216|   133M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   133M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  250|   133M|                       CONST_BITS + PASS1_BITS);
  251|       |
  252|       |    /* Odd part per figure 8 --- note paper omits factor of sqrt(2).
  253|       |     * cK represents cos(K*pi/16).
  254|       |     * i0..i3 in the paper are tmp4..tmp7 here.
  255|       |     */
  256|       |
  257|   133M|    z1 = tmp4 + tmp7;
  258|   133M|    z2 = tmp5 + tmp6;
  259|   133M|    z3 = tmp4 + tmp6;
  260|   133M|    z4 = tmp5 + tmp7;
  261|   133M|    z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  262|       |
  263|   133M|    tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  264|   133M|    tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  265|   133M|    tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  266|   133M|    tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  267|   133M|    z1 = MULTIPLY(z1, -FIX_0_899976223); /* sqrt(2) * ( c7-c3) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  268|   133M|    z2 = MULTIPLY(z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  269|   133M|    z3 = MULTIPLY(z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  270|   133M|    z4 = MULTIPLY(z4, -FIX_0_390180644); /* sqrt(2) * ( c5-c3) */
  ------------------
  |  |  134|   133M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  271|       |
  272|   133M|    z3 += z5;
  273|   133M|    z4 += z5;
  274|       |
  275|   133M|    dataptr[DCTSIZE * 7] = (DCTELEM)DESCALE(tmp4 + z1 + z3,
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  dataptr[DCTSIZE * 7] = (DCTELEM)DESCALE(tmp4 + z1 + z3,
  ------------------
  |  |  216|   133M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   133M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  276|   133M|                                            CONST_BITS + PASS1_BITS);
  277|   133M|    dataptr[DCTSIZE * 5] = (DCTELEM)DESCALE(tmp5 + z2 + z4,
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  dataptr[DCTSIZE * 5] = (DCTELEM)DESCALE(tmp5 + z2 + z4,
  ------------------
  |  |  216|   133M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   133M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  278|   133M|                                            CONST_BITS + PASS1_BITS);
  279|   133M|    dataptr[DCTSIZE * 3] = (DCTELEM)DESCALE(tmp6 + z2 + z3,
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  dataptr[DCTSIZE * 3] = (DCTELEM)DESCALE(tmp6 + z2 + z3,
  ------------------
  |  |  216|   133M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   133M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  280|   133M|                                            CONST_BITS + PASS1_BITS);
  281|   133M|    dataptr[DCTSIZE * 1] = (DCTELEM)DESCALE(tmp7 + z1 + z4,
  ------------------
  |  |   66|   133M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  dataptr[DCTSIZE * 1] = (DCTELEM)DESCALE(tmp7 + z1 + z4,
  ------------------
  |  |  216|   133M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   133M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  282|   133M|                                            CONST_BITS + PASS1_BITS);
  283|       |
  284|   133M|    dataptr++;                  /* advance pointer to next column */
  285|   133M|  }
  286|  16.6M|}

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

jinit_memory_mgr:
 1196|  52.8k|{
 1197|  52.8k|  my_mem_ptr mem;
 1198|  52.8k|  long max_to_use;
 1199|  52.8k|  int pool;
 1200|  52.8k|  size_t test_mac;
 1201|       |
 1202|  52.8k|  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|  52.8k|  if ((ALIGN_SIZE & (ALIGN_SIZE - 1)) != 0)
  ------------------
  |  |   89|  52.8k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
                if ((ALIGN_SIZE & (ALIGN_SIZE - 1)) != 0)
  ------------------
  |  |   89|  52.8k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (1211:7): [Folded, False: 52.8k]
  ------------------
 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|  52.8k|  test_mac = (size_t)MAX_ALLOC_CHUNK;
  ------------------
  |  |   62|  52.8k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
 1219|  52.8k|  if ((long)test_mac != MAX_ALLOC_CHUNK ||
  ------------------
  |  |   62|   105k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (1219:7): [True: 0, False: 52.8k]
  ------------------
 1220|  52.8k|      (MAX_ALLOC_CHUNK % ALIGN_SIZE) != 0)
  ------------------
  |  |   62|  52.8k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
                    (MAX_ALLOC_CHUNK % ALIGN_SIZE) != 0)
  ------------------
  |  |   89|  52.8k|#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|  52.8k|  max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */
 1224|       |
 1225|       |  /* Attempt to allocate memory manager's control block */
 1226|  52.8k|  mem = (my_mem_ptr)jpeg_get_small(cinfo, sizeof(my_memory_mgr));
 1227|       |
 1228|  52.8k|  if (mem == NULL) {
  ------------------
  |  Branch (1228:7): [True: 0, False: 52.8k]
  ------------------
 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|  52.8k|  mem->pub.alloc_small = alloc_small;
 1235|  52.8k|  mem->pub.alloc_large = alloc_large;
 1236|  52.8k|  mem->pub.alloc_sarray = alloc_sarray;
 1237|  52.8k|  mem->pub.alloc_barray = alloc_barray;
 1238|  52.8k|  mem->pub.request_virt_sarray = request_virt_sarray;
 1239|  52.8k|  mem->pub.request_virt_barray = request_virt_barray;
 1240|  52.8k|  mem->pub.realize_virt_arrays = realize_virt_arrays;
 1241|  52.8k|  mem->pub.access_virt_sarray = access_virt_sarray;
 1242|  52.8k|  mem->pub.access_virt_barray = access_virt_barray;
 1243|  52.8k|  mem->pub.free_pool = free_pool;
 1244|  52.8k|  mem->pub.self_destruct = self_destruct;
 1245|       |
 1246|       |  /* Make MAX_ALLOC_CHUNK accessible to other modules */
 1247|  52.8k|  mem->pub.max_alloc_chunk = MAX_ALLOC_CHUNK;
  ------------------
  |  |   62|  52.8k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
 1248|       |
 1249|       |  /* Initialize working state */
 1250|  52.8k|  mem->pub.max_memory_to_use = max_to_use;
 1251|       |
 1252|   158k|  for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  890|  52.8k|#define JPOOL_NUMPOOLS   2
  ------------------
                for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  888|   158k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  |  Branch (1252:35): [True: 105k, False: 52.8k]
  ------------------
 1253|   105k|    mem->small_list[pool] = NULL;
 1254|   105k|    mem->large_list[pool] = NULL;
 1255|   105k|  }
 1256|  52.8k|  mem->virt_sarray_list = NULL;
 1257|  52.8k|  mem->virt_barray_list = NULL;
 1258|       |
 1259|  52.8k|  mem->total_space_allocated = sizeof(my_memory_mgr);
 1260|       |
 1261|       |  /* Declare ourselves open for business */
 1262|  52.8k|  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|  52.8k|#ifndef NO_GETENV
 1271|  52.8k|  {
 1272|  52.8k|    char memenv[30] = { 0 };
 1273|       |
 1274|  52.8k|    if (!GETENV_S(memenv, 30, "JPEGMEM") && strlen(memenv) > 0) {
  ------------------
  |  Branch (1274:9): [True: 52.8k, False: 0]
  |  Branch (1274:45): [True: 0, False: 52.8k]
  ------------------
 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|  52.8k|  }
 1288|  52.8k|#endif
 1289|       |
 1290|  52.8k|}
jmemmgr.c:alloc_small:
  269|   806k|{
  270|   806k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  271|   806k|  small_pool_ptr hdr_ptr, prev_hdr_ptr;
  272|   806k|  char *data_ptr;
  273|   806k|  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|   806k|  if (sizeofobject > MAX_ALLOC_CHUNK) {
  ------------------
  |  |   62|   806k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (281:7): [True: 0, False: 806k]
  ------------------
  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|   806k|  sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
  ------------------
  |  |   89|   806k|#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|   806k|  if ((sizeof(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) >
  ------------------
  |  |   89|   806k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (289:7): [True: 0, False: 806k]
  ------------------
  290|   806k|      MAX_ALLOC_CHUNK)
  ------------------
  |  |   62|   806k|#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|   806k|  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
  ------------------
  |  |  890|   806k|#define JPOOL_NUMPOOLS   2
  ------------------
  |  Branch (294:7): [True: 0, False: 806k]
  |  Branch (294:22): [True: 0, False: 806k]
  ------------------
  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|   806k|  prev_hdr_ptr = NULL;
  297|   806k|  hdr_ptr = mem->small_list[pool_id];
  298|   950k|  while (hdr_ptr != NULL) {
  ------------------
  |  Branch (298:10): [True: 779k, False: 170k]
  ------------------
  299|   779k|    if (hdr_ptr->bytes_left >= sizeofobject)
  ------------------
  |  Branch (299:9): [True: 636k, False: 143k]
  ------------------
  300|   636k|      break;                    /* found pool with enough space */
  301|   143k|    prev_hdr_ptr = hdr_ptr;
  302|   143k|    hdr_ptr = hdr_ptr->next;
  303|   143k|  }
  304|       |
  305|       |  /* Time to make a new pool? */
  306|   806k|  if (hdr_ptr == NULL) {
  ------------------
  |  Branch (306:7): [True: 170k, False: 636k]
  ------------------
  307|       |    /* min_request is what we need now, slop is what will be leftover */
  308|   170k|    min_request = sizeof(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1;
  ------------------
  |  |   89|   170k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  309|   170k|    if (prev_hdr_ptr == NULL)   /* first pool in class? */
  ------------------
  |  Branch (309:9): [True: 119k, False: 51.3k]
  ------------------
  310|   119k|      slop = first_pool_slop[pool_id];
  311|  51.3k|    else
  312|  51.3k|      slop = extra_pool_slop[pool_id];
  313|       |    /* Don't ask for more than MAX_ALLOC_CHUNK */
  314|   170k|    if (slop > (size_t)(MAX_ALLOC_CHUNK - min_request))
  ------------------
  |  |   62|   170k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (314:9): [True: 0, False: 170k]
  ------------------
  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|   170k|    for (;;) {
  318|   170k|      hdr_ptr = (small_pool_ptr)jpeg_get_small(cinfo, min_request + slop);
  319|   170k|      if (hdr_ptr != NULL)
  ------------------
  |  Branch (319:11): [True: 170k, False: 0]
  ------------------
  320|   170k|        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|   170k|    mem->total_space_allocated += min_request + slop;
  326|       |    /* Success, initialize the new pool header and add to end of list */
  327|   170k|    hdr_ptr->next = NULL;
  328|   170k|    hdr_ptr->bytes_used = 0;
  329|   170k|    hdr_ptr->bytes_left = sizeofobject + slop;
  330|   170k|    if (prev_hdr_ptr == NULL)   /* first pool in class? */
  ------------------
  |  Branch (330:9): [True: 119k, False: 51.3k]
  ------------------
  331|   119k|      mem->small_list[pool_id] = hdr_ptr;
  332|  51.3k|    else
  333|  51.3k|      prev_hdr_ptr->next = hdr_ptr;
  334|   170k|  }
  335|       |
  336|       |  /* OK, allocate the object from the current pool */
  337|   806k|  data_ptr = (char *)hdr_ptr; /* point to first data byte in pool... */
  338|   806k|  data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
  339|   806k|  if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
  ------------------
  |  |   89|   806k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (339:7): [True: 806k, False: 0]
  ------------------
  340|   806k|    data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
  ------------------
  |  |   89|   806k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
                  data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
  ------------------
  |  |   89|   806k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  341|   806k|  data_ptr += hdr_ptr->bytes_used; /* point to place for object */
  342|   806k|  hdr_ptr->bytes_used += sizeofobject;
  343|   806k|  hdr_ptr->bytes_left -= sizeofobject;
  344|       |
  345|   806k|  return (void *)data_ptr;
  346|   806k|}
jmemmgr.c:round_up_pow2:
   45|  1.12M|{
   46|  1.12M|  return ((a + b - 1) & (~(b - 1)));
   47|  1.12M|}
jmemmgr.c:alloc_large:
  366|   181k|{
  367|   181k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  368|   181k|  large_pool_ptr hdr_ptr;
  369|   181k|  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|   181k|  if (sizeofobject > MAX_ALLOC_CHUNK) {
  ------------------
  |  |   62|   181k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (376:7): [True: 0, False: 181k]
  ------------------
  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|   181k|  sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
  ------------------
  |  |   89|   181k|#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|   181k|  if ((sizeof(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) >
  ------------------
  |  |   89|   181k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (384:7): [True: 0, False: 181k]
  ------------------
  385|   181k|      MAX_ALLOC_CHUNK)
  ------------------
  |  |   62|   181k|#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|   181k|  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
  ------------------
  |  |  890|   181k|#define JPOOL_NUMPOOLS   2
  ------------------
  |  Branch (389:7): [True: 0, False: 181k]
  |  Branch (389:22): [True: 0, False: 181k]
  ------------------
  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|   181k|  hdr_ptr = (large_pool_ptr)jpeg_get_large(cinfo, sizeofobject +
  393|   181k|                                           sizeof(large_pool_hdr) +
  394|   181k|                                           ALIGN_SIZE - 1);
  ------------------
  |  |   89|   181k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  395|   181k|  if (hdr_ptr == NULL)
  ------------------
  |  Branch (395:7): [True: 0, False: 181k]
  ------------------
  396|      0|    out_of_memory(cinfo, 4);    /* jpeg_get_large failed */
  397|   181k|  mem->total_space_allocated += sizeofobject + sizeof(large_pool_hdr) +
  398|   181k|                                ALIGN_SIZE - 1;
  ------------------
  |  |   89|   181k|#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|   181k|  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|   181k|  hdr_ptr->bytes_used = sizeofobject;
  406|   181k|  hdr_ptr->bytes_left = 0;
  407|   181k|  mem->large_list[pool_id] = hdr_ptr;
  408|       |
  409|   181k|  data_ptr = (char *)hdr_ptr; /* point to first data byte in pool... */
  410|   181k|  data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
  411|   181k|  if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
  ------------------
  |  |   89|   181k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (411:7): [True: 181k, False: 0]
  ------------------
  412|   181k|    data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
  ------------------
  |  |   89|   181k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
                  data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
  ------------------
  |  |   89|   181k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  413|       |
  414|   181k|  return (void *)data_ptr;
  415|   181k|}
jmemmgr.c:alloc_sarray:
  438|   134k|{
  439|   134k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  440|   134k|  JSAMPARRAY result;
  441|   134k|  JSAMPROW workspace;
  442|   134k|  JDIMENSION rowsperchunk, currow, i;
  443|   134k|  long ltemp;
  444|   134k|  J12SAMPARRAY result12;
  445|   134k|  J12SAMPROW workspace12;
  446|   134k|#if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
  447|   134k|  J16SAMPARRAY result16;
  448|   134k|  J16SAMPROW workspace16;
  449|   134k|#endif
  450|   134k|  int data_precision = cinfo->is_decompressor ?
  ------------------
  |  Branch (450:24): [True: 0, False: 134k]
  ------------------
  451|      0|                        ((j_decompress_ptr)cinfo)->data_precision :
  452|   134k|                        ((j_compress_ptr)cinfo)->data_precision;
  453|   134k|  size_t sample_size = data_precision > 12 ?
  ------------------
  |  Branch (453:24): [True: 0, False: 134k]
  ------------------
  454|   134k|                       sizeof(J16SAMPLE) : (data_precision > 8 ?
  ------------------
  |  Branch (454:45): [True: 134k, False: 0]
  ------------------
  455|   134k|                                            sizeof(J12SAMPLE) :
  456|   134k|                                            sizeof(JSAMPLE));
  457|       |
  458|       |  /* Make sure each row is properly aligned */
  459|   134k|  if ((ALIGN_SIZE % sample_size) != 0)
  ------------------
  |  |   89|   134k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (459:7): [True: 0, False: 134k]
  ------------------
  460|      0|    out_of_memory(cinfo, 5);    /* safety check */
  461|       |
  462|   134k|  if (samplesperrow > MAX_ALLOC_CHUNK) {
  ------------------
  |  |   62|   134k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  |  Branch (462:7): [True: 0, False: 134k]
  ------------------
  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|   134k|  samplesperrow = (JDIMENSION)round_up_pow2(samplesperrow, (2 * ALIGN_SIZE) /
  ------------------
  |  |   89|   134k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  468|   134k|                                                           sample_size);
  469|       |
  470|       |  /* Calculate max # of rows allowed in one allocation chunk */
  471|   134k|  ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
  ------------------
  |  |   62|   134k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  472|   134k|          ((long)samplesperrow * (long)sample_size);
  473|   134k|  if (ltemp <= 0)
  ------------------
  |  Branch (473:7): [True: 0, False: 134k]
  ------------------
  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|   134k|  if (ltemp < (long)numrows)
  ------------------
  |  Branch (475:7): [True: 0, False: 134k]
  ------------------
  476|      0|    rowsperchunk = (JDIMENSION)ltemp;
  477|   134k|  else
  478|   134k|    rowsperchunk = numrows;
  479|   134k|  mem->last_rowsperchunk = rowsperchunk;
  480|       |
  481|   134k|  if (data_precision <= 8) {
  ------------------
  |  Branch (481:7): [True: 0, False: 134k]
  ------------------
  482|       |    /* Get space for row pointers (small object) */
  483|      0|    result = (JSAMPARRAY)alloc_small(cinfo, pool_id,
  484|      0|                                     (size_t)(numrows * sizeof(JSAMPROW)));
  485|       |
  486|       |    /* Get the rows themselves (large objects) */
  487|      0|    currow = 0;
  488|      0|    while (currow < numrows) {
  ------------------
  |  Branch (488:12): [True: 0, False: 0]
  ------------------
  489|      0|      rowsperchunk = MIN(rowsperchunk, numrows - currow);
  ------------------
  |  |  515|      0|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  490|      0|      workspace = (JSAMPROW)alloc_large(cinfo, pool_id,
  491|      0|        (size_t)((size_t)rowsperchunk * (size_t)samplesperrow * sample_size));
  492|      0|      for (i = rowsperchunk; i > 0; i--) {
  ------------------
  |  Branch (492:30): [True: 0, False: 0]
  ------------------
  493|      0|        result[currow++] = workspace;
  494|      0|        workspace += samplesperrow;
  495|      0|      }
  496|      0|    }
  497|       |
  498|      0|    return result;
  499|   134k|  } else if (data_precision <= 12) {
  ------------------
  |  Branch (499:14): [True: 134k, False: 0]
  ------------------
  500|       |    /* Get space for row pointers (small object) */
  501|   134k|    result12 = (J12SAMPARRAY)alloc_small(cinfo, pool_id,
  502|   134k|                                         (size_t)(numrows *
  503|   134k|                                                  sizeof(J12SAMPROW)));
  504|       |
  505|       |    /* Get the rows themselves (large objects) */
  506|   134k|    currow = 0;
  507|   268k|    while (currow < numrows) {
  ------------------
  |  Branch (507:12): [True: 134k, False: 134k]
  ------------------
  508|   134k|      rowsperchunk = MIN(rowsperchunk, numrows - currow);
  ------------------
  |  |  515|   134k|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 0, False: 134k]
  |  |  ------------------
  ------------------
  509|   134k|      workspace12 = (J12SAMPROW)alloc_large(cinfo, pool_id,
  510|   134k|        (size_t)((size_t)rowsperchunk * (size_t)samplesperrow * sample_size));
  511|   724k|      for (i = rowsperchunk; i > 0; i--) {
  ------------------
  |  Branch (511:30): [True: 590k, False: 134k]
  ------------------
  512|   590k|        result12[currow++] = workspace12;
  513|   590k|        workspace12 += samplesperrow;
  514|   590k|      }
  515|   134k|    }
  516|       |
  517|   134k|    return (JSAMPARRAY)result12;
  518|   134k|  } 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|   134k|}
jmemmgr.c:alloc_barray:
  555|  43.9k|{
  556|  43.9k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  557|  43.9k|  JBLOCKARRAY result;
  558|  43.9k|  JBLOCKROW workspace;
  559|  43.9k|  JDIMENSION rowsperchunk, currow, i;
  560|  43.9k|  long ltemp;
  561|       |
  562|       |  /* Make sure each row is properly aligned */
  563|  43.9k|  if ((sizeof(JBLOCK) % ALIGN_SIZE) != 0)
  ------------------
  |  |   89|  43.9k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
  |  Branch (563:7): [Folded, False: 43.9k]
  ------------------
  564|      0|    out_of_memory(cinfo, 6);    /* safety check */
  565|       |
  566|       |  /* Calculate max # of rows allowed in one allocation chunk */
  567|  43.9k|  ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
  ------------------
  |  |   62|  43.9k|#define MAX_ALLOC_CHUNK  1000000000L
  ------------------
  568|  43.9k|          ((long)blocksperrow * sizeof(JBLOCK));
  569|  43.9k|  if (ltemp <= 0)
  ------------------
  |  Branch (569:7): [True: 0, False: 43.9k]
  ------------------
  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|  43.9k|  if (ltemp < (long)numrows)
  ------------------
  |  Branch (571:7): [True: 0, False: 43.9k]
  ------------------
  572|      0|    rowsperchunk = (JDIMENSION)ltemp;
  573|  43.9k|  else
  574|  43.9k|    rowsperchunk = numrows;
  575|  43.9k|  mem->last_rowsperchunk = rowsperchunk;
  576|       |
  577|       |  /* Get space for row pointers (small object) */
  578|  43.9k|  result = (JBLOCKARRAY)alloc_small(cinfo, pool_id,
  579|  43.9k|                                    (size_t)(numrows * sizeof(JBLOCKROW)));
  580|       |
  581|       |  /* Get the rows themselves (large objects) */
  582|  43.9k|  currow = 0;
  583|  87.9k|  while (currow < numrows) {
  ------------------
  |  Branch (583:10): [True: 43.9k, False: 43.9k]
  ------------------
  584|  43.9k|    rowsperchunk = MIN(rowsperchunk, numrows - currow);
  ------------------
  |  |  515|  43.9k|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 0, False: 43.9k]
  |  |  ------------------
  ------------------
  585|  43.9k|    workspace = (JBLOCKROW)alloc_large(cinfo, pool_id,
  586|  43.9k|        (size_t)((size_t)rowsperchunk * (size_t)blocksperrow *
  587|  43.9k|                  sizeof(JBLOCK)));
  588|  7.55M|    for (i = rowsperchunk; i > 0; i--) {
  ------------------
  |  Branch (588:28): [True: 7.51M, False: 43.9k]
  ------------------
  589|  7.51M|      result[currow++] = workspace;
  590|  7.51M|      workspace += blocksperrow;
  591|  7.51M|    }
  592|  43.9k|  }
  593|       |
  594|  43.9k|  return result;
  595|  43.9k|}
jmemmgr.c:request_virt_barray:
  670|  43.9k|{
  671|  43.9k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  672|  43.9k|  jvirt_barray_ptr result;
  673|       |
  674|       |  /* Only IMAGE-lifetime virtual arrays are currently supported */
  675|  43.9k|  if (pool_id != JPOOL_IMAGE)
  ------------------
  |  |  889|  43.9k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  |  Branch (675:7): [True: 0, False: 43.9k]
  ------------------
  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|  43.9k|  result = (jvirt_barray_ptr)alloc_small(cinfo, pool_id,
  680|  43.9k|                                         sizeof(struct jvirt_barray_control));
  681|       |
  682|  43.9k|  result->mem_buffer = NULL;    /* marks array not yet realized */
  683|  43.9k|  result->rows_in_array = numrows;
  684|  43.9k|  result->blocksperrow = blocksperrow;
  685|  43.9k|  result->maxaccess = maxaccess;
  686|  43.9k|  result->pre_zero = pre_zero;
  687|  43.9k|  result->b_s_open = FALSE;     /* no associated backing-store object */
  ------------------
  |  |  207|  43.9k|#define FALSE   0               /* values of boolean */
  ------------------
  688|  43.9k|  result->next = mem->virt_barray_list; /* add to list of virtual arrays */
  689|  43.9k|  mem->virt_barray_list = result;
  690|       |
  691|  43.9k|  return result;
  692|  43.9k|}
jmemmgr.c:realize_virt_arrays:
  698|  41.3k|{
  699|  41.3k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
  700|  41.3k|  size_t space_per_minheight, maximum_space, avail_mem;
  701|  41.3k|  size_t minheights, max_minheights;
  702|  41.3k|  jvirt_sarray_ptr sptr;
  703|  41.3k|  jvirt_barray_ptr bptr;
  704|  41.3k|  int data_precision = cinfo->is_decompressor ?
  ------------------
  |  Branch (704:24): [True: 0, False: 41.3k]
  ------------------
  705|      0|                        ((j_decompress_ptr)cinfo)->data_precision :
  706|  41.3k|                        ((j_compress_ptr)cinfo)->data_precision;
  707|  41.3k|  size_t sample_size = data_precision > 12 ?
  ------------------
  |  Branch (707:24): [True: 0, False: 41.3k]
  ------------------
  708|  41.3k|                       sizeof(J16SAMPLE) : (data_precision > 8 ?
  ------------------
  |  Branch (708:45): [True: 41.3k, False: 0]
  ------------------
  709|  41.3k|                                            sizeof(J12SAMPLE) :
  710|  41.3k|                                            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|  41.3k|  space_per_minheight = 0;
  717|  41.3k|  maximum_space = 0;
  718|  41.3k|  for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
  ------------------
  |  Branch (718:38): [True: 0, False: 41.3k]
  ------------------
  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|  85.3k|  for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
  ------------------
  |  Branch (730:38): [True: 43.9k, False: 41.3k]
  ------------------
  731|  43.9k|    if (bptr->mem_buffer == NULL) { /* if not realized yet */
  ------------------
  |  Branch (731:9): [True: 43.9k, False: 0]
  ------------------
  732|  43.9k|      size_t new_space = (size_t)bptr->rows_in_array *
  733|  43.9k|                         (size_t)bptr->blocksperrow * sizeof(JBLOCK);
  734|       |
  735|  43.9k|      space_per_minheight += (size_t)bptr->maxaccess *
  736|  43.9k|                             (size_t)bptr->blocksperrow * sizeof(JBLOCK);
  737|  43.9k|      if (SIZE_MAX - maximum_space < new_space)
  ------------------
  |  Branch (737:11): [True: 0, False: 43.9k]
  ------------------
  738|      0|        out_of_memory(cinfo, 11);
  739|  43.9k|      maximum_space += new_space;
  740|  43.9k|    }
  741|  43.9k|  }
  742|       |
  743|  41.3k|  if (space_per_minheight <= 0)
  ------------------
  |  Branch (743:7): [True: 23.3k, False: 18.0k]
  ------------------
  744|  23.3k|    return;                     /* no unrealized arrays, no work */
  745|       |
  746|       |  /* Determine amount of memory to actually use; this is system-dependent. */
  747|  18.0k|  avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space,
  748|  18.0k|                                 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|  18.0k|  if (avail_mem >= maximum_space)
  ------------------
  |  Branch (754:7): [True: 18.0k, False: 0]
  ------------------
  755|  18.0k|    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|  18.0k|  for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
  ------------------
  |  Branch (767:38): [True: 0, False: 18.0k]
  ------------------
  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|  62.0k|  for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
  ------------------
  |  Branch (791:38): [True: 43.9k, False: 18.0k]
  ------------------
  792|  43.9k|    if (bptr->mem_buffer == NULL) { /* if not realized yet */
  ------------------
  |  Branch (792:9): [True: 43.9k, False: 0]
  ------------------
  793|  43.9k|      minheights = ((long)bptr->rows_in_array - 1L) / bptr->maxaccess + 1L;
  794|  43.9k|      if (minheights <= max_minheights) {
  ------------------
  |  Branch (794:11): [True: 43.9k, False: 0]
  ------------------
  795|       |        /* This buffer fits in memory */
  796|  43.9k|        bptr->rows_in_mem = bptr->rows_in_array;
  797|  43.9k|      } 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|  43.9k|      bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  43.9k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  807|  43.9k|                                      bptr->blocksperrow, bptr->rows_in_mem);
  808|  43.9k|      bptr->rowsperchunk = mem->last_rowsperchunk;
  809|  43.9k|      bptr->cur_start_row = 0;
  810|  43.9k|      bptr->first_undef_row = 0;
  811|  43.9k|      bptr->dirty = FALSE;
  ------------------
  |  |  207|  43.9k|#define FALSE   0               /* values of boolean */
  ------------------
  812|  43.9k|    }
  813|  43.9k|  }
  814|  18.0k|}
jmemmgr.c:access_virt_barray:
 1015|  29.2M|{
 1016|  29.2M|  JDIMENSION end_row = start_row + num_rows;
 1017|  29.2M|  JDIMENSION undef_row;
 1018|       |
 1019|       |  /* debugging check */
 1020|  29.2M|  if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess ||
  ------------------
  |  Branch (1020:7): [True: 0, False: 29.2M]
  |  Branch (1020:39): [True: 0, False: 29.2M]
  ------------------
 1021|  29.2M|      ptr->mem_buffer == NULL)
  ------------------
  |  Branch (1021:7): [True: 0, False: 29.2M]
  ------------------
 1022|      0|    ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
 1023|       |
 1024|       |  /* Make the desired part of the virtual array accessible */
 1025|  29.2M|  if (start_row < ptr->cur_start_row ||
  ------------------
  |  Branch (1025:7): [True: 0, False: 29.2M]
  ------------------
 1026|  29.2M|      end_row > ptr->cur_start_row + ptr->rows_in_mem) {
  ------------------
  |  Branch (1026:7): [True: 0, False: 29.2M]
  ------------------
 1027|      0|    if (!ptr->b_s_open)
  ------------------
  |  Branch (1027:9): [True: 0, False: 0]
  ------------------
 1028|      0|      ERREXIT(cinfo, JERR_VIRTUAL_BUG);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
 1029|       |    /* Flush old buffer contents if necessary */
 1030|      0|    if (ptr->dirty) {
  ------------------
  |  Branch (1030:9): [True: 0, False: 0]
  ------------------
 1031|      0|      do_barray_io(cinfo, ptr, TRUE);
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
 1032|      0|      ptr->dirty = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
 1033|      0|    }
 1034|       |    /* Decide what part of virtual array to access.
 1035|       |     * Algorithm: if target address > current window, assume forward scan,
 1036|       |     * load starting at target address.  If target address < current window,
 1037|       |     * assume backward scan, load so that target area is top of window.
 1038|       |     * Note that when switching from forward write to forward read, will have
 1039|       |     * start_row = 0, so the limiting case applies and we load from 0 anyway.
 1040|       |     */
 1041|      0|    if (start_row > ptr->cur_start_row) {
  ------------------
  |  Branch (1041:9): [True: 0, False: 0]
  ------------------
 1042|      0|      ptr->cur_start_row = start_row;
 1043|      0|    } else {
 1044|       |      /* use long arithmetic here to avoid overflow & unsigned problems */
 1045|      0|      long ltemp;
 1046|       |
 1047|      0|      ltemp = (long)end_row - (long)ptr->rows_in_mem;
 1048|      0|      if (ltemp < 0)
  ------------------
  |  Branch (1048:11): [True: 0, False: 0]
  ------------------
 1049|      0|        ltemp = 0;              /* don't fall off front end of file */
 1050|      0|      ptr->cur_start_row = (JDIMENSION)ltemp;
 1051|      0|    }
 1052|       |    /* Read in the selected part of the array.
 1053|       |     * During the initial write pass, we will do no actual read
 1054|       |     * because the selected part is all undefined.
 1055|       |     */
 1056|      0|    do_barray_io(cinfo, ptr, FALSE);
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
 1057|      0|  }
 1058|       |  /* Ensure the accessed part of the array is defined; prezero if needed.
 1059|       |   * To improve locality of access, we only prezero the part of the array
 1060|       |   * that the caller is about to access, not the entire in-memory array.
 1061|       |   */
 1062|  29.2M|  if (ptr->first_undef_row < end_row) {
  ------------------
  |  Branch (1062:7): [True: 6.96M, False: 22.3M]
  ------------------
 1063|  6.96M|    if (ptr->first_undef_row < start_row) {
  ------------------
  |  Branch (1063:9): [True: 0, False: 6.96M]
  ------------------
 1064|      0|      if (writable)             /* writer skipped over a section of array */
  ------------------
  |  Branch (1064:11): [True: 0, False: 0]
  ------------------
 1065|      0|        ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
 1066|      0|      undef_row = start_row;    /* but reader is allowed to read ahead */
 1067|  6.96M|    } else {
 1068|  6.96M|      undef_row = ptr->first_undef_row;
 1069|  6.96M|    }
 1070|  6.96M|    if (writable)
  ------------------
  |  Branch (1070:9): [True: 6.96M, False: 0]
  ------------------
 1071|  6.96M|      ptr->first_undef_row = end_row;
 1072|  6.96M|    if (ptr->pre_zero) {
  ------------------
  |  Branch (1072:9): [True: 0, False: 6.96M]
  ------------------
 1073|      0|      size_t bytesperrow = (size_t)ptr->blocksperrow * sizeof(JBLOCK);
 1074|      0|      undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
 1075|      0|      end_row -= ptr->cur_start_row;
 1076|      0|      while (undef_row < end_row) {
  ------------------
  |  Branch (1076:14): [True: 0, False: 0]
  ------------------
 1077|      0|        jzero_far((void *)ptr->mem_buffer[undef_row], bytesperrow);
 1078|      0|        undef_row++;
 1079|      0|      }
 1080|  6.96M|    } else {
 1081|  6.96M|      if (!writable)            /* reader looking at undefined data */
  ------------------
  |  Branch (1081:11): [True: 0, False: 6.96M]
  ------------------
 1082|      0|        ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
 1083|  6.96M|    }
 1084|  6.96M|  }
 1085|       |  /* Flag the buffer dirty if caller will write in it */
 1086|  29.2M|  if (writable)
  ------------------
  |  Branch (1086:7): [True: 6.96M, False: 22.3M]
  ------------------
 1087|  6.96M|    ptr->dirty = TRUE;
  ------------------
  |  |  210|  6.96M|#define TRUE    1
  ------------------
 1088|       |  /* Return address of proper part of the buffer */
 1089|  29.2M|  return ptr->mem_buffer + (start_row - ptr->cur_start_row);
 1090|  29.2M|}
jmemmgr.c:free_pool:
 1099|   126k|{
 1100|   126k|  my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
 1101|   126k|  small_pool_ptr shdr_ptr;
 1102|   126k|  large_pool_ptr lhdr_ptr;
 1103|   126k|  size_t space_freed;
 1104|       |
 1105|   126k|  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
  ------------------
  |  |  890|   126k|#define JPOOL_NUMPOOLS   2
  ------------------
  |  Branch (1105:7): [True: 0, False: 126k]
  |  Branch (1105:22): [True: 0, False: 126k]
  ------------------
 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|   126k|  if (pool_id == JPOOL_IMAGE) {
  ------------------
  |  |  889|   126k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  |  Branch (1114:7): [True: 73.6k, False: 52.8k]
  ------------------
 1115|  73.6k|    jvirt_sarray_ptr sptr;
 1116|  73.6k|    jvirt_barray_ptr bptr;
 1117|       |
 1118|  73.6k|    for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
  ------------------
  |  Branch (1118:40): [True: 0, False: 73.6k]
  ------------------
 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|  73.6k|    mem->virt_sarray_list = NULL;
 1125|   117k|    for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
  ------------------
  |  Branch (1125:40): [True: 43.9k, False: 73.6k]
  ------------------
 1126|  43.9k|      if (bptr->b_s_open) {     /* there may be no backing store */
  ------------------
  |  Branch (1126:11): [True: 0, False: 43.9k]
  ------------------
 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|  43.9k|    }
 1131|  73.6k|    mem->virt_barray_list = NULL;
 1132|  73.6k|  }
 1133|       |
 1134|       |  /* Release large objects */
 1135|   126k|  lhdr_ptr = mem->large_list[pool_id];
 1136|   126k|  mem->large_list[pool_id] = NULL;
 1137|       |
 1138|   307k|  while (lhdr_ptr != NULL) {
  ------------------
  |  Branch (1138:10): [True: 181k, False: 126k]
  ------------------
 1139|   181k|    large_pool_ptr next_lhdr_ptr = lhdr_ptr->next;
 1140|   181k|    space_freed = lhdr_ptr->bytes_used +
 1141|   181k|                  lhdr_ptr->bytes_left +
 1142|   181k|                  sizeof(large_pool_hdr) + ALIGN_SIZE - 1;
  ------------------
  |  |   89|   181k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
 1143|   181k|    jpeg_free_large(cinfo, (void *)lhdr_ptr, space_freed);
 1144|   181k|    mem->total_space_allocated -= space_freed;
 1145|   181k|    lhdr_ptr = next_lhdr_ptr;
 1146|   181k|  }
 1147|       |
 1148|       |  /* Release small objects */
 1149|   126k|  shdr_ptr = mem->small_list[pool_id];
 1150|   126k|  mem->small_list[pool_id] = NULL;
 1151|       |
 1152|   297k|  while (shdr_ptr != NULL) {
  ------------------
  |  Branch (1152:10): [True: 170k, False: 126k]
  ------------------
 1153|   170k|    small_pool_ptr next_shdr_ptr = shdr_ptr->next;
 1154|   170k|    space_freed = shdr_ptr->bytes_used + shdr_ptr->bytes_left +
 1155|   170k|                  sizeof(small_pool_hdr) + ALIGN_SIZE - 1;
  ------------------
  |  |   89|   170k|#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
  ------------------
 1156|   170k|    jpeg_free_small(cinfo, (void *)shdr_ptr, space_freed);
 1157|   170k|    mem->total_space_allocated -= space_freed;
 1158|   170k|    shdr_ptr = next_shdr_ptr;
 1159|   170k|  }
 1160|   126k|}
jmemmgr.c:self_destruct:
 1170|  52.8k|{
 1171|  52.8k|  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|   158k|  for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  890|  52.8k|#define JPOOL_NUMPOOLS   2
  ------------------
                for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
  ------------------
  |  |  888|   158k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  |  Branch (1177:35): [True: 105k, False: 52.8k]
  ------------------
 1178|   105k|    free_pool(cinfo, pool);
 1179|   105k|  }
 1180|       |
 1181|       |  /* Release the memory manager control block too. */
 1182|  52.8k|  jpeg_free_small(cinfo, (void *)cinfo->mem, sizeof(my_memory_mgr));
 1183|  52.8k|  cinfo->mem = NULL;            /* ensures I will be called only once */
 1184|       |
 1185|  52.8k|  jpeg_mem_term(cinfo);         /* system-dependent cleanup */
 1186|  52.8k|}

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

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

jdiv_round_up:
   81|   265k|{
   82|   265k|  return (a + b - 1L) / b;
   83|   265k|}
jround_up:
   90|  87.9k|{
   91|  87.9k|  a += b - 1L;
   92|  87.9k|  return a - (a % b);
   93|  87.9k|}
jzero_far:
  144|  1.88M|{
  145|  1.88M|  memset(target, 0, bytestozero);
  146|  1.88M|}
j12copy_sample_rows:
  110|  36.3M|{
  111|  36.3M|  register _JSAMPROW inptr, outptr;
  112|  36.3M|  register size_t count = (size_t)(num_cols * sizeof(_JSAMPLE));
  113|  36.3M|  register int row;
  114|       |
  115|  36.3M|  input_array += source_row;
  116|  36.3M|  output_array += dest_row;
  117|       |
  118|  79.1M|  for (row = num_rows; row > 0; row--) {
  ------------------
  |  Branch (118:24): [True: 42.8M, False: 36.3M]
  ------------------
  119|  42.8M|    inptr = *input_array++;
  120|  42.8M|    outptr = *output_array++;
  121|  42.8M|    memcpy(outptr, inptr, count);
  122|  42.8M|  }
  123|  36.3M|}

jinit_read_bmp:
  662|     21|{
  663|     21|  bmp_source_ptr source;
  664|       |
  665|     21|  if (cinfo->data_precision != 8)
  ------------------
  |  Branch (665:7): [True: 21, False: 0]
  ------------------
  666|     21|    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|     21|  ((cinfo)->err->msg_code = (code), \
  |  |  244|     21|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|     21|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  667|       |
  668|       |  /* Create module interface object */
  669|     21|  source = (bmp_source_ptr)
  670|     21|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|     21|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  671|     21|                                sizeof(bmp_source_struct));
  672|     21|  source->cinfo = cinfo;        /* make back link for subroutines */
  673|       |  /* Fill in method ptrs, except get_pixel_rows which start_input sets */
  674|     21|  source->pub.start_input = start_input_bmp;
  675|     21|  source->pub.read_icc_profile = read_icc_profile_bmp;
  676|     21|  source->pub.finish_input = finish_input_bmp;
  677|     21|  source->pub.max_pixels = 0;
  678|       |
  679|     21|  source->use_inversion_array = use_inversion_array;
  680|       |
  681|     21|  return (cjpeg_source_ptr)source;
  682|     21|}

j12init_read_png:
  703|  28.3k|{
  704|  28.3k|  png_source_ptr source;
  705|       |
  706|       |#if BITS_IN_JSAMPLE == 8
  707|       |  if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  708|       |#else
  709|  28.3k|  if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  ------------------
  |  |   12|  56.7k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (709:7): [True: 0, False: 28.3k]
  ------------------
  710|  28.3k|      cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  ------------------
  |  |   12|  28.3k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (710:7): [True: 0, False: 28.3k]
  ------------------
  711|      0|#endif
  712|      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)))
  ------------------
  713|       |
  714|       |  /* Create module interface object */
  715|  28.3k|  source = (png_source_ptr)
  716|  28.3k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  28.3k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  717|  28.3k|                                sizeof(png_source_struct));
  718|       |  /* Fill in method ptrs, except get_pixel_rows which start_input sets */
  719|  28.3k|  source->pub.start_input = start_input_png;
  720|  28.3k|  source->pub.read_icc_profile = read_icc_profile_png;
  721|  28.3k|  source->pub.finish_input = finish_input_png;
  722|  28.3k|  source->pub.max_pixels = 0;
  723|       |
  724|  28.3k|  return (cjpeg_source_ptr)source;
  725|  28.3k|}
rdpng-12.c:start_input_png:
  472|  28.3k|{
  473|  28.3k|  png_source_ptr source = (png_source_ptr)sinfo;
  474|  28.3k|  struct spng_ihdr ihdr;
  475|  28.3k|  int png_components = 3;
  476|  28.3k|  boolean use_raw_buffer;
  477|       |#ifdef ZERO_BUFFERS
  478|       |  struct spng_alloc alloc;
  479|       |
  480|       |  alloc.malloc_fn = spng_malloc;
  481|       |  alloc.realloc_fn = realloc;
  482|       |  alloc.calloc_fn = calloc;
  483|       |  alloc.free_fn = free;
  484|       |  source->ctx = spng_ctx_new2(&alloc, 0);
  485|       |#else
  486|  28.3k|  source->ctx = spng_ctx_new(0);
  487|  28.3k|#endif
  488|  28.3k|  if (!source->ctx)
  ------------------
  |  Branch (488:7): [True: 0, False: 28.3k]
  ------------------
  489|      0|    ERREXITS(cinfo, JERR_PNG_LIBSPNG, "Could not create context");
  ------------------
  |  |  274|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  275|      0|   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX - 1), \
  |  |  ------------------
  |  |  |  |  800|      0|#define JMSG_STR_PARM_MAX  80
  |  |  ------------------
  |  |  276|      0|   (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
  |  |  ------------------
  |  |  |  |  800|      0|#define JMSG_STR_PARM_MAX  80
  |  |  ------------------
  |  |  277|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  490|       |
  491|  28.3k|  TRY_SPNG(spng_set_png_file(source->ctx, sinfo->input_file));
  ------------------
  |  |   33|  28.3k|#define TRY_SPNG(f) { \
  |  |   34|  28.3k|  int __spng_error = (f); \
  |  |   35|  28.3k|  if (__spng_error) \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 0, False: 28.3k]
  |  |  ------------------
  |  |   36|  28.3k|    ERREXITS(cinfo, JERR_PNG_LIBSPNG, spng_strerror(__spng_error)); \
  |  |  ------------------
  |  |  |  |  274|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  |  |  275|      0|   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX - 1), \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|      0|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  276|      0|   (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|      0|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  277|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  |  |  ------------------
  |  |   37|  28.3k|}
  ------------------
  492|       |
  493|  28.3k|  TRY_SPNG(spng_get_ihdr(source->ctx, &ihdr));
  ------------------
  |  |   33|  28.3k|#define TRY_SPNG(f) { \
  |  |   34|  28.3k|  int __spng_error = (f); \
  |  |   35|  28.3k|  if (__spng_error) \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 1.46k, False: 26.9k]
  |  |  ------------------
  |  |   36|  28.3k|    ERREXITS(cinfo, JERR_PNG_LIBSPNG, spng_strerror(__spng_error)); \
  |  |  ------------------
  |  |  |  |  274|  1.46k|  ((cinfo)->err->msg_code = (code), \
  |  |  |  |  275|  1.46k|   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX - 1), \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|  1.46k|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  276|  1.46k|   (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|  1.46k|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  277|  1.46k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  |  |  ------------------
  |  |   37|  28.3k|}
  ------------------
  494|       |
  495|  28.3k|  if (ihdr.width > JPEG_MAX_DIMENSION || ihdr.height > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  56.7k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
                if (ihdr.width > JPEG_MAX_DIMENSION || ihdr.height > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  23.7k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (495:7): [True: 4.57k, False: 23.7k]
  |  Branch (495:42): [True: 868, False: 22.9k]
  ------------------
  496|  3.98k|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, JPEG_MAX_DIMENSION);
  ------------------
  |  |  243|  3.98k|  ((cinfo)->err->msg_code = (code), \
  |  |  244|  3.98k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|  3.98k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  497|  28.3k|  if (ihdr.bit_depth != 8 && ihdr.bit_depth != 16)
  ------------------
  |  Branch (497:7): [True: 10.4k, False: 17.9k]
  |  Branch (497:30): [True: 6.29k, False: 4.11k]
  ------------------
  498|  6.29k|    ERREXIT(cinfo, JERR_PNG_BADDEPTH);
  ------------------
  |  |  240|  6.29k|  ((cinfo)->err->msg_code = (code), \
  |  |  241|  6.29k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  499|  28.3k|  if (sinfo->max_pixels &&
  ------------------
  |  Branch (499:7): [True: 16.6k, False: 11.7k]
  ------------------
  500|  16.6k|      (unsigned long long)ihdr.width * ihdr.height > sinfo->max_pixels)
  ------------------
  |  Branch (500:7): [True: 238, False: 16.3k]
  ------------------
  501|    238|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
  ------------------
  |  |  243|    238|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    238|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    238|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  502|       |
  503|  28.3k|  cinfo->image_width = (JDIMENSION)ihdr.width;
  504|  28.3k|  cinfo->image_height = (JDIMENSION)ihdr.height;
  505|  28.3k|  source->png_bit_depth = ihdr.bit_depth;
  506|  28.3k|  source->png_color_type = ihdr.color_type;
  507|       |
  508|       |  /* initialize flags to most common settings */
  509|  28.3k|  use_raw_buffer = FALSE;       /* do we map input buffer onto I/O buffer? */
  ------------------
  |  |  207|  28.3k|#define FALSE   0               /* values of boolean */
  ------------------
  510|       |
  511|  28.3k|  switch (ihdr.color_type) {
  512|    483|  case SPNG_COLOR_TYPE_GRAYSCALE_ALPHA:
  ------------------
  |  Branch (512:3): [True: 483, False: 27.8k]
  ------------------
  513|  5.40k|  case SPNG_COLOR_TYPE_GRAYSCALE:
  ------------------
  |  Branch (513:3): [True: 4.92k, False: 23.4k]
  ------------------
  514|  5.40k|    if (cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (514:9): [True: 0, False: 5.40k]
  ------------------
  515|  5.40k|        cinfo->in_color_space == JCS_RGB)
  ------------------
  |  Branch (515:9): [True: 0, False: 5.40k]
  ------------------
  516|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  517|  5.40k|    TRACEMS3(cinfo, 1, JTRC_PNG_GRAYSCALE, ihdr.width, ihdr.height,
  ------------------
  |  |  309|  5.40k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  5.40k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 5.40k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  5.40k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  5.40k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  5.40k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  518|  5.40k|             ihdr.bit_depth);
  519|  5.40k|    if (cinfo->in_color_space == JCS_GRAYSCALE) {
  ------------------
  |  Branch (519:9): [True: 772, False: 4.63k]
  ------------------
  520|    772|      if (ihdr.color_type == SPNG_COLOR_TYPE_GRAYSCALE &&
  ------------------
  |  Branch (520:11): [True: 703, False: 69]
  ------------------
  521|    703|          cinfo->data_precision == ihdr.bit_depth) {
  ------------------
  |  Branch (521:11): [True: 0, False: 703]
  ------------------
  522|      0|        source->pub.get_pixel_rows = get_raw_row;
  523|      0|        use_raw_buffer = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  524|      0|      } else
  525|    772|        source->pub.get_pixel_rows = get_gray_row;
  526|  4.63k|    } else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  4.63k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 4.63k]
  |  |  |  Branch (78:22): [True: 3.86k, False: 772]
  |  |  |  Branch (78:43): [True: 3.86k, False: 0]
  |  |  ------------------
  ------------------
  527|  3.86k|      source->pub.get_pixel_rows = get_gray_rgb_row;
  528|    772|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (528:14): [True: 772, False: 0]
  ------------------
  529|    772|        source->pub.get_pixel_rows = get_gray_cmyk_row;
  530|      0|    else
  531|      0|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  532|  5.40k|    if (ihdr.color_type == SPNG_COLOR_TYPE_GRAYSCALE_ALPHA) {
  ------------------
  |  Branch (532:9): [True: 483, False: 4.92k]
  ------------------
  533|    483|      png_components = 2;
  534|    483|      source->png_alpha = 1;
  535|  4.92k|    } else {
  536|  4.92k|      png_components = 1;
  537|  4.92k|      source->png_alpha = 0;
  538|  4.92k|    }
  539|  5.40k|    break;
  540|       |
  541|  7.29k|  case SPNG_COLOR_TYPE_TRUECOLOR:
  ------------------
  |  Branch (541:3): [True: 7.29k, False: 21.0k]
  ------------------
  542|  10.5k|  case SPNG_COLOR_TYPE_TRUECOLOR_ALPHA:
  ------------------
  |  Branch (542:3): [True: 3.22k, False: 25.1k]
  ------------------
  543|  10.5k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (543:9): [True: 0, False: 10.5k]
  ------------------
  544|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  545|  10.5k|    TRACEMS3(cinfo, 1, JTRC_PNG_TRUECOLOR, ihdr.width, ihdr.height,
  ------------------
  |  |  309|  10.5k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  10.5k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 10.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  10.5k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  10.5k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  10.5k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  546|  10.5k|             ihdr.bit_depth);
  547|  10.5k|    if (ihdr.color_type == SPNG_COLOR_TYPE_TRUECOLOR &&
  ------------------
  |  Branch (547:9): [True: 7.29k, False: 3.22k]
  ------------------
  548|  7.29k|        cinfo->data_precision == ihdr.bit_depth &&
  ------------------
  |  Branch (548:9): [True: 0, False: 7.29k]
  ------------------
  549|      0|#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3
  550|      0|        (cinfo->in_color_space == JCS_EXT_RGB ||
  ------------------
  |  Branch (550:10): [True: 0, False: 0]
  ------------------
  551|      0|         cinfo->in_color_space == JCS_RGB)) {
  ------------------
  |  Branch (551:10): [True: 0, False: 0]
  ------------------
  552|       |#else
  553|       |        cinfo->in_color_space == JCS_EXT_RGB) {
  554|       |#endif
  555|      0|      source->pub.get_pixel_rows = get_raw_row;
  556|      0|      use_raw_buffer = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  557|  10.5k|    } else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  10.5k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 10.5k]
  |  |  |  Branch (78:22): [True: 7.51k, False: 3.00k]
  |  |  |  Branch (78:43): [True: 7.51k, False: 0]
  |  |  ------------------
  ------------------
  558|  7.51k|      source->pub.get_pixel_rows = get_rgb_row;
  559|  3.00k|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (559:14): [True: 1.50k, False: 1.50k]
  ------------------
  560|  1.50k|      source->pub.get_pixel_rows = get_rgb_cmyk_row;
  561|  1.50k|    else
  562|  1.50k|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|  1.50k|  ((cinfo)->err->msg_code = (code), \
  |  |  241|  1.50k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  563|  10.5k|    if (ihdr.color_type == SPNG_COLOR_TYPE_TRUECOLOR_ALPHA) {
  ------------------
  |  Branch (563:9): [True: 2.76k, False: 7.75k]
  ------------------
  564|  2.76k|      png_components = 4;
  565|  2.76k|      source->png_alpha = 1;
  566|  7.75k|    } else {
  567|  7.75k|      png_components = 3;
  568|  7.75k|      source->png_alpha = 0;
  569|  7.75k|    }
  570|  10.5k|    break;
  571|       |
  572|    469|  case SPNG_COLOR_TYPE_INDEXED:
  ------------------
  |  Branch (572:3): [True: 469, False: 27.9k]
  ------------------
  573|    469|  {
  574|    469|    int i, gray = 1;
  575|       |
  576|    469|    TRACEMS3(cinfo, 1, JTRC_PNG_INDEXED, ihdr.width, ihdr.height,
  ------------------
  |  |  309|    469|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|    469|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 469]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|    469|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|    469|           (cinfo)->err->msg_code = (code); \
  |  |  312|    469|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  577|    469|             ihdr.bit_depth);
  578|    469|    TRY_SPNG(spng_get_plte(source->ctx, &source->colormap));
  ------------------
  |  |   33|    469|#define TRY_SPNG(f) { \
  |  |   34|    469|  int __spng_error = (f); \
  |  |   35|    469|  if (__spng_error) \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 231, False: 238]
  |  |  ------------------
  |  |   36|    469|    ERREXITS(cinfo, JERR_PNG_LIBSPNG, spng_strerror(__spng_error)); \
  |  |  ------------------
  |  |  |  |  274|    231|  ((cinfo)->err->msg_code = (code), \
  |  |  |  |  275|    231|   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX - 1), \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|    231|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  276|    231|   (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|    231|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  277|    231|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  |  |  ------------------
  |  |   37|    469|}
  ------------------
  579|    469|    if (source->png_bit_depth != 8 || source->colormap.n_entries > 256)
  ------------------
  |  Branch (579:9): [True: 231, False: 238]
  |  Branch (579:39): [True: 0, False: 238]
  ------------------
  580|      0|      ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  581|       |
  582|  14.4k|    for (i = 0; i < (int)source->colormap.n_entries; i++) {
  ------------------
  |  Branch (582:17): [True: 13.9k, False: 469]
  ------------------
  583|  13.9k|      if (source->colormap.entries[i].red !=
  ------------------
  |  Branch (583:11): [True: 8.68k, False: 5.28k]
  ------------------
  584|  13.9k|          source->colormap.entries[i].green ||
  585|  5.28k|          source->colormap.entries[i].green !=
  ------------------
  |  Branch (585:11): [True: 476, False: 4.80k]
  ------------------
  586|  5.28k|          source->colormap.entries[i].blue)
  587|  9.16k|        gray = 0;
  588|  13.9k|    }
  589|       |
  590|    469|    if ((cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (590:10): [True: 231, False: 238]
  ------------------
  591|    238|         cinfo->in_color_space == JCS_RGB) && gray)
  ------------------
  |  Branch (591:10): [True: 0, False: 238]
  |  Branch (591:47): [True: 0, False: 0]
  ------------------
  592|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  593|    469|    if (cinfo->in_color_space == JCS_GRAYSCALE && !gray)
  ------------------
  |  Branch (593:9): [True: 34, False: 435]
  |  Branch (593:51): [True: 23, False: 11]
  ------------------
  594|     23|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|     23|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     23|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  595|       |
  596|    469|    source->pub.get_pixel_rows = get_indexed_row;
  597|    469|    png_components = 1;
  598|    469|    source->png_alpha = 0;
  599|    469|    break;
  600|  7.29k|  }
  601|       |
  602|      0|  default:
  ------------------
  |  Branch (602:3): [True: 0, False: 28.3k]
  ------------------
  603|      0|    ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  604|  28.3k|  }
  605|       |
  606|  14.6k|  if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  14.6k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 14.6k]
  |  |  |  Branch (78:22): [True: 11.5k, False: 3.09k]
  |  |  |  Branch (78:43): [True: 11.5k, False: 0]
  |  |  ------------------
  ------------------
  607|  11.5k|    cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
  608|  3.09k|  else if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (608:12): [True: 783, False: 2.30k]
  ------------------
  609|    783|    cinfo->input_components = 1;
  610|  2.30k|  else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (610:12): [True: 2.30k, False: 0]
  ------------------
  611|  2.30k|    cinfo->input_components = 4;
  612|       |
  613|       |  /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */
  614|  14.6k|  source->buffer_width =
  615|  14.6k|    (size_t)ihdr.width * png_components * source->png_bit_depth / 8;
  616|  14.6k|  source->iobuffer = (unsigned char *)
  617|  14.6k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  14.6k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  618|  14.6k|                                source->buffer_width);
  619|       |
  620|       |  /* Create compressor input buffer. */
  621|  14.6k|  if (use_raw_buffer) {
  ------------------
  |  Branch (621:7): [True: 0, False: 14.6k]
  ------------------
  622|       |    /* For unscaled raw-input case, we can just map it onto the I/O buffer. */
  623|       |    /* Synthesize a _JSAMPARRAY pointer structure */
  624|      0|    source->pixrow = (_JSAMPROW)source->iobuffer;
  625|      0|    source->pub._buffer = &source->pixrow;
  ------------------
  |  |  210|      0|#define _buffer  buffer12
  ------------------
  626|      0|    source->pub.buffer_height = 1;
  627|  14.6k|  } else {
  628|  14.6k|    unsigned int maxval = source->png_bit_depth == 16 ? 65535 : 255;
  ------------------
  |  Branch (628:27): [True: 3.71k, False: 10.9k]
  ------------------
  629|  14.6k|    size_t val, half_maxval;
  630|       |
  631|       |    /* Need to translate anyway, so make a separate sample buffer. */
  632|  14.6k|    source->pub._buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  ------------------
  |  |  210|  14.6k|#define _buffer  buffer12
  ------------------
  633|  14.6k|      ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  14.6k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  634|  14.6k|       (JDIMENSION)ihdr.width * cinfo->input_components, (JDIMENSION)1);
  635|  14.6k|    source->pub.buffer_height = 1;
  636|       |
  637|       |    /* Compute the rescaling array. */
  638|  14.6k|    source->rescale = (_JSAMPLE *)
  639|  14.6k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  14.6k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  640|  14.6k|                                  (maxval + 1L) * sizeof(_JSAMPLE));
  641|  14.6k|    memset(source->rescale, 0, (maxval + 1L) * sizeof(_JSAMPLE));
  642|  14.6k|    half_maxval = maxval / 2;
  643|   245M|    for (val = 0; val <= maxval; val++) {
  ------------------
  |  Branch (643:19): [True: 245M, False: 14.6k]
  ------------------
  644|       |      /* The multiplication here must be done in 32 bits to avoid overflow */
  645|   245M|      source->rescale[val] =
  646|   245M|        (_JSAMPLE)((val * ((1 << cinfo->data_precision) - 1) + half_maxval) /
  647|   245M|                   maxval);
  648|   245M|    }
  649|  14.6k|  }
  650|       |
  651|  14.6k|  TRY_SPNG(spng_decode_image(source->ctx, NULL, 0, SPNG_FMT_PNG,
  ------------------
  |  |   33|  14.6k|#define TRY_SPNG(f) { \
  |  |   34|  14.6k|  int __spng_error = (f); \
  |  |   35|  14.6k|  if (__spng_error) \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 8.95k, False: 5.68k]
  |  |  ------------------
  |  |   36|  14.6k|    ERREXITS(cinfo, JERR_PNG_LIBSPNG, spng_strerror(__spng_error)); \
  |  |  ------------------
  |  |  |  |  274|  8.95k|  ((cinfo)->err->msg_code = (code), \
  |  |  |  |  275|  8.95k|   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX - 1), \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|  8.95k|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  276|  8.95k|   (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|  8.95k|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  277|  8.95k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  |  |  ------------------
  |  |   37|  14.6k|}
  ------------------
  652|  14.6k|                             SPNG_DECODE_PROGRESSIVE));
  653|  14.6k|}
rdpng-12.c:get_raw_row:
   75|   376k|{
   76|   376k|  png_source_ptr source = (png_source_ptr)sinfo;
   77|   376k|  int spng_error;
   78|       |
   79|   376k|  spng_error = spng_decode_row(source->ctx, source->iobuffer,
   80|   376k|                               source->buffer_width);
   81|   376k|  if (spng_error && spng_error != SPNG_EOI)
  ------------------
  |  Branch (81:7): [True: 4.97k, False: 371k]
  |  Branch (81:21): [True: 3.31k, False: 1.65k]
  ------------------
   82|  3.31k|    ERREXITS(cinfo, JERR_PNG_LIBSPNG, spng_strerror(spng_error)); \
  ------------------
  |  |  274|  3.31k|  ((cinfo)->err->msg_code = (code), \
  |  |  275|  3.31k|   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX - 1), \
  |  |  ------------------
  |  |  |  |  800|  3.31k|#define JMSG_STR_PARM_MAX  80
  |  |  ------------------
  |  |  276|  3.31k|   (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
  |  |  ------------------
  |  |  |  |  800|  3.31k|#define JMSG_STR_PARM_MAX  80
  |  |  ------------------
  |  |  277|  3.31k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   83|   376k|  return 1;
   84|   376k|}
rdpng-12.c:get_gray_row:
  102|  3.12k|{
  103|  3.12k|  png_source_ptr source = (png_source_ptr)sinfo;
  104|  3.12k|  register _JSAMPROW ptr;
  105|  3.12k|  register _JSAMPLE *rescale = source->rescale;
  106|  3.12k|  JDIMENSION col;
  107|       |
  108|  3.12k|  get_raw_row(cinfo, sinfo);
  109|  3.12k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  3.12k|#define _buffer  buffer12
  ------------------
  110|       |#if BITS_IN_JSAMPLE != 12
  111|       |  if (source->png_bit_depth == cinfo->data_precision) {
  112|       |    _JSAMPLE *bufferptr = (_JSAMPLE *)source->iobuffer;
  113|       |    for (col = cinfo->image_width; col > 0; col--) {
  114|       |      *ptr++ = *bufferptr++;
  115|       |      bufferptr += source->png_alpha;
  116|       |    }
  117|       |  } else
  118|       |#endif
  119|  3.12k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (119:7): [True: 1.87k, False: 1.25k]
  ------------------
  120|  1.87k|    register unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  121|  90.8k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (121:36): [True: 88.9k, False: 1.87k]
  ------------------
  122|  88.9k|      *ptr++ = rescale[*bufferptr++];
  123|  88.9k|      bufferptr += source->png_alpha;
  124|  88.9k|    }
  125|  1.87k|  } else {
  126|  1.25k|    register unsigned char *bufferptr = source->iobuffer;
  127|  91.0k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (127:36): [True: 89.7k, False: 1.25k]
  ------------------
  128|  89.7k|      *ptr++ = rescale[*bufferptr++];
  129|  89.7k|      bufferptr += source->png_alpha;
  130|  89.7k|    }
  131|  1.25k|  }
  132|  3.12k|  return 1;
  133|  3.12k|}
rdpng-12.c:get_gray_rgb_row:
  141|  15.6k|{
  142|  15.6k|  png_source_ptr source = (png_source_ptr)sinfo;
  143|  15.6k|  register _JSAMPROW ptr;
  144|  15.6k|  register _JSAMPLE *rescale = source->rescale;
  145|  15.6k|  JDIMENSION col;
  146|  15.6k|  register int rindex = rgb_red[cinfo->in_color_space];
  147|  15.6k|  register int gindex = rgb_green[cinfo->in_color_space];
  148|  15.6k|  register int bindex = rgb_blue[cinfo->in_color_space];
  149|  15.6k|  register int aindex = alpha_index[cinfo->in_color_space];
  150|  15.6k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  151|       |
  152|  15.6k|  get_raw_row(cinfo, sinfo);
  153|  15.6k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  15.6k|#define _buffer  buffer12
  ------------------
  154|       |#if BITS_IN_JSAMPLE != 12
  155|       |  if (source->png_bit_depth == cinfo->data_precision) {
  156|       |    _JSAMPLE *bufferptr = (_JSAMPLE *)source->iobuffer;
  157|       |    if (aindex >= 0)
  158|       |      GRAY_RGB_READ_LOOP(*bufferptr++, ptr[aindex] = _MAXJSAMPLE;,
  159|       |                         bufferptr += source->png_alpha;)
  160|       |    else
  161|       |      GRAY_RGB_READ_LOOP(*bufferptr++, {}, bufferptr += source->png_alpha;)
  162|       |  } else
  163|       |#endif
  164|  15.6k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (164:7): [True: 9.35k, False: 6.29k]
  ------------------
  165|  9.35k|    register unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  166|  9.35k|    if (aindex >= 0)
  ------------------
  |  Branch (166:9): [True: 1.87k, False: 7.48k]
  ------------------
  167|  1.87k|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |   87|  1.87k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |   88|  90.8k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (88:34): [True: 88.9k, False: 1.87k]
  |  |  ------------------
  |  |   89|  88.9k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |   90|  88.9k|    alpha_set_op \
  |  |   91|  88.9k|    ptr += ps; \
  |  |   92|  88.9k|    pointer_op \
  |  |   93|  88.9k|  } \
  |  |   94|  1.87k|}
  ------------------
  168|  9.35k|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;,
  169|  9.35k|                         bufferptr += source->png_alpha;)
  170|  7.48k|    else
  171|  7.48k|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++], {},
  ------------------
  |  |   87|  7.48k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |   88|   363k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (88:34): [True: 355k, False: 7.48k]
  |  |  ------------------
  |  |   89|   355k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |   90|   355k|    alpha_set_op \
  |  |   91|   355k|    ptr += ps; \
  |  |   92|   355k|    pointer_op \
  |  |   93|   355k|  } \
  |  |   94|  7.48k|}
  ------------------
  172|  9.35k|                         bufferptr += source->png_alpha;)
  173|  9.35k|  } else {
  174|  6.29k|    register unsigned char *bufferptr = source->iobuffer;
  175|  6.29k|    if (aindex >= 0)
  ------------------
  |  Branch (175:9): [True: 1.10k, False: 5.18k]
  ------------------
  176|  1.10k|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |   87|  1.10k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |   88|  90.8k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (88:34): [True: 89.7k, False: 1.10k]
  |  |  ------------------
  |  |   89|  89.7k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |   90|  89.7k|    alpha_set_op \
  |  |   91|  89.7k|    ptr += ps; \
  |  |   92|  89.7k|    pointer_op \
  |  |   93|  89.7k|  } \
  |  |   94|  1.10k|}
  ------------------
  177|  6.29k|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;,
  178|  6.29k|                         bufferptr += source->png_alpha;)
  179|  5.18k|    else
  180|  5.18k|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++], {},
  ------------------
  |  |   87|  5.18k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |   88|   364k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (88:34): [True: 359k, False: 5.18k]
  |  |  ------------------
  |  |   89|   359k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |   90|   359k|    alpha_set_op \
  |  |   91|   359k|    ptr += ps; \
  |  |   92|   359k|    pointer_op \
  |  |   93|   359k|  } \
  |  |   94|  5.18k|}
  ------------------
  181|  6.29k|                         bufferptr += source->png_alpha;)
  182|  6.29k|  }
  183|  15.6k|  return 1;
  184|  15.6k|}
rdpng-12.c:get_gray_cmyk_row:
  192|  3.12k|{
  193|  3.12k|  png_source_ptr source = (png_source_ptr)sinfo;
  194|  3.12k|  register _JSAMPROW ptr;
  195|  3.12k|  register _JSAMPLE *rescale = source->rescale;
  196|  3.12k|  JDIMENSION col;
  197|       |
  198|  3.12k|  get_raw_row(cinfo, sinfo);
  199|  3.12k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  3.12k|#define _buffer  buffer12
  ------------------
  200|       |#if BITS_IN_JSAMPLE != 12
  201|       |  if (source->png_bit_depth == cinfo->data_precision) {
  202|       |    register _JSAMPLE *bufferptr = (_JSAMPLE *)source->iobuffer;
  203|       |    for (col = cinfo->image_width; col > 0; col--) {
  204|       |      _JSAMPLE gray = *bufferptr++;
  205|       |      bufferptr += source->png_alpha;
  206|       |      rgb_to_cmyk(_MAXJSAMPLE, gray, gray, gray, ptr, ptr + 1, ptr + 2,
  207|       |                  ptr + 3);
  208|       |      ptr += 4;
  209|       |    }
  210|       |  } else
  211|       |#endif
  212|  3.12k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (212:7): [True: 1.87k, False: 1.25k]
  ------------------
  213|  1.87k|    unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  214|  90.8k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (214:36): [True: 88.9k, False: 1.87k]
  ------------------
  215|  88.9k|      _JSAMPLE gray = rescale[*bufferptr++];
  ------------------
  |  |  108|  88.9k|#define _JSAMPLE  J12SAMPLE
  ------------------
  216|  88.9k|      bufferptr += source->png_alpha;
  217|  88.9k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  218|  88.9k|                  ptr + 1, ptr + 2, ptr + 3);
  219|  88.9k|      ptr += 4;
  220|  88.9k|    }
  221|  1.87k|  } else {
  222|  1.25k|    register unsigned char *bufferptr = source->iobuffer;
  223|  91.0k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (223:36): [True: 89.7k, False: 1.25k]
  ------------------
  224|  89.7k|      _JSAMPLE gray = rescale[*bufferptr++];
  ------------------
  |  |  108|  89.7k|#define _JSAMPLE  J12SAMPLE
  ------------------
  225|  89.7k|      bufferptr += source->png_alpha;
  226|  89.7k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  227|  89.7k|                  ptr + 1, ptr + 2, ptr + 3);
  228|  89.7k|      ptr += 4;
  229|  89.7k|    }
  230|  1.25k|  }
  231|  3.12k|  return 1;
  232|  3.12k|}
rdpng-12.c:get_rgb_row:
  252|   295k|{
  253|   295k|  png_source_ptr source = (png_source_ptr)sinfo;
  254|   295k|  register _JSAMPROW ptr;
  255|   295k|  register _JSAMPLE *rescale = source->rescale;
  256|   295k|  JDIMENSION col;
  257|   295k|  register int rindex = rgb_red[cinfo->in_color_space];
  258|   295k|  register int gindex = rgb_green[cinfo->in_color_space];
  259|   295k|  register int bindex = rgb_blue[cinfo->in_color_space];
  260|   295k|  register int aindex = alpha_index[cinfo->in_color_space];
  261|   295k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  262|       |
  263|   295k|  get_raw_row(cinfo, sinfo);
  264|   295k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|   295k|#define _buffer  buffer12
  ------------------
  265|       |#if BITS_IN_JSAMPLE != 12
  266|       |  if (source->png_bit_depth == cinfo->data_precision) {
  267|       |    register _JSAMPLE *bufferptr = (_JSAMPLE *)source->iobuffer;
  268|       |    if (aindex >= 0)
  269|       |      RGB_READ_LOOP(*bufferptr++, ptr[aindex] = _MAXJSAMPLE;,
  270|       |                    bufferptr += source->png_alpha;)
  271|       |    else
  272|       |      RGB_READ_LOOP(*bufferptr++, {}, bufferptr += source->png_alpha;)
  273|       |  } else
  274|       |#endif
  275|   295k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (275:7): [True: 14.5k, False: 280k]
  ------------------
  276|  14.5k|    unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  277|  14.5k|    if (aindex >= 0)
  ------------------
  |  Branch (277:9): [True: 2.90k, False: 11.6k]
  ------------------
  278|  2.90k|      RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  235|  2.90k|#define RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |  236|   195k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (236:34): [True: 192k, False: 2.90k]
  |  |  ------------------
  |  |  237|   192k|    ptr[rindex] = read_op; \
  |  |  238|   192k|    ptr[gindex] = read_op; \
  |  |  239|   192k|    ptr[bindex] = read_op; \
  |  |  240|   192k|    alpha_set_op \
  |  |  241|   192k|    pointer_op \
  |  |  242|   192k|    ptr += ps; \
  |  |  243|   192k|  } \
  |  |  244|  2.90k|}
  ------------------
  279|  14.5k|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;,
  280|  14.5k|                    bufferptr += source->png_alpha;)
  281|  11.6k|    else
  282|  11.6k|      RGB_READ_LOOP(rescale[*bufferptr++], {},
  ------------------
  |  |  235|  11.6k|#define RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |  236|   782k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (236:34): [True: 771k, False: 11.6k]
  |  |  ------------------
  |  |  237|   771k|    ptr[rindex] = read_op; \
  |  |  238|   771k|    ptr[gindex] = read_op; \
  |  |  239|   771k|    ptr[bindex] = read_op; \
  |  |  240|   771k|    alpha_set_op \
  |  |  241|   771k|    pointer_op \
  |  |  242|   771k|    ptr += ps; \
  |  |  243|   771k|  } \
  |  |  244|  11.6k|}
  ------------------
  283|  14.5k|                    bufferptr += source->png_alpha;)
  284|   280k|  } else {
  285|   280k|    register unsigned char *bufferptr = source->iobuffer;
  286|   280k|    if (aindex >= 0)
  ------------------
  |  Branch (286:9): [True: 55.7k, False: 224k]
  ------------------
  287|  55.7k|      RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  235|  55.7k|#define RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |  236|  12.5M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (236:34): [True: 12.4M, False: 55.7k]
  |  |  ------------------
  |  |  237|  12.4M|    ptr[rindex] = read_op; \
  |  |  238|  12.4M|    ptr[gindex] = read_op; \
  |  |  239|  12.4M|    ptr[bindex] = read_op; \
  |  |  240|  12.4M|    alpha_set_op \
  |  |  241|  12.4M|    pointer_op \
  |  |  242|  12.4M|    ptr += ps; \
  |  |  243|  12.4M|  } \
  |  |  244|  55.7k|}
  ------------------
  288|   280k|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;,
  289|   280k|                    bufferptr += source->png_alpha;)
  290|   224k|    else
  291|   224k|      RGB_READ_LOOP(rescale[*bufferptr++], {},
  ------------------
  |  |  235|   224k|#define RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |  236|  50.0M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (236:34): [True: 49.8M, False: 224k]
  |  |  ------------------
  |  |  237|  49.8M|    ptr[rindex] = read_op; \
  |  |  238|  49.8M|    ptr[gindex] = read_op; \
  |  |  239|  49.8M|    ptr[bindex] = read_op; \
  |  |  240|  49.8M|    alpha_set_op \
  |  |  241|  49.8M|    pointer_op \
  |  |  242|  49.8M|    ptr += ps; \
  |  |  243|  49.8M|  } \
  |  |  244|   224k|}
  ------------------
  292|   280k|                    bufferptr += source->png_alpha;)
  293|   280k|  }
  294|   295k|  return 1;
  295|   295k|}
rdpng-12.c:get_rgb_cmyk_row:
  303|  59.0k|{
  304|  59.0k|  png_source_ptr source = (png_source_ptr)sinfo;
  305|  59.0k|  register _JSAMPROW ptr;
  306|  59.0k|  register _JSAMPLE *rescale = source->rescale;
  307|  59.0k|  JDIMENSION col;
  308|       |
  309|  59.0k|  get_raw_row(cinfo, sinfo);
  310|  59.0k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  59.0k|#define _buffer  buffer12
  ------------------
  311|       |#if BITS_IN_JSAMPLE != 12
  312|       |  if (source->png_bit_depth == cinfo->data_precision) {
  313|       |    register _JSAMPLE *bufferptr = (_JSAMPLE *)source->iobuffer;
  314|       |    for (col = cinfo->image_width; col > 0; col--) {
  315|       |      _JSAMPLE r = *bufferptr++;
  316|       |      _JSAMPLE g = *bufferptr++;
  317|       |      _JSAMPLE b = *bufferptr++;
  318|       |      bufferptr += source->png_alpha;
  319|       |      rgb_to_cmyk(_MAXJSAMPLE, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
  320|       |      ptr += 4;
  321|       |    }
  322|       |  } else
  323|       |#endif
  324|  59.0k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (324:7): [True: 2.90k, False: 56.1k]
  ------------------
  325|  2.90k|    unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  326|   195k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (326:36): [True: 192k, False: 2.90k]
  ------------------
  327|   192k|      _JSAMPLE r = rescale[*bufferptr++];
  ------------------
  |  |  108|   192k|#define _JSAMPLE  J12SAMPLE
  ------------------
  328|   192k|      _JSAMPLE g = rescale[*bufferptr++];
  ------------------
  |  |  108|   192k|#define _JSAMPLE  J12SAMPLE
  ------------------
  329|   192k|      _JSAMPLE b = rescale[*bufferptr++];
  ------------------
  |  |  108|   192k|#define _JSAMPLE  J12SAMPLE
  ------------------
  330|   192k|      bufferptr += source->png_alpha;
  331|   192k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  332|   192k|                  ptr + 2, ptr + 3);
  333|   192k|      ptr += 4;
  334|   192k|    }
  335|  56.1k|  } else {
  336|  56.1k|    register unsigned char *bufferptr = source->iobuffer;
  337|  12.5M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (337:36): [True: 12.4M, False: 56.1k]
  ------------------
  338|  12.4M|      _JSAMPLE r = rescale[*bufferptr++];
  ------------------
  |  |  108|  12.4M|#define _JSAMPLE  J12SAMPLE
  ------------------
  339|  12.4M|      _JSAMPLE g = rescale[*bufferptr++];
  ------------------
  |  |  108|  12.4M|#define _JSAMPLE  J12SAMPLE
  ------------------
  340|  12.4M|      _JSAMPLE b = rescale[*bufferptr++];
  ------------------
  |  |  108|  12.4M|#define _JSAMPLE  J12SAMPLE
  ------------------
  341|  12.4M|      bufferptr += source->png_alpha;
  342|  12.4M|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  343|  12.4M|                  ptr + 2, ptr + 3);
  344|  12.4M|      ptr += 4;
  345|  12.4M|    }
  346|  56.1k|  }
  347|  59.0k|  return 1;
  348|  59.0k|}
rdpng-12.c:get_indexed_row:
  353|    582|{
  354|       |/* This version is for reading 8-bit-per-channel indexed-color PNG files and
  355|       | * converting to extended RGB or CMYK.
  356|       | */
  357|    582|  png_source_ptr source = (png_source_ptr)sinfo;
  358|    582|  register _JSAMPROW ptr;
  359|    582|  register JSAMPLE *bufferptr = (JSAMPLE *)source->iobuffer;
  360|    582|  register _JSAMPLE *rescale = source->rescale;
  361|    582|  JDIMENSION col;
  362|       |
  363|    582|  get_raw_row(cinfo, sinfo);
  364|    582|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|    582|#define _buffer  buffer12
  ------------------
  365|       |#if BITS_IN_JSAMPLE == 8
  366|       |  if (source->png_bit_depth == cinfo->data_precision) {
  367|       |    if (cinfo->in_color_space == JCS_GRAYSCALE) {
  368|       |      for (col = cinfo->image_width; col > 0; col--) {
  369|       |        JSAMPLE index = *bufferptr++;
  370|       |
  371|       |        if (index >= source->colormap.n_entries)
  372|       |          ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  373|       |        *ptr++ = source->colormap.entries[index].red;
  374|       |      }
  375|       |    } else if (cinfo->in_color_space == JCS_CMYK) {
  376|       |      for (col = cinfo->image_width; col > 0; col--) {
  377|       |        JSAMPLE index = *bufferptr++;
  378|       |
  379|       |        if (index >= source->colormap.n_entries)
  380|       |          ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  381|       |        rgb_to_cmyk(_MAXJSAMPLE, source->colormap.entries[index].red,
  382|       |                    source->colormap.entries[index].green,
  383|       |                    source->colormap.entries[index].blue, ptr, ptr + 1,
  384|       |                    ptr + 2, ptr + 3);
  385|       |        ptr += 4;
  386|       |      }
  387|       |    } else {
  388|       |      register int rindex = rgb_red[cinfo->in_color_space];
  389|       |      register int gindex = rgb_green[cinfo->in_color_space];
  390|       |      register int bindex = rgb_blue[cinfo->in_color_space];
  391|       |      register int aindex = alpha_index[cinfo->in_color_space];
  392|       |      register int ps = rgb_pixelsize[cinfo->in_color_space];
  393|       |
  394|       |      for (col = cinfo->image_width; col > 0; col--) {
  395|       |        JSAMPLE index = *bufferptr++;
  396|       |
  397|       |        if (index >= source->colormap.n_entries)
  398|       |          ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  399|       |        ptr[rindex] = source->colormap.entries[index].red;
  400|       |        ptr[gindex] = source->colormap.entries[index].green;
  401|       |        ptr[bindex] = source->colormap.entries[index].blue;
  402|       |        if (aindex >= 0)
  403|       |          ptr[aindex] = _MAXJSAMPLE;
  404|       |        ptr += ps;
  405|       |      }
  406|       |    }
  407|       |  } else
  408|       |#endif
  409|    582|  {
  410|    582|    if (cinfo->in_color_space == JCS_GRAYSCALE) {
  ------------------
  |  Branch (410:9): [True: 39, False: 543]
  ------------------
  411|    335|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (411:38): [True: 296, False: 39]
  ------------------
  412|    296|        JSAMPLE index = *bufferptr++;
  413|       |
  414|    296|        if (index >= source->colormap.n_entries)
  ------------------
  |  Branch (414:13): [True: 6, False: 290]
  ------------------
  415|      6|          ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  ------------------
  |  |  240|      6|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      6|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  416|    296|        *ptr++ = rescale[source->colormap.entries[index].red];
  417|    296|      }
  418|    543|    } else if (cinfo->in_color_space == JCS_CMYK) {
  ------------------
  |  Branch (418:16): [True: 81, False: 462]
  ------------------
  419|  1.17k|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (419:38): [True: 1.09k, False: 81]
  ------------------
  420|  1.09k|        JSAMPLE index = *bufferptr++;
  421|       |
  422|  1.09k|        if (index >= source->colormap.n_entries)
  ------------------
  |  Branch (422:13): [True: 14, False: 1.07k]
  ------------------
  423|     14|          ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  ------------------
  |  |  240|     14|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     14|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  424|  1.09k|        rgb_to_cmyk((1 << cinfo->data_precision) - 1,
  425|  1.09k|                    rescale[source->colormap.entries[index].red],
  426|  1.09k|                    rescale[source->colormap.entries[index].green],
  427|  1.09k|                    rescale[source->colormap.entries[index].blue], ptr,
  428|  1.09k|                    ptr + 1, ptr + 2, ptr + 3);
  429|  1.09k|        ptr += 4;
  430|  1.09k|      }
  431|    462|    } else {
  432|    462|      register int rindex = rgb_red[cinfo->in_color_space];
  433|    462|      register int gindex = rgb_green[cinfo->in_color_space];
  434|    462|      register int bindex = rgb_blue[cinfo->in_color_space];
  435|    462|      register int aindex = alpha_index[cinfo->in_color_space];
  436|    462|      register int ps = rgb_pixelsize[cinfo->in_color_space];
  437|       |
  438|  5.91k|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (438:38): [True: 5.45k, False: 462]
  ------------------
  439|  5.45k|        JSAMPLE index = *bufferptr++;
  440|       |
  441|  5.45k|        if (index >= source->colormap.n_entries)
  ------------------
  |  Branch (441:13): [True: 70, False: 5.38k]
  ------------------
  442|     70|          ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  ------------------
  |  |  240|     70|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     70|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  443|  5.45k|        ptr[rindex] = rescale[source->colormap.entries[index].red];
  444|  5.45k|        ptr[gindex] = rescale[source->colormap.entries[index].green];
  445|  5.45k|        ptr[bindex] = rescale[source->colormap.entries[index].blue];
  446|  5.45k|        if (aindex >= 0)
  ------------------
  |  Branch (446:13): [True: 1.07k, False: 4.37k]
  ------------------
  447|  1.07k|          ptr[aindex] = (1 << cinfo->data_precision) - 1;
  448|  5.45k|        ptr += ps;
  449|  5.45k|      }
  450|    462|    }
  451|    582|  }
  452|    582|  return 1;
  453|    582|}
rdpng-12.c:read_icc_profile_png:
  663|  5.68k|{
  664|  5.68k|  png_source_ptr source = (png_source_ptr)sinfo;
  665|  5.68k|  struct spng_iccp iccp;
  666|       |
  667|  5.68k|  if (!icc_data_ptr || !icc_data_len)
  ------------------
  |  Branch (667:7): [True: 0, False: 5.68k]
  |  Branch (667:24): [True: 0, False: 5.68k]
  ------------------
  668|      0|    ERREXIT(cinfo, JERR_BUFFER_SIZE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  669|       |
  670|  5.68k|  if (source->ctx && spng_get_iccp(source->ctx, &iccp) == 0) {
  ------------------
  |  Branch (670:7): [True: 5.68k, False: 0]
  |  Branch (670:22): [True: 20, False: 5.66k]
  ------------------
  671|     20|    *icc_data_ptr = (JOCTET *)iccp.profile;
  672|     20|    *icc_data_len = (unsigned int)iccp.profile_len;
  673|     20|    return TRUE;
  ------------------
  |  |  210|     20|#define TRUE    1
  ------------------
  674|     20|  }
  675|       |
  676|  5.66k|  return FALSE;
  ------------------
  |  |  207|  5.66k|#define FALSE   0               /* values of boolean */
  ------------------
  677|  5.68k|}
rdpng-12.c:finish_input_png:
  686|  28.3k|{
  687|  28.3k|  png_source_ptr source = (png_source_ptr)sinfo;
  688|       |
  689|  28.3k|  if (source->ctx) {
  ------------------
  |  Branch (689:7): [True: 28.3k, False: 0]
  ------------------
  690|  28.3k|    spng_decode_chunks(source->ctx);
  691|  28.3k|    spng_ctx_free(source->ctx);
  692|       |    source->ctx = NULL;
  693|  28.3k|  }
  694|  28.3k|}

j12init_read_ppm:
  924|  17.1k|{
  925|  17.1k|  ppm_source_ptr source;
  926|       |
  927|       |#if BITS_IN_JSAMPLE == 8
  928|       |  if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  929|       |#else
  930|  17.1k|  if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  ------------------
  |  |   12|  34.2k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (930:7): [True: 0, False: 17.1k]
  ------------------
  931|  17.1k|      cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  ------------------
  |  |   12|  17.1k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (931:7): [True: 0, False: 17.1k]
  ------------------
  932|      0|#endif
  933|      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)))
  ------------------
  934|       |
  935|       |  /* Create module interface object */
  936|  17.1k|  source = (ppm_source_ptr)
  937|  17.1k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  17.1k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  938|  17.1k|                                sizeof(ppm_source_struct));
  939|       |  /* Fill in method ptrs, except get_pixel_rows which start_input sets */
  940|  17.1k|  source->pub.start_input = start_input_ppm;
  941|  17.1k|  source->pub.read_icc_profile = read_icc_profile_ppm;
  942|  17.1k|  source->pub.finish_input = finish_input_ppm;
  943|  17.1k|  source->pub.max_pixels = 0;
  944|       |
  945|  17.1k|  return (cjpeg_source_ptr)source;
  946|  17.1k|}
rdppm-12.c:start_input_ppm:
  703|  17.1k|{
  704|  17.1k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  705|  17.1k|  int c;
  706|  17.1k|  unsigned int w, h, maxval;
  707|  17.1k|  boolean need_iobuffer, use_raw_buffer, need_rescale;
  708|       |
  709|  17.1k|  if (getc(source->pub.input_file) != 'P')
  ------------------
  |  Branch (709:7): [True: 0, False: 17.1k]
  ------------------
  710|      0|    ERREXIT(cinfo, JERR_PPM_NOT);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  711|       |
  712|  17.1k|  c = getc(source->pub.input_file); /* subformat discriminator character */
  713|       |
  714|       |  /* detect unsupported variants (ie, PBM) before trying to read header */
  715|  17.1k|  switch (c) {
  716|  1.54k|  case '2':                     /* it's a text-format PGM file */
  ------------------
  |  Branch (716:3): [True: 1.54k, False: 15.5k]
  ------------------
  717|  3.15k|  case '3':                     /* it's a text-format PPM file */
  ------------------
  |  Branch (717:3): [True: 1.61k, False: 15.5k]
  ------------------
  718|  12.8k|  case '5':                     /* it's a raw-format PGM file */
  ------------------
  |  Branch (718:3): [True: 9.66k, False: 7.44k]
  ------------------
  719|  17.0k|  case '6':                     /* it's a raw-format PPM file */
  ------------------
  |  Branch (719:3): [True: 4.22k, False: 12.8k]
  ------------------
  720|  17.0k|    break;
  721|     70|  default:
  ------------------
  |  Branch (721:3): [True: 70, False: 17.0k]
  ------------------
  722|     70|    ERREXIT(cinfo, JERR_PPM_NOT);
  ------------------
  |  |  240|     70|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     70|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  723|     70|    break;
  724|  17.1k|  }
  725|       |
  726|       |  /* fetch the remaining header info */
  727|  17.0k|  w = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  728|  17.0k|  h = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  729|  17.0k|  maxval = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  730|       |
  731|  17.0k|  if (w <= 0 || h <= 0 || maxval <= 0) /* error check */
  ------------------
  |  Branch (731:7): [True: 1.21k, False: 15.8k]
  |  Branch (731:17): [True: 14, False: 15.8k]
  |  Branch (731:27): [True: 14, False: 15.8k]
  ------------------
  732|     35|    ERREXIT(cinfo, JERR_PPM_NOT);
  ------------------
  |  |  240|     35|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     35|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  733|  17.0k|  if (w > JPEG_MAX_DIMENSION || h > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  34.0k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
                if (w > JPEG_MAX_DIMENSION || h > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  15.7k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (733:7): [True: 1.24k, False: 15.7k]
  |  Branch (733:33): [True: 14, False: 15.7k]
  ------------------
  734|     21|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, JPEG_MAX_DIMENSION);
  ------------------
  |  |  243|     21|  ((cinfo)->err->msg_code = (code), \
  |  |  244|     21|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|     21|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  735|  17.0k|  if (sinfo->max_pixels && (unsigned long long)w * h > sinfo->max_pixels)
  ------------------
  |  Branch (735:7): [True: 15.7k, False: 1.26k]
  |  Branch (735:28): [True: 224, False: 15.5k]
  ------------------
  736|    224|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
  ------------------
  |  |  243|    224|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    224|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    224|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  737|       |
  738|  17.0k|  cinfo->image_width = (JDIMENSION)w;
  739|  17.0k|  cinfo->image_height = (JDIMENSION)h;
  740|  17.0k|  source->maxval = maxval;
  741|       |
  742|       |  /* initialize flags to most common settings */
  743|  17.0k|  need_iobuffer = TRUE;         /* do we need an I/O buffer? */
  ------------------
  |  |  210|  17.0k|#define TRUE    1
  ------------------
  744|  17.0k|  use_raw_buffer = FALSE;       /* do we map input buffer onto I/O buffer? */
  ------------------
  |  |  207|  17.0k|#define FALSE   0               /* values of boolean */
  ------------------
  745|  17.0k|  need_rescale = TRUE;          /* do we need a rescale array? */
  ------------------
  |  |  210|  17.0k|#define TRUE    1
  ------------------
  746|       |
  747|  17.0k|  switch (c) {
  ------------------
  |  Branch (747:11): [True: 15.5k, False: 1.48k]
  ------------------
  748|  1.10k|  case '2':                     /* it's a text-format PGM file */
  ------------------
  |  Branch (748:3): [True: 1.10k, False: 15.9k]
  ------------------
  749|  1.10k|    if (cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (749:9): [True: 0, False: 1.10k]
  ------------------
  750|  1.10k|        cinfo->in_color_space == JCS_RGB)
  ------------------
  |  Branch (750:9): [True: 0, False: 1.10k]
  ------------------
  751|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  752|  1.10k|    TRACEMS3(cinfo, 1, JTRC_PGM_TEXT, w, h, maxval);
  ------------------
  |  |  309|  1.10k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.10k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.10k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  1.10k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  1.10k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  1.10k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  753|  1.10k|    if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (753:9): [True: 158, False: 948]
  ------------------
  754|    158|      source->pub.get_pixel_rows = get_text_gray_row;
  755|    948|    else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|    948|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 948]
  |  |  |  Branch (78:22): [True: 790, False: 158]
  |  |  |  Branch (78:43): [True: 790, False: 0]
  |  |  ------------------
  ------------------
  756|    790|      source->pub.get_pixel_rows = get_text_gray_rgb_row;
  757|    158|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (757:14): [True: 158, False: 0]
  ------------------
  758|    158|      source->pub.get_pixel_rows = get_text_gray_cmyk_row;
  759|      0|    else
  760|      0|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  761|  1.10k|    need_iobuffer = FALSE;
  ------------------
  |  |  207|  1.10k|#define FALSE   0               /* values of boolean */
  ------------------
  762|  1.10k|    break;
  763|       |
  764|  1.22k|  case '3':                     /* it's a text-format PPM file */
  ------------------
  |  Branch (764:3): [True: 1.22k, False: 15.8k]
  ------------------
  765|  1.22k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (765:9): [True: 0, False: 1.22k]
  ------------------
  766|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  767|  1.22k|    TRACEMS3(cinfo, 1, JTRC_PPM_TEXT, w, h, maxval);
  ------------------
  |  |  309|  1.22k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.22k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.22k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  1.22k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  1.22k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  1.22k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  768|  1.22k|    if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  1.22k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 1.22k]
  |  |  |  Branch (78:22): [True: 875, False: 350]
  |  |  |  Branch (78:43): [True: 875, False: 0]
  |  |  ------------------
  ------------------
  769|    875|      source->pub.get_pixel_rows = get_text_rgb_row;
  770|    350|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (770:14): [True: 175, False: 175]
  ------------------
  771|    175|      source->pub.get_pixel_rows = get_text_rgb_cmyk_row;
  772|    175|    else
  773|    175|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    175|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    175|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  774|  1.22k|    need_iobuffer = FALSE;
  ------------------
  |  |  207|  1.22k|#define FALSE   0               /* values of boolean */
  ------------------
  775|  1.22k|    break;
  776|       |
  777|  9.25k|  case '5':                     /* it's a raw-format PGM file */
  ------------------
  |  Branch (777:3): [True: 9.25k, False: 7.79k]
  ------------------
  778|  9.25k|    if (cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (778:9): [True: 0, False: 9.25k]
  ------------------
  779|  9.25k|        cinfo->in_color_space == JCS_RGB)
  ------------------
  |  Branch (779:9): [True: 0, False: 9.25k]
  ------------------
  780|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  781|  9.25k|    TRACEMS3(cinfo, 1, JTRC_PGM, w, h, maxval);
  ------------------
  |  |  309|  9.25k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  9.25k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 9.25k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  9.25k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  9.25k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  9.25k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  782|  9.25k|    if (maxval > 255) {
  ------------------
  |  Branch (782:9): [True: 1.09k, False: 8.15k]
  ------------------
  783|  1.09k|      if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (783:11): [True: 157, False: 942]
  ------------------
  784|    157|        source->pub.get_pixel_rows = get_word_gray_row;
  785|    942|      else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|    942|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 942]
  |  |  |  Branch (78:22): [True: 785, False: 157]
  |  |  |  Branch (78:43): [True: 785, False: 0]
  |  |  ------------------
  ------------------
  786|    785|        source->pub.get_pixel_rows = get_word_gray_rgb_row;
  787|    157|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (787:16): [True: 157, False: 0]
  ------------------
  788|    157|        source->pub.get_pixel_rows = get_word_gray_cmyk_row;
  789|      0|      else
  790|      0|        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  791|       |#if BITS_IN_JSAMPLE == 8
  792|       |    } else if (maxval <= _MAXJSAMPLE &&
  793|       |               maxval == ((1U << cinfo->data_precision) - 1U) &&
  794|       |               cinfo->in_color_space == JCS_GRAYSCALE) {
  795|       |      source->pub.get_pixel_rows = get_raw_row;
  796|       |      use_raw_buffer = TRUE;
  797|       |      need_rescale = FALSE;
  798|       |#endif
  799|  8.15k|    } else {
  800|  8.15k|      if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (800:11): [True: 1.16k, False: 6.99k]
  ------------------
  801|  1.16k|        source->pub.get_pixel_rows = get_scaled_gray_row;
  802|  6.99k|      else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  6.99k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 6.99k]
  |  |  |  Branch (78:22): [True: 5.82k, False: 1.16k]
  |  |  |  Branch (78:43): [True: 5.82k, False: 0]
  |  |  ------------------
  ------------------
  803|  5.82k|        source->pub.get_pixel_rows = get_gray_rgb_row;
  804|  1.16k|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (804:16): [True: 1.16k, False: 0]
  ------------------
  805|  1.16k|        source->pub.get_pixel_rows = get_gray_cmyk_row;
  806|      0|      else
  807|      0|        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  808|  8.15k|    }
  809|  9.25k|    break;
  810|       |
  811|  3.97k|  case '6':                     /* it's a raw-format PPM file */
  ------------------
  |  Branch (811:3): [True: 3.97k, False: 13.0k]
  ------------------
  812|  3.97k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (812:9): [True: 0, False: 3.97k]
  ------------------
  813|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  814|  3.97k|    TRACEMS3(cinfo, 1, JTRC_PPM, w, h, maxval);
  ------------------
  |  |  309|  3.97k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  3.97k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 3.97k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  3.97k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  3.97k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  3.97k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  815|  3.97k|    if (maxval > 255) {
  ------------------
  |  Branch (815:9): [True: 1.84k, False: 2.12k]
  ------------------
  816|  1.84k|      if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  1.84k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 1.84k]
  |  |  |  Branch (78:22): [True: 1.32k, False: 528]
  |  |  |  Branch (78:43): [True: 1.32k, False: 0]
  |  |  ------------------
  ------------------
  817|  1.32k|        source->pub.get_pixel_rows = get_word_rgb_row;
  818|    528|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (818:16): [True: 264, False: 264]
  ------------------
  819|    264|        source->pub.get_pixel_rows = get_word_rgb_cmyk_row;
  820|    264|      else
  821|    264|        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    264|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    264|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  822|       |#if BITS_IN_JSAMPLE == 8
  823|       |    } else if (maxval <= _MAXJSAMPLE &&
  824|       |               maxval == ((1U << cinfo->data_precision) - 1U) &&
  825|       |#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3
  826|       |               (cinfo->in_color_space == JCS_EXT_RGB ||
  827|       |                cinfo->in_color_space == JCS_RGB)) {
  828|       |#else
  829|       |               cinfo->in_color_space == JCS_EXT_RGB) {
  830|       |#endif
  831|       |      source->pub.get_pixel_rows = get_raw_row;
  832|       |      use_raw_buffer = TRUE;
  833|       |      need_rescale = FALSE;
  834|       |#endif
  835|  2.12k|    } else {
  836|  2.12k|      if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  2.12k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 2.12k]
  |  |  |  Branch (78:22): [True: 1.52k, False: 608]
  |  |  |  Branch (78:43): [True: 1.52k, False: 0]
  |  |  ------------------
  ------------------
  837|  1.52k|        source->pub.get_pixel_rows = get_rgb_row;
  838|    608|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (838:16): [True: 304, False: 304]
  ------------------
  839|    304|        source->pub.get_pixel_rows = get_rgb_cmyk_row;
  840|    304|      else
  841|    304|        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    304|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    304|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  842|  2.12k|    }
  843|  3.97k|    break;
  844|  17.0k|  }
  845|       |
  846|  14.8k|  if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  14.8k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 14.8k]
  |  |  |  Branch (78:22): [True: 11.1k, False: 3.70k]
  |  |  |  Branch (78:43): [True: 11.1k, False: 0]
  |  |  ------------------
  ------------------
  847|  11.1k|    cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
  848|  3.70k|  else if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (848:12): [True: 1.48k, False: 2.22k]
  ------------------
  849|  1.48k|    cinfo->input_components = 1;
  850|  2.22k|  else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (850:12): [True: 2.22k, False: 0]
  ------------------
  851|  2.22k|    cinfo->input_components = 4;
  852|       |
  853|       |  /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */
  854|  14.8k|  if (need_iobuffer) {
  ------------------
  |  Branch (854:7): [True: 12.6k, False: 2.15k]
  ------------------
  855|  12.6k|    if (c == '6')
  ------------------
  |  Branch (855:9): [True: 3.40k, False: 9.25k]
  ------------------
  856|  3.40k|      source->buffer_width = (size_t)w * 3 * (maxval <= 255 ? 1 : 2);
  ------------------
  |  Branch (856:47): [True: 1.82k, False: 1.58k]
  ------------------
  857|  9.25k|    else
  858|  9.25k|      source->buffer_width = (size_t)w * (maxval <= 255 ? 1 : 2);
  ------------------
  |  Branch (858:43): [True: 8.15k, False: 1.09k]
  ------------------
  859|  12.6k|    source->iobuffer = (unsigned char *)
  860|  12.6k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  12.6k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  861|  12.6k|                                  source->buffer_width);
  862|  12.6k|  }
  863|       |
  864|       |  /* Create compressor input buffer. */
  865|  14.8k|  if (use_raw_buffer) {
  ------------------
  |  Branch (865:7): [True: 0, False: 14.8k]
  ------------------
  866|       |    /* For unscaled raw-input case, we can just map it onto the I/O buffer. */
  867|       |    /* Synthesize a _JSAMPARRAY pointer structure */
  868|      0|    source->pixrow = (_JSAMPROW)source->iobuffer;
  869|      0|    source->pub._buffer = &source->pixrow;
  ------------------
  |  |  210|      0|#define _buffer  buffer12
  ------------------
  870|      0|    source->pub.buffer_height = 1;
  871|  14.8k|  } else {
  872|       |    /* Need to translate anyway, so make a separate sample buffer. */
  873|  14.8k|    source->pub._buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  ------------------
  |  |  210|  14.8k|#define _buffer  buffer12
  ------------------
  874|  14.8k|      ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  14.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  875|  14.8k|       (JDIMENSION)w * cinfo->input_components, (JDIMENSION)1);
  876|  14.8k|    source->pub.buffer_height = 1;
  877|  14.8k|  }
  878|       |
  879|       |  /* Compute the rescaling array if required. */
  880|  14.8k|  if (need_rescale) {
  ------------------
  |  Branch (880:7): [True: 14.8k, False: 0]
  ------------------
  881|  14.8k|    size_t val, half_maxval;
  882|       |
  883|       |    /* On 16-bit-int machines we have to be careful of maxval = 65535 */
  884|  14.8k|    source->rescale = (_JSAMPLE *)
  885|  14.8k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  14.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  886|  14.8k|                                  (MAX(maxval, 255) + 1L) * sizeof(_JSAMPLE));
  ------------------
  |  |  513|  14.8k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 3.58k, False: 11.2k]
  |  |  ------------------
  ------------------
  887|  14.8k|    memset(source->rescale, 0, (MAX(maxval, 255) + 1L) * sizeof(_JSAMPLE));
  ------------------
  |  |  513|  14.8k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 3.58k, False: 11.2k]
  |  |  ------------------
  ------------------
  888|  14.8k|    half_maxval = (size_t)maxval / 2;
  889|  28.6M|    for (val = 0; val <= (size_t)maxval; val++) {
  ------------------
  |  Branch (889:19): [True: 28.6M, False: 14.8k]
  ------------------
  890|       |      /* The multiplication here must be done in 32 bits to avoid overflow */
  891|  28.6M|      source->rescale[val] =
  892|  28.6M|        (_JSAMPLE)((val * ((1 << cinfo->data_precision) - 1) + half_maxval) /
  893|  28.6M|                   maxval);
  894|  28.6M|    }
  895|  14.8k|  }
  896|  14.8k|}
rdppm-12.c:read_pbm_integer:
   92|   124k|{
   93|   124k|  register int ch;
   94|   124k|  register unsigned int val;
   95|       |
   96|       |  /* Skip any leading whitespace */
   97|   132k|  do {
   98|   132k|    ch = pbm_getc(infile);
   99|   132k|    if (ch == EOF)
  ------------------
  |  Branch (99:9): [True: 2.63k, False: 129k]
  ------------------
  100|  2.63k|      ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|  2.63k|  ((cinfo)->err->msg_code = (code), \
  |  |  241|  2.63k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  101|   132k|  } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
  ------------------
  |  Branch (101:12): [True: 3.75k, False: 128k]
  |  Branch (101:25): [True: 1.00k, False: 127k]
  |  Branch (101:39): [True: 4.17k, False: 123k]
  |  Branch (101:53): [True: 1.25k, False: 122k]
  ------------------
  102|       |
  103|   124k|  if (ch < '0' || ch > '9')
  ------------------
  |  Branch (103:7): [True: 2.78k, False: 122k]
  |  Branch (103:19): [True: 169, False: 121k]
  ------------------
  104|    319|    ERREXIT(cinfo, JERR_PPM_NONNUMERIC);
  ------------------
  |  |  240|    319|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    319|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  105|       |
  106|   124k|  val = ch - '0';
  107|   168k|  while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') {
  ------------------
  |  Branch (107:10): [True: 104k, False: 64.0k]
  |  Branch (107:44): [True: 43.2k, False: 60.8k]
  ------------------
  108|  43.2k|    val *= 10;
  109|  43.2k|    val += ch - '0';
  110|  43.2k|    if (val > maxval)
  ------------------
  |  Branch (110:9): [True: 126, False: 43.0k]
  ------------------
  111|    126|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    126|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    126|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  112|  43.2k|  }
  113|       |
  114|   124k|  return val;
  115|   124k|}
rdppm-12.c:pbm_getc:
   73|   297k|{
   74|   297k|  register int ch;
   75|       |
   76|   297k|  ch = getc(infile);
   77|   297k|  if (ch == '#') {
  ------------------
  |  Branch (77:7): [True: 3.65k, False: 293k]
  ------------------
   78|  73.5k|    do {
   79|  73.5k|      ch = getc(infile);
   80|  73.5k|    } while (ch != '\n' && ch != EOF);
  ------------------
  |  Branch (80:14): [True: 70.2k, False: 3.27k]
  |  Branch (80:28): [True: 69.8k, False: 384]
  ------------------
   81|  3.65k|  }
   82|   297k|  return ch;
   83|   297k|}
rdppm-12.c:get_text_gray_row:
  133|  1.27k|{
  134|  1.27k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  135|  1.27k|  FILE *infile = source->pub.input_file;
  136|  1.27k|  register _JSAMPROW ptr;
  137|  1.27k|  register _JSAMPLE *rescale = source->rescale;
  138|  1.27k|  JDIMENSION col;
  139|  1.27k|  unsigned int maxval = source->maxval;
  140|       |
  141|  1.27k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  1.27k|#define _buffer  buffer12
  ------------------
  142|  3.47k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (142:34): [True: 2.20k, False: 1.27k]
  ------------------
  143|  2.20k|    *ptr++ = rescale[read_pbm_integer(cinfo, infile, maxval)];
  144|  2.20k|  }
  145|  1.27k|  return 1;
  146|  1.27k|}
rdppm-12.c:get_text_gray_rgb_row:
  161|  6.38k|{
  162|  6.38k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  163|  6.38k|  FILE *infile = source->pub.input_file;
  164|  6.38k|  register _JSAMPROW ptr;
  165|  6.38k|  register _JSAMPLE *rescale = source->rescale;
  166|  6.38k|  JDIMENSION col;
  167|  6.38k|  unsigned int maxval = source->maxval;
  168|  6.38k|  register int rindex = rgb_red[cinfo->in_color_space];
  169|  6.38k|  register int gindex = rgb_green[cinfo->in_color_space];
  170|  6.38k|  register int bindex = rgb_blue[cinfo->in_color_space];
  171|  6.38k|  register int aindex = alpha_index[cinfo->in_color_space];
  172|  6.38k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  173|       |
  174|  6.38k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  6.38k|#define _buffer  buffer12
  ------------------
  175|  6.38k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (175:7): [True: 1.22k, False: 5.16k]
  ------------------
  176|  1.22k|    if (aindex >= 0)
  ------------------
  |  Branch (176:9): [True: 244, False: 976]
  ------------------
  177|    244|      GRAY_RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
  ------------------
  |  |  149|    244|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|    686|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 442, False: 244]
  |  |  ------------------
  |  |  151|    442|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|    442|    alpha_set_op \
  |  |  153|    442|    ptr += ps; \
  |  |  154|    442|  } \
  |  |  155|    244|}
  ------------------
  178|  1.22k|                         ptr[aindex] = (_JSAMPLE)maxval;)
  179|    976|    else
  180|    976|      GRAY_RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
  ------------------
  |  |  149|    976|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  2.74k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 1.76k, False: 976]
  |  |  ------------------
  |  |  151|  1.76k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  1.76k|    alpha_set_op \
  |  |  153|  1.76k|    ptr += ps; \
  |  |  154|  1.76k|  } \
  |  |  155|    976|}
  ------------------
  181|  5.16k|  } else {
  182|  5.16k|    if (aindex >= 0)
  ------------------
  |  Branch (182:9): [True: 1.03k, False: 4.13k]
  ------------------
  183|  1.03k|      GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
  ------------------
  |  |  149|  1.03k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  2.79k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 1.75k, False: 1.03k]
  |  |  ------------------
  |  |  151|  1.75k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  1.75k|    alpha_set_op \
  |  |  153|  1.75k|    ptr += ps; \
  |  |  154|  1.75k|  } \
  |  |  155|  1.03k|}
  ------------------
  184|  5.16k|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  185|  4.13k|    else
  186|  4.13k|      GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
  ------------------
  |  |  149|  4.13k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  11.1k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 7.03k, False: 4.13k]
  |  |  ------------------
  |  |  151|  7.03k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  7.03k|    alpha_set_op \
  |  |  153|  7.03k|    ptr += ps; \
  |  |  154|  7.03k|  } \
  |  |  155|  4.13k|}
  ------------------
  187|  5.16k|  }
  188|  6.38k|  return 1;
  189|  6.38k|}
rdppm-12.c:get_text_gray_cmyk_row:
  196|  1.27k|{
  197|  1.27k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  198|  1.27k|  FILE *infile = source->pub.input_file;
  199|  1.27k|  register _JSAMPROW ptr;
  200|  1.27k|  register _JSAMPLE *rescale = source->rescale;
  201|  1.27k|  JDIMENSION col;
  202|  1.27k|  unsigned int maxval = source->maxval;
  203|       |
  204|  1.27k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  1.27k|#define _buffer  buffer12
  ------------------
  205|  1.27k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (205:7): [True: 244, False: 1.03k]
  ------------------
  206|    686|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (206:36): [True: 442, False: 244]
  ------------------
  207|    442|      _JSAMPLE gray = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  108|    442|#define _JSAMPLE  J12SAMPLE
  ------------------
  208|    442|      rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
  209|    442|      ptr += 4;
  210|    442|    }
  211|  1.03k|  } else {
  212|  2.79k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (212:36): [True: 1.75k, False: 1.03k]
  ------------------
  213|  1.75k|      _JSAMPLE gray = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  108|  1.75k|#define _JSAMPLE  J12SAMPLE
  ------------------
  214|  1.75k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  215|  1.75k|                  ptr + 1, ptr + 2, ptr + 3);
  216|  1.75k|      ptr += 4;
  217|  1.75k|    }
  218|  1.03k|  }
  219|  1.27k|  return 1;
  220|  1.27k|}
rdppm-12.c:get_text_rgb_row:
  236|  7.16k|{
  237|  7.16k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  238|  7.16k|  FILE *infile = source->pub.input_file;
  239|  7.16k|  register _JSAMPROW ptr;
  240|  7.16k|  register _JSAMPLE *rescale = source->rescale;
  241|  7.16k|  JDIMENSION col;
  242|  7.16k|  unsigned int maxval = source->maxval;
  243|  7.16k|  register int rindex = rgb_red[cinfo->in_color_space];
  244|  7.16k|  register int gindex = rgb_green[cinfo->in_color_space];
  245|  7.16k|  register int bindex = rgb_blue[cinfo->in_color_space];
  246|  7.16k|  register int aindex = alpha_index[cinfo->in_color_space];
  247|  7.16k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  248|       |
  249|  7.16k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  7.16k|#define _buffer  buffer12
  ------------------
  250|  7.16k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (250:7): [True: 1.33k, False: 5.83k]
  ------------------
  251|  1.33k|    if (aindex >= 0)
  ------------------
  |  Branch (251:9): [True: 266, False: 1.06k]
  ------------------
  252|    266|      RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
  ------------------
  |  |  223|    266|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  1.71k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 1.44k, False: 266]
  |  |  ------------------
  |  |  225|  1.44k|    ptr[rindex] = read_op; \
  |  |  226|  1.44k|    ptr[gindex] = read_op; \
  |  |  227|  1.44k|    ptr[bindex] = read_op; \
  |  |  228|  1.44k|    alpha_set_op \
  |  |  229|  1.44k|    ptr += ps; \
  |  |  230|  1.44k|  } \
  |  |  231|    266|}
  ------------------
  253|  1.33k|                    ptr[aindex] = (_JSAMPLE)maxval;)
  254|  1.06k|    else
  255|  1.06k|      RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
  ------------------
  |  |  223|  1.06k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  6.84k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 5.77k, False: 1.06k]
  |  |  ------------------
  |  |  225|  5.77k|    ptr[rindex] = read_op; \
  |  |  226|  5.77k|    ptr[gindex] = read_op; \
  |  |  227|  5.77k|    ptr[bindex] = read_op; \
  |  |  228|  5.77k|    alpha_set_op \
  |  |  229|  5.77k|    ptr += ps; \
  |  |  230|  5.77k|  } \
  |  |  231|  1.06k|}
  ------------------
  256|  5.83k|  } else {
  257|  5.83k|    if (aindex >= 0)
  ------------------
  |  Branch (257:9): [True: 1.16k, False: 4.66k]
  ------------------
  258|  1.16k|      RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
  ------------------
  |  |  223|  1.16k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  3.17k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 2.00k, False: 1.16k]
  |  |  ------------------
  |  |  225|  2.00k|    ptr[rindex] = read_op; \
  |  |  226|  2.00k|    ptr[gindex] = read_op; \
  |  |  227|  2.00k|    ptr[bindex] = read_op; \
  |  |  228|  2.00k|    alpha_set_op \
  |  |  229|  2.00k|    ptr += ps; \
  |  |  230|  2.00k|  } \
  |  |  231|  1.16k|}
  ------------------
  259|  5.83k|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  260|  4.66k|    else
  261|  4.66k|      RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
  ------------------
  |  |  223|  4.66k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  12.6k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 8.01k, False: 4.66k]
  |  |  ------------------
  |  |  225|  8.01k|    ptr[rindex] = read_op; \
  |  |  226|  8.01k|    ptr[gindex] = read_op; \
  |  |  227|  8.01k|    ptr[bindex] = read_op; \
  |  |  228|  8.01k|    alpha_set_op \
  |  |  229|  8.01k|    ptr += ps; \
  |  |  230|  8.01k|  } \
  |  |  231|  4.66k|}
  ------------------
  262|  5.83k|  }
  263|  7.16k|  return 1;
  264|  7.16k|}
rdppm-12.c:get_text_rgb_cmyk_row:
  271|  1.43k|{
  272|  1.43k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  273|  1.43k|  FILE *infile = source->pub.input_file;
  274|  1.43k|  register _JSAMPROW ptr;
  275|  1.43k|  register _JSAMPLE *rescale = source->rescale;
  276|  1.43k|  JDIMENSION col;
  277|  1.43k|  unsigned int maxval = source->maxval;
  278|       |
  279|  1.43k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  1.43k|#define _buffer  buffer12
  ------------------
  280|  1.43k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (280:7): [True: 266, False: 1.16k]
  ------------------
  281|  1.71k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (281:36): [True: 1.44k, False: 266]
  ------------------
  282|  1.44k|      _JSAMPLE r = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  108|  1.44k|#define _JSAMPLE  J12SAMPLE
  ------------------
  283|  1.44k|      _JSAMPLE g = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  108|  1.44k|#define _JSAMPLE  J12SAMPLE
  ------------------
  284|  1.44k|      _JSAMPLE b = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  108|  1.44k|#define _JSAMPLE  J12SAMPLE
  ------------------
  285|  1.44k|      rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
  286|  1.44k|      ptr += 4;
  287|  1.44k|    }
  288|  1.16k|  } else {
  289|  3.17k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (289:36): [True: 2.00k, False: 1.16k]
  ------------------
  290|  2.00k|      _JSAMPLE r = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  108|  2.00k|#define _JSAMPLE  J12SAMPLE
  ------------------
  291|  2.00k|      _JSAMPLE g = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  108|  2.00k|#define _JSAMPLE  J12SAMPLE
  ------------------
  292|  2.00k|      _JSAMPLE b = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  108|  2.00k|#define _JSAMPLE  J12SAMPLE
  ------------------
  293|  2.00k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  294|  2.00k|                  ptr + 2, ptr + 3);
  295|  2.00k|      ptr += 4;
  296|  2.00k|    }
  297|  1.16k|  }
  298|  1.43k|  return 1;
  299|  1.43k|}
rdppm-12.c:get_word_gray_row:
  491|  34.6k|{
  492|  34.6k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  493|  34.6k|  register _JSAMPROW ptr;
  494|  34.6k|  register unsigned char *bufferptr;
  495|  34.6k|  register _JSAMPLE *rescale = source->rescale;
  496|  34.6k|  JDIMENSION col;
  497|  34.6k|  unsigned int maxval = source->maxval;
  498|       |
  499|  34.6k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  34.6k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (499:7): [True: 86, False: 34.5k]
  ------------------
  500|     86|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     86|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     86|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  501|  34.6k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  34.6k|#define _buffer  buffer12
  ------------------
  502|  34.6k|  bufferptr = source->iobuffer;
  503|  70.3k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (503:34): [True: 35.7k, False: 34.6k]
  ------------------
  504|  35.7k|    register unsigned int temp;
  505|  35.7k|    temp  = (*bufferptr++) << 8;
  506|  35.7k|    temp |= (*bufferptr++);
  507|  35.7k|    if (temp > maxval)
  ------------------
  |  Branch (507:9): [True: 58, False: 35.6k]
  ------------------
  508|     58|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     58|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     58|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  509|  35.7k|    *ptr++ = rescale[temp];
  510|  35.7k|  }
  511|  34.6k|  return 1;
  512|  34.6k|}
rdppm-12.c:get_word_gray_rgb_row:
  518|   173k|{
  519|   173k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  520|   173k|  register _JSAMPROW ptr;
  521|   173k|  register unsigned char *bufferptr;
  522|   173k|  register _JSAMPLE *rescale = source->rescale;
  523|   173k|  JDIMENSION col;
  524|   173k|  unsigned int maxval = source->maxval;
  525|   173k|  register int rindex = rgb_red[cinfo->in_color_space];
  526|   173k|  register int gindex = rgb_green[cinfo->in_color_space];
  527|   173k|  register int bindex = rgb_blue[cinfo->in_color_space];
  528|   173k|  register int aindex = alpha_index[cinfo->in_color_space];
  529|   173k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  530|       |
  531|   173k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|   173k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (531:7): [True: 430, False: 172k]
  ------------------
  532|    430|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    430|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    430|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  533|   173k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|   173k|#define _buffer  buffer12
  ------------------
  534|   173k|  bufferptr = source->iobuffer;
  535|   351k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (535:34): [True: 178k, False: 173k]
  ------------------
  536|   178k|    register unsigned int temp;
  537|   178k|    temp  = (*bufferptr++) << 8;
  538|   178k|    temp |= (*bufferptr++);
  539|   178k|    if (temp > maxval)
  ------------------
  |  Branch (539:9): [True: 290, False: 178k]
  ------------------
  540|    290|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    290|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    290|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  541|   178k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = rescale[temp];
  542|   178k|    if (aindex >= 0)
  ------------------
  |  Branch (542:9): [True: 35.6k, False: 143k]
  ------------------
  543|  35.6k|      ptr[aindex] = (1 << cinfo->data_precision) - 1;
  544|   178k|    ptr += ps;
  545|   178k|  }
  546|   173k|  return 1;
  547|   173k|}
rdppm-12.c:get_word_gray_cmyk_row:
  553|  34.6k|{
  554|  34.6k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  555|  34.6k|  register _JSAMPROW ptr;
  556|  34.6k|  register unsigned char *bufferptr;
  557|  34.6k|  register _JSAMPLE *rescale = source->rescale;
  558|  34.6k|  JDIMENSION col;
  559|  34.6k|  unsigned int maxval = source->maxval;
  560|       |
  561|  34.6k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  34.6k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (561:7): [True: 86, False: 34.5k]
  ------------------
  562|     86|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     86|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     86|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  563|  34.6k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  34.6k|#define _buffer  buffer12
  ------------------
  564|  34.6k|  bufferptr = source->iobuffer;
  565|  34.6k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (565:7): [True: 272, False: 34.3k]
  ------------------
  566|  1.08k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (566:36): [True: 812, False: 272]
  ------------------
  567|    812|      register unsigned int gray;
  568|    812|      gray  = (*bufferptr++) << 8;
  569|    812|      gray |= (*bufferptr++);
  570|    812|      if (gray > maxval)
  ------------------
  |  Branch (570:11): [True: 21, False: 791]
  ------------------
  571|     21|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     21|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     21|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  572|    812|      rgb_to_cmyk(maxval, (_JSAMPLE)gray, (_JSAMPLE)gray, (_JSAMPLE)gray, ptr,
  573|    812|                  ptr + 1, ptr + 2, ptr + 3);
  574|    812|      ptr += 4;
  575|    812|    }
  576|  34.3k|  } else {
  577|  69.2k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (577:36): [True: 34.9k, False: 34.3k]
  ------------------
  578|  34.9k|      register unsigned int temp;
  579|  34.9k|      _JSAMPLE gray;
  ------------------
  |  |  108|  34.9k|#define _JSAMPLE  J12SAMPLE
  ------------------
  580|  34.9k|      temp  = (*bufferptr++) << 8;
  581|  34.9k|      temp |= (*bufferptr++);
  582|  34.9k|      if (temp > maxval)
  ------------------
  |  Branch (582:11): [True: 37, False: 34.9k]
  ------------------
  583|     37|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     37|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     37|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  584|  34.9k|      gray = rescale[temp];
  585|  34.9k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  586|  34.9k|                  ptr + 1, ptr + 2, ptr + 3);
  587|  34.9k|      ptr += 4;
  588|  34.9k|    }
  589|  34.3k|  }
  590|  34.6k|  return 1;
  591|  34.6k|}
rdppm-12.c:get_scaled_gray_row:
  305|  3.51M|{
  306|  3.51M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  307|  3.51M|  register _JSAMPROW ptr;
  308|  3.51M|  register unsigned char *bufferptr;
  309|  3.51M|  register _JSAMPLE *rescale = source->rescale;
  310|  3.51M|  JDIMENSION col;
  311|       |
  312|  3.51M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  3.51M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (312:7): [True: 74, False: 3.51M]
  ------------------
  313|     74|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     74|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     74|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  314|  3.51M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  3.51M|#define _buffer  buffer12
  ------------------
  315|  3.51M|  bufferptr = source->iobuffer;
  316|  22.9M|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (316:34): [True: 19.4M, False: 3.51M]
  ------------------
  317|  19.4M|    *ptr++ = rescale[*bufferptr++];
  318|  19.4M|  }
  319|  3.51M|  return 1;
  320|  3.51M|}
rdppm-12.c:get_gray_rgb_row:
  327|  17.5M|{
  328|  17.5M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  329|  17.5M|  register _JSAMPROW ptr;
  330|  17.5M|  register unsigned char *bufferptr;
  331|  17.5M|  register _JSAMPLE *rescale = source->rescale;
  332|  17.5M|  JDIMENSION col;
  333|  17.5M|  unsigned int maxval = source->maxval;
  334|  17.5M|  register int rindex = rgb_red[cinfo->in_color_space];
  335|  17.5M|  register int gindex = rgb_green[cinfo->in_color_space];
  336|  17.5M|  register int bindex = rgb_blue[cinfo->in_color_space];
  337|  17.5M|  register int aindex = alpha_index[cinfo->in_color_space];
  338|  17.5M|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  339|       |
  340|  17.5M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  17.5M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (340:7): [True: 370, False: 17.5M]
  ------------------
  341|    370|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    370|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    370|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  342|  17.5M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  17.5M|#define _buffer  buffer12
  ------------------
  343|  17.5M|  bufferptr = source->iobuffer;
  344|  17.5M|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (344:7): [True: 0, False: 17.5M]
  ------------------
  345|      0|    if (aindex >= 0)
  ------------------
  |  Branch (345:9): [True: 0, False: 0]
  ------------------
  346|      0|      GRAY_RGB_READ_LOOP(*bufferptr++, ptr[aindex] = (_JSAMPLE)maxval;)
  ------------------
  |  |  149|      0|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|      0|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 0, False: 0]
  |  |  ------------------
  |  |  151|      0|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|      0|    alpha_set_op \
  |  |  153|      0|    ptr += ps; \
  |  |  154|      0|  } \
  |  |  155|      0|}
  ------------------
  347|      0|    else
  348|      0|      GRAY_RGB_READ_LOOP(*bufferptr++, {})
  ------------------
  |  |  149|      0|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|      0|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 0, False: 0]
  |  |  ------------------
  |  |  151|      0|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|      0|    alpha_set_op \
  |  |  153|      0|    ptr += ps; \
  |  |  154|      0|  } \
  |  |  155|      0|}
  ------------------
  349|  17.5M|  } else {
  350|  17.5M|    if (aindex >= 0)
  ------------------
  |  Branch (350:9): [True: 3.51M, False: 14.0M]
  ------------------
  351|  3.51M|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  149|  3.51M|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  22.9M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 19.4M, False: 3.51M]
  |  |  ------------------
  |  |  151|  19.4M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  19.4M|    alpha_set_op \
  |  |  153|  19.4M|    ptr += ps; \
  |  |  154|  19.4M|  } \
  |  |  155|  3.51M|}
  ------------------
  352|  17.5M|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  353|  14.0M|    else
  354|  14.0M|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++], {})
  ------------------
  |  |  149|  14.0M|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  91.8M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 77.8M, False: 14.0M]
  |  |  ------------------
  |  |  151|  77.8M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  77.8M|    alpha_set_op \
  |  |  153|  77.8M|    ptr += ps; \
  |  |  154|  77.8M|  } \
  |  |  155|  14.0M|}
  ------------------
  355|  17.5M|  }
  356|  17.5M|  return 1;
  357|  17.5M|}
rdppm-12.c:get_gray_cmyk_row:
  364|  3.51M|{
  365|  3.51M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  366|  3.51M|  register _JSAMPROW ptr;
  367|  3.51M|  register unsigned char *bufferptr;
  368|  3.51M|  register _JSAMPLE *rescale = source->rescale;
  369|  3.51M|  JDIMENSION col;
  370|  3.51M|  unsigned int maxval = source->maxval;
  371|       |
  372|  3.51M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  3.51M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (372:7): [True: 74, False: 3.51M]
  ------------------
  373|     74|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     74|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     74|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  374|  3.51M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  3.51M|#define _buffer  buffer12
  ------------------
  375|  3.51M|  bufferptr = source->iobuffer;
  376|  3.51M|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (376:7): [True: 0, False: 3.51M]
  ------------------
  377|      0|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (377:36): [True: 0, False: 0]
  ------------------
  378|      0|      _JSAMPLE gray = *bufferptr++;
  ------------------
  |  |  108|      0|#define _JSAMPLE  J12SAMPLE
  ------------------
  379|      0|      rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
  380|      0|      ptr += 4;
  381|      0|    }
  382|  3.51M|  } else {
  383|  22.9M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (383:36): [True: 19.4M, False: 3.51M]
  ------------------
  384|  19.4M|      _JSAMPLE gray = rescale[*bufferptr++];
  ------------------
  |  |  108|  19.4M|#define _JSAMPLE  J12SAMPLE
  ------------------
  385|  19.4M|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  386|  19.4M|                  ptr + 1, ptr + 2, ptr + 3);
  387|  19.4M|      ptr += 4;
  388|  19.4M|    }
  389|  3.51M|  }
  390|  3.51M|  return 1;
  391|  3.51M|}
rdppm-12.c:get_word_rgb_row:
  597|  15.3k|{
  598|  15.3k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  599|  15.3k|  register _JSAMPROW ptr;
  600|  15.3k|  register unsigned char *bufferptr;
  601|  15.3k|  register _JSAMPLE *rescale = source->rescale;
  602|  15.3k|  JDIMENSION col;
  603|  15.3k|  unsigned int maxval = source->maxval;
  604|  15.3k|  register int rindex = rgb_red[cinfo->in_color_space];
  605|  15.3k|  register int gindex = rgb_green[cinfo->in_color_space];
  606|  15.3k|  register int bindex = rgb_blue[cinfo->in_color_space];
  607|  15.3k|  register int aindex = alpha_index[cinfo->in_color_space];
  608|  15.3k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  609|       |
  610|  15.3k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  15.3k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (610:7): [True: 575, False: 14.8k]
  ------------------
  611|    575|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    575|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    575|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  612|  15.3k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  15.3k|#define _buffer  buffer12
  ------------------
  613|  15.3k|  bufferptr = source->iobuffer;
  614|  37.5k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (614:34): [True: 22.1k, False: 15.3k]
  ------------------
  615|  22.1k|    register unsigned int temp;
  616|  22.1k|    temp  = (*bufferptr++) << 8;
  617|  22.1k|    temp |= (*bufferptr++);
  618|  22.1k|    if (temp > maxval)
  ------------------
  |  Branch (618:9): [True: 270, False: 21.9k]
  ------------------
  619|    270|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    270|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    270|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  620|  22.1k|    ptr[rindex] = rescale[temp];
  621|  22.1k|    temp  = (*bufferptr++) << 8;
  622|  22.1k|    temp |= (*bufferptr++);
  623|  22.1k|    if (temp > maxval)
  ------------------
  |  Branch (623:9): [True: 235, False: 21.9k]
  ------------------
  624|    235|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    235|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    235|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  625|  22.1k|    ptr[gindex] = rescale[temp];
  626|  22.1k|    temp  = (*bufferptr++) << 8;
  627|  22.1k|    temp |= (*bufferptr++);
  628|  22.1k|    if (temp > maxval)
  ------------------
  |  Branch (628:9): [True: 190, False: 21.9k]
  ------------------
  629|    190|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    190|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    190|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  630|  22.1k|    ptr[bindex] = rescale[temp];
  631|  22.1k|    if (aindex >= 0)
  ------------------
  |  Branch (631:9): [True: 4.29k, False: 17.8k]
  ------------------
  632|  4.29k|      ptr[aindex] = (1 << cinfo->data_precision) - 1;
  633|  22.1k|    ptr += ps;
  634|  22.1k|  }
  635|  15.3k|  return 1;
  636|  15.3k|}
rdppm-12.c:get_word_rgb_cmyk_row:
  642|  3.07k|{
  643|  3.07k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  644|  3.07k|  register _JSAMPROW ptr;
  645|  3.07k|  register unsigned char *bufferptr;
  646|  3.07k|  register _JSAMPLE *rescale = source->rescale;
  647|  3.07k|  JDIMENSION col;
  648|  3.07k|  unsigned int maxval = source->maxval;
  649|       |
  650|  3.07k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  3.07k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (650:7): [True: 115, False: 2.96k]
  ------------------
  651|    115|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    115|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    115|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  652|  3.07k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  3.07k|#define _buffer  buffer12
  ------------------
  653|  3.07k|  bufferptr = source->iobuffer;
  654|  3.07k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (654:7): [True: 629, False: 2.44k]
  ------------------
  655|  1.81k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (655:36): [True: 1.18k, False: 629]
  ------------------
  656|  1.18k|      register unsigned int r, g, b;
  657|  1.18k|      r  = (*bufferptr++) << 8;
  658|  1.18k|      r |= (*bufferptr++);
  659|  1.18k|      if (r > maxval)
  ------------------
  |  Branch (659:11): [True: 20, False: 1.16k]
  ------------------
  660|     20|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     20|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     20|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  661|  1.18k|      g  = (*bufferptr++) << 8;
  662|  1.18k|      g |= (*bufferptr++);
  663|  1.18k|      if (g > maxval)
  ------------------
  |  Branch (663:11): [True: 22, False: 1.16k]
  ------------------
  664|     22|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     22|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     22|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  665|  1.18k|      b  = (*bufferptr++) << 8;
  666|  1.18k|      b |= (*bufferptr++);
  667|  1.18k|      if (b > maxval)
  ------------------
  |  Branch (667:11): [True: 17, False: 1.17k]
  ------------------
  668|     17|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     17|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     17|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  669|  1.18k|      rgb_to_cmyk(maxval, (_JSAMPLE)r, (_JSAMPLE)g, (_JSAMPLE)b, ptr, ptr + 1,
  670|  1.18k|                  ptr + 2, ptr + 3);
  671|  1.18k|      ptr += 4;
  672|  1.18k|    }
  673|  2.44k|  } else {
  674|  5.69k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (674:36): [True: 3.24k, False: 2.44k]
  ------------------
  675|  3.24k|      register unsigned int r, g, b;
  676|  3.24k|      r  = (*bufferptr++) << 8;
  677|  3.24k|      r |= (*bufferptr++);
  678|  3.24k|      if (r > maxval)
  ------------------
  |  Branch (678:11): [True: 34, False: 3.21k]
  ------------------
  679|     34|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     34|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     34|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  680|  3.24k|      g  = (*bufferptr++) << 8;
  681|  3.24k|      g |= (*bufferptr++);
  682|  3.24k|      if (g > maxval)
  ------------------
  |  Branch (682:11): [True: 25, False: 3.22k]
  ------------------
  683|     25|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     25|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     25|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  684|  3.24k|      b  = (*bufferptr++) << 8;
  685|  3.24k|      b |= (*bufferptr++);
  686|  3.24k|      if (b > maxval)
  ------------------
  |  Branch (686:11): [True: 21, False: 3.22k]
  ------------------
  687|     21|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     21|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     21|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  688|  3.24k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, rescale[r], rescale[g],
  689|  3.24k|                  rescale[b], ptr, ptr + 1, ptr + 2, ptr + 3);
  690|  3.24k|      ptr += 4;
  691|  3.24k|    }
  692|  2.44k|  }
  693|  3.07k|  return 1;
  694|  3.07k|}
rdppm-12.c:get_rgb_row:
  397|  3.84M|{
  398|  3.84M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  399|  3.84M|  register _JSAMPROW ptr;
  400|  3.84M|  register unsigned char *bufferptr;
  401|  3.84M|  register _JSAMPLE *rescale = source->rescale;
  402|  3.84M|  JDIMENSION col;
  403|  3.84M|  unsigned int maxval = source->maxval;
  404|  3.84M|  register int rindex = rgb_red[cinfo->in_color_space];
  405|  3.84M|  register int gindex = rgb_green[cinfo->in_color_space];
  406|  3.84M|  register int bindex = rgb_blue[cinfo->in_color_space];
  407|  3.84M|  register int aindex = alpha_index[cinfo->in_color_space];
  408|  3.84M|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  409|       |
  410|  3.84M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  3.84M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (410:7): [True: 495, False: 3.84M]
  ------------------
  411|    495|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    495|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    495|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  412|  3.84M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  3.84M|#define _buffer  buffer12
  ------------------
  413|  3.84M|  bufferptr = source->iobuffer;
  414|  3.84M|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (414:7): [True: 0, False: 3.84M]
  ------------------
  415|      0|    if (aindex >= 0)
  ------------------
  |  Branch (415:9): [True: 0, False: 0]
  ------------------
  416|      0|      RGB_READ_LOOP(*bufferptr++, ptr[aindex] = (_JSAMPLE)maxval;)
  ------------------
  |  |  223|      0|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|      0|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 0, False: 0]
  |  |  ------------------
  |  |  225|      0|    ptr[rindex] = read_op; \
  |  |  226|      0|    ptr[gindex] = read_op; \
  |  |  227|      0|    ptr[bindex] = read_op; \
  |  |  228|      0|    alpha_set_op \
  |  |  229|      0|    ptr += ps; \
  |  |  230|      0|  } \
  |  |  231|      0|}
  ------------------
  417|      0|    else
  418|      0|      RGB_READ_LOOP(*bufferptr++, {})
  ------------------
  |  |  223|      0|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|      0|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 0, False: 0]
  |  |  ------------------
  |  |  225|      0|    ptr[rindex] = read_op; \
  |  |  226|      0|    ptr[gindex] = read_op; \
  |  |  227|      0|    ptr[bindex] = read_op; \
  |  |  228|      0|    alpha_set_op \
  |  |  229|      0|    ptr += ps; \
  |  |  230|      0|  } \
  |  |  231|      0|}
  ------------------
  419|  3.84M|  } else {
  420|  3.84M|    if (aindex >= 0)
  ------------------
  |  Branch (420:9): [True: 769k, False: 3.07M]
  ------------------
  421|   769k|      RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  223|   769k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  6.22M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 5.45M, False: 769k]
  |  |  ------------------
  |  |  225|  5.45M|    ptr[rindex] = read_op; \
  |  |  226|  5.45M|    ptr[gindex] = read_op; \
  |  |  227|  5.45M|    ptr[bindex] = read_op; \
  |  |  228|  5.45M|    alpha_set_op \
  |  |  229|  5.45M|    ptr += ps; \
  |  |  230|  5.45M|  } \
  |  |  231|   769k|}
  ------------------
  422|  3.84M|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  423|  3.07M|    else
  424|  3.07M|      RGB_READ_LOOP(rescale[*bufferptr++], {})
  ------------------
  |  |  223|  3.07M|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  24.8M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 21.8M, False: 3.07M]
  |  |  ------------------
  |  |  225|  21.8M|    ptr[rindex] = read_op; \
  |  |  226|  21.8M|    ptr[gindex] = read_op; \
  |  |  227|  21.8M|    ptr[bindex] = read_op; \
  |  |  228|  21.8M|    alpha_set_op \
  |  |  229|  21.8M|    ptr += ps; \
  |  |  230|  21.8M|  } \
  |  |  231|  3.07M|}
  ------------------
  425|  3.84M|  }
  426|  3.84M|  return 1;
  427|  3.84M|}
rdppm-12.c:get_rgb_cmyk_row:
  434|   769k|{
  435|   769k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  436|   769k|  register _JSAMPROW ptr;
  437|   769k|  register unsigned char *bufferptr;
  438|   769k|  register _JSAMPLE *rescale = source->rescale;
  439|   769k|  JDIMENSION col;
  440|   769k|  unsigned int maxval = source->maxval;
  441|       |
  442|   769k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|   769k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (442:7): [True: 99, False: 769k]
  ------------------
  443|     99|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     99|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     99|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  444|   769k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|   769k|#define _buffer  buffer12
  ------------------
  445|   769k|  bufferptr = source->iobuffer;
  446|   769k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (446:7): [True: 0, False: 769k]
  ------------------
  447|      0|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (447:36): [True: 0, False: 0]
  ------------------
  448|      0|      _JSAMPLE r = *bufferptr++;
  ------------------
  |  |  108|      0|#define _JSAMPLE  J12SAMPLE
  ------------------
  449|      0|      _JSAMPLE g = *bufferptr++;
  ------------------
  |  |  108|      0|#define _JSAMPLE  J12SAMPLE
  ------------------
  450|      0|      _JSAMPLE b = *bufferptr++;
  ------------------
  |  |  108|      0|#define _JSAMPLE  J12SAMPLE
  ------------------
  451|      0|      rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
  452|      0|      ptr += 4;
  453|      0|    }
  454|   769k|  } else {
  455|  6.22M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (455:36): [True: 5.45M, False: 769k]
  ------------------
  456|  5.45M|      _JSAMPLE r = rescale[*bufferptr++];
  ------------------
  |  |  108|  5.45M|#define _JSAMPLE  J12SAMPLE
  ------------------
  457|  5.45M|      _JSAMPLE g = rescale[*bufferptr++];
  ------------------
  |  |  108|  5.45M|#define _JSAMPLE  J12SAMPLE
  ------------------
  458|  5.45M|      _JSAMPLE b = rescale[*bufferptr++];
  ------------------
  |  |  108|  5.45M|#define _JSAMPLE  J12SAMPLE
  ------------------
  459|  5.45M|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  460|  5.45M|                  ptr + 2, ptr + 3);
  461|  5.45M|      ptr += 4;
  462|  5.45M|    }
  463|   769k|  }
  464|   769k|  return 1;
  465|   769k|}
rdppm-12.c:finish_input_ppm:
  913|  17.1k|{
  914|       |  /* no work */
  915|  17.1k|}

spng_decode_scanline:
 3294|   376k|{
 3295|   376k|    if(ctx == NULL || out == NULL) return 1;
  ------------------
  |  Branch (3295:8): [True: 0, False: 376k]
  |  Branch (3295:23): [True: 0, False: 376k]
  ------------------
 3296|       |
 3297|   376k|    if(ctx->state >= SPNG_STATE_EOI) return SPNG_EOI;
  ------------------
  |  Branch (3297:8): [True: 0, False: 376k]
  ------------------
 3298|       |
 3299|   376k|    struct decode_flags f = ctx->decode_flags;
 3300|       |
 3301|   376k|    struct spng_row_info *ri = &ctx->row_info;
 3302|   376k|    const struct spng_subimage *sub = ctx->subimage;
 3303|       |
 3304|   376k|    const struct spng_ihdr *ihdr = &ctx->ihdr;
 3305|   376k|    const uint16_t *gamma_lut = ctx->gamma_lut;
 3306|   376k|    unsigned char *trns_px = ctx->trns_px;
 3307|   376k|    const struct spng_sbit *sb = &ctx->decode_sb;
 3308|   376k|    const struct spng_plte_entry *plte = ctx->decode_plte.rgba;
 3309|   376k|    struct spng__iter iter = spng__iter_init(ihdr->bit_depth, ctx->scanline);
 3310|       |
 3311|   376k|    const unsigned char *scanline;
 3312|       |
 3313|   376k|    const int pass = ri->pass;
 3314|   376k|    const int fmt = ctx->fmt;
 3315|   376k|    const size_t scanline_width = sub[pass].scanline_width;
 3316|   376k|    const uint32_t width = sub[pass].width;
 3317|   376k|    uint32_t k;
 3318|   376k|    uint8_t r_8, g_8, b_8, a_8, gray_8;
 3319|   376k|    uint16_t r_16, g_16, b_16, a_16, gray_16;
 3320|   376k|    r_8=0; g_8=0; b_8=0; a_8=0; gray_8=0;
 3321|   376k|    r_16=0; g_16=0; b_16=0; a_16=0; gray_16=0;
 3322|   376k|    size_t pixel_size = 4; /* SPNG_FMT_RGBA8 */
 3323|   376k|    size_t pixel_offset = 0;
 3324|   376k|    unsigned char *pixel;
 3325|   376k|    unsigned processing_depth = ihdr->bit_depth;
 3326|       |
 3327|   376k|    if(f.indexed) processing_depth = 8;
  ------------------
  |  Branch (3327:8): [True: 582, False: 375k]
  ------------------
 3328|       |
 3329|   376k|    if(fmt == SPNG_FMT_RGBA16) pixel_size = 8;
  ------------------
  |  Branch (3329:8): [True: 0, False: 376k]
  ------------------
 3330|   376k|    else if(fmt == SPNG_FMT_RGB8) pixel_size = 3;
  ------------------
  |  Branch (3330:13): [True: 0, False: 376k]
  ------------------
 3331|       |
 3332|   376k|    if(len < sub[pass].out_width) return SPNG_EBUFSIZ;
  ------------------
  |  Branch (3332:8): [True: 0, False: 376k]
  ------------------
 3333|       |
 3334|   376k|    int ret = read_scanline(ctx);
 3335|       |
 3336|   376k|    if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3336:8): [True: 3.26k, False: 373k]
  ------------------
 3337|       |
 3338|   373k|    scanline = ctx->scanline;
 3339|       |
 3340|   373k|    for(k=0; k < width; k++)
  ------------------
  |  Branch (3340:14): [True: 373k, False: 0]
  ------------------
 3341|   373k|    {
 3342|   373k|        pixel = (unsigned char*)out + pixel_offset;
 3343|   373k|        pixel_offset += pixel_size;
 3344|       |
 3345|   373k|        if(f.same_layout)
  ------------------
  |  Branch (3345:12): [True: 373k, False: 0]
  ------------------
 3346|   373k|        {
 3347|   373k|            if(f.zerocopy) break;
  ------------------
  |  Branch (3347:16): [True: 0, False: 373k]
  ------------------
 3348|       |
 3349|   373k|            memcpy(out, scanline, scanline_width - 1);
 3350|   373k|            break;
 3351|   373k|        }
 3352|       |
 3353|      0|        if(f.unpack)
  ------------------
  |  Branch (3353:12): [True: 0, False: 0]
  ------------------
 3354|      0|        {
 3355|      0|            unpack_scanline(out, scanline, width, ihdr->bit_depth, fmt);
 3356|      0|            break;
 3357|      0|        }
 3358|       |
 3359|      0|        if(ihdr->color_type == SPNG_COLOR_TYPE_TRUECOLOR)
  ------------------
  |  Branch (3359:12): [True: 0, False: 0]
  ------------------
 3360|      0|        {
 3361|      0|            if(ihdr->bit_depth == 16)
  ------------------
  |  Branch (3361:16): [True: 0, False: 0]
  ------------------
 3362|      0|            {
 3363|      0|                memcpy(&r_16, scanline + (k * 6), 2);
 3364|      0|                memcpy(&g_16, scanline + (k * 6) + 2, 2);
 3365|      0|                memcpy(&b_16, scanline + (k * 6) + 4, 2);
 3366|       |
 3367|      0|                a_16 = 65535;
 3368|      0|            }
 3369|      0|            else /* == 8 */
 3370|      0|            {
 3371|      0|                if(fmt == SPNG_FMT_RGBA8)
  ------------------
  |  Branch (3371:20): [True: 0, False: 0]
  ------------------
 3372|      0|                {
 3373|      0|                    rgb8_row_to_rgba8(scanline, out, width);
 3374|      0|                    break;
 3375|      0|                }
 3376|       |
 3377|      0|                r_8 = scanline[k * 3];
 3378|      0|                g_8 = scanline[k * 3 + 1];
 3379|      0|                b_8 = scanline[k * 3 + 2];
 3380|       |
 3381|      0|                a_8 = 255;
 3382|      0|            }
 3383|      0|        }
 3384|      0|        else if(ihdr->color_type == SPNG_COLOR_TYPE_INDEXED)
  ------------------
  |  Branch (3384:17): [True: 0, False: 0]
  ------------------
 3385|      0|        {
 3386|      0|            uint8_t entry = 0;
 3387|       |
 3388|      0|            if(ihdr->bit_depth == 8)
  ------------------
  |  Branch (3388:16): [True: 0, False: 0]
  ------------------
 3389|      0|            {
 3390|      0|                if(fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGB8))
  ------------------
  |  Branch (3390:20): [True: 0, False: 0]
  ------------------
 3391|      0|                {
 3392|      0|                    expand_row(out, scanline, &ctx->decode_plte, width, fmt);
 3393|      0|                    break;
 3394|      0|                }
 3395|       |
 3396|      0|                entry = scanline[k];
 3397|      0|            }
 3398|      0|            else /* < 8 */
 3399|      0|            {
 3400|      0|                entry = get_sample(&iter);
 3401|      0|            }
 3402|       |
 3403|      0|            if(fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGB8))
  ------------------
  |  Branch (3403:16): [True: 0, False: 0]
  ------------------
 3404|      0|            {
 3405|      0|                pixel[0] = plte[entry].red;
 3406|      0|                pixel[1] = plte[entry].green;
 3407|      0|                pixel[2] = plte[entry].blue;
 3408|      0|                if(fmt == SPNG_FMT_RGBA8) pixel[3] = plte[entry].alpha;
  ------------------
  |  Branch (3408:20): [True: 0, False: 0]
  ------------------
 3409|       |
 3410|      0|                continue;
 3411|      0|            }
 3412|      0|            else /* RGBA16 */
 3413|      0|            {
 3414|      0|                r_16 = plte[entry].red;
 3415|      0|                g_16 = plte[entry].green;
 3416|      0|                b_16 = plte[entry].blue;
 3417|      0|                a_16 = plte[entry].alpha;
 3418|       |
 3419|      0|                r_16 = (r_16 << 8) | r_16;
 3420|      0|                g_16 = (g_16 << 8) | g_16;
 3421|      0|                b_16 = (b_16 << 8) | b_16;
 3422|      0|                a_16 = (a_16 << 8) | a_16;
 3423|       |
 3424|      0|                memcpy(pixel, &r_16, 2);
 3425|      0|                memcpy(pixel + 2, &g_16, 2);
 3426|      0|                memcpy(pixel + 4, &b_16, 2);
 3427|      0|                memcpy(pixel + 6, &a_16, 2);
 3428|       |
 3429|      0|                continue;
 3430|      0|            }
 3431|      0|        }
 3432|      0|        else if(ihdr->color_type == SPNG_COLOR_TYPE_TRUECOLOR_ALPHA)
  ------------------
  |  Branch (3432:17): [True: 0, False: 0]
  ------------------
 3433|      0|        {
 3434|      0|            if(ihdr->bit_depth == 16)
  ------------------
  |  Branch (3434:16): [True: 0, False: 0]
  ------------------
 3435|      0|            {
 3436|      0|                memcpy(&r_16, scanline + (k * 8), 2);
 3437|      0|                memcpy(&g_16, scanline + (k * 8) + 2, 2);
 3438|      0|                memcpy(&b_16, scanline + (k * 8) + 4, 2);
 3439|      0|                memcpy(&a_16, scanline + (k * 8) + 6, 2);
 3440|      0|            }
 3441|      0|            else /* == 8 */
 3442|      0|            {
 3443|      0|                r_8 = scanline[k * 4];
 3444|      0|                g_8 = scanline[k * 4 + 1];
 3445|      0|                b_8 = scanline[k * 4 + 2];
 3446|      0|                a_8 = scanline[k * 4 + 3];
 3447|      0|            }
 3448|      0|        }
 3449|      0|        else if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE)
  ------------------
  |  Branch (3449:17): [True: 0, False: 0]
  ------------------
 3450|      0|        {
 3451|      0|            if(ihdr->bit_depth == 16)
  ------------------
  |  Branch (3451:16): [True: 0, False: 0]
  ------------------
 3452|      0|            {
 3453|      0|                memcpy(&gray_16, scanline + k * 2, 2);
 3454|       |
 3455|      0|                if(f.apply_trns && ctx->trns.gray == gray_16) a_16 = 0;
  ------------------
  |  Branch (3455:20): [True: 0, False: 0]
  |  Branch (3455:36): [True: 0, False: 0]
  ------------------
 3456|      0|                else a_16 = 65535;
 3457|       |
 3458|      0|                r_16 = gray_16;
 3459|      0|                g_16 = gray_16;
 3460|      0|                b_16 = gray_16;
 3461|      0|            }
 3462|      0|            else /* <= 8 */
 3463|      0|            {
 3464|      0|                gray_8 = get_sample(&iter);
 3465|       |
 3466|      0|                if(f.apply_trns && ctx->trns.gray == gray_8) a_8 = 0;
  ------------------
  |  Branch (3466:20): [True: 0, False: 0]
  |  Branch (3466:36): [True: 0, False: 0]
  ------------------
 3467|      0|                else a_8 = 255;
 3468|       |
 3469|      0|                r_8 = gray_8; g_8 = gray_8; b_8 = gray_8;
 3470|      0|            }
 3471|      0|        }
 3472|      0|        else if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE_ALPHA)
  ------------------
  |  Branch (3472:17): [True: 0, False: 0]
  ------------------
 3473|      0|        {
 3474|      0|            if(ihdr->bit_depth == 16)
  ------------------
  |  Branch (3474:16): [True: 0, False: 0]
  ------------------
 3475|      0|            {
 3476|      0|                memcpy(&gray_16, scanline + (k * 4), 2);
 3477|      0|                memcpy(&a_16, scanline + (k * 4) + 2, 2);
 3478|       |
 3479|      0|                r_16 = gray_16;
 3480|      0|                g_16 = gray_16;
 3481|      0|                b_16 = gray_16;
 3482|      0|            }
 3483|      0|            else /* == 8 */
 3484|      0|            {
 3485|      0|                gray_8 = scanline[k * 2];
 3486|      0|                a_8 = scanline[k * 2 + 1];
 3487|       |
 3488|      0|                r_8 = gray_8;
 3489|      0|                g_8 = gray_8;
 3490|      0|                b_8 = gray_8;
 3491|      0|            }
 3492|      0|        }
 3493|       |
 3494|       |
 3495|      0|        if(fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGB8))
  ------------------
  |  Branch (3495:12): [True: 0, False: 0]
  ------------------
 3496|      0|        {
 3497|      0|            if(ihdr->bit_depth == 16)
  ------------------
  |  Branch (3497:16): [True: 0, False: 0]
  ------------------
 3498|      0|            {
 3499|      0|                r_8 = r_16 >> 8;
 3500|      0|                g_8 = g_16 >> 8;
 3501|      0|                b_8 = b_16 >> 8;
 3502|      0|                a_8 = a_16 >> 8;
 3503|      0|            }
 3504|       |
 3505|      0|            pixel[0] = r_8;
 3506|      0|            pixel[1] = g_8;
 3507|      0|            pixel[2] = b_8;
 3508|       |
 3509|      0|            if(fmt == SPNG_FMT_RGBA8) pixel[3] = a_8;
  ------------------
  |  Branch (3509:16): [True: 0, False: 0]
  ------------------
 3510|      0|        }
 3511|      0|        else if(fmt == SPNG_FMT_RGBA16)
  ------------------
  |  Branch (3511:17): [True: 0, False: 0]
  ------------------
 3512|      0|        {
 3513|      0|            if(ihdr->bit_depth != 16)
  ------------------
  |  Branch (3513:16): [True: 0, False: 0]
  ------------------
 3514|      0|            {
 3515|      0|                r_16 = r_8;
 3516|      0|                g_16 = g_8;
 3517|      0|                b_16 = b_8;
 3518|      0|                a_16 = a_8;
 3519|      0|            }
 3520|       |
 3521|      0|            memcpy(pixel, &r_16, 2);
 3522|      0|            memcpy(pixel + 2, &g_16, 2);
 3523|      0|            memcpy(pixel + 4, &b_16, 2);
 3524|      0|            memcpy(pixel + 6, &a_16, 2);
 3525|      0|        }
 3526|      0|    }/* for(k=0; k < width; k++) */
 3527|       |
 3528|   373k|    if(f.apply_trns) trns_row(out, scanline, trns_px, ctx->bytes_per_pixel, &ctx->ihdr, width, fmt);
  ------------------
  |  Branch (3528:8): [True: 0, False: 373k]
  ------------------
 3529|       |
 3530|   373k|    if(f.do_scaling) scale_row(out, width, fmt, processing_depth, sb);
  ------------------
  |  Branch (3530:8): [True: 0, False: 373k]
  ------------------
 3531|       |
 3532|   373k|    if(f.apply_gamma) gamma_correct_row(out, width, fmt, gamma_lut);
  ------------------
  |  Branch (3532:8): [True: 0, False: 373k]
  ------------------
 3533|       |
 3534|       |    /* The previous scanline is always defiltered */
 3535|   373k|    void *t = ctx->prev_scanline;
 3536|   373k|    ctx->prev_scanline = ctx->scanline;
 3537|   373k|    ctx->scanline = t;
 3538|       |
 3539|   373k|    ret = update_row_info(ctx);
 3540|       |
 3541|   373k|    if(ret == SPNG_EOI)
  ------------------
  |  Branch (3541:8): [True: 1.70k, False: 371k]
  ------------------
 3542|  1.70k|    {
 3543|  1.70k|        if(ctx->cur_chunk_bytes_left) /* zlib stream ended before an IDAT chunk boundary */
  ------------------
  |  Branch (3543:12): [True: 56, False: 1.65k]
  ------------------
 3544|     56|        {/* Discard the rest of the chunk */
 3545|     56|            int error = discard_chunk_bytes(ctx, ctx->cur_chunk_bytes_left);
 3546|     56|            if(error) return decode_err(ctx, error);
  ------------------
  |  Branch (3546:16): [True: 49, False: 7]
  ------------------
 3547|     56|        }
 3548|       |
 3549|  1.65k|        ctx->last_idat = ctx->current_chunk;
 3550|  1.65k|    }
 3551|       |
 3552|   373k|    return ret;
 3553|   373k|}
spng_decode_row:
 3556|   376k|{
 3557|   376k|    if(ctx == NULL || out == NULL) return 1;
  ------------------
  |  Branch (3557:8): [True: 0, False: 376k]
  |  Branch (3557:23): [True: 0, False: 376k]
  ------------------
 3558|   376k|    if(ctx->state >= SPNG_STATE_EOI) return SPNG_EOI;
  ------------------
  |  Branch (3558:8): [True: 0, False: 376k]
  ------------------
 3559|   376k|    if(len < ctx->image_width) return SPNG_EBUFSIZ;
  ------------------
  |  Branch (3559:8): [True: 0, False: 376k]
  ------------------
 3560|       |
 3561|   376k|    const struct spng_ihdr *ihdr = &ctx->ihdr;
 3562|   376k|    int ret, pass = ctx->row_info.pass;
 3563|   376k|    unsigned char *outptr = out;
 3564|       |
 3565|   376k|    if(!ihdr->interlace_method || pass == 6) return spng_decode_scanline(ctx, out, len);
  ------------------
  |  Branch (3565:8): [True: 164k, False: 212k]
  |  Branch (3565:35): [True: 0, False: 212k]
  ------------------
 3566|       |
 3567|   212k|    ret = spng_decode_scanline(ctx, ctx->row, ctx->image_width);
 3568|   212k|    if(ret && ret != SPNG_EOI) return ret;
  ------------------
  |  Branch (3568:8): [True: 625, False: 211k]
  |  Branch (3568:15): [True: 625, False: 0]
  ------------------
 3569|       |
 3570|   211k|    uint32_t k;
 3571|   211k|    unsigned pixel_size = 4; /* RGBA8 */
 3572|   211k|    if(ctx->fmt == SPNG_FMT_RGBA16) pixel_size = 8;
  ------------------
  |  Branch (3572:8): [True: 0, False: 211k]
  ------------------
 3573|   211k|    else if(ctx->fmt == SPNG_FMT_RGB8) pixel_size = 3;
  ------------------
  |  Branch (3573:13): [True: 0, False: 211k]
  ------------------
 3574|   211k|    else if(ctx->fmt == SPNG_FMT_G8) pixel_size = 1;
  ------------------
  |  Branch (3574:13): [True: 0, False: 211k]
  ------------------
 3575|   211k|    else if(ctx->fmt == SPNG_FMT_GA8) pixel_size = 2;
  ------------------
  |  Branch (3575:13): [True: 0, False: 211k]
  ------------------
 3576|   211k|    else if(ctx->fmt & (SPNG_FMT_PNG | SPNG_FMT_RAW))
  ------------------
  |  Branch (3576:13): [True: 211k, False: 0]
  ------------------
 3577|   211k|    {
 3578|   211k|        if(ihdr->bit_depth < 8)
  ------------------
  |  Branch (3578:12): [True: 0, False: 211k]
  ------------------
 3579|      0|        {
 3580|      0|            struct spng__iter iter = spng__iter_init(ihdr->bit_depth, ctx->row);
 3581|      0|            const uint8_t samples_per_byte = 8 / ihdr->bit_depth;
 3582|      0|            uint8_t sample;
 3583|       |
 3584|      0|            for(k=0; k < ctx->subimage[pass].width; k++)
  ------------------
  |  Branch (3584:22): [True: 0, False: 0]
  ------------------
 3585|      0|            {
 3586|      0|                sample = get_sample(&iter);
 3587|       |
 3588|      0|                size_t ioffset = adam7_x_start[pass] + k * adam7_x_delta[pass];
 3589|       |
 3590|      0|                sample = sample << (iter.initial_shift - ioffset * ihdr->bit_depth % 8);
 3591|       |
 3592|      0|                ioffset /= samples_per_byte;
 3593|       |
 3594|      0|                outptr[ioffset] |= sample;
 3595|      0|            }
 3596|       |
 3597|      0|            return 0;
 3598|      0|        }
 3599|   211k|        else pixel_size = ctx->bytes_per_pixel;
 3600|   211k|    }
 3601|       |
 3602|  15.9M|    for(k=0; k < ctx->subimage[pass].width; k++)
  ------------------
  |  Branch (3602:14): [True: 15.6M, False: 211k]
  ------------------
 3603|  15.6M|    {
 3604|  15.6M|        size_t ioffset = (adam7_x_start[pass] + (size_t) k * adam7_x_delta[pass]) * pixel_size;
 3605|       |
 3606|  15.6M|        memcpy(outptr + ioffset, ctx->row + k * pixel_size, pixel_size);
 3607|  15.6M|    }
 3608|       |
 3609|   211k|    return 0;
 3610|   211k|}
spng_decode_chunks:
 3613|  28.3k|{
 3614|  28.3k|    if(ctx == NULL) return 1;
  ------------------
  |  Branch (3614:8): [True: 0, False: 28.3k]
  ------------------
 3615|  28.3k|    if(ctx->encode_only) return SPNG_ECTXTYPE;
  ------------------
  |  Branch (3615:8): [True: 0, False: 28.3k]
  ------------------
 3616|  28.3k|    if(ctx->state < SPNG_STATE_INPUT) return SPNG_ENOSRC;
  ------------------
  |  Branch (3616:8): [True: 13.9k, False: 14.4k]
  ------------------
 3617|  14.4k|    if(ctx->state == SPNG_STATE_IEND) return 0;
  ------------------
  |  Branch (3617:8): [True: 0, False: 14.4k]
  ------------------
 3618|       |
 3619|  14.4k|    return read_chunks(ctx, 0);
 3620|  14.4k|}
spng_decode_image:
 3623|  14.6k|{
 3624|  14.6k|    if(ctx == NULL) return 1;
  ------------------
  |  Branch (3624:8): [True: 0, False: 14.6k]
  ------------------
 3625|  14.6k|    if(ctx->encode_only) return SPNG_ECTXTYPE;
  ------------------
  |  Branch (3625:8): [True: 0, False: 14.6k]
  ------------------
 3626|  14.6k|    if(ctx->state >= SPNG_STATE_EOI) return SPNG_EOI;
  ------------------
  |  Branch (3626:8): [True: 0, False: 14.6k]
  ------------------
 3627|       |
 3628|  14.6k|    const struct spng_ihdr *ihdr = &ctx->ihdr;
 3629|       |
 3630|  14.6k|    int ret = read_chunks(ctx, 0);
 3631|  14.6k|    if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3631:8): [True: 7.59k, False: 7.03k]
  ------------------
 3632|       |
 3633|  7.03k|    ret = check_decode_fmt(ihdr, fmt);
 3634|  7.03k|    if(ret) return ret;
  ------------------
  |  Branch (3634:8): [True: 0, False: 7.03k]
  ------------------
 3635|       |
 3636|  7.03k|    ret = calculate_image_width(ihdr, fmt, &ctx->image_width);
 3637|  7.03k|    if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3637:8): [True: 0, False: 7.03k]
  ------------------
 3638|       |
 3639|  7.03k|    if(ctx->image_width > SIZE_MAX / ihdr->height) ctx->image_size = 0; /* overflow */
  ------------------
  |  Branch (3639:8): [True: 0, False: 7.03k]
  ------------------
 3640|  7.03k|    else ctx->image_size = ctx->image_width * ihdr->height;
 3641|       |
 3642|  7.03k|    if( !(flags & SPNG_DECODE_PROGRESSIVE) )
  ------------------
  |  Branch (3642:9): [True: 0, False: 7.03k]
  ------------------
 3643|      0|    {
 3644|      0|        if(out == NULL) return 1;
  ------------------
  |  Branch (3644:12): [True: 0, False: 0]
  ------------------
 3645|      0|        if(!ctx->image_size) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (3645:12): [True: 0, False: 0]
  ------------------
 3646|      0|        if(len < ctx->image_size) return SPNG_EBUFSIZ;
  ------------------
  |  Branch (3646:12): [True: 0, False: 0]
  ------------------
 3647|      0|    }
 3648|       |
 3649|  7.03k|    uint32_t bytes_read = 0;
 3650|       |
 3651|  7.03k|    ret = read_idat_bytes(ctx, &bytes_read);
 3652|  7.03k|    if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3652:8): [True: 253, False: 6.78k]
  ------------------
 3653|       |
 3654|  6.78k|    if(bytes_read > 1)
  ------------------
  |  Branch (3654:8): [True: 6.07k, False: 707]
  ------------------
 3655|  6.07k|    {
 3656|  6.07k|        int valid = read_u16(ctx->data) % 31 ? 0 : 1;
  ------------------
  |  Branch (3656:21): [True: 71, False: 6.00k]
  ------------------
 3657|       |
 3658|  6.07k|        unsigned flg = ctx->data[1];
 3659|  6.07k|        unsigned flevel = flg >> 6;
 3660|  6.07k|        int compression_level = Z_DEFAULT_COMPRESSION;
  ------------------
  |  |  197|  6.07k|#define Z_DEFAULT_COMPRESSION  (-1)
  ------------------
 3661|       |
 3662|  6.07k|        if(flevel == 0) compression_level = 0; /* fastest */
  ------------------
  |  Branch (3662:12): [True: 255, False: 5.82k]
  ------------------
 3663|  5.82k|        else if(flevel == 1) compression_level = 1; /* fast */
  ------------------
  |  Branch (3663:17): [True: 27, False: 5.79k]
  ------------------
 3664|  5.79k|        else if(flevel == 2) compression_level = 6; /* default */
  ------------------
  |  Branch (3664:17): [True: 2.83k, False: 2.96k]
  ------------------
 3665|  2.96k|        else if(flevel == 3) compression_level = 9; /* slowest, max compression */
  ------------------
  |  Branch (3665:17): [True: 2.96k, False: 0]
  ------------------
 3666|       |
 3667|  6.07k|        if(valid) ctx->image_options.compression_level = compression_level;
  ------------------
  |  Branch (3667:12): [True: 6.00k, False: 71]
  ------------------
 3668|  6.07k|    }
 3669|       |
 3670|  6.78k|    ret = spng__inflate_init(ctx, ctx->image_options.window_bits);
 3671|  6.78k|    if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3671:8): [True: 0, False: 6.78k]
  ------------------
 3672|       |
 3673|  6.78k|    ctx->zstream.avail_in = bytes_read;
 3674|  6.78k|    ctx->zstream.next_in = ctx->data;
 3675|       |
 3676|  6.78k|    size_t scanline_buf_size = ctx->subimage[ctx->widest_pass].scanline_width;
 3677|       |
 3678|  6.78k|    scanline_buf_size += 32;
 3679|       |
 3680|  6.78k|    if(scanline_buf_size < 32) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (3680:8): [True: 0, False: 6.78k]
  ------------------
 3681|       |
 3682|  6.78k|    ctx->scanline_buf = spng__malloc(ctx, scanline_buf_size);
 3683|  6.78k|    ctx->prev_scanline_buf = spng__malloc(ctx, scanline_buf_size);
 3684|       |
 3685|  6.78k|    ctx->scanline = ctx->scanline_buf;
 3686|  6.78k|    ctx->prev_scanline = ctx->prev_scanline_buf;
 3687|       |
 3688|  6.78k|    struct decode_flags f = {0};
 3689|       |
 3690|  6.78k|    ctx->fmt = fmt;
 3691|       |
 3692|  6.78k|    if(ihdr->color_type == SPNG_COLOR_TYPE_INDEXED) f.indexed = 1;
  ------------------
  |  Branch (3692:8): [True: 197, False: 6.58k]
  ------------------
 3693|       |
 3694|  6.78k|    unsigned processing_depth = ihdr->bit_depth;
 3695|       |
 3696|  6.78k|    if(f.indexed) processing_depth = 8;
  ------------------
  |  Branch (3696:8): [True: 197, False: 6.58k]
  ------------------
 3697|       |
 3698|  6.78k|    if(ihdr->interlace_method)
  ------------------
  |  Branch (3698:8): [True: 1.45k, False: 5.33k]
  ------------------
 3699|  1.45k|    {
 3700|  1.45k|        f.interlaced = 1;
 3701|  1.45k|        ctx->row_buf = spng__malloc(ctx, ctx->image_width);
 3702|  1.45k|        ctx->row = ctx->row_buf;
 3703|       |
 3704|  1.45k|        if(ctx->row == NULL) return decode_err(ctx, SPNG_EMEM);
  ------------------
  |  Branch (3704:12): [True: 0, False: 1.45k]
  ------------------
 3705|  1.45k|    }
 3706|       |
 3707|  6.78k|    if(ctx->scanline == NULL || ctx->prev_scanline == NULL)
  ------------------
  |  Branch (3707:8): [True: 0, False: 6.78k]
  |  Branch (3707:33): [True: 0, False: 6.78k]
  ------------------
 3708|      0|    {
 3709|      0|        return decode_err(ctx, SPNG_EMEM);
 3710|      0|    }
 3711|       |
 3712|  6.78k|    f.do_scaling = 1;
 3713|  6.78k|    if(f.indexed) f.do_scaling = 0;
  ------------------
  |  Branch (3713:8): [True: 197, False: 6.58k]
  ------------------
 3714|       |
 3715|  6.78k|    unsigned depth_target = 8; /* FMT_RGBA8, G8 */
 3716|  6.78k|    if(fmt == SPNG_FMT_RGBA16) depth_target = 16;
  ------------------
  |  Branch (3716:8): [True: 0, False: 6.78k]
  ------------------
 3717|       |
 3718|  6.78k|    if(flags & SPNG_DECODE_TRNS && ctx->stored.trns) f.apply_trns = 1;
  ------------------
  |  Branch (3718:8): [True: 0, False: 6.78k]
  |  Branch (3718:36): [True: 0, False: 0]
  ------------------
 3719|  6.78k|    else flags &= ~SPNG_DECODE_TRNS;
 3720|       |
 3721|  6.78k|    if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE_ALPHA ||
  ------------------
  |  Branch (3721:8): [True: 434, False: 6.35k]
  ------------------
 3722|  6.35k|       ihdr->color_type == SPNG_COLOR_TYPE_TRUECOLOR_ALPHA) flags &= ~SPNG_DECODE_TRNS;
  ------------------
  |  Branch (3722:8): [True: 1.82k, False: 4.52k]
  ------------------
 3723|       |
 3724|  6.78k|    if(flags & SPNG_DECODE_GAMMA && ctx->stored.gama) f.apply_gamma = 1;
  ------------------
  |  Branch (3724:8): [True: 0, False: 6.78k]
  |  Branch (3724:37): [True: 0, False: 0]
  ------------------
 3725|  6.78k|    else flags &= ~SPNG_DECODE_GAMMA;
 3726|       |
 3727|  6.78k|    if(flags & SPNG_DECODE_USE_SBIT && ctx->stored.sbit) f.use_sbit = 1;
  ------------------
  |  Branch (3727:8): [True: 0, False: 6.78k]
  |  Branch (3727:40): [True: 0, False: 0]
  ------------------
 3728|  6.78k|    else flags &= ~SPNG_DECODE_USE_SBIT;
 3729|       |
 3730|  6.78k|    if(fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGBA16))
  ------------------
  |  Branch (3730:8): [True: 0, False: 6.78k]
  ------------------
 3731|      0|    {
 3732|      0|        if(ihdr->color_type == SPNG_COLOR_TYPE_TRUECOLOR_ALPHA &&
  ------------------
  |  Branch (3732:12): [True: 0, False: 0]
  ------------------
 3733|      0|           ihdr->bit_depth == depth_target) f.same_layout = 1;
  ------------------
  |  Branch (3733:12): [True: 0, False: 0]
  ------------------
 3734|      0|    }
 3735|  6.78k|    else if(fmt == SPNG_FMT_RGB8)
  ------------------
  |  Branch (3735:13): [True: 0, False: 6.78k]
  ------------------
 3736|      0|    {
 3737|      0|        if(ihdr->color_type == SPNG_COLOR_TYPE_TRUECOLOR &&
  ------------------
  |  Branch (3737:12): [True: 0, False: 0]
  ------------------
 3738|      0|           ihdr->bit_depth == depth_target) f.same_layout = 1;
  ------------------
  |  Branch (3738:12): [True: 0, False: 0]
  ------------------
 3739|       |
 3740|      0|        f.apply_trns = 0; /* not applicable */
 3741|      0|    }
 3742|  6.78k|    else if(fmt & (SPNG_FMT_PNG | SPNG_FMT_RAW))
  ------------------
  |  Branch (3742:13): [True: 6.78k, False: 0]
  ------------------
 3743|  6.78k|    {
 3744|  6.78k|        f.same_layout = 1;
 3745|  6.78k|        f.do_scaling = 0;
 3746|  6.78k|        f.apply_gamma = 0; /* for now */
 3747|  6.78k|        f.apply_trns = 0;
 3748|  6.78k|    }
 3749|      0|    else if(fmt == SPNG_FMT_G8 && ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE && ihdr->bit_depth <= 8)
  ------------------
  |  Branch (3749:13): [True: 0, False: 0]
  |  Branch (3749:35): [True: 0, False: 0]
  |  Branch (3749:84): [True: 0, False: 0]
  ------------------
 3750|      0|    {
 3751|      0|        if(ihdr->bit_depth == depth_target) f.same_layout = 1;
  ------------------
  |  Branch (3751:12): [True: 0, False: 0]
  ------------------
 3752|      0|        else if(ihdr->bit_depth < 8) f.unpack = 1;
  ------------------
  |  Branch (3752:17): [True: 0, False: 0]
  ------------------
 3753|       |
 3754|      0|        f.apply_trns = 0;
 3755|      0|    }
 3756|      0|    else if(fmt == SPNG_FMT_GA8 && ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE && ihdr->bit_depth <= 8)
  ------------------
  |  Branch (3756:13): [True: 0, False: 0]
  |  Branch (3756:36): [True: 0, False: 0]
  |  Branch (3756:85): [True: 0, False: 0]
  ------------------
 3757|      0|    {
 3758|      0|        if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE_ALPHA &&
  ------------------
  |  Branch (3758:12): [True: 0, False: 0]
  ------------------
 3759|      0|           ihdr->bit_depth == depth_target) f.same_layout = 1;
  ------------------
  |  Branch (3759:12): [True: 0, False: 0]
  ------------------
 3760|      0|        else if(ihdr->bit_depth <= 8) f.unpack = 1;
  ------------------
  |  Branch (3760:17): [True: 0, False: 0]
  ------------------
 3761|      0|    }
 3762|      0|    else if(fmt == SPNG_FMT_GA16 && ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE && ihdr->bit_depth == 16)
  ------------------
  |  Branch (3762:13): [True: 0, False: 0]
  |  Branch (3762:37): [True: 0, False: 0]
  |  Branch (3762:86): [True: 0, False: 0]
  ------------------
 3763|      0|    {
 3764|      0|        if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE_ALPHA &&
  ------------------
  |  Branch (3764:12): [True: 0, False: 0]
  ------------------
 3765|      0|           ihdr->bit_depth == depth_target) f.same_layout = 1;
  ------------------
  |  Branch (3765:12): [True: 0, False: 0]
  ------------------
 3766|      0|        else if(ihdr->bit_depth == 16) f.unpack = 1;
  ------------------
  |  Branch (3766:17): [True: 0, False: 0]
  ------------------
 3767|      0|    }
 3768|       |
 3769|       |    /*if(f.same_layout && !flags && !f.interlaced) f.zerocopy = 1;*/
 3770|       |
 3771|  6.78k|    uint16_t *gamma_lut = NULL;
 3772|       |
 3773|  6.78k|    if(f.apply_gamma)
  ------------------
  |  Branch (3773:8): [True: 0, False: 6.78k]
  ------------------
 3774|      0|    {
 3775|      0|        float file_gamma = (float)ctx->gama / 100000.0f;
 3776|      0|        float max;
 3777|       |
 3778|      0|        unsigned lut_entries;
 3779|       |
 3780|      0|        if(fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGB8))
  ------------------
  |  Branch (3780:12): [True: 0, False: 0]
  ------------------
 3781|      0|        {
 3782|      0|            lut_entries = 256;
 3783|      0|            max = 255.0f;
 3784|       |
 3785|      0|            gamma_lut = ctx->gamma_lut8;
 3786|      0|            ctx->gamma_lut = ctx->gamma_lut8;
 3787|      0|        }
 3788|      0|        else /* SPNG_FMT_RGBA16 */
 3789|      0|        {
 3790|      0|            lut_entries = 65536;
 3791|      0|            max = 65535.0f;
 3792|       |
 3793|      0|            ctx->gamma_lut16 = spng__malloc(ctx, lut_entries * sizeof(uint16_t));
 3794|      0|            if(ctx->gamma_lut16 == NULL) return decode_err(ctx, SPNG_EMEM);
  ------------------
  |  Branch (3794:16): [True: 0, False: 0]
  ------------------
 3795|       |
 3796|      0|            gamma_lut = ctx->gamma_lut16;
 3797|      0|            ctx->gamma_lut = ctx->gamma_lut16;
 3798|      0|        }
 3799|       |
 3800|      0|        float screen_gamma = 2.2f;
 3801|      0|        float exponent = file_gamma * screen_gamma;
 3802|       |
 3803|      0|        if(FP_ZERO == fpclassify(exponent)) return decode_err(ctx, SPNG_EGAMA);
  ------------------
  |  Branch (3803:12): [True: 0, False: 0]
  ------------------
 3804|       |
 3805|      0|        exponent = 1.0f / exponent;
 3806|       |
 3807|      0|        unsigned i;
 3808|      0|        for(i=0; i < lut_entries; i++)
  ------------------
  |  Branch (3808:18): [True: 0, False: 0]
  ------------------
 3809|      0|        {
 3810|       |#if 0 /* libjpeg-turbo: Eliminate libm dependency */
 3811|       |            float c = pow((float)i / max, exponent) * max;
 3812|       |#endif
 3813|      0|            float c = 0.0f;
 3814|      0|            if(c > max) c = max;
  ------------------
  |  Branch (3814:16): [True: 0, False: 0]
  ------------------
 3815|       |
 3816|      0|            gamma_lut[i] = (uint16_t)c;
 3817|      0|        }
 3818|      0|    }
 3819|       |
 3820|  6.78k|    struct spng_sbit *sb = &ctx->decode_sb;
 3821|       |
 3822|  6.78k|    sb->red_bits = processing_depth;
 3823|  6.78k|    sb->green_bits = processing_depth;
 3824|  6.78k|    sb->blue_bits = processing_depth;
 3825|  6.78k|    sb->alpha_bits = processing_depth;
 3826|  6.78k|    sb->grayscale_bits = processing_depth;
 3827|       |
 3828|  6.78k|    if(f.use_sbit)
  ------------------
  |  Branch (3828:8): [True: 0, False: 6.78k]
  ------------------
 3829|      0|    {
 3830|      0|        if(ihdr->color_type == 0)
  ------------------
  |  Branch (3830:12): [True: 0, False: 0]
  ------------------
 3831|      0|        {
 3832|      0|            sb->grayscale_bits = ctx->sbit.grayscale_bits;
 3833|      0|            sb->alpha_bits = ihdr->bit_depth;
 3834|      0|        }
 3835|      0|        else if(ihdr->color_type == 2 || ihdr->color_type == 3)
  ------------------
  |  Branch (3835:17): [True: 0, False: 0]
  |  Branch (3835:42): [True: 0, False: 0]
  ------------------
 3836|      0|        {
 3837|      0|            sb->red_bits = ctx->sbit.red_bits;
 3838|      0|            sb->green_bits = ctx->sbit.green_bits;
 3839|      0|            sb->blue_bits = ctx->sbit.blue_bits;
 3840|      0|            sb->alpha_bits = ihdr->bit_depth;
 3841|      0|        }
 3842|      0|        else if(ihdr->color_type == 4)
  ------------------
  |  Branch (3842:17): [True: 0, False: 0]
  ------------------
 3843|      0|        {
 3844|      0|            sb->grayscale_bits = ctx->sbit.grayscale_bits;
 3845|      0|            sb->alpha_bits = ctx->sbit.alpha_bits;
 3846|      0|        }
 3847|      0|        else /* == 6 */
 3848|      0|        {
 3849|      0|            sb->red_bits = ctx->sbit.red_bits;
 3850|      0|            sb->green_bits = ctx->sbit.green_bits;
 3851|      0|            sb->blue_bits = ctx->sbit.blue_bits;
 3852|      0|            sb->alpha_bits = ctx->sbit.alpha_bits;
 3853|      0|        }
 3854|      0|    }
 3855|       |
 3856|  6.78k|    if(ihdr->bit_depth == 16 && fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGB8))
  ------------------
  |  Branch (3856:8): [True: 2.29k, False: 4.49k]
  |  Branch (3856:33): [True: 0, False: 2.29k]
  ------------------
 3857|      0|    {/* samples are scaled down by 8 bits in the decode loop */
 3858|      0|        sb->red_bits -= 8;
 3859|      0|        sb->green_bits -= 8;
 3860|      0|        sb->blue_bits -= 8;
 3861|      0|        sb->alpha_bits -= 8;
 3862|      0|        sb->grayscale_bits -= 8;
 3863|       |
 3864|      0|        processing_depth = 8;
 3865|      0|    }
 3866|       |
 3867|       |    /* Prevent infinite loops in sample_to_target() */
 3868|  6.78k|    if(!depth_target || depth_target > 16 ||
  ------------------
  |  Branch (3868:8): [True: 0, False: 6.78k]
  |  Branch (3868:25): [True: 0, False: 6.78k]
  ------------------
 3869|  6.78k|       !processing_depth || processing_depth > 16 ||
  ------------------
  |  Branch (3869:8): [True: 0, False: 6.78k]
  |  Branch (3869:29): [True: 0, False: 6.78k]
  ------------------
 3870|  6.78k|       !sb->grayscale_bits || sb->grayscale_bits > processing_depth ||
  ------------------
  |  Branch (3870:8): [True: 0, False: 6.78k]
  |  Branch (3870:31): [True: 0, False: 6.78k]
  ------------------
 3871|  6.78k|       !sb->alpha_bits || sb->alpha_bits > processing_depth ||
  ------------------
  |  Branch (3871:8): [True: 0, False: 6.78k]
  |  Branch (3871:27): [True: 0, False: 6.78k]
  ------------------
 3872|  6.78k|       !sb->red_bits || sb->red_bits > processing_depth ||
  ------------------
  |  Branch (3872:8): [True: 0, False: 6.78k]
  |  Branch (3872:25): [True: 0, False: 6.78k]
  ------------------
 3873|  6.78k|       !sb->green_bits || sb->green_bits > processing_depth ||
  ------------------
  |  Branch (3873:8): [True: 0, False: 6.78k]
  |  Branch (3873:27): [True: 0, False: 6.78k]
  ------------------
 3874|  6.78k|       !sb->blue_bits || sb->blue_bits > processing_depth)
  ------------------
  |  Branch (3874:8): [True: 0, False: 6.78k]
  |  Branch (3874:26): [True: 0, False: 6.78k]
  ------------------
 3875|      0|    {
 3876|      0|        return decode_err(ctx, SPNG_ESBIT);
 3877|      0|    }
 3878|       |
 3879|  6.78k|    if(sb->red_bits == sb->green_bits &&
  ------------------
  |  Branch (3879:8): [True: 6.78k, False: 0]
  ------------------
 3880|  6.78k|       sb->green_bits == sb->blue_bits &&
  ------------------
  |  Branch (3880:8): [True: 6.78k, False: 0]
  ------------------
 3881|  6.78k|       sb->blue_bits == sb->alpha_bits &&
  ------------------
  |  Branch (3881:8): [True: 6.78k, False: 0]
  ------------------
 3882|  6.78k|       sb->alpha_bits == processing_depth &&
  ------------------
  |  Branch (3882:8): [True: 6.78k, False: 0]
  ------------------
 3883|  6.78k|       processing_depth == depth_target) f.do_scaling = 0;
  ------------------
  |  Branch (3883:8): [True: 4.49k, False: 2.29k]
  ------------------
 3884|       |
 3885|  6.78k|    struct spng_plte_entry *plte = ctx->decode_plte.rgba;
 3886|       |
 3887|       |    /* Pre-process palette entries */
 3888|  6.78k|    if(f.indexed)
  ------------------
  |  Branch (3888:8): [True: 197, False: 6.58k]
  ------------------
 3889|    197|    {
 3890|    197|        uint8_t red, green, blue, alpha;
 3891|       |
 3892|    197|        uint32_t i;
 3893|  50.6k|        for(i=0; i < 256; i++)
  ------------------
  |  Branch (3893:18): [True: 50.4k, False: 197]
  ------------------
 3894|  50.4k|        {
 3895|  50.4k|            if(f.apply_trns && i < ctx->trns.n_type3_entries)
  ------------------
  |  Branch (3895:16): [True: 0, False: 50.4k]
  |  Branch (3895:32): [True: 0, False: 0]
  ------------------
 3896|      0|                ctx->plte.entries[i].alpha = ctx->trns.type3_alpha[i];
 3897|  50.4k|            else
 3898|  50.4k|                ctx->plte.entries[i].alpha = 255;
 3899|       |
 3900|  50.4k|            red   = sample_to_target(ctx->plte.entries[i].red, 8, sb->red_bits, 8);
 3901|  50.4k|            green = sample_to_target(ctx->plte.entries[i].green, 8, sb->green_bits, 8);
 3902|  50.4k|            blue  = sample_to_target(ctx->plte.entries[i].blue, 8, sb->blue_bits, 8);
 3903|  50.4k|            alpha = sample_to_target(ctx->plte.entries[i].alpha, 8, sb->alpha_bits, 8);
 3904|       |
 3905|       |#if defined(SPNG_ARM)
 3906|       |            if(fmt == SPNG_FMT_RGB8 && ihdr->bit_depth == 8)
 3907|       |            {/* Working with 3 bytes at a time is more of an ARM thing */
 3908|       |                ctx->decode_plte.rgb[i * 3 + 0] = red;
 3909|       |                ctx->decode_plte.rgb[i * 3 + 1] = green;
 3910|       |                ctx->decode_plte.rgb[i * 3 + 2] = blue;
 3911|       |                continue;
 3912|       |            }
 3913|       |#endif
 3914|  50.4k|            plte[i].red = red;
 3915|  50.4k|            plte[i].green = green;
 3916|  50.4k|            plte[i].blue = blue;
 3917|  50.4k|            plte[i].alpha = alpha;
 3918|  50.4k|        }
 3919|       |
 3920|    197|        f.apply_trns = 0;
 3921|    197|    }
 3922|       |
 3923|  6.78k|    unsigned char *trns_px = ctx->trns_px;
 3924|       |
 3925|  6.78k|    if(f.apply_trns)
  ------------------
  |  Branch (3925:8): [True: 0, False: 6.78k]
  ------------------
 3926|      0|    {
 3927|      0|        uint16_t mask = ~0;
 3928|      0|        if(ctx->ihdr.bit_depth < 16) mask = (1 << ctx->ihdr.bit_depth) - 1;
  ------------------
  |  Branch (3928:12): [True: 0, False: 0]
  ------------------
 3929|       |
 3930|      0|        if(fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGBA16))
  ------------------
  |  Branch (3930:12): [True: 0, False: 0]
  ------------------
 3931|      0|        {
 3932|      0|            if(ihdr->color_type == SPNG_COLOR_TYPE_TRUECOLOR)
  ------------------
  |  Branch (3932:16): [True: 0, False: 0]
  ------------------
 3933|      0|            {
 3934|      0|                if(ihdr->bit_depth == 16)
  ------------------
  |  Branch (3934:20): [True: 0, False: 0]
  ------------------
 3935|      0|                {
 3936|      0|                    memcpy(trns_px, &ctx->trns.red, 2);
 3937|      0|                    memcpy(trns_px + 2, &ctx->trns.green, 2);
 3938|      0|                    memcpy(trns_px + 4, &ctx->trns.blue, 2);
 3939|      0|                }
 3940|      0|                else
 3941|      0|                {
 3942|      0|                    trns_px[0] = ctx->trns.red & mask;
 3943|      0|                    trns_px[1] = ctx->trns.green & mask;
 3944|      0|                    trns_px[2] = ctx->trns.blue & mask;
 3945|      0|                }
 3946|      0|            }
 3947|      0|        }
 3948|      0|        else if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE) // fmt == SPNG_FMT_GA8 &&
  ------------------
  |  Branch (3948:17): [True: 0, False: 0]
  ------------------
 3949|      0|        {
 3950|      0|            if(ihdr->bit_depth == 16)
  ------------------
  |  Branch (3950:16): [True: 0, False: 0]
  ------------------
 3951|      0|            {
 3952|      0|                memcpy(trns_px, &ctx->trns.gray, 2);
 3953|      0|            }
 3954|      0|            else
 3955|      0|            {
 3956|      0|                trns_px[0] = ctx->trns.gray & mask;
 3957|      0|            }
 3958|      0|        }
 3959|      0|    }
 3960|       |
 3961|  6.78k|    ctx->decode_flags = f;
 3962|       |
 3963|  6.78k|    ctx->state = SPNG_STATE_DECODE_INIT;
 3964|       |
 3965|  6.78k|    struct spng_row_info *ri = &ctx->row_info;
 3966|  6.78k|    struct spng_subimage *sub = ctx->subimage;
 3967|       |
 3968|  6.78k|    while(!sub[ri->pass].width || !sub[ri->pass].height) ri->pass++;
  ------------------
  |  Branch (3968:11): [True: 0, False: 6.78k]
  |  Branch (3968:35): [True: 0, False: 6.78k]
  ------------------
 3969|       |
 3970|  6.78k|    if(f.interlaced) ri->row_num = adam7_y_start[ri->pass];
  ------------------
  |  Branch (3970:8): [True: 1.45k, False: 5.33k]
  ------------------
 3971|       |
 3972|  6.78k|    unsigned pixel_size = 4; /* SPNG_FMT_RGBA8 */
 3973|       |
 3974|  6.78k|    if(fmt == SPNG_FMT_RGBA16) pixel_size = 8;
  ------------------
  |  Branch (3974:8): [True: 0, False: 6.78k]
  ------------------
 3975|  6.78k|    else if(fmt == SPNG_FMT_RGB8) pixel_size = 3;
  ------------------
  |  Branch (3975:13): [True: 0, False: 6.78k]
  ------------------
 3976|  6.78k|    else if(fmt == SPNG_FMT_G8) pixel_size = 1;
  ------------------
  |  Branch (3976:13): [True: 0, False: 6.78k]
  ------------------
 3977|  6.78k|    else if(fmt == SPNG_FMT_GA8) pixel_size = 2;
  ------------------
  |  Branch (3977:13): [True: 0, False: 6.78k]
  ------------------
 3978|       |
 3979|  6.78k|    int i;
 3980|  22.2k|    for(i=ri->pass; i <= ctx->last_pass; i++)
  ------------------
  |  Branch (3980:21): [True: 15.4k, False: 6.78k]
  ------------------
 3981|  15.4k|    {
 3982|  15.4k|        if(!sub[i].scanline_width) continue;
  ------------------
  |  Branch (3982:12): [True: 0, False: 15.4k]
  ------------------
 3983|       |
 3984|  15.4k|        if(fmt & (SPNG_FMT_PNG | SPNG_FMT_RAW)) sub[i].out_width = sub[i].scanline_width - 1;
  ------------------
  |  Branch (3984:12): [True: 15.4k, False: 0]
  ------------------
 3985|      0|        else sub[i].out_width = (size_t)sub[i].width * pixel_size;
 3986|       |
 3987|  15.4k|        if(sub[i].out_width > UINT32_MAX) return decode_err(ctx, SPNG_EOVERFLOW);
  ------------------
  |  Branch (3987:12): [True: 0, False: 15.4k]
  ------------------
 3988|  15.4k|    }
 3989|       |
 3990|       |    /* Read the first filter byte, offsetting all reads by 1 byte.
 3991|       |    The scanlines will be aligned with the start of the array with
 3992|       |    the next scanline's filter byte at the end,
 3993|       |    the last scanline will end up being 1 byte "shorter". */
 3994|  6.78k|    ret = read_scanline_bytes(ctx, &ri->filter, 1);
 3995|  6.78k|    if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3995:8): [True: 1.06k, False: 5.72k]
  ------------------
 3996|       |
 3997|  5.72k|    if(ri->filter > 4) return decode_err(ctx, SPNG_EFILTER);
  ------------------
  |  Branch (3997:8): [True: 38, False: 5.68k]
  ------------------
 3998|       |
 3999|  5.68k|    if(flags & SPNG_DECODE_PROGRESSIVE)
  ------------------
  |  Branch (3999:8): [True: 5.68k, False: 0]
  ------------------
 4000|  5.68k|    {
 4001|  5.68k|        return 0;
 4002|  5.68k|    }
 4003|       |
 4004|      0|    do
 4005|      0|    {
 4006|      0|        size_t ioffset = ri->row_num * ctx->image_width;
 4007|       |
 4008|      0|        ret = spng_decode_row(ctx, (unsigned char*)out + ioffset, ctx->image_width);
 4009|      0|    }while(!ret);
  ------------------
  |  Branch (4009:12): [True: 0, False: 0]
  ------------------
 4010|       |
 4011|      0|    if(ret != SPNG_EOI) return decode_err(ctx, ret);
  ------------------
  |  Branch (4011:8): [True: 0, False: 0]
  ------------------
 4012|       |
 4013|      0|    return 0;
 4014|      0|}
spng_ctx_new:
 4886|  28.3k|{
 4887|  28.3k|    struct spng_alloc alloc =
 4888|  28.3k|    {
 4889|  28.3k|        .malloc_fn = malloc,
 4890|  28.3k|        .realloc_fn = realloc,
 4891|  28.3k|        .calloc_fn = calloc,
 4892|  28.3k|        .free_fn = free
 4893|  28.3k|    };
 4894|       |
 4895|  28.3k|    return spng_ctx_new2(&alloc, flags);
 4896|  28.3k|}
spng_ctx_new2:
 4899|  28.3k|{
 4900|  28.3k|    if(alloc == NULL) return NULL;
  ------------------
  |  Branch (4900:8): [True: 0, False: 28.3k]
  ------------------
 4901|  28.3k|    if(flags != (flags & SPNG__CTX_FLAGS_ALL)) return NULL;
  ------------------
  |  Branch (4901:8): [True: 0, False: 28.3k]
  ------------------
 4902|       |
 4903|  28.3k|    if(alloc->malloc_fn == NULL) return NULL;
  ------------------
  |  Branch (4903:8): [True: 0, False: 28.3k]
  ------------------
 4904|  28.3k|    if(alloc->realloc_fn == NULL) return NULL;
  ------------------
  |  Branch (4904:8): [True: 0, False: 28.3k]
  ------------------
 4905|  28.3k|    if(alloc->calloc_fn == NULL) return NULL;
  ------------------
  |  Branch (4905:8): [True: 0, False: 28.3k]
  ------------------
 4906|  28.3k|    if(alloc->free_fn == NULL) return NULL;
  ------------------
  |  Branch (4906:8): [True: 0, False: 28.3k]
  ------------------
 4907|       |
 4908|  28.3k|    spng_ctx *ctx = alloc->calloc_fn(1, sizeof(spng_ctx));
 4909|  28.3k|    if(ctx == NULL) return NULL;
  ------------------
  |  Branch (4909:8): [True: 0, False: 28.3k]
  ------------------
 4910|       |
 4911|  28.3k|    ctx->alloc = *alloc;
 4912|       |
 4913|  28.3k|    ctx->max_width = spng_u32max;
 4914|  28.3k|    ctx->max_height = spng_u32max;
 4915|       |
 4916|  28.3k|    ctx->max_chunk_size = spng_u32max;
 4917|  28.3k|    ctx->chunk_cache_limit = SIZE_MAX;
 4918|  28.3k|    ctx->chunk_count_limit = SPNG_MAX_CHUNK_COUNT;
  ------------------
  |  |   32|  28.3k|#define SPNG_MAX_CHUNK_COUNT (1000)
  ------------------
 4919|       |
 4920|  28.3k|    ctx->state = SPNG_STATE_INIT;
 4921|       |
 4922|  28.3k|    ctx->crc_action_critical = SPNG_CRC_ERROR;
 4923|  28.3k|    ctx->crc_action_ancillary = SPNG_CRC_DISCARD;
 4924|       |
 4925|  28.3k|    const struct spng__zlib_options image_defaults =
 4926|  28.3k|    {
 4927|  28.3k|        .compression_level = Z_DEFAULT_COMPRESSION,
  ------------------
  |  |  197|  28.3k|#define Z_DEFAULT_COMPRESSION  (-1)
  ------------------
 4928|  28.3k|        .window_bits = 15,
 4929|  28.3k|        .mem_level = 8,
 4930|  28.3k|        .strategy = Z_FILTERED,
  ------------------
  |  |  200|  28.3k|#define Z_FILTERED            1
  ------------------
 4931|  28.3k|        .data_type = 0 /* Z_BINARY */
 4932|  28.3k|    };
 4933|       |
 4934|  28.3k|    const struct spng__zlib_options text_defaults =
 4935|  28.3k|    {
 4936|  28.3k|        .compression_level = Z_DEFAULT_COMPRESSION,
  ------------------
  |  |  197|  28.3k|#define Z_DEFAULT_COMPRESSION  (-1)
  ------------------
 4937|  28.3k|        .window_bits = 15,
 4938|  28.3k|        .mem_level = 8,
 4939|  28.3k|        .strategy = Z_DEFAULT_STRATEGY,
  ------------------
  |  |  204|  28.3k|#define Z_DEFAULT_STRATEGY    0
  ------------------
 4940|  28.3k|        .data_type = 1 /* Z_TEXT */
 4941|  28.3k|    };
 4942|       |
 4943|  28.3k|    ctx->image_options = image_defaults;
 4944|  28.3k|    ctx->text_options = text_defaults;
 4945|       |
 4946|  28.3k|    ctx->optimize_option = ~0;
 4947|  28.3k|    ctx->encode_flags.filter_choice = SPNG_FILTER_CHOICE_ALL;
 4948|       |
 4949|  28.3k|    ctx->flags = flags;
 4950|       |
 4951|  28.3k|    if(flags & SPNG_CTX_ENCODER) ctx->encode_only = 1;
  ------------------
  |  Branch (4951:8): [True: 0, False: 28.3k]
  ------------------
 4952|       |
 4953|  28.3k|    return ctx;
 4954|  28.3k|}
spng_ctx_free:
 4957|  28.3k|{
 4958|  28.3k|    if(ctx == NULL) return;
  ------------------
  |  Branch (4958:8): [True: 0, False: 28.3k]
  ------------------
 4959|       |
 4960|  28.3k|    if(ctx->streaming && ctx->stream_buf != NULL) spng__free(ctx, ctx->stream_buf);
  ------------------
  |  Branch (4960:8): [True: 28.3k, False: 0]
  |  Branch (4960:26): [True: 28.3k, False: 0]
  ------------------
 4961|       |
 4962|  28.3k|    if(!ctx->user.exif) spng__free(ctx, ctx->exif.data);
  ------------------
  |  Branch (4962:8): [True: 28.3k, False: 0]
  ------------------
 4963|       |
 4964|  28.3k|    if(!ctx->user.iccp) spng__free(ctx, ctx->iccp.profile);
  ------------------
  |  Branch (4964:8): [True: 28.3k, False: 0]
  ------------------
 4965|       |
 4966|  28.3k|    uint32_t i;
 4967|       |
 4968|  28.3k|    if(ctx->splt_list != NULL && !ctx->user.splt)
  ------------------
  |  Branch (4968:8): [True: 1.82k, False: 26.5k]
  |  Branch (4968:34): [True: 1.82k, False: 0]
  ------------------
 4969|  1.82k|    {
 4970|  2.62k|        for(i=0; i < ctx->n_splt; i++)
  ------------------
  |  Branch (4970:18): [True: 805, False: 1.82k]
  ------------------
 4971|    805|        {
 4972|    805|            spng__free(ctx, ctx->splt_list[i].entries);
 4973|    805|        }
 4974|  1.82k|        spng__free(ctx, ctx->splt_list);
 4975|  1.82k|    }
 4976|       |
 4977|  28.3k|    if(ctx->text_list != NULL)
  ------------------
  |  Branch (4977:8): [True: 7.74k, False: 20.6k]
  ------------------
 4978|  7.74k|    {
 4979|  44.1k|        for(i=0; i< ctx->n_text; i++)
  ------------------
  |  Branch (4979:18): [True: 36.4k, False: 7.74k]
  ------------------
 4980|  36.4k|        {
 4981|  36.4k|            if(ctx->user.text) break;
  ------------------
  |  Branch (4981:16): [True: 0, False: 36.4k]
  ------------------
 4982|       |
 4983|  36.4k|            spng__free(ctx, ctx->text_list[i].keyword);
 4984|  36.4k|            if(ctx->text_list[i].compression_flag) spng__free(ctx, ctx->text_list[i].text);
  ------------------
  |  Branch (4984:16): [True: 29.6k, False: 6.78k]
  ------------------
 4985|  36.4k|        }
 4986|  7.74k|        spng__free(ctx, ctx->text_list);
 4987|  7.74k|    }
 4988|       |
 4989|  28.3k|    if(ctx->chunk_list != NULL && !ctx->user.unknown)
  ------------------
  |  Branch (4989:8): [True: 0, False: 28.3k]
  |  Branch (4989:35): [True: 0, False: 0]
  ------------------
 4990|      0|    {
 4991|      0|        for(i=0; i< ctx->n_chunks; i++)
  ------------------
  |  Branch (4991:18): [True: 0, False: 0]
  ------------------
 4992|      0|        {
 4993|      0|            spng__free(ctx, ctx->chunk_list[i].data);
 4994|      0|        }
 4995|      0|        spng__free(ctx, ctx->chunk_list);
 4996|      0|    }
 4997|       |
 4998|  28.3k|    if(ctx->deflate) deflateEnd(&ctx->zstream);
  ------------------
  |  Branch (4998:8): [True: 0, False: 28.3k]
  ------------------
 4999|  28.3k|    else inflateEnd(&ctx->zstream);
 5000|       |
 5001|  28.3k|    if(!ctx->user_owns_out_png) spng__free(ctx, ctx->out_png);
  ------------------
  |  Branch (5001:8): [True: 28.3k, False: 0]
  ------------------
 5002|       |
 5003|  28.3k|    spng__free(ctx, ctx->gamma_lut16);
 5004|       |
 5005|  28.3k|    spng__free(ctx, ctx->row_buf);
 5006|  28.3k|    spng__free(ctx, ctx->scanline_buf);
 5007|  28.3k|    spng__free(ctx, ctx->prev_scanline_buf);
 5008|  28.3k|    spng__free(ctx, ctx->filtered_scanline_buf);
 5009|       |
 5010|  28.3k|    spng_free_fn *free_fn = ctx->alloc.free_fn;
 5011|       |
 5012|  28.3k|    memset(ctx, 0, sizeof(spng_ctx));
 5013|       |
 5014|  28.3k|    free_fn(ctx);
 5015|  28.3k|}
spng_set_png_stream:
 5076|  28.3k|{
 5077|  28.3k|    if(ctx == NULL || rw_func == NULL) return 1;
  ------------------
  |  Branch (5077:8): [True: 0, False: 28.3k]
  |  Branch (5077:23): [True: 0, False: 28.3k]
  ------------------
 5078|  28.3k|    if(!ctx->state) return SPNG_EBADSTATE;
  ------------------
  |  Branch (5078:8): [True: 0, False: 28.3k]
  ------------------
 5079|       |
 5080|       |    /* SPNG_STATE_OUTPUT shares the same value */
 5081|  28.3k|    if(ctx->state >= SPNG_STATE_INPUT) return SPNG_EBUF_SET;
  ------------------
  |  Branch (5081:8): [True: 0, False: 28.3k]
  ------------------
 5082|       |
 5083|  28.3k|    if(ctx->encode_only)
  ------------------
  |  Branch (5083:8): [True: 0, False: 28.3k]
  ------------------
 5084|      0|    {
 5085|      0|        if(ctx->out_png != NULL) return SPNG_EBUF_SET;
  ------------------
  |  Branch (5085:12): [True: 0, False: 0]
  ------------------
 5086|       |
 5087|      0|        ctx->write_fn = rw_func;
 5088|      0|        ctx->write_ptr = ctx->stream_buf;
 5089|       |
 5090|      0|        ctx->state = SPNG_STATE_OUTPUT;
 5091|      0|    }
 5092|  28.3k|    else
 5093|  28.3k|    {
 5094|  28.3k|        ctx->stream_buf = spng__malloc(ctx, SPNG_READ_SIZE);
  ------------------
  |  |   30|  28.3k|#define SPNG_READ_SIZE (8192)
  ------------------
 5095|  28.3k|        if(ctx->stream_buf == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (5095:12): [True: 0, False: 28.3k]
  ------------------
 5096|       |
 5097|  28.3k|        ctx->read_fn = rw_func;
 5098|  28.3k|        ctx->data = ctx->stream_buf;
 5099|  28.3k|        ctx->data_size = SPNG_READ_SIZE;
  ------------------
  |  |   30|  28.3k|#define SPNG_READ_SIZE (8192)
  ------------------
 5100|       |
 5101|  28.3k|        ctx->state = SPNG_STATE_INPUT;
 5102|  28.3k|    }
 5103|       |
 5104|  28.3k|    ctx->stream_user_ptr = user;
 5105|       |
 5106|  28.3k|    ctx->streaming = 1;
 5107|       |
 5108|  28.3k|    return 0;
 5109|  28.3k|}
spng_set_png_file:
 5112|  28.3k|{
 5113|  28.3k|    if(file == NULL) return 1;
  ------------------
  |  Branch (5113:8): [True: 0, False: 28.3k]
  ------------------
 5114|       |
 5115|  28.3k|    if(ctx->encode_only) return spng_set_png_stream(ctx, file_write_fn, file);
  ------------------
  |  Branch (5115:8): [True: 0, False: 28.3k]
  ------------------
 5116|       |
 5117|  28.3k|    return spng_set_png_stream(ctx, file_read_fn, file);
 5118|  28.3k|}
spng_get_ihdr:
 5381|  28.3k|{
 5382|  28.3k|    if(ctx == NULL) return 1;
  ------------------
  |  Branch (5382:8): [True: 0, False: 28.3k]
  ------------------
 5383|  28.3k|    int ret = read_chunks(ctx, 1);
 5384|  28.3k|    if(ret) return ret;
  ------------------
  |  Branch (5384:8): [True: 1.46k, False: 26.9k]
  ------------------
 5385|  26.9k|    if(ihdr == NULL) return 1;
  ------------------
  |  Branch (5385:8): [True: 0, False: 26.9k]
  ------------------
 5386|       |
 5387|  26.9k|    *ihdr = ctx->ihdr;
 5388|       |
 5389|  26.9k|    return 0;
 5390|  26.9k|}
spng_get_plte:
 5393|    469|{
 5394|    945|    SPNG_GET_CHUNK_BOILERPLATE(plte);
  ------------------
  |  |  117|    469|    if(ctx == NULL) return 1; \
  |  |  ------------------
  |  |  |  Branch (117:8): [True: 0, False: 469]
  |  |  ------------------
  |  |  118|    469|    int ret = read_chunks(ctx, 0); \
  |  |  119|    469|    if(ret) return ret; \
  |  |  ------------------
  |  |  |  Branch (119:8): [True: 231, False: 238]
  |  |  ------------------
  |  |  120|    469|    if(!ctx->stored.chunk) return SPNG_ECHUNKAVAIL; \
  |  |  ------------------
  |  |  |  Branch (120:8): [True: 0, False: 238]
  |  |  ------------------
  |  |  121|    238|    if(chunk == NULL) return 1
  |  |  ------------------
  |  |  |  Branch (121:8): [True: 0, False: 238]
  |  |  ------------------
  ------------------
 5395|       |
 5396|    238|    *plte = ctx->plte;
 5397|       |
 5398|    238|    return 0;
 5399|    945|}
spng_get_iccp:
 5456|  5.68k|{
 5457|  11.3k|    SPNG_GET_CHUNK_BOILERPLATE(iccp);
  ------------------
  |  |  117|  5.68k|    if(ctx == NULL) return 1; \
  |  |  ------------------
  |  |  |  Branch (117:8): [True: 0, False: 5.68k]
  |  |  ------------------
  |  |  118|  5.68k|    int ret = read_chunks(ctx, 0); \
  |  |  119|  5.68k|    if(ret) return ret; \
  |  |  ------------------
  |  |  |  Branch (119:8): [True: 0, False: 5.68k]
  |  |  ------------------
  |  |  120|  5.68k|    if(!ctx->stored.chunk) return SPNG_ECHUNKAVAIL; \
  |  |  ------------------
  |  |  |  Branch (120:8): [True: 5.66k, False: 20]
  |  |  ------------------
  |  |  121|  5.68k|    if(chunk == NULL) return 1
  |  |  ------------------
  |  |  |  Branch (121:8): [True: 0, False: 20]
  |  |  ------------------
  ------------------
 5458|       |
 5459|     20|    *iccp = ctx->iccp;
 5460|       |
 5461|     20|    return 0;
 5462|  11.3k|}
spng_strerror:
 6049|  13.9k|{
 6050|  13.9k|    switch(err)
 6051|  13.9k|    {
 6052|  8.34k|        case SPNG_IO_EOF: return "end of stream";
  ------------------
  |  Branch (6052:9): [True: 8.34k, False: 5.62k]
  ------------------
 6053|      0|        case SPNG_IO_ERROR: return "stream error";
  ------------------
  |  Branch (6053:9): [True: 0, False: 13.9k]
  ------------------
 6054|      0|        case SPNG_OK: return "success";
  ------------------
  |  Branch (6054:9): [True: 0, False: 13.9k]
  ------------------
 6055|      0|        case SPNG_EINVAL: return "invalid argument";
  ------------------
  |  Branch (6055:9): [True: 0, False: 13.9k]
  ------------------
 6056|      0|        case SPNG_EMEM: return "out of memory";
  ------------------
  |  Branch (6056:9): [True: 0, False: 13.9k]
  ------------------
 6057|     28|        case SPNG_EOVERFLOW: return "arithmetic overflow";
  ------------------
  |  Branch (6057:9): [True: 28, False: 13.9k]
  ------------------
 6058|    308|        case SPNG_ESIGNATURE: return "invalid signature";
  ------------------
  |  Branch (6058:9): [True: 308, False: 13.6k]
  ------------------
 6059|    224|        case SPNG_EWIDTH: return "invalid image width";
  ------------------
  |  Branch (6059:9): [True: 224, False: 13.7k]
  ------------------
 6060|    175|        case SPNG_EHEIGHT: return "invalid image height";
  ------------------
  |  Branch (6060:9): [True: 175, False: 13.7k]
  ------------------
 6061|      0|        case SPNG_EUSER_WIDTH: return "image width exceeds user limit";
  ------------------
  |  Branch (6061:9): [True: 0, False: 13.9k]
  ------------------
 6062|      0|        case SPNG_EUSER_HEIGHT: return "image height exceeds user limit";
  ------------------
  |  Branch (6062:9): [True: 0, False: 13.9k]
  ------------------
 6063|    217|        case SPNG_EBIT_DEPTH: return "invalid bit depth";
  ------------------
  |  Branch (6063:9): [True: 217, False: 13.7k]
  ------------------
 6064|     49|        case SPNG_ECOLOR_TYPE: return "invalid color type";
  ------------------
  |  Branch (6064:9): [True: 49, False: 13.9k]
  ------------------
 6065|     49|        case SPNG_ECOMPRESSION_METHOD: return "invalid compression method";
  ------------------
  |  Branch (6065:9): [True: 49, False: 13.9k]
  ------------------
 6066|     42|        case SPNG_EFILTER_METHOD: return "invalid filter method";
  ------------------
  |  Branch (6066:9): [True: 42, False: 13.9k]
  ------------------
 6067|     35|        case SPNG_EINTERLACE_METHOD: return "invalid interlace method";
  ------------------
  |  Branch (6067:9): [True: 35, False: 13.9k]
  ------------------
 6068|    266|        case SPNG_EIHDR_SIZE: return "invalid IHDR chunk size";
  ------------------
  |  Branch (6068:9): [True: 266, False: 13.6k]
  ------------------
 6069|     63|        case SPNG_ENOIHDR: return "missing IHDR chunk";
  ------------------
  |  Branch (6069:9): [True: 63, False: 13.8k]
  ------------------
 6070|     20|        case SPNG_ECHUNK_POS: return "invalid chunk position";
  ------------------
  |  Branch (6070:9): [True: 20, False: 13.9k]
  ------------------
 6071|     50|        case SPNG_ECHUNK_SIZE: return "invalid chunk length";
  ------------------
  |  Branch (6071:9): [True: 50, False: 13.9k]
  ------------------
 6072|    892|        case SPNG_ECHUNK_CRC: return "invalid chunk checksum";
  ------------------
  |  Branch (6072:9): [True: 892, False: 13.0k]
  ------------------
 6073|      0|        case SPNG_ECHUNK_TYPE: return "invalid chunk type";
  ------------------
  |  Branch (6073:9): [True: 0, False: 13.9k]
  ------------------
 6074|    580|        case SPNG_ECHUNK_UNKNOWN_CRITICAL: return "unknown critical chunk";
  ------------------
  |  Branch (6074:9): [True: 580, False: 13.3k]
  ------------------
 6075|      0|        case SPNG_EDUP_PLTE: return "duplicate PLTE chunk";
  ------------------
  |  Branch (6075:9): [True: 0, False: 13.9k]
  ------------------
 6076|      0|        case SPNG_EDUP_CHRM: return "duplicate cHRM chunk";
  ------------------
  |  Branch (6076:9): [True: 0, False: 13.9k]
  ------------------
 6077|      0|        case SPNG_EDUP_GAMA: return "duplicate gAMA chunk";
  ------------------
  |  Branch (6077:9): [True: 0, False: 13.9k]
  ------------------
 6078|      0|        case SPNG_EDUP_ICCP: return "duplicate iCCP chunk";
  ------------------
  |  Branch (6078:9): [True: 0, False: 13.9k]
  ------------------
 6079|      0|        case SPNG_EDUP_SBIT: return "duplicate sBIT chunk";
  ------------------
  |  Branch (6079:9): [True: 0, False: 13.9k]
  ------------------
 6080|      0|        case SPNG_EDUP_SRGB: return "duplicate sRGB chunk";
  ------------------
  |  Branch (6080:9): [True: 0, False: 13.9k]
  ------------------
 6081|      0|        case SPNG_EDUP_BKGD: return "duplicate bKGD chunk";
  ------------------
  |  Branch (6081:9): [True: 0, False: 13.9k]
  ------------------
 6082|      0|        case SPNG_EDUP_HIST: return "duplicate hIST chunk";
  ------------------
  |  Branch (6082:9): [True: 0, False: 13.9k]
  ------------------
 6083|      0|        case SPNG_EDUP_TRNS: return "duplicate tRNS chunk";
  ------------------
  |  Branch (6083:9): [True: 0, False: 13.9k]
  ------------------
 6084|      0|        case SPNG_EDUP_PHYS: return "duplicate pHYs chunk";
  ------------------
  |  Branch (6084:9): [True: 0, False: 13.9k]
  ------------------
 6085|      0|        case SPNG_EDUP_TIME: return "duplicate tIME chunk";
  ------------------
  |  Branch (6085:9): [True: 0, False: 13.9k]
  ------------------
 6086|      0|        case SPNG_EDUP_OFFS: return "duplicate oFFs chunk";
  ------------------
  |  Branch (6086:9): [True: 0, False: 13.9k]
  ------------------
 6087|      0|        case SPNG_EDUP_EXIF: return "duplicate eXIf chunk";
  ------------------
  |  Branch (6087:9): [True: 0, False: 13.9k]
  ------------------
 6088|      0|        case SPNG_ECHRM: return "invalid cHRM chunk";
  ------------------
  |  Branch (6088:9): [True: 0, False: 13.9k]
  ------------------
 6089|      0|        case SPNG_EPLTE_IDX: return "invalid palette (PLTE) index";
  ------------------
  |  Branch (6089:9): [True: 0, False: 13.9k]
  ------------------
 6090|      0|        case SPNG_ETRNS_COLOR_TYPE: return "tRNS chunk with incompatible color type";
  ------------------
  |  Branch (6090:9): [True: 0, False: 13.9k]
  ------------------
 6091|      0|        case SPNG_ETRNS_NO_PLTE: return "missing palette (PLTE) for tRNS chunk";
  ------------------
  |  Branch (6091:9): [True: 0, False: 13.9k]
  ------------------
 6092|      0|        case SPNG_EGAMA: return "invalid gAMA chunk";
  ------------------
  |  Branch (6092:9): [True: 0, False: 13.9k]
  ------------------
 6093|      0|        case SPNG_EICCP_NAME: return "invalid iCCP profile name";
  ------------------
  |  Branch (6093:9): [True: 0, False: 13.9k]
  ------------------
 6094|      0|        case SPNG_EICCP_COMPRESSION_METHOD: return "invalid iCCP compression method";
  ------------------
  |  Branch (6094:9): [True: 0, False: 13.9k]
  ------------------
 6095|      0|        case SPNG_ESBIT: return "invalid sBIT chunk";
  ------------------
  |  Branch (6095:9): [True: 0, False: 13.9k]
  ------------------
 6096|      0|        case SPNG_ESRGB: return "invalid sRGB chunk";
  ------------------
  |  Branch (6096:9): [True: 0, False: 13.9k]
  ------------------
 6097|      0|        case SPNG_ETEXT: return "invalid tEXt chunk";
  ------------------
  |  Branch (6097:9): [True: 0, False: 13.9k]
  ------------------
 6098|      0|        case SPNG_ETEXT_KEYWORD: return "invalid tEXt keyword";
  ------------------
  |  Branch (6098:9): [True: 0, False: 13.9k]
  ------------------
 6099|      0|        case SPNG_EZTXT: return "invalid zTXt chunk";
  ------------------
  |  Branch (6099:9): [True: 0, False: 13.9k]
  ------------------
 6100|      0|        case SPNG_EZTXT_COMPRESSION_METHOD: return "invalid zTXt compression method";
  ------------------
  |  Branch (6100:9): [True: 0, False: 13.9k]
  ------------------
 6101|      0|        case SPNG_EITXT: return "invalid iTXt chunk";
  ------------------
  |  Branch (6101:9): [True: 0, False: 13.9k]
  ------------------
 6102|      0|        case SPNG_EITXT_COMPRESSION_FLAG: return "invalid iTXt compression flag";
  ------------------
  |  Branch (6102:9): [True: 0, False: 13.9k]
  ------------------
 6103|      0|        case SPNG_EITXT_COMPRESSION_METHOD: return "invalid iTXt compression method";
  ------------------
  |  Branch (6103:9): [True: 0, False: 13.9k]
  ------------------
 6104|      0|        case SPNG_EITXT_LANG_TAG: return "invalid iTXt language tag";
  ------------------
  |  Branch (6104:9): [True: 0, False: 13.9k]
  ------------------
 6105|      0|        case SPNG_EITXT_TRANSLATED_KEY: return "invalid iTXt translated key";
  ------------------
  |  Branch (6105:9): [True: 0, False: 13.9k]
  ------------------
 6106|      0|        case SPNG_EBKGD_NO_PLTE: return "missing palette for bKGD chunk";
  ------------------
  |  Branch (6106:9): [True: 0, False: 13.9k]
  ------------------
 6107|      0|        case SPNG_EBKGD_PLTE_IDX: return "invalid palette index for bKGD chunk";
  ------------------
  |  Branch (6107:9): [True: 0, False: 13.9k]
  ------------------
 6108|      0|        case SPNG_EHIST_NO_PLTE: return "missing palette for hIST chunk";
  ------------------
  |  Branch (6108:9): [True: 0, False: 13.9k]
  ------------------
 6109|      0|        case SPNG_EPHYS: return "invalid pHYs chunk";
  ------------------
  |  Branch (6109:9): [True: 0, False: 13.9k]
  ------------------
 6110|      0|        case SPNG_ESPLT_NAME: return "invalid suggested palette name";
  ------------------
  |  Branch (6110:9): [True: 0, False: 13.9k]
  ------------------
 6111|      0|        case SPNG_ESPLT_DUP_NAME: return "duplicate suggested palette (sPLT) name";
  ------------------
  |  Branch (6111:9): [True: 0, False: 13.9k]
  ------------------
 6112|      0|        case SPNG_ESPLT_DEPTH: return "invalid suggested palette (sPLT) sample depth";
  ------------------
  |  Branch (6112:9): [True: 0, False: 13.9k]
  ------------------
 6113|      0|        case SPNG_ETIME: return "invalid tIME chunk";
  ------------------
  |  Branch (6113:9): [True: 0, False: 13.9k]
  ------------------
 6114|      0|        case SPNG_EOFFS: return "invalid oFFs chunk";
  ------------------
  |  Branch (6114:9): [True: 0, False: 13.9k]
  ------------------
 6115|      0|        case SPNG_EEXIF: return "invalid eXIf chunk";
  ------------------
  |  Branch (6115:9): [True: 0, False: 13.9k]
  ------------------
 6116|    128|        case SPNG_EIDAT_TOO_SHORT: return "IDAT stream too short";
  ------------------
  |  Branch (6116:9): [True: 128, False: 13.8k]
  ------------------
 6117|  1.34k|        case SPNG_EIDAT_STREAM: return "IDAT stream error";
  ------------------
  |  Branch (6117:9): [True: 1.34k, False: 12.6k]
  ------------------
 6118|      0|        case SPNG_EZLIB: return "zlib error";
  ------------------
  |  Branch (6118:9): [True: 0, False: 13.9k]
  ------------------
 6119|    908|        case SPNG_EFILTER: return "invalid scanline filter";
  ------------------
  |  Branch (6119:9): [True: 908, False: 13.0k]
  ------------------
 6120|      0|        case SPNG_EBUFSIZ: return "invalid buffer size";
  ------------------
  |  Branch (6120:9): [True: 0, False: 13.9k]
  ------------------
 6121|      0|        case SPNG_EIO: return "i/o error";
  ------------------
  |  Branch (6121:9): [True: 0, False: 13.9k]
  ------------------
 6122|      0|        case SPNG_EOF: return "end of file";
  ------------------
  |  Branch (6122:9): [True: 0, False: 13.9k]
  ------------------
 6123|      0|        case SPNG_EBUF_SET: return "buffer already set";
  ------------------
  |  Branch (6123:9): [True: 0, False: 13.9k]
  ------------------
 6124|      0|        case SPNG_EBADSTATE: return "non-recoverable state";
  ------------------
  |  Branch (6124:9): [True: 0, False: 13.9k]
  ------------------
 6125|      0|        case SPNG_EFMT: return "invalid format";
  ------------------
  |  Branch (6125:9): [True: 0, False: 13.9k]
  ------------------
 6126|      0|        case SPNG_EFLAGS: return "invalid flags";
  ------------------
  |  Branch (6126:9): [True: 0, False: 13.9k]
  ------------------
 6127|      0|        case SPNG_ECHUNKAVAIL: return "chunk not available";
  ------------------
  |  Branch (6127:9): [True: 0, False: 13.9k]
  ------------------
 6128|      0|        case SPNG_ENCODE_ONLY: return "encode only context";
  ------------------
  |  Branch (6128:9): [True: 0, False: 13.9k]
  ------------------
 6129|      0|        case SPNG_EOI: return "reached end-of-image state";
  ------------------
  |  Branch (6129:9): [True: 0, False: 13.9k]
  ------------------
 6130|      7|        case SPNG_ENOPLTE: return "missing PLTE for indexed image";
  ------------------
  |  Branch (6130:9): [True: 7, False: 13.9k]
  ------------------
 6131|      0|        case SPNG_ECHUNK_LIMITS: return "reached chunk/cache limits";
  ------------------
  |  Branch (6131:9): [True: 0, False: 13.9k]
  ------------------
 6132|      0|        case SPNG_EZLIB_INIT: return "zlib init error";
  ------------------
  |  Branch (6132:9): [True: 0, False: 13.9k]
  ------------------
 6133|    235|        case SPNG_ECHUNK_STDLEN: return "chunk exceeds maximum standard length";
  ------------------
  |  Branch (6133:9): [True: 235, False: 13.7k]
  ------------------
 6134|      0|        case SPNG_EINTERNAL: return "internal error";
  ------------------
  |  Branch (6134:9): [True: 0, False: 13.9k]
  ------------------
 6135|      0|        case SPNG_ECTXTYPE: return "invalid operation for context type";
  ------------------
  |  Branch (6135:9): [True: 0, False: 13.9k]
  ------------------
 6136|      0|        case SPNG_ENOSRC: return "source PNG not set";
  ------------------
  |  Branch (6136:9): [True: 0, False: 13.9k]
  ------------------
 6137|      0|        case SPNG_ENODST: return "PNG output not set";
  ------------------
  |  Branch (6137:9): [True: 0, False: 13.9k]
  ------------------
 6138|      0|        case SPNG_EOPSTATE: return "invalid operation for state";
  ------------------
  |  Branch (6138:9): [True: 0, False: 13.9k]
  ------------------
 6139|      0|        case SPNG_ENOTFINAL: return "PNG not finalized";
  ------------------
  |  Branch (6139:9): [True: 0, False: 13.9k]
  ------------------
 6140|      0|        default: return "unknown error";
  ------------------
  |  Branch (6140:9): [True: 0, False: 13.9k]
  ------------------
 6141|  13.9k|    }
 6142|  13.9k|}
spng.c:spng__iter_init:
  489|   376k|{
  490|   376k|    struct spng__iter iter =
  491|   376k|    {
  492|   376k|        .mask = (uint32_t)(1 << bit_depth) - 1,
  493|   376k|        .shift_amount = 8 - bit_depth,
  494|   376k|        .initial_shift = 8 - bit_depth,
  495|   376k|        .bit_depth = bit_depth,
  496|   376k|        .samples = samples
  497|   376k|    };
  498|       |
  499|   376k|    return iter;
  500|   376k|}
spng.c:read_scanline:
 3221|   376k|{
 3222|   376k|    int ret, pass = ctx->row_info.pass;
 3223|   376k|    struct spng_row_info *ri = &ctx->row_info;
 3224|   376k|    const struct spng_subimage *sub = ctx->subimage;
 3225|   376k|    size_t scanline_width = sub[pass].scanline_width;
 3226|   376k|    uint32_t scanline_idx = ri->scanline_idx;
 3227|       |
 3228|   376k|    uint8_t next_filter = 0;
 3229|       |
 3230|   376k|    if(scanline_idx == (sub[pass].height - 1) && ri->pass == ctx->last_pass)
  ------------------
  |  Branch (3230:8): [True: 6.91k, False: 369k]
  |  Branch (3230:50): [True: 1.85k, False: 5.06k]
  ------------------
 3231|  1.85k|    {
 3232|  1.85k|        ret = read_scanline_bytes(ctx, ctx->scanline, scanline_width - 1);
 3233|  1.85k|    }
 3234|   374k|    else
 3235|   374k|    {
 3236|   374k|        ret = read_scanline_bytes(ctx, ctx->scanline, scanline_width);
 3237|   374k|        if(ret) return ret;
  ------------------
  |  Branch (3237:12): [True: 2.24k, False: 372k]
  ------------------
 3238|       |
 3239|   372k|        next_filter = ctx->scanline[scanline_width - 1];
 3240|   372k|        if(next_filter > 4) ret = SPNG_EFILTER;
  ------------------
  |  Branch (3240:12): [True: 870, False: 371k]
  ------------------
 3241|   372k|    }
 3242|       |
 3243|   374k|    if(ret) return ret;
  ------------------
  |  Branch (3243:8): [True: 1.01k, False: 373k]
  ------------------
 3244|       |
 3245|   373k|    if(!scanline_idx && ri->filter > 1)
  ------------------
  |  Branch (3245:8): [True: 10.3k, False: 362k]
  |  Branch (3245:25): [True: 2.28k, False: 8.05k]
  ------------------
 3246|  2.28k|    {
 3247|       |        /* prev_scanline is all zeros for the first scanline */
 3248|  2.28k|        memset(ctx->prev_scanline, 0, scanline_width);
 3249|  2.28k|    }
 3250|       |
 3251|   373k|    if(ctx->ihdr.bit_depth == 16 && ctx->fmt != SPNG_FMT_RAW) u16_row_to_host(ctx->scanline, scanline_width - 1);
  ------------------
  |  Branch (3251:8): [True: 30.5k, False: 342k]
  |  Branch (3251:37): [True: 30.5k, False: 0]
  ------------------
 3252|       |
 3253|   373k|    ret = defilter_scanline(ctx->prev_scanline, ctx->scanline, scanline_width, ctx->bytes_per_pixel, ri->filter);
 3254|   373k|    if(ret) return ret;
  ------------------
  |  Branch (3254:8): [True: 0, False: 373k]
  ------------------
 3255|       |
 3256|   373k|    ri->filter = next_filter;
 3257|       |
 3258|   373k|    return 0;
 3259|   373k|}
spng.c:u16_row_to_host:
  519|  30.5k|{
  520|  30.5k|    uint16_t *px = row;
  521|  30.5k|    size_t i, n = size / 2;
  522|       |
  523|  3.17M|    for(i=0; i < n; i++)
  ------------------
  |  Branch (523:14): [True: 3.14M, False: 30.5k]
  ------------------
  524|  3.14M|    {
  525|  3.14M|        px[i] = read_u16(&px[i]);
  526|  3.14M|    }
  527|  30.5k|}
spng.c:defilter_scanline:
 1458|   373k|{
 1459|   373k|    if(prev_scanline == NULL || scanline == NULL || !scanline_width) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1459:8): [True: 0, False: 373k]
  |  Branch (1459:33): [True: 0, False: 373k]
  |  Branch (1459:53): [True: 0, False: 373k]
  ------------------
 1460|       |
 1461|   373k|    size_t i;
 1462|   373k|    scanline_width--;
 1463|       |
 1464|   373k|    if(filter == 0) return 0;
  ------------------
  |  Branch (1464:8): [True: 207k, False: 165k]
  ------------------
 1465|       |
 1466|   165k|#ifndef SPNG_DISABLE_OPT
 1467|   165k|    if(filter == SPNG_FILTER_UP) goto no_opt;
  ------------------
  |  Branch (1467:8): [True: 22.0k, False: 143k]
  ------------------
 1468|       |
 1469|   143k|    if(bytes_per_pixel == 4)
  ------------------
  |  Branch (1469:8): [True: 29.8k, False: 113k]
  ------------------
 1470|  29.8k|    {
 1471|  29.8k|        if(filter == SPNG_FILTER_SUB)
  ------------------
  |  Branch (1471:12): [True: 2.35k, False: 27.5k]
  ------------------
 1472|  2.35k|            defilter_sub4(scanline_width, scanline);
 1473|  27.5k|        else if(filter == SPNG_FILTER_AVERAGE)
  ------------------
  |  Branch (1473:17): [True: 2.68k, False: 24.8k]
  ------------------
 1474|  2.68k|            defilter_avg4(scanline_width, scanline, prev_scanline);
 1475|  24.8k|        else if(filter == SPNG_FILTER_PAETH)
  ------------------
  |  Branch (1475:17): [True: 24.8k, False: 0]
  ------------------
 1476|  24.8k|            defilter_paeth4(scanline_width, scanline, prev_scanline);
 1477|      0|        else return SPNG_EFILTER;
 1478|       |
 1479|  29.8k|        return 0;
 1480|  29.8k|    }
 1481|   113k|    else if(bytes_per_pixel == 3)
  ------------------
  |  Branch (1481:13): [True: 95.9k, False: 17.5k]
  ------------------
 1482|  95.9k|    {
 1483|  95.9k|        if(filter == SPNG_FILTER_SUB)
  ------------------
  |  Branch (1483:12): [True: 13.3k, False: 82.5k]
  ------------------
 1484|  13.3k|            defilter_sub3(scanline_width, scanline);
 1485|  82.5k|        else if(filter == SPNG_FILTER_AVERAGE)
  ------------------
  |  Branch (1485:17): [True: 384, False: 82.1k]
  ------------------
 1486|    384|            defilter_avg3(scanline_width, scanline, prev_scanline);
 1487|  82.1k|        else if(filter == SPNG_FILTER_PAETH)
  ------------------
  |  Branch (1487:17): [True: 82.1k, False: 0]
  ------------------
 1488|  82.1k|            defilter_paeth3(scanline_width, scanline, prev_scanline);
 1489|      0|        else return SPNG_EFILTER;
 1490|       |
 1491|  95.9k|        return 0;
 1492|  95.9k|    }
 1493|  39.5k|no_opt:
 1494|  39.5k|#endif
 1495|       |
 1496|  39.5k|    if(filter == SPNG_FILTER_UP)
  ------------------
  |  Branch (1496:8): [True: 22.0k, False: 17.5k]
  ------------------
 1497|  22.0k|    {
 1498|  22.0k|        defilter_up(scanline_width, scanline, prev_scanline);
 1499|  22.0k|        return 0;
 1500|  22.0k|    }
 1501|       |
 1502|  2.69M|    for(i=0; i < scanline_width; i++)
  ------------------
  |  Branch (1502:14): [True: 2.68M, False: 17.5k]
  ------------------
 1503|  2.68M|    {
 1504|  2.68M|        uint8_t x, a, b, c;
 1505|       |
 1506|  2.68M|        if(i >= bytes_per_pixel)
  ------------------
  |  Branch (1506:12): [True: 2.61M, False: 65.3k]
  ------------------
 1507|  2.61M|        {
 1508|  2.61M|            a = scanline[i - bytes_per_pixel];
 1509|  2.61M|            b = prev_scanline[i];
 1510|  2.61M|            c = prev_scanline[i - bytes_per_pixel];
 1511|  2.61M|        }
 1512|  65.3k|        else /* First pixel in row */
 1513|  65.3k|        {
 1514|  65.3k|            a = 0;
 1515|  65.3k|            b = prev_scanline[i];
 1516|  65.3k|            c = 0;
 1517|  65.3k|        }
 1518|       |
 1519|  2.68M|        x = scanline[i];
 1520|       |
 1521|  2.68M|        switch(filter)
  ------------------
  |  Branch (1521:16): [True: 2.68M, False: 0]
  ------------------
 1522|  2.68M|        {
 1523|  1.10M|            case SPNG_FILTER_SUB:
  ------------------
  |  Branch (1523:13): [True: 1.10M, False: 1.57M]
  ------------------
 1524|  1.10M|            {
 1525|  1.10M|                x = x + a;
 1526|  1.10M|                break;
 1527|      0|            }
 1528|   714k|            case SPNG_FILTER_AVERAGE:
  ------------------
  |  Branch (1528:13): [True: 714k, False: 1.96M]
  ------------------
 1529|   714k|            {
 1530|   714k|                uint16_t avg = (a + b) / 2;
 1531|   714k|                x = x + avg;
 1532|   714k|                break;
 1533|      0|            }
 1534|   856k|            case SPNG_FILTER_PAETH:
  ------------------
  |  Branch (1534:13): [True: 856k, False: 1.82M]
  ------------------
 1535|   856k|            {
 1536|   856k|                x = x + paeth(a,b,c);
 1537|   856k|                break;
 1538|      0|            }
 1539|  2.68M|        }
 1540|       |
 1541|  2.68M|        scanline[i] = x;
 1542|  2.68M|    }
 1543|       |
 1544|  17.5k|    return 0;
 1545|  17.5k|}
spng.c:defilter_sub4:
 6286|  2.35k|{
 6287|       |    /* The Sub filter predicts each pixel as the previous pixel, a.
 6288|       |     * There is no pixel to the left of the first pixel.  It's encoded directly.
 6289|       |     * That works with our main loop if we just say that left pixel was zero.
 6290|       |     */
 6291|  2.35k|    size_t rb = rowbytes+4;
 6292|       |
 6293|  2.35k|    __m128i a, d = _mm_setzero_si128();
 6294|       |
 6295|   228k|    while(rb > 4)
  ------------------
  |  Branch (6295:11): [True: 226k, False: 2.35k]
  ------------------
 6296|   226k|    {
 6297|   226k|        a = d; d = load4(row);
 6298|   226k|        d = _mm_add_epi8(d, a);
 6299|   226k|        store4(row, d);
 6300|       |
 6301|   226k|        row += 4;
 6302|   226k|        rb  -= 4;
 6303|   226k|    }
 6304|  2.35k|}
spng.c:load4:
 6232|  22.1M|{
 6233|  22.1M|    int tmp;
 6234|  22.1M|    memcpy(&tmp, p, sizeof(tmp));
 6235|  22.1M|    return _mm_cvtsi32_si128(tmp);
 6236|  22.1M|}
spng.c:store4:
 6239|  2.74M|{
 6240|  2.74M|    int tmp = _mm_cvtsi128_si32(v);
 6241|  2.74M|    memcpy(p, &tmp, sizeof(int));
 6242|  2.74M|}
spng.c:defilter_avg4:
 6358|  2.68k|{
 6359|       |    /* The Avg filter predicts each pixel as the (truncated) average of a and b.
 6360|       |     * There's no pixel to the left of the first pixel.  Luckily, it's
 6361|       |     * predicted to be half of the pixel above it.  So again, this works
 6362|       |     * perfectly with our loop if we make sure a starts at zero.
 6363|       |     */
 6364|  2.68k|    size_t rb = rowbytes+4;
 6365|       |
 6366|  2.68k|    const __m128i zero = _mm_setzero_si128();
 6367|  2.68k|    __m128i    b;
 6368|  2.68k|    __m128i a, d = zero;
 6369|       |
 6370|  65.6k|    while(rb > 4)
  ------------------
  |  Branch (6370:11): [True: 62.9k, False: 2.68k]
  ------------------
 6371|  62.9k|    {
 6372|  62.9k|        __m128i avg;
 6373|  62.9k|               b = load4(prev);
 6374|  62.9k|        a = d; d = load4(row );
 6375|       |
 6376|       |        /* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
 6377|  62.9k|        avg = _mm_avg_epu8(a,b);
 6378|       |        /* ...but we can fix it up by subtracting off 1 if it rounded up. */
 6379|  62.9k|        avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a, b),
 6380|  62.9k|                                            _mm_set1_epi8(1)));
 6381|       |
 6382|  62.9k|        d = _mm_add_epi8(d, avg);
 6383|  62.9k|        store4(row, d);
 6384|       |
 6385|  62.9k|        prev += 4;
 6386|  62.9k|        row  += 4;
 6387|  62.9k|        rb   -= 4;
 6388|  62.9k|    }
 6389|  2.68k|}
spng.c:defilter_paeth4:
 6517|  24.8k|{
 6518|       |    /* Paeth tries to predict pixel d using the pixel to the left of it, a,
 6519|       |     * and two pixels from the previous row, b and c:
 6520|       |     *   prev: c b
 6521|       |     *   row:  a d
 6522|       |     * The Paeth function predicts d to be whichever of a, b, or c is nearest to
 6523|       |     * p=a+b-c.
 6524|       |     *
 6525|       |     * The first pixel has no left context, and so uses an Up filter, p = b.
 6526|       |     * This works naturally with our main loop's p = a+b-c if we force a and c
 6527|       |     * to zero.
 6528|       |     * Here we zero b and d, which become c and a respectively at the start of
 6529|       |     * the loop.
 6530|       |     */
 6531|  24.8k|    size_t rb = rowbytes+4;
 6532|       |
 6533|  24.8k|    const __m128i zero = _mm_setzero_si128();
 6534|  24.8k|    __m128i pa, pb, pc, smallest, nearest;
 6535|  24.8k|    __m128i c, b = zero,
 6536|  24.8k|            a, d = zero;
 6537|       |
 6538|  2.48M|    while(rb > 4)
  ------------------
  |  Branch (6538:11): [True: 2.45M, False: 24.8k]
  ------------------
 6539|  2.45M|    {
 6540|       |        /* It's easiest to do this math (particularly, deal with pc) with 16-bit
 6541|       |         * intermediates.
 6542|       |         */
 6543|  2.45M|        c = b; b = _mm_unpacklo_epi8(load4(prev), zero);
 6544|  2.45M|        a = d; d = _mm_unpacklo_epi8(load4(row ), zero);
 6545|       |
 6546|       |        /* (p-a) == (a+b-c - a) == (b-c) */
 6547|  2.45M|        pa = _mm_sub_epi16(b, c);
 6548|       |
 6549|       |        /* (p-b) == (a+b-c - b) == (a-c) */
 6550|  2.45M|        pb = _mm_sub_epi16(a, c);
 6551|       |
 6552|       |        /* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
 6553|  2.45M|        pc = _mm_add_epi16(pa, pb);
 6554|       |
 6555|  2.45M|        pa = abs_i16(pa);  /* |p-a| */
 6556|  2.45M|        pb = abs_i16(pb);  /* |p-b| */
 6557|  2.45M|        pc = abs_i16(pc);  /* |p-c| */
 6558|       |
 6559|  2.45M|        smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
 6560|       |
 6561|       |        /* Paeth breaks ties favoring a over b over c. */
 6562|  2.45M|        nearest  = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
 6563|  2.45M|                            if_then_else(_mm_cmpeq_epi16(smallest, pb), b, c));
 6564|       |
 6565|       |        /* Note `_epi8`: we need addition to wrap modulo 255. */
 6566|  2.45M|        d = _mm_add_epi8(d, nearest);
 6567|  2.45M|        store4(row, _mm_packus_epi16(d, d));
 6568|       |
 6569|  2.45M|        prev += 4;
 6570|  2.45M|        row  += 4;
 6571|  2.45M|        rb   -= 4;
 6572|  2.45M|    }
 6573|  24.8k|}
spng.c:abs_i16:
 6396|  30.3M|{
 6397|       |#if SPNG_SSE >= 3
 6398|       |    return _mm_abs_epi16(x);
 6399|       |#else
 6400|       |    /* Read this all as, return x<0 ? -x : x.
 6401|       |     * To negate two's complement, you flip all the bits then add 1.
 6402|       |     */
 6403|  30.3M|    __m128i is_negative = _mm_cmplt_epi16(x, _mm_setzero_si128());
 6404|       |
 6405|       |    /* Flip negative lanes. */
 6406|  30.3M|    x = _mm_xor_si128(x, is_negative);
 6407|       |
 6408|       |    /* +1 to negative lanes, else +0. */
 6409|  30.3M|    x = _mm_sub_epi16(x, is_negative);
 6410|  30.3M|    return x;
 6411|  30.3M|#endif
 6412|  30.3M|}
spng.c:if_then_else:
 6416|  20.2M|{
 6417|       |#if SPNG_SSE >= 4
 6418|       |    return _mm_blendv_epi8(e, t, c);
 6419|       |#else
 6420|  20.2M|    return _mm_or_si128(_mm_and_si128(c, t), _mm_andnot_si128(c, e));
 6421|  20.2M|#endif
 6422|  20.2M|}
spng.c:defilter_sub3:
 6258|  13.3k|{
 6259|       |    /* The Sub filter predicts each pixel as the previous pixel, a.
 6260|       |     * There is no pixel to the left of the first pixel.  It's encoded directly.
 6261|       |     * That works with our main loop if we just say that left pixel was zero.
 6262|       |     */
 6263|  13.3k|    size_t rb = rowbytes;
 6264|       |
 6265|  13.3k|    __m128i a, d = _mm_setzero_si128();
 6266|       |
 6267|  1.65M|    while(rb >= 4)
  ------------------
  |  Branch (6267:11): [True: 1.64M, False: 13.3k]
  ------------------
 6268|  1.64M|    {
 6269|  1.64M|        a = d; d = load4(row);
 6270|  1.64M|        d = _mm_add_epi8(d, a);
 6271|  1.64M|        store3(row, d);
 6272|       |
 6273|  1.64M|        row += 3;
 6274|  1.64M|        rb  -= 3;
 6275|  1.64M|    }
 6276|       |
 6277|  13.3k|    if(rb > 0)
  ------------------
  |  Branch (6277:8): [True: 13.3k, False: 0]
  ------------------
 6278|  13.3k|    {
 6279|  13.3k|        a = d; d = load3(row);
 6280|  13.3k|        d = _mm_add_epi8(d, a);
 6281|  13.3k|        store3(row, d);
 6282|  13.3k|    }
 6283|  13.3k|}
spng.c:store3:
 6252|  9.35M|{
 6253|  9.35M|    int tmp = _mm_cvtsi128_si32(v);
 6254|  9.35M|    memcpy(p, &tmp, 3);
 6255|  9.35M|}
spng.c:load3:
 6245|   178k|{
 6246|   178k|    uint32_t tmp = 0;
 6247|   178k|    memcpy(&tmp, p, 3);
 6248|   178k|    return _mm_cvtsi32_si128(tmp);
 6249|   178k|}
spng.c:defilter_avg3:
 6307|    384|{
 6308|       |    /* The Avg filter predicts each pixel as the (truncated) average of a and b.
 6309|       |     * There's no pixel to the left of the first pixel.  Luckily, it's
 6310|       |     * predicted to be half of the pixel above it.  So again, this works
 6311|       |     * perfectly with our loop if we make sure a starts at zero.
 6312|       |     */
 6313|       |
 6314|    384|    size_t rb = rowbytes;
 6315|       |
 6316|    384|    const __m128i zero = _mm_setzero_si128();
 6317|       |
 6318|    384|    __m128i b;
 6319|    384|    __m128i a, d = zero;
 6320|       |
 6321|  29.9k|    while(rb >= 4)
  ------------------
  |  Branch (6321:11): [True: 29.5k, False: 384]
  ------------------
 6322|  29.5k|    {
 6323|  29.5k|        __m128i avg;
 6324|  29.5k|               b = load4(prev);
 6325|  29.5k|        a = d; d = load4(row );
 6326|       |
 6327|       |        /* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
 6328|  29.5k|        avg = _mm_avg_epu8(a,b);
 6329|       |        /* ...but we can fix it up by subtracting off 1 if it rounded up. */
 6330|  29.5k|        avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a, b),
 6331|  29.5k|                                            _mm_set1_epi8(1)));
 6332|  29.5k|        d = _mm_add_epi8(d, avg);
 6333|  29.5k|        store3(row, d);
 6334|       |
 6335|  29.5k|        prev += 3;
 6336|  29.5k|        row  += 3;
 6337|  29.5k|        rb   -= 3;
 6338|  29.5k|    }
 6339|       |
 6340|    384|    if(rb > 0)
  ------------------
  |  Branch (6340:8): [True: 384, False: 0]
  ------------------
 6341|    384|    {
 6342|    384|        __m128i avg;
 6343|    384|               b = load3(prev);
 6344|    384|        a = d; d = load3(row );
 6345|       |
 6346|       |        /* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
 6347|    384|        avg = _mm_avg_epu8(a, b);
 6348|       |        /* ...but we can fix it up by subtracting off 1 if it rounded up. */
 6349|    384|        avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a, b),
 6350|    384|                                            _mm_set1_epi8(1)));
 6351|       |
 6352|    384|        d = _mm_add_epi8(d, avg);
 6353|    384|        store3(row, d);
 6354|    384|    }
 6355|    384|}
spng.c:defilter_paeth3:
 6425|  82.1k|{
 6426|       |    /* Paeth tries to predict pixel d using the pixel to the left of it, a,
 6427|       |     * and two pixels from the previous row, b and c:
 6428|       |     *   prev: c b
 6429|       |     *   row:  a d
 6430|       |     * The Paeth function predicts d to be whichever of a, b, or c is nearest to
 6431|       |     * p=a+b-c.
 6432|       |     *
 6433|       |     * The first pixel has no left context, and so uses an Up filter, p = b.
 6434|       |     * This works naturally with our main loop's p = a+b-c if we force a and c
 6435|       |     * to zero.
 6436|       |     * Here we zero b and d, which become c and a respectively at the start of
 6437|       |     * the loop.
 6438|       |     */
 6439|  82.1k|    size_t rb = rowbytes;
 6440|  82.1k|    const __m128i zero = _mm_setzero_si128();
 6441|  82.1k|    __m128i c, b = zero,
 6442|  82.1k|            a, d = zero;
 6443|       |
 6444|  7.66M|    while(rb >= 4)
  ------------------
  |  Branch (6444:11): [True: 7.58M, False: 82.1k]
  ------------------
 6445|  7.58M|    {
 6446|       |        /* It's easiest to do this math (particularly, deal with pc) with 16-bit
 6447|       |         * intermediates.
 6448|       |         */
 6449|  7.58M|        __m128i pa,pb,pc,smallest,nearest;
 6450|  7.58M|        c = b; b = _mm_unpacklo_epi8(load4(prev), zero);
 6451|  7.58M|        a = d; d = _mm_unpacklo_epi8(load4(row ), zero);
 6452|       |
 6453|       |        /* (p-a) == (a+b-c - a) == (b-c) */
 6454|       |
 6455|  7.58M|        pa = _mm_sub_epi16(b, c);
 6456|       |
 6457|       |        /* (p-b) == (a+b-c - b) == (a-c) */
 6458|  7.58M|        pb = _mm_sub_epi16(a, c);
 6459|       |
 6460|       |        /* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
 6461|  7.58M|        pc = _mm_add_epi16(pa, pb);
 6462|       |
 6463|  7.58M|        pa = abs_i16(pa);  /* |p-a| */
 6464|  7.58M|        pb = abs_i16(pb);  /* |p-b| */
 6465|  7.58M|        pc = abs_i16(pc);  /* |p-c| */
 6466|       |
 6467|  7.58M|        smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
 6468|       |
 6469|       |        /* Paeth breaks ties favoring a over b over c. */
 6470|  7.58M|        nearest  = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
 6471|  7.58M|                            if_then_else(_mm_cmpeq_epi16(smallest, pb), b, c));
 6472|       |
 6473|       |        /* Note `_epi8`: we need addition to wrap modulo 255. */
 6474|  7.58M|        d = _mm_add_epi8(d, nearest);
 6475|  7.58M|        store3(row, _mm_packus_epi16(d, d));
 6476|       |
 6477|  7.58M|        prev += 3;
 6478|  7.58M|        row  += 3;
 6479|  7.58M|        rb   -= 3;
 6480|  7.58M|    }
 6481|       |
 6482|  82.1k|    if(rb > 0)
  ------------------
  |  Branch (6482:8): [True: 82.1k, False: 0]
  ------------------
 6483|  82.1k|    {
 6484|       |        /* It's easiest to do this math (particularly, deal with pc) with 16-bit
 6485|       |         * intermediates.
 6486|       |         */
 6487|  82.1k|        __m128i pa, pb, pc, smallest, nearest;
 6488|  82.1k|        c = b; b = _mm_unpacklo_epi8(load3(prev), zero);
 6489|  82.1k|        a = d; d = _mm_unpacklo_epi8(load3(row ), zero);
 6490|       |
 6491|       |        /* (p-a) == (a+b-c - a) == (b-c) */
 6492|  82.1k|        pa = _mm_sub_epi16(b, c);
 6493|       |
 6494|       |        /* (p-b) == (a+b-c - b) == (a-c) */
 6495|  82.1k|        pb = _mm_sub_epi16(a, c);
 6496|       |
 6497|       |        /* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
 6498|  82.1k|        pc = _mm_add_epi16(pa, pb);
 6499|       |
 6500|  82.1k|        pa = abs_i16(pa);  /* |p-a| */
 6501|  82.1k|        pb = abs_i16(pb);  /* |p-b| */
 6502|  82.1k|        pc = abs_i16(pc);  /* |p-c| */
 6503|       |
 6504|  82.1k|        smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
 6505|       |
 6506|       |        /* Paeth breaks ties favoring a over b over c. */
 6507|  82.1k|        nearest  = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
 6508|  82.1k|                            if_then_else(_mm_cmpeq_epi16(smallest, pb), b, c));
 6509|       |
 6510|       |        /* Note `_epi8`: we need addition to wrap modulo 255. */
 6511|  82.1k|        d = _mm_add_epi8(d, nearest);
 6512|  82.1k|        store3(row, _mm_packus_epi16(d, d));
 6513|  82.1k|    }
 6514|  82.1k|}
spng.c:defilter_up:
 1444|  22.0k|{
 1445|  22.0k|    size_t i;
 1446|  11.3M|    for(i=0; i < bytes; i++)
  ------------------
  |  Branch (1446:14): [True: 11.3M, False: 22.0k]
  ------------------
 1447|  11.3M|    {
 1448|  11.3M|        row[i] += prev[i];
 1449|  11.3M|    }
 1450|  22.0k|}
spng.c:paeth:
 1430|   856k|{
 1431|   856k|    int16_t p = a + b - c;
 1432|   856k|    int16_t pa = abs(p - a);
 1433|   856k|    int16_t pb = abs(p - b);
 1434|   856k|    int16_t pc = abs(p - c);
 1435|       |
 1436|   856k|    if(pa <= pb && pa <= pc) return a;
  ------------------
  |  Branch (1436:8): [True: 470k, False: 386k]
  |  Branch (1436:20): [True: 435k, False: 35.2k]
  ------------------
 1437|   421k|    else if(pb <= pc) return b;
  ------------------
  |  Branch (1437:13): [True: 359k, False: 62.3k]
  ------------------
 1438|       |
 1439|  62.3k|    return c;
 1440|   856k|}
spng.c:decode_err:
  759|  34.4k|{
  760|  34.4k|    ctx->state = SPNG_STATE_INVALID;
  761|       |
  762|  34.4k|    return err;
  763|  34.4k|}
spng.c:update_row_info:
 3262|   373k|{
 3263|   373k|    int interlacing = ctx->ihdr.interlace_method;
 3264|   373k|    struct spng_row_info *ri = &ctx->row_info;
 3265|   373k|    const struct spng_subimage *sub = ctx->subimage;
 3266|       |
 3267|   373k|    if(ri->scanline_idx == (sub[ri->pass].height - 1)) /* Last scanline */
  ------------------
  |  Branch (3267:8): [True: 6.69k, False: 366k]
  ------------------
 3268|  6.69k|    {
 3269|  6.69k|        if(ri->pass == ctx->last_pass)
  ------------------
  |  Branch (3269:12): [True: 1.70k, False: 4.98k]
  ------------------
 3270|  1.70k|        {
 3271|  1.70k|            ctx->state = SPNG_STATE_EOI;
 3272|       |
 3273|  1.70k|            return SPNG_EOI;
 3274|  1.70k|        }
 3275|       |
 3276|  4.98k|        ri->scanline_idx = 0;
 3277|  4.98k|        ri->pass++;
 3278|       |
 3279|       |        /* Skip empty passes */
 3280|  4.98k|        while( (!sub[ri->pass].width || !sub[ri->pass].height) && (ri->pass < ctx->last_pass)) ri->pass++;
  ------------------
  |  Branch (3280:17): [True: 0, False: 4.98k]
  |  Branch (3280:41): [True: 0, False: 4.98k]
  |  Branch (3280:67): [True: 0, False: 0]
  ------------------
 3281|  4.98k|    }
 3282|   366k|    else
 3283|   366k|    {
 3284|   366k|        ri->row_num++;
 3285|   366k|        ri->scanline_idx++;
 3286|   366k|    }
 3287|       |
 3288|   371k|    if(interlacing) ri->row_num = adam7_y_start[ri->pass] + ri->scanline_idx * adam7_y_delta[ri->pass];
  ------------------
  |  Branch (3288:8): [True: 211k, False: 159k]
  ------------------
 3289|       |
 3290|   371k|    return 0;
 3291|   373k|}
spng.c:discard_chunk_bytes:
 1155|   367k|{
 1156|   367k|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1156:8): [True: 0, False: 367k]
  ------------------
 1157|   367k|    if(!bytes) return 0;
  ------------------
  |  Branch (1157:8): [True: 324k, False: 43.6k]
  ------------------
 1158|       |
 1159|  43.6k|    int ret;
 1160|       |
 1161|  43.6k|    if(ctx->streaming) /* Do small, consecutive reads */
  ------------------
  |  Branch (1161:8): [True: 43.6k, False: 0]
  ------------------
 1162|  43.6k|    {
 1163|  89.5k|        while(bytes)
  ------------------
  |  Branch (1163:15): [True: 50.7k, False: 38.8k]
  ------------------
 1164|  50.7k|        {
 1165|  50.7k|            uint32_t len = SPNG_READ_SIZE;
  ------------------
  |  |   30|  50.7k|#define SPNG_READ_SIZE (8192)
  ------------------
 1166|       |
 1167|  50.7k|            if(len > bytes) len = bytes;
  ------------------
  |  Branch (1167:16): [True: 40.0k, False: 10.6k]
  ------------------
 1168|       |
 1169|  50.7k|            ret = read_chunk_bytes(ctx, len);
 1170|  50.7k|            if(ret) return ret;
  ------------------
  |  Branch (1170:16): [True: 4.80k, False: 45.8k]
  ------------------
 1171|       |
 1172|  45.8k|            bytes -= len;
 1173|  45.8k|        }
 1174|  43.6k|    }
 1175|      0|    else
 1176|      0|    {
 1177|      0|        ret = read_chunk_bytes(ctx, bytes);
 1178|      0|        if(ret) return ret;
  ------------------
  |  Branch (1178:12): [True: 0, False: 0]
  ------------------
 1179|      0|    }
 1180|       |
 1181|  38.8k|    return 0;
 1182|  43.6k|}
spng.c:read_chunk_bytes:
 1101|   248k|{
 1102|   248k|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1102:8): [True: 0, False: 248k]
  ------------------
 1103|   248k|    if(!ctx->cur_chunk_bytes_left || !bytes) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1103:8): [True: 4.24k, False: 244k]
  |  Branch (1103:38): [True: 0, False: 244k]
  ------------------
 1104|   244k|    if(bytes > ctx->cur_chunk_bytes_left) return SPNG_EINTERNAL; /* XXX: more specific error? */
  ------------------
  |  Branch (1104:8): [True: 0, False: 244k]
  ------------------
 1105|       |
 1106|   244k|    int ret;
 1107|       |
 1108|   244k|    ret = read_data(ctx, bytes);
 1109|   244k|    if(ret) return ret;
  ------------------
  |  Branch (1109:8): [True: 7.61k, False: 237k]
  ------------------
 1110|       |
 1111|   237k|    if(!ctx->skip_crc) ctx->cur_actual_crc = crc32(ctx->cur_actual_crc, ctx->data, bytes);
  ------------------
  |  Branch (1111:8): [True: 237k, False: 0]
  ------------------
 1112|       |
 1113|   237k|    ctx->cur_chunk_bytes_left -= bytes;
 1114|       |
 1115|   237k|    return ret;
 1116|   244k|}
spng.c:read_data:
  773|  1.11M|{
  774|  1.11M|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (774:8): [True: 0, False: 1.11M]
  ------------------
  775|  1.11M|    if(!bytes) return 0;
  ------------------
  |  Branch (775:8): [True: 0, False: 1.11M]
  ------------------
  776|       |
  777|  1.11M|    if(ctx->streaming && (bytes > SPNG_READ_SIZE)) return SPNG_EINTERNAL;
  ------------------
  |  |   30|  1.11M|#define SPNG_READ_SIZE (8192)
  ------------------
  |  Branch (777:8): [True: 1.11M, False: 0]
  |  Branch (777:26): [True: 0, False: 1.11M]
  ------------------
  778|       |
  779|  1.11M|    int ret = ctx->read_fn(ctx, ctx->stream_user_ptr, ctx->stream_buf, bytes);
  780|       |
  781|  1.11M|    if(ret)
  ------------------
  |  Branch (781:8): [True: 25.5k, False: 1.08M]
  ------------------
  782|  25.5k|    {
  783|  25.5k|        if(ret > 0 || ret < SPNG_IO_ERROR) ret = SPNG_IO_ERROR;
  ------------------
  |  Branch (783:12): [True: 0, False: 25.5k]
  |  Branch (783:23): [True: 0, False: 25.5k]
  ------------------
  784|       |
  785|  25.5k|        return ret;
  786|  25.5k|    }
  787|       |
  788|  1.08M|    ctx->bytes_read += bytes;
  789|  1.08M|    if(ctx->bytes_read < bytes) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (789:8): [True: 0, False: 1.08M]
  ------------------
  790|       |
  791|  1.08M|    return 0;
  792|  1.08M|}
spng.c:read_chunks:
 3109|  63.5k|{
 3110|  63.5k|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (3110:8): [True: 0, False: 63.5k]
  ------------------
 3111|  63.5k|    if(!ctx->state) return SPNG_EBADSTATE;
  ------------------
  |  Branch (3111:8): [True: 0, False: 63.5k]
  ------------------
 3112|  63.5k|    if(ctx->data == NULL)
  ------------------
  |  Branch (3112:8): [True: 0, False: 63.5k]
  ------------------
 3113|      0|    {
 3114|      0|        if(ctx->encode_only) return 0;
  ------------------
  |  Branch (3114:12): [True: 0, False: 0]
  ------------------
 3115|      0|        else return SPNG_EINTERNAL;
 3116|      0|    }
 3117|       |
 3118|  63.5k|    int ret = 0;
 3119|       |
 3120|  63.5k|    if(ctx->state == SPNG_STATE_INPUT)
  ------------------
  |  Branch (3120:8): [True: 28.3k, False: 35.2k]
  ------------------
 3121|  28.3k|    {
 3122|  28.3k|        ret = read_ihdr(ctx);
 3123|       |
 3124|  28.3k|        if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3124:12): [True: 1.46k, False: 26.9k]
  ------------------
 3125|       |
 3126|  26.9k|        ctx->state = SPNG_STATE_IHDR;
 3127|  26.9k|    }
 3128|       |
 3129|  62.1k|    if(only_ihdr) return 0;
  ------------------
  |  Branch (3129:8): [True: 26.9k, False: 35.2k]
  ------------------
 3130|       |
 3131|  35.2k|    if(ctx->state == SPNG_STATE_EOI)
  ------------------
  |  Branch (3131:8): [True: 1.65k, False: 33.5k]
  ------------------
 3132|  1.65k|    {
 3133|  1.65k|        ctx->state = SPNG_STATE_AFTER_IDAT;
 3134|  1.65k|        ctx->prev_was_idat = 1;
 3135|  1.65k|    }
 3136|       |
 3137|   347k|    while(ctx->state < SPNG_STATE_FIRST_IDAT || ctx->state == SPNG_STATE_AFTER_IDAT)
  ------------------
  |  Branch (3137:11): [True: 326k, False: 20.8k]
  |  Branch (3137:49): [True: 6.36k, False: 14.5k]
  ------------------
 3138|   332k|    {
 3139|   332k|        ret = read_non_idat_chunks(ctx);
 3140|       |
 3141|   332k|        if(!ret)
  ------------------
  |  Branch (3141:12): [True: 7.88k, False: 324k]
  ------------------
 3142|  7.88k|        {
 3143|  7.88k|            if(ctx->state < SPNG_STATE_FIRST_IDAT) ctx->state = SPNG_STATE_FIRST_IDAT;
  ------------------
  |  Branch (3143:16): [True: 7.81k, False: 65]
  ------------------
 3144|     65|            else if(ctx->state == SPNG_STATE_AFTER_IDAT) ctx->state = SPNG_STATE_IEND;
  ------------------
  |  Branch (3144:21): [True: 65, False: 0]
  ------------------
 3145|  7.88k|        }
 3146|   324k|        else
 3147|   324k|        {
 3148|   324k|            switch(ret)
 3149|   324k|            {
 3150|  4.03k|                case SPNG_ECHUNK_POS:
  ------------------
  |  Branch (3150:17): [True: 4.03k, False: 320k]
  ------------------
 3151|   135k|                case SPNG_ECHUNK_SIZE: /* size != expected size, SPNG_ECHUNK_STDLEN = invalid size */
  ------------------
  |  Branch (3151:17): [True: 131k, False: 193k]
  ------------------
 3152|   135k|                case SPNG_EDUP_PLTE:
  ------------------
  |  Branch (3152:17): [True: 0, False: 324k]
  ------------------
 3153|   136k|                case SPNG_EDUP_CHRM:
  ------------------
  |  Branch (3153:17): [True: 581, False: 324k]
  ------------------
 3154|   136k|                case SPNG_EDUP_GAMA:
  ------------------
  |  Branch (3154:17): [True: 98, False: 324k]
  ------------------
 3155|   156k|                case SPNG_EDUP_ICCP:
  ------------------
  |  Branch (3155:17): [True: 19.9k, False: 304k]
  ------------------
 3156|   156k|                case SPNG_EDUP_SBIT:
  ------------------
  |  Branch (3156:17): [True: 441, False: 324k]
  ------------------
 3157|   157k|                case SPNG_EDUP_SRGB:
  ------------------
  |  Branch (3157:17): [True: 308, False: 324k]
  ------------------
 3158|   161k|                case SPNG_EDUP_BKGD:
  ------------------
  |  Branch (3158:17): [True: 4.25k, False: 320k]
  ------------------
 3159|   162k|                case SPNG_EDUP_HIST:
  ------------------
  |  Branch (3159:17): [True: 469, False: 324k]
  ------------------
 3160|   164k|                case SPNG_EDUP_TRNS:
  ------------------
  |  Branch (3160:17): [True: 2.70k, False: 322k]
  ------------------
 3161|   165k|                case SPNG_EDUP_PHYS:
  ------------------
  |  Branch (3161:17): [True: 280, False: 324k]
  ------------------
 3162|   168k|                case SPNG_EDUP_TIME:
  ------------------
  |  Branch (3162:17): [True: 3.80k, False: 321k]
  ------------------
 3163|   168k|                case SPNG_EDUP_OFFS:
  ------------------
  |  Branch (3163:17): [True: 77, False: 324k]
  ------------------
 3164|   171k|                case SPNG_EDUP_EXIF:
  ------------------
  |  Branch (3164:17): [True: 2.10k, False: 322k]
  ------------------
 3165|   172k|                case SPNG_ECHRM:
  ------------------
  |  Branch (3165:17): [True: 1.23k, False: 323k]
  ------------------
 3166|   172k|                case SPNG_ETRNS_COLOR_TYPE:
  ------------------
  |  Branch (3166:17): [True: 392, False: 324k]
  ------------------
 3167|   172k|                case SPNG_ETRNS_NO_PLTE:
  ------------------
  |  Branch (3167:17): [True: 0, False: 324k]
  ------------------
 3168|   172k|                case SPNG_EGAMA:
  ------------------
  |  Branch (3168:17): [True: 364, False: 324k]
  ------------------
 3169|   173k|                case SPNG_EICCP_NAME:
  ------------------
  |  Branch (3169:17): [True: 105, False: 324k]
  ------------------
 3170|   173k|                case SPNG_EICCP_COMPRESSION_METHOD:
  ------------------
  |  Branch (3170:17): [True: 119, False: 324k]
  ------------------
 3171|   176k|                case SPNG_ESBIT:
  ------------------
  |  Branch (3171:17): [True: 2.99k, False: 321k]
  ------------------
 3172|   176k|                case SPNG_ESRGB:
  ------------------
  |  Branch (3172:17): [True: 140, False: 324k]
  ------------------
 3173|   176k|                case SPNG_ETEXT:
  ------------------
  |  Branch (3173:17): [True: 0, False: 324k]
  ------------------
 3174|   188k|                case SPNG_ETEXT_KEYWORD:
  ------------------
  |  Branch (3174:17): [True: 12.0k, False: 312k]
  ------------------
 3175|   194k|                case SPNG_EZTXT:
  ------------------
  |  Branch (3175:17): [True: 5.90k, False: 319k]
  ------------------
 3176|   200k|                case SPNG_EZTXT_COMPRESSION_METHOD:
  ------------------
  |  Branch (3176:17): [True: 6.41k, False: 318k]
  ------------------
 3177|   201k|                case SPNG_EITXT:
  ------------------
  |  Branch (3177:17): [True: 581, False: 324k]
  ------------------
 3178|   202k|                case SPNG_EITXT_COMPRESSION_FLAG:
  ------------------
  |  Branch (3178:17): [True: 1.23k, False: 323k]
  ------------------
 3179|   204k|                case SPNG_EITXT_COMPRESSION_METHOD:
  ------------------
  |  Branch (3179:17): [True: 2.17k, False: 322k]
  ------------------
 3180|   204k|                case SPNG_EITXT_LANG_TAG:
  ------------------
  |  Branch (3180:17): [True: 77, False: 324k]
  ------------------
 3181|   204k|                case SPNG_EITXT_TRANSLATED_KEY:
  ------------------
  |  Branch (3181:17): [True: 0, False: 324k]
  ------------------
 3182|   205k|                case SPNG_EBKGD_NO_PLTE:
  ------------------
  |  Branch (3182:17): [True: 1.12k, False: 323k]
  ------------------
 3183|   206k|                case SPNG_EBKGD_PLTE_IDX:
  ------------------
  |  Branch (3183:17): [True: 630, False: 324k]
  ------------------
 3184|   207k|                case SPNG_EHIST_NO_PLTE:
  ------------------
  |  Branch (3184:17): [True: 469, False: 324k]
  ------------------
 3185|   209k|                case SPNG_EPHYS:
  ------------------
  |  Branch (3185:17): [True: 2.57k, False: 322k]
  ------------------
 3186|   275k|                case SPNG_ESPLT_NAME:
  ------------------
  |  Branch (3186:17): [True: 65.4k, False: 259k]
  ------------------
 3187|   275k|                case SPNG_ESPLT_DUP_NAME:
  ------------------
  |  Branch (3187:17): [True: 119, False: 324k]
  ------------------
 3188|   275k|                case SPNG_ESPLT_DEPTH:
  ------------------
  |  Branch (3188:17): [True: 385, False: 324k]
  ------------------
 3189|   279k|                case SPNG_ETIME:
  ------------------
  |  Branch (3189:17): [True: 4.24k, False: 320k]
  ------------------
 3190|   279k|                case SPNG_EOFFS:
  ------------------
  |  Branch (3190:17): [True: 105, False: 324k]
  ------------------
 3191|   280k|                case SPNG_EEXIF:
  ------------------
  |  Branch (3191:17): [True: 462, False: 324k]
  ------------------
 3192|   307k|                case SPNG_EZLIB:
  ------------------
  |  Branch (3192:17): [True: 27.3k, False: 297k]
  ------------------
 3193|   307k|                {
 3194|   307k|                    if(!ctx->strict && !is_critical_chunk(&ctx->current_chunk))
  ------------------
  |  Branch (3194:24): [True: 307k, False: 0]
  |  Branch (3194:40): [True: 307k, False: 238]
  ------------------
 3195|   307k|                    {
 3196|   307k|                        ret = discard_chunk_bytes(ctx, ctx->cur_chunk_bytes_left);
 3197|   307k|                        if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3197:28): [True: 3.26k, False: 304k]
  ------------------
 3198|       |
 3199|   304k|                        if(ctx->undo) ctx->undo(ctx);
  ------------------
  |  Branch (3199:28): [True: 131k, False: 173k]
  ------------------
 3200|       |
 3201|   304k|                        ctx->stored = ctx->prev_stored;
 3202|       |
 3203|   304k|                        ctx->discard = 0;
 3204|   304k|                        ctx->undo = NULL;
 3205|       |
 3206|   304k|                        continue;
 3207|   307k|                    }
 3208|    238|                    else return decode_err(ctx, ret);
 3209|       |
 3210|      0|                    break;
 3211|   307k|                }
 3212|  17.1k|                default: return decode_err(ctx, ret);
  ------------------
  |  Branch (3212:17): [True: 17.1k, False: 307k]
  ------------------
 3213|   324k|            }
 3214|   324k|        }
 3215|   332k|    }
 3216|       |
 3217|  14.5k|    return ret;
 3218|  35.2k|}
spng.c:read_ihdr:
 2270|  28.3k|{
 2271|  28.3k|    int ret;
 2272|  28.3k|    struct spng_chunk *chunk = &ctx->current_chunk;
 2273|  28.3k|    const unsigned char *data;
 2274|       |
 2275|  28.3k|    chunk->offset = 8;
 2276|  28.3k|    chunk->length = 13;
 2277|  28.3k|    size_t sizeof_sig_ihdr = 29;
 2278|       |
 2279|  28.3k|    ret = read_data(ctx, sizeof_sig_ihdr);
 2280|  28.3k|    if(ret) return ret;
  ------------------
  |  Branch (2280:8): [True: 7, False: 28.3k]
  ------------------
 2281|       |
 2282|  28.3k|    data = ctx->data;
 2283|       |
 2284|  28.3k|    if(memcmp(data, spng_signature, sizeof(spng_signature))) return SPNG_ESIGNATURE;
  ------------------
  |  Branch (2284:8): [True: 308, False: 28.0k]
  ------------------
 2285|       |
 2286|  28.0k|    chunk->length = read_u32(data + 8);
 2287|  28.0k|    memcpy(&chunk->type, data + 12, 4);
 2288|       |
 2289|  28.0k|    if(chunk->length != 13) return SPNG_EIHDR_SIZE;
  ------------------
  |  Branch (2289:8): [True: 266, False: 27.7k]
  ------------------
 2290|  27.7k|    if(memcmp(chunk->type, type_ihdr, 4)) return SPNG_ENOIHDR;
  ------------------
  |  Branch (2290:8): [True: 63, False: 27.7k]
  ------------------
 2291|       |
 2292|  27.7k|    ctx->cur_actual_crc = crc32(0, NULL, 0);
 2293|  27.7k|    ctx->cur_actual_crc = crc32(ctx->cur_actual_crc, data + 12, 17);
 2294|       |
 2295|  27.7k|    ctx->ihdr.width = read_u32(data + 16);
 2296|  27.7k|    ctx->ihdr.height = read_u32(data + 20);
 2297|  27.7k|    ctx->ihdr.bit_depth = data[24];
 2298|  27.7k|    ctx->ihdr.color_type = data[25];
 2299|  27.7k|    ctx->ihdr.compression_method = data[26];
 2300|  27.7k|    ctx->ihdr.filter_method = data[27];
 2301|  27.7k|    ctx->ihdr.interlace_method = data[28];
 2302|       |
 2303|  27.7k|    ret = check_ihdr(&ctx->ihdr, ctx->max_width, ctx->max_height);
 2304|  27.7k|    if(ret) return ret;
  ------------------
  |  Branch (2304:8): [True: 791, False: 26.9k]
  ------------------
 2305|       |
 2306|  26.9k|    ctx->file.ihdr = 1;
 2307|  26.9k|    ctx->stored.ihdr = 1;
 2308|       |
 2309|  26.9k|    if(ctx->ihdr.bit_depth < 8) ctx->bytes_per_pixel = 1;
  ------------------
  |  Branch (2309:8): [True: 9.77k, False: 17.1k]
  ------------------
 2310|  17.1k|    else ctx->bytes_per_pixel = num_channels(&ctx->ihdr) * (ctx->ihdr.bit_depth / 8);
 2311|       |
 2312|  26.9k|    ret = calculate_subimages(ctx);
 2313|  26.9k|    if(ret) return ret;
  ------------------
  |  Branch (2313:8): [True: 28, False: 26.9k]
  ------------------
 2314|       |
 2315|  26.9k|    return 0;
 2316|  26.9k|}
spng.c:read_u32:
  449|   932k|{
  450|   932k|    const unsigned char *data = src;
  451|       |
  452|   932k|    return (data[0] & 0xFFUL) << 24 | (data[1] & 0xFFUL) << 16 |
  453|   932k|           (data[2] & 0xFFUL) << 8  | (data[3] & 0xFFUL);
  454|   932k|}
spng.c:read_non_idat_chunks:
 2363|   332k|{
 2364|   332k|    int ret;
 2365|   332k|    struct spng_chunk chunk;
 2366|   332k|    const unsigned char *data;
 2367|       |
 2368|   332k|    ctx->discard = 0;
 2369|   332k|    ctx->undo = NULL;
 2370|   332k|    ctx->prev_stored = ctx->stored;
 2371|       |
 2372|   399k|    while( !(ret = read_header(ctx)))
  ------------------
  |  Branch (2372:12): [True: 388k, False: 10.3k]
  ------------------
 2373|   388k|    {
 2374|   388k|        if(ctx->discard)
  ------------------
  |  Branch (2374:12): [True: 148k, False: 239k]
  ------------------
 2375|   148k|        {
 2376|   148k|            if(ctx->undo) ctx->undo(ctx);
  ------------------
  |  Branch (2376:16): [True: 4.57k, False: 144k]
  ------------------
 2377|       |
 2378|   148k|            ctx->stored = ctx->prev_stored;
 2379|   148k|        }
 2380|       |
 2381|   388k|        ctx->discard = 0;
 2382|   388k|        ctx->undo = NULL;
 2383|       |
 2384|   388k|        ctx->prev_stored = ctx->stored;
 2385|   388k|        chunk = ctx->current_chunk;
 2386|       |
 2387|   388k|        if(!memcmp(chunk.type, type_idat, 4))
  ------------------
  |  Branch (2387:12): [True: 8.25k, False: 380k]
  ------------------
 2388|  8.25k|        {
 2389|  8.25k|            if(ctx->state < SPNG_STATE_FIRST_IDAT)
  ------------------
  |  Branch (2389:16): [True: 7.83k, False: 419]
  ------------------
 2390|  7.83k|            {
 2391|  7.83k|                if(ctx->ihdr.color_type == 3 && !ctx->stored.plte) return SPNG_ENOPLTE;
  ------------------
  |  Branch (2391:20): [True: 252, False: 7.58k]
  |  Branch (2391:49): [True: 14, False: 238]
  ------------------
 2392|       |
 2393|  7.81k|                ctx->first_idat = chunk;
 2394|  7.81k|                return 0;
 2395|  7.83k|            }
 2396|       |
 2397|    419|            if(ctx->prev_was_idat)
  ------------------
  |  Branch (2397:16): [True: 412, False: 7]
  ------------------
 2398|    412|            {
 2399|       |                /* Ignore extra IDAT's */
 2400|    412|                ret = discard_chunk_bytes(ctx, chunk.length);
 2401|    412|                if(ret) return ret;
  ------------------
  |  Branch (2401:20): [True: 196, False: 216]
  ------------------
 2402|       |
 2403|    216|                continue;
 2404|    412|            }
 2405|      7|            else return SPNG_ECHUNK_POS; /* IDAT chunk not at the end of the IDAT sequence */
 2406|    419|        }
 2407|       |
 2408|   380k|        ctx->prev_was_idat = 0;
 2409|       |
 2410|   380k|        if(is_small_chunk(chunk.type))
  ------------------
  |  Branch (2410:12): [True: 47.6k, False: 332k]
  ------------------
 2411|  47.6k|        {
 2412|       |            /* None of the known chunks can be zero length */
 2413|  47.6k|            if(!chunk.length) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2413:16): [True: 301, False: 47.3k]
  ------------------
 2414|       |
 2415|       |            /* The largest of these chunks is PLTE with 256 entries */
 2416|  47.3k|            ret = read_chunk_bytes(ctx, chunk.length > 768 ? 768 : chunk.length);
  ------------------
  |  Branch (2416:41): [True: 1.99k, False: 45.3k]
  ------------------
 2417|  47.3k|            if(ret) return ret;
  ------------------
  |  Branch (2417:16): [True: 343, False: 46.9k]
  ------------------
 2418|  47.3k|        }
 2419|       |
 2420|   379k|        data = ctx->data;
 2421|       |
 2422|   379k|        if(is_critical_chunk(&chunk))
  ------------------
  |  Branch (2422:12): [True: 3.20k, False: 376k]
  ------------------
 2423|  3.20k|        {
 2424|  3.20k|            if(!memcmp(chunk.type, type_plte, 4))
  ------------------
  |  Branch (2424:16): [True: 1.29k, False: 1.90k]
  ------------------
 2425|  1.29k|            {
 2426|  1.29k|                if(ctx->file.trns || ctx->file.hist || ctx->file.bkgd) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2426:20): [True: 7, False: 1.28k]
  |  Branch (2426:38): [True: 7, False: 1.28k]
  |  Branch (2426:56): [True: 7, False: 1.27k]
  ------------------
 2427|  1.27k|                if(chunk.length % 3 != 0) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2427:20): [True: 14, False: 1.26k]
  ------------------
 2428|       |
 2429|  1.26k|                ctx->plte.n_entries = chunk.length / 3;
 2430|       |
 2431|  1.26k|                if(check_plte(&ctx->plte, &ctx->ihdr)) return SPNG_ECHUNK_SIZE; /* XXX: EPLTE? */
  ------------------
  |  Branch (2431:20): [True: 154, False: 1.10k]
  ------------------
 2432|       |
 2433|  1.10k|                size_t i;
 2434|  23.8k|                for(i=0; i < ctx->plte.n_entries; i++)
  ------------------
  |  Branch (2434:26): [True: 22.7k, False: 1.10k]
  ------------------
 2435|  22.7k|                {
 2436|  22.7k|                    ctx->plte.entries[i].red   = data[i * 3];
 2437|  22.7k|                    ctx->plte.entries[i].green = data[i * 3 + 1];
 2438|  22.7k|                    ctx->plte.entries[i].blue  = data[i * 3 + 2];
 2439|  22.7k|                }
 2440|       |
 2441|  1.10k|                ctx->file.plte = 1;
 2442|  1.10k|                ctx->stored.plte = 1;
 2443|  1.10k|            }
 2444|  1.90k|            else if(!memcmp(chunk.type, type_iend, 4))
  ------------------
  |  Branch (2444:21): [True: 309, False: 1.59k]
  ------------------
 2445|    309|            {
 2446|    309|                if(ctx->state == SPNG_STATE_AFTER_IDAT)
  ------------------
  |  Branch (2446:20): [True: 295, False: 14]
  ------------------
 2447|    295|                {
 2448|    295|                    if(chunk.length) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2448:24): [True: 21, False: 274]
  ------------------
 2449|       |
 2450|    274|                    ret = read_and_check_crc(ctx);
 2451|    274|                    if(ret == -SPNG_CRC_DISCARD) ret = 0;
  ------------------
  |  Branch (2451:24): [True: 7, False: 267]
  ------------------
 2452|       |
 2453|    274|                    return ret;
 2454|    295|                }
 2455|     14|                else return SPNG_ECHUNK_POS;
 2456|    309|            }
 2457|  1.59k|            else if(!memcmp(chunk.type, type_ihdr, 4)) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2457:21): [True: 7, False: 1.58k]
  ------------------
 2458|  1.58k|            else return SPNG_ECHUNK_UNKNOWN_CRITICAL;
 2459|  3.20k|        }
 2460|   376k|        else if(!memcmp(chunk.type, type_chrm, 4)) /* Ancillary chunks */
  ------------------
  |  Branch (2460:17): [True: 2.92k, False: 373k]
  ------------------
 2461|  2.92k|        {
 2462|  2.92k|            if(ctx->file.plte) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2462:16): [True: 77, False: 2.84k]
  ------------------
 2463|  2.84k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2463:16): [True: 91, False: 2.75k]
  ------------------
 2464|  2.75k|            if(ctx->file.chrm) return SPNG_EDUP_CHRM;
  ------------------
  |  Branch (2464:16): [True: 581, False: 2.17k]
  ------------------
 2465|       |
 2466|  2.17k|            if(chunk.length != 32) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2466:16): [True: 273, False: 1.90k]
  ------------------
 2467|       |
 2468|  1.90k|            ctx->chrm_int.white_point_x = read_u32(data);
 2469|  1.90k|            ctx->chrm_int.white_point_y = read_u32(data + 4);
 2470|  1.90k|            ctx->chrm_int.red_x = read_u32(data + 8);
 2471|  1.90k|            ctx->chrm_int.red_y = read_u32(data + 12);
 2472|  1.90k|            ctx->chrm_int.green_x = read_u32(data + 16);
 2473|  1.90k|            ctx->chrm_int.green_y = read_u32(data + 20);
 2474|  1.90k|            ctx->chrm_int.blue_x = read_u32(data + 24);
 2475|  1.90k|            ctx->chrm_int.blue_y = read_u32(data + 28);
 2476|       |
 2477|  1.90k|            if(check_chrm_int(&ctx->chrm_int)) return SPNG_ECHRM;
  ------------------
  |  Branch (2477:16): [True: 1.23k, False: 665]
  ------------------
 2478|       |
 2479|    665|            ctx->file.chrm = 1;
 2480|    665|            ctx->stored.chrm = 1;
 2481|    665|        }
 2482|   373k|        else if(!memcmp(chunk.type, type_gama, 4))
  ------------------
  |  Branch (2482:17): [True: 3.32k, False: 370k]
  ------------------
 2483|  3.32k|        {
 2484|  3.32k|            if(ctx->file.plte) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2484:16): [True: 63, False: 3.26k]
  ------------------
 2485|  3.26k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2485:16): [True: 1.19k, False: 2.06k]
  ------------------
 2486|  2.06k|            if(ctx->file.gama) return SPNG_EDUP_GAMA;
  ------------------
  |  Branch (2486:16): [True: 98, False: 1.96k]
  ------------------
 2487|       |
 2488|  1.96k|            if(chunk.length != 4) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2488:16): [True: 707, False: 1.26k]
  ------------------
 2489|       |
 2490|  1.26k|            ctx->gama = read_u32(data);
 2491|       |
 2492|  1.26k|            if(!ctx->gama) return SPNG_EGAMA;
  ------------------
  |  Branch (2492:16): [True: 21, False: 1.23k]
  ------------------
 2493|  1.23k|            if(ctx->gama > spng_u32max) return SPNG_EGAMA;
  ------------------
  |  Branch (2493:16): [True: 343, False: 896]
  ------------------
 2494|       |
 2495|    896|            ctx->file.gama = 1;
 2496|    896|            ctx->stored.gama = 1;
 2497|    896|        }
 2498|   370k|        else if(!memcmp(chunk.type, type_sbit, 4))
  ------------------
  |  Branch (2498:17): [True: 6.02k, False: 364k]
  ------------------
 2499|  6.02k|        {
 2500|  6.02k|            if(ctx->file.plte) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2500:16): [True: 91, False: 5.93k]
  ------------------
 2501|  5.93k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2501:16): [True: 77, False: 5.85k]
  ------------------
 2502|  5.85k|            if(ctx->file.sbit) return SPNG_EDUP_SBIT;
  ------------------
  |  Branch (2502:16): [True: 441, False: 5.41k]
  ------------------
 2503|       |
 2504|  5.41k|            if(ctx->ihdr.color_type == 0)
  ------------------
  |  Branch (2504:16): [True: 3.15k, False: 2.26k]
  ------------------
 2505|  3.15k|            {
 2506|  3.15k|                if(chunk.length != 1) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2506:20): [True: 1.72k, False: 1.42k]
  ------------------
 2507|       |
 2508|  1.42k|                ctx->sbit.grayscale_bits = data[0];
 2509|  1.42k|            }
 2510|  2.26k|            else if(ctx->ihdr.color_type == 2 || ctx->ihdr.color_type == 3)
  ------------------
  |  Branch (2510:21): [True: 315, False: 1.95k]
  |  Branch (2510:50): [True: 735, False: 1.21k]
  ------------------
 2511|  1.05k|            {
 2512|  1.05k|                if(chunk.length != 3) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2512:20): [True: 441, False: 609]
  ------------------
 2513|       |
 2514|    609|                ctx->sbit.red_bits = data[0];
 2515|    609|                ctx->sbit.green_bits = data[1];
 2516|    609|                ctx->sbit.blue_bits = data[2];
 2517|    609|            }
 2518|  1.21k|            else if(ctx->ihdr.color_type == 4)
  ------------------
  |  Branch (2518:21): [True: 210, False: 1.00k]
  ------------------
 2519|    210|            {
 2520|    210|                if(chunk.length != 2) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2520:20): [True: 21, False: 189]
  ------------------
 2521|       |
 2522|    189|                ctx->sbit.grayscale_bits = data[0];
 2523|    189|                ctx->sbit.alpha_bits = data[1];
 2524|    189|            }
 2525|  1.00k|            else if(ctx->ihdr.color_type == 6)
  ------------------
  |  Branch (2525:21): [True: 1.00k, False: 0]
  ------------------
 2526|  1.00k|            {
 2527|  1.00k|                if(chunk.length != 4) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2527:20): [True: 112, False: 896]
  ------------------
 2528|       |
 2529|    896|                ctx->sbit.red_bits = data[0];
 2530|    896|                ctx->sbit.green_bits = data[1];
 2531|    896|                ctx->sbit.blue_bits = data[2];
 2532|    896|                ctx->sbit.alpha_bits = data[3];
 2533|    896|            }
 2534|       |
 2535|  3.11k|            if(check_sbit(&ctx->sbit, &ctx->ihdr)) return SPNG_ESBIT;
  ------------------
  |  Branch (2535:16): [True: 2.99k, False: 119]
  ------------------
 2536|       |
 2537|    119|            ctx->file.sbit = 1;
 2538|    119|            ctx->stored.sbit = 1;
 2539|    119|        }
 2540|   364k|        else if(!memcmp(chunk.type, type_srgb, 4))
  ------------------
  |  Branch (2540:17): [True: 875, False: 363k]
  ------------------
 2541|    875|        {
 2542|    875|            if(ctx->file.plte) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2542:16): [True: 42, False: 833]
  ------------------
 2543|    833|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2543:16): [True: 77, False: 756]
  ------------------
 2544|    756|            if(ctx->file.srgb) return SPNG_EDUP_SRGB;
  ------------------
  |  Branch (2544:16): [True: 308, False: 448]
  ------------------
 2545|       |
 2546|    448|            if(chunk.length != 1) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2546:16): [True: 224, False: 224]
  ------------------
 2547|       |
 2548|    224|            ctx->srgb_rendering_intent = data[0];
 2549|       |
 2550|    224|            if(ctx->srgb_rendering_intent > 3) return SPNG_ESRGB;
  ------------------
  |  Branch (2550:16): [True: 140, False: 84]
  ------------------
 2551|       |
 2552|     84|            ctx->file.srgb = 1;
 2553|     84|            ctx->stored.srgb = 1;
 2554|     84|        }
 2555|   363k|        else if(!memcmp(chunk.type, type_bkgd, 4))
  ------------------
  |  Branch (2555:17): [True: 12.1k, False: 351k]
  ------------------
 2556|  12.1k|        {
 2557|  12.1k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2557:16): [True: 903, False: 11.2k]
  ------------------
 2558|  11.2k|            if(ctx->file.bkgd) return SPNG_EDUP_BKGD;
  ------------------
  |  Branch (2558:16): [True: 4.25k, False: 6.96k]
  ------------------
 2559|       |
 2560|  6.96k|            if(ctx->ihdr.color_type == 0 || ctx->ihdr.color_type == 4)
  ------------------
  |  Branch (2560:16): [True: 1.89k, False: 5.07k]
  |  Branch (2560:45): [True: 189, False: 4.88k]
  ------------------
 2561|  2.07k|            {
 2562|  2.07k|                if(chunk.length != 2) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2562:20): [True: 959, False: 1.12k]
  ------------------
 2563|       |
 2564|  1.12k|                ctx->bkgd.gray = read_u16(data);
 2565|  1.12k|            }
 2566|  4.88k|            else if(ctx->ihdr.color_type == 2 || ctx->ihdr.color_type == 6)
  ------------------
  |  Branch (2566:21): [True: 1.42k, False: 3.46k]
  |  Branch (2566:50): [True: 119, False: 3.34k]
  ------------------
 2567|  1.54k|            {
 2568|  1.54k|                if(chunk.length != 6) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2568:20): [True: 1.05k, False: 483]
  ------------------
 2569|       |
 2570|    483|                ctx->bkgd.red = read_u16(data);
 2571|    483|                ctx->bkgd.green = read_u16(data + 2);
 2572|    483|                ctx->bkgd.blue = read_u16(data + 4);
 2573|    483|            }
 2574|  3.34k|            else if(ctx->ihdr.color_type == 3)
  ------------------
  |  Branch (2574:21): [True: 3.34k, False: 0]
  ------------------
 2575|  3.34k|            {
 2576|  3.34k|                if(chunk.length != 1) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2576:20): [True: 1.28k, False: 2.06k]
  ------------------
 2577|  2.06k|                if(!ctx->file.plte) return SPNG_EBKGD_NO_PLTE;
  ------------------
  |  Branch (2577:20): [True: 1.12k, False: 945]
  ------------------
 2578|       |
 2579|    945|                ctx->bkgd.plte_index = data[0];
 2580|    945|                if(ctx->bkgd.plte_index >= ctx->plte.n_entries) return SPNG_EBKGD_PLTE_IDX;
  ------------------
  |  Branch (2580:20): [True: 630, False: 315]
  ------------------
 2581|    945|            }
 2582|       |
 2583|  1.91k|            ctx->file.bkgd = 1;
 2584|  1.91k|            ctx->stored.bkgd = 1;
 2585|  1.91k|        }
 2586|   351k|        else if(!memcmp(chunk.type, type_trns, 4))
  ------------------
  |  Branch (2586:17): [True: 4.57k, False: 346k]
  ------------------
 2587|  4.57k|        {
 2588|  4.57k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2588:16): [True: 245, False: 4.32k]
  ------------------
 2589|  4.32k|            if(ctx->file.trns) return SPNG_EDUP_TRNS;
  ------------------
  |  Branch (2589:16): [True: 2.70k, False: 1.61k]
  ------------------
 2590|  1.61k|            if(!chunk.length) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2590:16): [True: 0, False: 1.61k]
  ------------------
 2591|       |
 2592|  1.61k|            if(ctx->ihdr.color_type == 0)
  ------------------
  |  Branch (2592:16): [True: 399, False: 1.21k]
  ------------------
 2593|    399|            {
 2594|    399|                if(chunk.length != 2) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2594:20): [True: 301, False: 98]
  ------------------
 2595|       |
 2596|     98|                ctx->trns.gray = read_u16(data);
 2597|     98|            }
 2598|  1.21k|            else if(ctx->ihdr.color_type == 2)
  ------------------
  |  Branch (2598:21): [True: 336, False: 882]
  ------------------
 2599|    336|            {
 2600|    336|                if(chunk.length != 6) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2600:20): [True: 315, False: 21]
  ------------------
 2601|       |
 2602|     21|                ctx->trns.red = read_u16(data);
 2603|     21|                ctx->trns.green = read_u16(data + 2);
 2604|     21|                ctx->trns.blue = read_u16(data + 4);
 2605|     21|            }
 2606|    882|            else if(ctx->ihdr.color_type == 3)
  ------------------
  |  Branch (2606:21): [True: 490, False: 392]
  ------------------
 2607|    490|            {
 2608|    490|                if(chunk.length > ctx->plte.n_entries) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2608:20): [True: 462, False: 28]
  ------------------
 2609|     28|                if(!ctx->file.plte) return SPNG_ETRNS_NO_PLTE;
  ------------------
  |  Branch (2609:20): [True: 0, False: 28]
  ------------------
 2610|       |
 2611|     28|                memcpy(ctx->trns.type3_alpha, data, chunk.length);
 2612|     28|                ctx->trns.n_type3_entries = chunk.length;
 2613|     28|            }
 2614|       |
 2615|    539|            if(ctx->ihdr.color_type == 4 || ctx->ihdr.color_type == 6)  return SPNG_ETRNS_COLOR_TYPE;
  ------------------
  |  Branch (2615:16): [True: 154, False: 385]
  |  Branch (2615:45): [True: 238, False: 147]
  ------------------
 2616|       |
 2617|    147|            ctx->file.trns = 1;
 2618|    147|            ctx->stored.trns = 1;
 2619|    147|        }
 2620|   346k|        else if(!memcmp(chunk.type, type_hist, 4))
  ------------------
  |  Branch (2620:17): [True: 1.23k, False: 345k]
  ------------------
 2621|  1.23k|        {
 2622|  1.23k|            if(!ctx->file.plte) return SPNG_EHIST_NO_PLTE;
  ------------------
  |  Branch (2622:16): [True: 469, False: 770]
  ------------------
 2623|    770|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2623:16): [True: 0, False: 770]
  ------------------
 2624|    770|            if(ctx->file.hist) return SPNG_EDUP_HIST;
  ------------------
  |  Branch (2624:16): [True: 469, False: 301]
  ------------------
 2625|       |
 2626|    301|            if( (chunk.length / 2) != (ctx->plte.n_entries) ) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2626:17): [True: 231, False: 70]
  ------------------
 2627|       |
 2628|     70|            size_t k;
 2629|    476|            for(k=0; k < (chunk.length / 2); k++)
  ------------------
  |  Branch (2629:22): [True: 406, False: 70]
  ------------------
 2630|    406|            {
 2631|    406|                ctx->hist.frequency[k] = read_u16(data + k*2);
 2632|    406|            }
 2633|       |
 2634|     70|            ctx->file.hist = 1;
 2635|     70|            ctx->stored.hist = 1;
 2636|     70|        }
 2637|   345k|        else if(!memcmp(chunk.type, type_phys, 4))
  ------------------
  |  Branch (2637:17): [True: 4.80k, False: 340k]
  ------------------
 2638|  4.80k|        {
 2639|  4.80k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2639:16): [True: 42, False: 4.76k]
  ------------------
 2640|  4.76k|            if(ctx->file.phys) return SPNG_EDUP_PHYS;
  ------------------
  |  Branch (2640:16): [True: 280, False: 4.48k]
  ------------------
 2641|       |
 2642|  4.48k|            if(chunk.length != 9) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2642:16): [True: 301, False: 4.17k]
  ------------------
 2643|       |
 2644|  4.17k|            ctx->phys.ppu_x = read_u32(data);
 2645|  4.17k|            ctx->phys.ppu_y = read_u32(data + 4);
 2646|  4.17k|            ctx->phys.unit_specifier = data[8];
 2647|       |
 2648|  4.17k|            if(check_phys(&ctx->phys)) return SPNG_EPHYS;
  ------------------
  |  Branch (2648:16): [True: 2.57k, False: 1.60k]
  ------------------
 2649|       |
 2650|  1.60k|            ctx->file.phys = 1;
 2651|  1.60k|            ctx->stored.phys = 1;
 2652|  1.60k|        }
 2653|   340k|        else if(!memcmp(chunk.type, type_time, 4))
  ------------------
  |  Branch (2653:17): [True: 9.07k, False: 331k]
  ------------------
 2654|  9.07k|        {
 2655|  9.07k|            if(ctx->file.time) return SPNG_EDUP_TIME;
  ------------------
  |  Branch (2655:16): [True: 3.80k, False: 5.27k]
  ------------------
 2656|       |
 2657|  5.27k|            if(chunk.length != 7) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2657:16): [True: 168, False: 5.10k]
  ------------------
 2658|       |
 2659|  5.10k|            struct spng_time time;
 2660|       |
 2661|  5.10k|            time.year = read_u16(data);
 2662|  5.10k|            time.month = data[2];
 2663|  5.10k|            time.day = data[3];
 2664|  5.10k|            time.hour = data[4];
 2665|  5.10k|            time.minute = data[5];
 2666|  5.10k|            time.second = data[6];
 2667|       |
 2668|  5.10k|            if(check_time(&time)) return SPNG_ETIME;
  ------------------
  |  Branch (2668:16): [True: 4.24k, False: 861]
  ------------------
 2669|       |
 2670|    861|            ctx->file.time = 1;
 2671|       |
 2672|    861|            if(!ctx->user.time) ctx->time = time;
  ------------------
  |  Branch (2672:16): [True: 861, False: 0]
  ------------------
 2673|       |
 2674|    861|            ctx->stored.time = 1;
 2675|    861|        }
 2676|   331k|        else if(!memcmp(chunk.type, type_offs, 4))
  ------------------
  |  Branch (2676:17): [True: 721, False: 330k]
  ------------------
 2677|    721|        {
 2678|    721|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2678:16): [True: 140, False: 581]
  ------------------
 2679|    581|            if(ctx->file.offs) return SPNG_EDUP_OFFS;
  ------------------
  |  Branch (2679:16): [True: 77, False: 504]
  ------------------
 2680|       |
 2681|    504|            if(chunk.length != 9) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2681:16): [True: 315, False: 189]
  ------------------
 2682|       |
 2683|    189|            ctx->offs.x = read_s32(data);
 2684|    189|            ctx->offs.y = read_s32(data + 4);
 2685|    189|            ctx->offs.unit_specifier = data[8];
 2686|       |
 2687|    189|            if(check_offs(&ctx->offs)) return SPNG_EOFFS;
  ------------------
  |  Branch (2687:16): [True: 105, False: 84]
  ------------------
 2688|       |
 2689|     84|            ctx->file.offs = 1;
 2690|     84|            ctx->stored.offs = 1;
 2691|     84|        }
 2692|   330k|        else /* Arbitrary-length chunk */
 2693|   330k|        {
 2694|       |
 2695|   330k|            if(!memcmp(chunk.type, type_exif, 4))
  ------------------
  |  Branch (2695:16): [True: 2.90k, False: 328k]
  ------------------
 2696|  2.90k|            {
 2697|  2.90k|                if(ctx->file.exif) return SPNG_EDUP_EXIF;
  ------------------
  |  Branch (2697:20): [True: 2.10k, False: 798]
  ------------------
 2698|    798|                if(!chunk.length) return SPNG_EEXIF;
  ------------------
  |  Branch (2698:20): [True: 217, False: 581]
  ------------------
 2699|       |
 2700|    581|                ctx->file.exif = 1;
 2701|       |
 2702|    581|                if(ctx->user.exif) goto discard;
  ------------------
  |  Branch (2702:20): [True: 0, False: 581]
  ------------------
 2703|       |
 2704|    581|                if(increase_cache_usage(ctx, chunk.length, 1)) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (2704:20): [True: 0, False: 581]
  ------------------
 2705|       |
 2706|    581|                struct spng_exif exif;
 2707|       |
 2708|    581|                exif.length = chunk.length;
 2709|       |
 2710|    581|                exif.data = spng__malloc(ctx, chunk.length);
 2711|    581|                if(exif.data == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (2711:20): [True: 0, False: 581]
  ------------------
 2712|       |
 2713|    581|                ret = read_chunk_bytes2(ctx, exif.data, chunk.length);
 2714|    581|                if(ret)
  ------------------
  |  Branch (2714:20): [True: 322, False: 259]
  ------------------
 2715|    322|                {
 2716|    322|                    spng__free(ctx, exif.data);
 2717|    322|                    return ret;
 2718|    322|                }
 2719|       |
 2720|    259|                if(check_exif(&exif))
  ------------------
  |  Branch (2720:20): [True: 245, False: 14]
  ------------------
 2721|    245|                {
 2722|    245|                    spng__free(ctx, exif.data);
 2723|    245|                    return SPNG_EEXIF;
 2724|    245|                }
 2725|       |
 2726|     14|                ctx->exif = exif;
 2727|       |
 2728|     14|                ctx->stored.exif = 1;
 2729|     14|            }
 2730|   328k|            else if(!memcmp(chunk.type, type_iccp, 4))
  ------------------
  |  Branch (2730:21): [True: 24.6k, False: 303k]
  ------------------
 2731|  24.6k|            {/* TODO: add test file with color profile */
 2732|  24.6k|                if(ctx->file.plte) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2732:20): [True: 322, False: 24.3k]
  ------------------
 2733|  24.3k|                if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2733:20): [True: 231, False: 24.1k]
  ------------------
 2734|  24.1k|                if(ctx->file.iccp) return SPNG_EDUP_ICCP;
  ------------------
  |  Branch (2734:20): [True: 19.9k, False: 4.15k]
  ------------------
 2735|  4.15k|                if(!chunk.length) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2735:20): [True: 126, False: 4.02k]
  ------------------
 2736|       |
 2737|  4.02k|                ctx->file.iccp = 1;
 2738|       |
 2739|  4.02k|                uint32_t peek_bytes =  81 > chunk.length ? chunk.length : 81;
  ------------------
  |  Branch (2739:40): [True: 350, False: 3.67k]
  ------------------
 2740|       |
 2741|  4.02k|                ret = read_chunk_bytes(ctx, peek_bytes);
 2742|  4.02k|                if(ret) return ret;
  ------------------
  |  Branch (2742:20): [True: 238, False: 3.78k]
  ------------------
 2743|       |
 2744|  3.78k|                unsigned char *keyword_nul = memchr(ctx->data, '\0', peek_bytes);
 2745|  3.78k|                if(keyword_nul == NULL) return SPNG_EICCP_NAME;
  ------------------
  |  Branch (2745:20): [True: 7, False: 3.78k]
  ------------------
 2746|       |
 2747|  3.78k|                uint32_t keyword_len = keyword_nul - ctx->data;
 2748|       |
 2749|  3.78k|                if(keyword_len > 79) return SPNG_EICCP_NAME;
  ------------------
  |  Branch (2749:20): [True: 7, False: 3.77k]
  ------------------
 2750|       |
 2751|  3.77k|                memcpy(ctx->iccp.profile_name, ctx->data, keyword_len);
 2752|       |
 2753|  3.77k|                if(check_png_keyword(ctx->iccp.profile_name)) return SPNG_EICCP_NAME;
  ------------------
  |  Branch (2753:20): [True: 91, False: 3.68k]
  ------------------
 2754|       |
 2755|  3.68k|                if(chunk.length < (keyword_len + 2)) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2755:20): [True: 21, False: 3.66k]
  ------------------
 2756|       |
 2757|  3.66k|                if(ctx->data[keyword_len + 1] != 0) return SPNG_EICCP_COMPRESSION_METHOD;
  ------------------
  |  Branch (2757:20): [True: 119, False: 3.54k]
  ------------------
 2758|       |
 2759|  3.54k|                ret = spng__inflate_stream(ctx, &ctx->iccp.profile, &ctx->iccp.profile_len, 0, ctx->data + keyword_len + 2, peek_bytes - (keyword_len + 2));
 2760|       |
 2761|  3.54k|                if(ret) return ret;
  ------------------
  |  Branch (2761:20): [True: 3.46k, False: 77]
  ------------------
 2762|       |
 2763|     77|                ctx->stored.iccp = 1;
 2764|     77|            }
 2765|   303k|             else if(!memcmp(chunk.type, type_text, 4) ||
  ------------------
  |  Branch (2765:22): [True: 48.4k, False: 254k]
  ------------------
 2766|   254k|                     !memcmp(chunk.type, type_ztxt, 4) ||
  ------------------
  |  Branch (2766:22): [True: 97.9k, False: 156k]
  ------------------
 2767|   156k|                     !memcmp(chunk.type, type_itxt, 4))
  ------------------
  |  Branch (2767:22): [True: 47.3k, False: 109k]
  ------------------
 2768|   193k|            {
 2769|   193k|                if(!chunk.length) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2769:20): [True: 100k, False: 92.9k]
  ------------------
 2770|       |
 2771|  92.9k|                ctx->file.text = 1;
 2772|       |
 2773|  92.9k|                if(ctx->user.text) goto discard;
  ------------------
  |  Branch (2773:20): [True: 0, False: 92.9k]
  ------------------
 2774|       |
 2775|  92.9k|                if(increase_cache_usage(ctx, sizeof(struct spng_text2), 1)) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (2775:20): [True: 0, False: 92.9k]
  ------------------
 2776|       |
 2777|  92.9k|                ctx->n_text++;
 2778|  92.9k|                if(ctx->n_text < 1) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (2778:20): [True: 0, False: 92.9k]
  ------------------
 2779|  92.9k|                if(sizeof(struct spng_text2) > SIZE_MAX / ctx->n_text) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (2779:20): [True: 0, False: 92.9k]
  ------------------
 2780|       |
 2781|  92.9k|                void *buf = spng__realloc(ctx, ctx->text_list, ctx->n_text * sizeof(struct spng_text2));
 2782|  92.9k|                if(buf == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (2782:20): [True: 0, False: 92.9k]
  ------------------
 2783|  92.9k|                ctx->text_list = buf;
 2784|       |
 2785|  92.9k|                struct spng_text2 *text = &ctx->text_list[ctx->n_text - 1];
 2786|  92.9k|                memset(text, 0, sizeof(struct spng_text2));
 2787|       |
 2788|  92.9k|                ctx->undo = text_undo;
 2789|       |
 2790|  92.9k|                uint32_t text_offset = 0, language_tag_offset = 0, translated_keyword_offset = 0;
 2791|  92.9k|                uint32_t peek_bytes = 256; /* enough for 3 80-byte keywords and some text bytes */
 2792|  92.9k|                uint32_t keyword_len;
 2793|       |
 2794|  92.9k|                if(peek_bytes > chunk.length) peek_bytes = chunk.length;
  ------------------
  |  Branch (2794:20): [True: 87.0k, False: 5.93k]
  ------------------
 2795|       |
 2796|  92.9k|                ret = read_chunk_bytes(ctx, peek_bytes);
 2797|  92.9k|                if(ret) return ret;
  ------------------
  |  Branch (2797:20): [True: 369, False: 92.6k]
  ------------------
 2798|       |
 2799|  92.6k|                data = ctx->data;
 2800|       |
 2801|  92.6k|                const unsigned char *zlib_stream = NULL;
 2802|  92.6k|                const unsigned char *peek_end = data + peek_bytes;
 2803|  92.6k|                const unsigned char *keyword_nul = memchr(data, 0, chunk.length > 80 ? 80 : chunk.length);
  ------------------
  |  Branch (2803:68): [True: 5.84k, False: 86.7k]
  ------------------
 2804|       |
 2805|  92.6k|                if(keyword_nul == NULL) return SPNG_ETEXT_KEYWORD;
  ------------------
  |  Branch (2805:20): [True: 7.07k, False: 85.5k]
  ------------------
 2806|       |
 2807|  85.5k|                keyword_len = keyword_nul - data;
 2808|       |
 2809|  85.5k|                if(!memcmp(chunk.type, type_text, 4))
  ------------------
  |  Branch (2809:20): [True: 7.09k, False: 78.4k]
  ------------------
 2810|  7.09k|                {
 2811|  7.09k|                    text->type = SPNG_TEXT;
 2812|       |
 2813|  7.09k|                    text->text_length = chunk.length - keyword_len - 1;
 2814|       |
 2815|  7.09k|                    text_offset = keyword_len;
 2816|       |
 2817|       |                    /* increment past nul if there is a text field */
 2818|  7.09k|                    if(text->text_length) text_offset++;
  ------------------
  |  Branch (2818:24): [True: 5.16k, False: 1.93k]
  ------------------
 2819|  7.09k|                }
 2820|  78.4k|                else if(!memcmp(chunk.type, type_ztxt, 4))
  ------------------
  |  Branch (2820:25): [True: 67.2k, False: 11.1k]
  ------------------
 2821|  67.2k|                {
 2822|  67.2k|                    text->type = SPNG_ZTXT;
 2823|       |
 2824|  67.2k|                    if((peek_bytes - keyword_len) <= 2) return SPNG_EZTXT;
  ------------------
  |  Branch (2824:24): [True: 5.90k, False: 61.3k]
  ------------------
 2825|       |
 2826|  61.3k|                    if(keyword_nul[1]) return SPNG_EZTXT_COMPRESSION_METHOD;
  ------------------
  |  Branch (2826:24): [True: 6.41k, False: 54.9k]
  ------------------
 2827|       |
 2828|  54.9k|                    text->compression_flag = 1;
 2829|       |
 2830|  54.9k|                    text_offset = keyword_len + 2;
 2831|  54.9k|                }
 2832|  11.1k|                else if(!memcmp(chunk.type, type_itxt, 4))
  ------------------
  |  Branch (2832:25): [True: 11.1k, False: 0]
  ------------------
 2833|  11.1k|                {
 2834|  11.1k|                    text->type = SPNG_ITXT;
 2835|       |
 2836|       |                    /* at least two 1-byte fields, two >=0 length strings, and one byte of (compressed) text */
 2837|  11.1k|                    if((peek_bytes - keyword_len) < 5) return SPNG_EITXT;
  ------------------
  |  Branch (2837:24): [True: 357, False: 10.8k]
  ------------------
 2838|       |
 2839|  10.8k|                    text->compression_flag = keyword_nul[1];
 2840|       |
 2841|  10.8k|                    if(text->compression_flag > 1) return SPNG_EITXT_COMPRESSION_FLAG;
  ------------------
  |  Branch (2841:24): [True: 1.23k, False: 9.56k]
  ------------------
 2842|       |
 2843|  9.56k|                    if(keyword_nul[2]) return SPNG_EITXT_COMPRESSION_METHOD;
  ------------------
  |  Branch (2843:24): [True: 2.17k, False: 7.39k]
  ------------------
 2844|       |
 2845|  7.39k|                    language_tag_offset = keyword_len + 3;
 2846|       |
 2847|  7.39k|                    const unsigned char *term;
 2848|  7.39k|                    term = memchr(data + language_tag_offset, 0, peek_bytes - language_tag_offset);
 2849|  7.39k|                    if(term == NULL) return SPNG_EITXT_LANG_TAG;
  ------------------
  |  Branch (2849:24): [True: 77, False: 7.31k]
  ------------------
 2850|       |
 2851|  7.31k|                    if((peek_end - term) < 2) return SPNG_EITXT;
  ------------------
  |  Branch (2851:24): [True: 133, False: 7.18k]
  ------------------
 2852|       |
 2853|  7.18k|                    translated_keyword_offset = term - data + 1;
 2854|       |
 2855|  7.18k|                    zlib_stream = memchr(data + translated_keyword_offset, 0, peek_bytes - translated_keyword_offset);
 2856|  7.18k|                    if(zlib_stream == NULL) return SPNG_EITXT;
  ------------------
  |  Branch (2856:24): [True: 91, False: 7.09k]
  ------------------
 2857|  7.09k|                    if(zlib_stream == peek_end) return SPNG_EITXT;
  ------------------
  |  Branch (2857:24): [True: 0, False: 7.09k]
  ------------------
 2858|       |
 2859|  7.09k|                    text_offset = zlib_stream - data + 1;
 2860|  7.09k|                    text->text_length = chunk.length - text_offset;
 2861|  7.09k|                }
 2862|      0|                else return SPNG_EINTERNAL;
 2863|       |
 2864|       |
 2865|  69.1k|                if(text->compression_flag)
  ------------------
  |  Branch (2865:20): [True: 55.0k, False: 14.0k]
  ------------------
 2866|  55.0k|                {
 2867|       |                    /* cache usage = peek_bytes + decompressed text size + nul */
 2868|  55.0k|                    if(increase_cache_usage(ctx, peek_bytes, 0)) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (2868:24): [True: 0, False: 55.0k]
  ------------------
 2869|       |
 2870|  55.0k|                    text->keyword = spng__calloc(ctx, 1, peek_bytes);
 2871|  55.0k|                    if(text->keyword == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (2871:24): [True: 0, False: 55.0k]
  ------------------
 2872|       |
 2873|  55.0k|                    memcpy(text->keyword, data, peek_bytes);
 2874|       |
 2875|  55.0k|                    zlib_stream = ctx->data + text_offset;
 2876|       |
 2877|  55.0k|                    ret = spng__inflate_stream(ctx, &text->text, &text->text_length, 1, zlib_stream, peek_bytes - text_offset);
 2878|       |
 2879|  55.0k|                    if(ret) return ret;
  ------------------
  |  Branch (2879:24): [True: 25.3k, False: 29.7k]
  ------------------
 2880|       |
 2881|  29.7k|                    text->text[text->text_length - 1] = '\0';
 2882|  29.7k|                    text->cache_usage = text->text_length + peek_bytes;
 2883|  29.7k|                }
 2884|  14.0k|                else
 2885|  14.0k|                {
 2886|  14.0k|                    if(increase_cache_usage(ctx, chunk.length + 1, 0)) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (2886:24): [True: 0, False: 14.0k]
  ------------------
 2887|       |
 2888|  14.0k|                    text->keyword = spng__malloc(ctx, chunk.length + 1);
 2889|  14.0k|                    if(text->keyword == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (2889:24): [True: 0, False: 14.0k]
  ------------------
 2890|       |
 2891|  14.0k|                    memcpy(text->keyword, data, peek_bytes);
 2892|       |
 2893|  14.0k|                    if(chunk.length > peek_bytes)
  ------------------
  |  Branch (2893:24): [True: 945, False: 13.1k]
  ------------------
 2894|    945|                    {
 2895|    945|                        ret = read_chunk_bytes2(ctx, text->keyword + peek_bytes, chunk.length - peek_bytes);
 2896|    945|                        if(ret) return ret;
  ------------------
  |  Branch (2896:28): [True: 497, False: 448]
  ------------------
 2897|    945|                    }
 2898|       |
 2899|  13.6k|                    text->text = text->keyword + text_offset;
 2900|       |
 2901|  13.6k|                    text->text_length = chunk.length - text_offset;
 2902|       |
 2903|  13.6k|                    text->text[text->text_length] = '\0';
 2904|  13.6k|                    text->cache_usage = chunk.length + 1;
 2905|  13.6k|                }
 2906|       |
 2907|  43.3k|                if(check_png_keyword(text->keyword)) return SPNG_ETEXT_KEYWORD;
  ------------------
  |  Branch (2907:20): [True: 4.96k, False: 38.3k]
  ------------------
 2908|       |
 2909|  38.3k|                text->text_length = strlen(text->text);
 2910|       |
 2911|  38.3k|                if(text->type != SPNG_ITXT)
  ------------------
  |  Branch (2911:20): [True: 33.2k, False: 5.13k]
  ------------------
 2912|  33.2k|                {
 2913|  33.2k|                    language_tag_offset = keyword_len;
 2914|  33.2k|                    translated_keyword_offset = keyword_len;
 2915|       |
 2916|  33.2k|                    if(ctx->strict && check_png_text(text->text, text->text_length))
  ------------------
  |  Branch (2916:24): [True: 0, False: 33.2k]
  |  Branch (2916:39): [True: 0, False: 0]
  ------------------
 2917|      0|                    {
 2918|      0|                        if(text->type == SPNG_ZTXT) return SPNG_EZTXT;
  ------------------
  |  Branch (2918:28): [True: 0, False: 0]
  ------------------
 2919|      0|                        else return SPNG_ETEXT;
 2920|      0|                    }
 2921|  33.2k|                }
 2922|       |
 2923|  38.3k|                text->language_tag = text->keyword + language_tag_offset;
 2924|  38.3k|                text->translated_keyword = text->keyword + translated_keyword_offset;
 2925|       |
 2926|  38.3k|                ctx->stored.text = 1;
 2927|  38.3k|            }
 2928|   109k|            else if(!memcmp(chunk.type, type_splt, 4))
  ------------------
  |  Branch (2928:21): [True: 89.4k, False: 20.0k]
  ------------------
 2929|  89.4k|            {
 2930|  89.4k|                if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2930:20): [True: 385, False: 89.0k]
  ------------------
 2931|  89.0k|                if(ctx->user.splt) goto discard; /* XXX: could check profile names for uniqueness */
  ------------------
  |  Branch (2931:20): [True: 0, False: 89.0k]
  ------------------
 2932|  89.0k|                if(!chunk.length) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2932:20): [True: 9.07k, False: 79.9k]
  ------------------
 2933|       |
 2934|  79.9k|                ctx->file.splt = 1;
 2935|       |
 2936|       |                /* chunk.length + sizeof(struct spng_splt) + splt->n_entries * sizeof(struct spng_splt_entry) */
 2937|  79.9k|                if(increase_cache_usage(ctx, chunk.length + sizeof(struct spng_splt), 1)) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (2937:20): [True: 7, False: 79.9k]
  ------------------
 2938|       |
 2939|  79.9k|                ctx->n_splt++;
 2940|  79.9k|                if(ctx->n_splt < 1) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (2940:20): [True: 0, False: 79.9k]
  ------------------
 2941|  79.9k|                if(sizeof(struct spng_splt) > SIZE_MAX / ctx->n_splt) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (2941:20): [True: 0, False: 79.9k]
  ------------------
 2942|       |
 2943|  79.9k|                void *buf = spng__realloc(ctx, ctx->splt_list, ctx->n_splt * sizeof(struct spng_splt));
 2944|  79.9k|                if(buf == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (2944:20): [True: 0, False: 79.9k]
  ------------------
 2945|  79.9k|                ctx->splt_list = buf;
 2946|       |
 2947|  79.9k|                struct spng_splt *splt = &ctx->splt_list[ctx->n_splt - 1];
 2948|       |
 2949|  79.9k|                memset(splt, 0, sizeof(struct spng_splt));
 2950|       |
 2951|  79.9k|                ctx->undo = splt_undo;
 2952|       |
 2953|  79.9k|                void *t = spng__malloc(ctx, chunk.length);
 2954|  79.9k|                if(t == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (2954:20): [True: 0, False: 79.9k]
  ------------------
 2955|       |
 2956|  79.9k|                splt->entries = t; /* simplifies error handling */
 2957|  79.9k|                data = t;
 2958|       |
 2959|  79.9k|                ret = read_chunk_bytes2(ctx, t, chunk.length);
 2960|  79.9k|                if(ret) return ret;
  ------------------
  |  Branch (2960:20): [True: 343, False: 79.6k]
  ------------------
 2961|       |
 2962|  79.6k|                uint32_t keyword_len = chunk.length < 80 ? chunk.length : 80;
  ------------------
  |  Branch (2962:40): [True: 68.3k, False: 11.2k]
  ------------------
 2963|       |
 2964|  79.6k|                const unsigned char *keyword_nul = memchr(data, 0, keyword_len);
 2965|  79.6k|                if(keyword_nul == NULL) return SPNG_ESPLT_NAME;
  ------------------
  |  Branch (2965:20): [True: 5.62k, False: 74.0k]
  ------------------
 2966|       |
 2967|  74.0k|                keyword_len = keyword_nul - data;
 2968|       |
 2969|  74.0k|                memcpy(splt->name, data, keyword_len);
 2970|       |
 2971|  74.0k|                if(check_png_keyword(splt->name)) return SPNG_ESPLT_NAME;
  ------------------
  |  Branch (2971:20): [True: 59.8k, False: 14.1k]
  ------------------
 2972|       |
 2973|  14.1k|                uint32_t j;
 2974|  14.4k|                for(j=0; j < (ctx->n_splt - 1); j++)
  ------------------
  |  Branch (2974:26): [True: 441, False: 14.0k]
  ------------------
 2975|    441|                {
 2976|    441|                    if(!strcmp(ctx->splt_list[j].name, splt->name)) return SPNG_ESPLT_DUP_NAME;
  ------------------
  |  Branch (2976:24): [True: 119, False: 322]
  ------------------
 2977|    441|                }
 2978|       |
 2979|  14.0k|                if( (chunk.length - keyword_len) <= 2) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2979:21): [True: 12.2k, False: 1.83k]
  ------------------
 2980|       |
 2981|  1.83k|                splt->sample_depth = data[keyword_len + 1];
 2982|       |
 2983|  1.83k|                uint32_t entries_len = chunk.length - keyword_len - 2;
 2984|  1.83k|                if(!entries_len) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2984:20): [True: 0, False: 1.83k]
  ------------------
 2985|       |
 2986|  1.83k|                if(splt->sample_depth == 16)
  ------------------
  |  Branch (2986:20): [True: 672, False: 1.16k]
  ------------------
 2987|    672|                {
 2988|    672|                    if(entries_len % 10 != 0) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2988:24): [True: 77, False: 595]
  ------------------
 2989|    595|                    splt->n_entries = entries_len / 10;
 2990|    595|                }
 2991|  1.16k|                else if(splt->sample_depth == 8)
  ------------------
  |  Branch (2991:25): [True: 777, False: 385]
  ------------------
 2992|    777|                {
 2993|    777|                    if(entries_len % 6 != 0) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2993:24): [True: 168, False: 609]
  ------------------
 2994|    609|                    splt->n_entries = entries_len / 6;
 2995|    609|                }
 2996|    385|                else return SPNG_ESPLT_DEPTH;
 2997|       |
 2998|  1.20k|                if(!splt->n_entries) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2998:20): [True: 0, False: 1.20k]
  ------------------
 2999|       |
 3000|  1.20k|                size_t list_size = splt->n_entries;
 3001|       |
 3002|  1.20k|                if(list_size > SIZE_MAX / sizeof(struct spng_splt_entry)) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (3002:20): [True: 0, False: 1.20k]
  ------------------
 3003|       |
 3004|  1.20k|                list_size *= sizeof(struct spng_splt_entry);
 3005|       |
 3006|  1.20k|                if(increase_cache_usage(ctx, list_size, 0)) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (3006:20): [True: 0, False: 1.20k]
  ------------------
 3007|       |
 3008|  1.20k|                splt->entries = spng__malloc(ctx, list_size);
 3009|  1.20k|                if(splt->entries == NULL)
  ------------------
  |  Branch (3009:20): [True: 0, False: 1.20k]
  ------------------
 3010|      0|                {
 3011|      0|                    spng__free(ctx, t);
 3012|      0|                    return SPNG_EMEM;
 3013|      0|                }
 3014|       |
 3015|  1.20k|                data = (unsigned char*)t + keyword_len + 2;
 3016|       |
 3017|  1.20k|                uint32_t k;
 3018|  1.20k|                if(splt->sample_depth == 16)
  ------------------
  |  Branch (3018:20): [True: 595, False: 609]
  ------------------
 3019|    595|                {
 3020|  3.21k|                    for(k=0; k < splt->n_entries; k++)
  ------------------
  |  Branch (3020:30): [True: 2.61k, False: 595]
  ------------------
 3021|  2.61k|                    {
 3022|  2.61k|                        splt->entries[k].red =   read_u16(data + k * 10);
 3023|  2.61k|                        splt->entries[k].green = read_u16(data + k * 10 + 2);
 3024|  2.61k|                        splt->entries[k].blue =  read_u16(data + k * 10 + 4);
 3025|  2.61k|                        splt->entries[k].alpha = read_u16(data + k * 10 + 6);
 3026|  2.61k|                        splt->entries[k].frequency = read_u16(data + k * 10 + 8);
 3027|  2.61k|                    }
 3028|    595|                }
 3029|    609|                else if(splt->sample_depth == 8)
  ------------------
  |  Branch (3029:25): [True: 609, False: 0]
  ------------------
 3030|    609|                {
 3031|  2.59k|                    for(k=0; k < splt->n_entries; k++)
  ------------------
  |  Branch (3031:30): [True: 1.98k, False: 609]
  ------------------
 3032|  1.98k|                    {
 3033|  1.98k|                        splt->entries[k].red =   data[k * 6];
 3034|  1.98k|                        splt->entries[k].green = data[k * 6 + 1];
 3035|  1.98k|                        splt->entries[k].blue =  data[k * 6 + 2];
 3036|  1.98k|                        splt->entries[k].alpha = data[k * 6 + 3];
 3037|  1.98k|                        splt->entries[k].frequency = read_u16(data + k * 6 + 4);
 3038|  1.98k|                    }
 3039|    609|                }
 3040|       |
 3041|  1.20k|                spng__free(ctx, t);
 3042|  1.20k|                decrease_cache_usage(ctx, chunk.length);
 3043|       |
 3044|  1.20k|                ctx->stored.splt = 1;
 3045|  1.20k|            }
 3046|  20.0k|            else /* Unknown chunk */
 3047|  20.0k|            {
 3048|  20.0k|                ctx->file.unknown = 1;
 3049|       |
 3050|  20.0k|                if(!ctx->keep_unknown) goto discard;
  ------------------
  |  Branch (3050:20): [True: 20.0k, False: 0]
  ------------------
 3051|      0|                if(ctx->user.unknown) goto discard;
  ------------------
  |  Branch (3051:20): [True: 0, False: 0]
  ------------------
 3052|       |
 3053|      0|                if(increase_cache_usage(ctx, chunk.length + sizeof(struct spng_unknown_chunk), 1)) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (3053:20): [True: 0, False: 0]
  ------------------
 3054|       |
 3055|      0|                ctx->n_chunks++;
 3056|      0|                if(ctx->n_chunks < 1) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (3056:20): [True: 0, False: 0]
  ------------------
 3057|      0|                if(sizeof(struct spng_unknown_chunk) > SIZE_MAX / ctx->n_chunks) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (3057:20): [True: 0, False: 0]
  ------------------
 3058|       |
 3059|      0|                void *buf = spng__realloc(ctx, ctx->chunk_list, ctx->n_chunks * sizeof(struct spng_unknown_chunk));
 3060|      0|                if(buf == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (3060:20): [True: 0, False: 0]
  ------------------
 3061|      0|                ctx->chunk_list = buf;
 3062|       |
 3063|      0|                struct spng_unknown_chunk *chunkp = &ctx->chunk_list[ctx->n_chunks - 1];
 3064|       |
 3065|      0|                memset(chunkp, 0, sizeof(struct spng_unknown_chunk));
 3066|       |
 3067|      0|                ctx->undo = chunk_undo;
 3068|       |
 3069|      0|                memcpy(chunkp->type, chunk.type, 4);
 3070|       |
 3071|      0|                if(ctx->state < SPNG_STATE_FIRST_IDAT)
  ------------------
  |  Branch (3071:20): [True: 0, False: 0]
  ------------------
 3072|      0|                {
 3073|      0|                    if(ctx->file.plte) chunkp->location = SPNG_AFTER_PLTE;
  ------------------
  |  Branch (3073:24): [True: 0, False: 0]
  ------------------
 3074|      0|                    else chunkp->location = SPNG_AFTER_IHDR;
 3075|      0|                }
 3076|      0|                else if(ctx->state >= SPNG_STATE_AFTER_IDAT) chunkp->location = SPNG_AFTER_IDAT;
  ------------------
  |  Branch (3076:25): [True: 0, False: 0]
  ------------------
 3077|       |
 3078|      0|                if(chunk.length > 0)
  ------------------
  |  Branch (3078:20): [True: 0, False: 0]
  ------------------
 3079|      0|                {
 3080|      0|                    void *t = spng__malloc(ctx, chunk.length);
 3081|      0|                    if(t == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (3081:24): [True: 0, False: 0]
  ------------------
 3082|       |
 3083|      0|                    ret = read_chunk_bytes2(ctx, t, chunk.length);
 3084|      0|                    if(ret)
  ------------------
  |  Branch (3084:24): [True: 0, False: 0]
  ------------------
 3085|      0|                    {
 3086|      0|                        spng__free(ctx, t);
 3087|      0|                        return ret;
 3088|      0|                    }
 3089|       |
 3090|      0|                    chunkp->length = chunk.length;
 3091|      0|                    chunkp->data = t;
 3092|      0|                }
 3093|       |
 3094|      0|                ctx->stored.unknown = 1;
 3095|      0|            }
 3096|       |
 3097|  59.7k|discard:
 3098|  59.7k|            ret = discard_chunk_bytes(ctx, ctx->cur_chunk_bytes_left);
 3099|  59.7k|            if(ret) return ret;
  ------------------
  |  Branch (3099:16): [True: 1.29k, False: 58.4k]
  ------------------
 3100|  59.7k|        }
 3101|       |
 3102|   379k|    }
 3103|       |
 3104|  10.3k|    return ret;
 3105|   332k|}
spng.c:read_header:
 1055|   421k|{
 1056|   421k|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1056:8): [True: 0, False: 421k]
  ------------------
 1057|       |
 1058|   421k|    int ret;
 1059|   421k|    struct spng_chunk chunk = { 0 };
 1060|       |
 1061|   421k|    ret = read_and_check_crc(ctx);
 1062|   421k|    if(ret)
  ------------------
  |  Branch (1062:8): [True: 160k, False: 260k]
  ------------------
 1063|   160k|    {
 1064|   160k|        if(ret == -SPNG_CRC_DISCARD)
  ------------------
  |  Branch (1064:12): [True: 159k, False: 1.46k]
  ------------------
 1065|   159k|        {
 1066|   159k|            ctx->discard = 1;
 1067|   159k|        }
 1068|  1.46k|        else return ret;
 1069|   160k|    }
 1070|       |
 1071|   419k|    ret = read_data(ctx, 8);
 1072|   419k|    if(ret) return ret;
  ------------------
  |  Branch (1072:8): [True: 10.0k, False: 409k]
  ------------------
 1073|       |
 1074|   409k|    chunk.offset = ctx->bytes_read - 8;
 1075|       |
 1076|   409k|    chunk.length = read_u32(ctx->data);
 1077|       |
 1078|   409k|    memcpy(&chunk.type, ctx->data + 4, 4);
 1079|       |
 1080|   409k|    if(chunk.length > spng_u32max) return SPNG_ECHUNK_STDLEN;
  ------------------
  |  Branch (1080:8): [True: 629, False: 409k]
  ------------------
 1081|       |
 1082|   409k|    ctx->cur_chunk_bytes_left = chunk.length;
 1083|       |
 1084|   409k|    if(is_critical_chunk(&chunk) && ctx->crc_action_critical == SPNG_CRC_USE) ctx->skip_crc = 1;
  ------------------
  |  Branch (1084:8): [True: 32.0k, False: 377k]
  |  Branch (1084:37): [True: 0, False: 32.0k]
  ------------------
 1085|   409k|    else if(ctx->crc_action_ancillary == SPNG_CRC_USE) ctx->skip_crc = 1;
  ------------------
  |  Branch (1085:13): [True: 0, False: 409k]
  ------------------
 1086|   409k|    else ctx->skip_crc = 0;
 1087|       |
 1088|   409k|    if(!ctx->skip_crc)
  ------------------
  |  Branch (1088:8): [True: 409k, False: 0]
  ------------------
 1089|   409k|    {
 1090|   409k|        ctx->cur_actual_crc = crc32(0, NULL, 0);
 1091|   409k|        ctx->cur_actual_crc = crc32(ctx->cur_actual_crc, chunk.type, 4);
 1092|   409k|    }
 1093|       |
 1094|   409k|    ctx->current_chunk = chunk;
 1095|       |
 1096|   409k|    return 0;
 1097|   409k|}
spng.c:is_small_chunk:
 2254|   380k|{
 2255|   380k|    if(!memcmp(type, type_plte, 4)) return 1;
  ------------------
  |  Branch (2255:8): [True: 1.32k, False: 379k]
  ------------------
 2256|   379k|    else if(!memcmp(type, type_chrm, 4)) return 1;
  ------------------
  |  Branch (2256:13): [True: 2.96k, False: 376k]
  ------------------
 2257|   376k|    else if(!memcmp(type, type_gama, 4)) return 1;
  ------------------
  |  Branch (2257:13): [True: 3.43k, False: 372k]
  ------------------
 2258|   372k|    else if(!memcmp(type, type_sbit, 4)) return 1;
  ------------------
  |  Branch (2258:13): [True: 6.07k, False: 366k]
  ------------------
 2259|   366k|    else if(!memcmp(type, type_srgb, 4)) return 1;
  ------------------
  |  Branch (2259:13): [True: 889, False: 365k]
  ------------------
 2260|   365k|    else if(!memcmp(type, type_bkgd, 4)) return 1;
  ------------------
  |  Branch (2260:13): [True: 12.1k, False: 353k]
  ------------------
 2261|   353k|    else if(!memcmp(type, type_trns, 4)) return 1;
  ------------------
  |  Branch (2261:13): [True: 4.82k, False: 348k]
  ------------------
 2262|   348k|    else if(!memcmp(type, type_hist, 4)) return 1;
  ------------------
  |  Branch (2262:13): [True: 1.27k, False: 347k]
  ------------------
 2263|   347k|    else if(!memcmp(type, type_phys, 4)) return 1;
  ------------------
  |  Branch (2263:13): [True: 4.83k, False: 342k]
  ------------------
 2264|   342k|    else if(!memcmp(type, type_time, 4)) return 1;
  ------------------
  |  Branch (2264:13): [True: 9.10k, False: 333k]
  ------------------
 2265|   333k|    else if(!memcmp(type, type_offs, 4)) return 1;
  ------------------
  |  Branch (2265:13): [True: 735, False: 332k]
  ------------------
 2266|   332k|    else return 0;
 2267|   380k|}
spng.c:read_and_check_crc:
 1024|   421k|{
 1025|   421k|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1025:8): [True: 0, False: 421k]
  ------------------
 1026|       |
 1027|   421k|    int ret;
 1028|   421k|    ret = read_data(ctx, 4);
 1029|   421k|    if(ret) return ret;
  ------------------
  |  Branch (1029:8): [True: 7.91k, False: 413k]
  ------------------
 1030|       |
 1031|   413k|    ctx->current_chunk.crc = read_u32(ctx->data);
 1032|       |
 1033|   413k|    if(ctx->skip_crc) return 0;
  ------------------
  |  Branch (1033:8): [True: 0, False: 413k]
  ------------------
 1034|       |
 1035|   413k|    if(ctx->cur_actual_crc != ctx->current_chunk.crc)
  ------------------
  |  Branch (1035:8): [True: 153k, False: 260k]
  ------------------
 1036|   153k|    {
 1037|   153k|        if(is_critical_chunk(&ctx->current_chunk))
  ------------------
  |  Branch (1037:12): [True: 1.67k, False: 151k]
  ------------------
 1038|  1.67k|        {
 1039|  1.67k|            if(ctx->crc_action_critical == SPNG_CRC_USE) return 0;
  ------------------
  |  Branch (1039:16): [True: 0, False: 1.67k]
  ------------------
 1040|  1.67k|        }
 1041|   151k|        else
 1042|   151k|        {
 1043|   151k|            if(ctx->crc_action_ancillary == SPNG_CRC_USE) return 0;
  ------------------
  |  Branch (1043:16): [True: 0, False: 151k]
  ------------------
 1044|   151k|            if(ctx->crc_action_ancillary == SPNG_CRC_DISCARD) return -SPNG_CRC_DISCARD;
  ------------------
  |  Branch (1044:16): [True: 151k, False: 0]
  ------------------
 1045|   151k|        }
 1046|       |
 1047|  1.67k|        return SPNG_ECHUNK_CRC;
 1048|   153k|    }
 1049|       |
 1050|   260k|    return 0;
 1051|   413k|}
spng.c:read_s32:
  457|    378|{
  458|    378|    int32_t ret = (int32_t)read_u32(src);
  459|       |
  460|    378|    return ret;
  461|    378|}
spng.c:increase_cache_usage:
  718|   273k|{
  719|   273k|    if(ctx == NULL || !bytes) return SPNG_EINTERNAL;
  ------------------
  |  Branch (719:8): [True: 0, False: 273k]
  |  Branch (719:23): [True: 0, False: 273k]
  ------------------
  720|       |
  721|   273k|    if(new_chunk)
  ------------------
  |  Branch (721:8): [True: 173k, False: 100k]
  ------------------
  722|   173k|    {
  723|   173k|        ctx->chunk_count_total++;
  724|   173k|        if(ctx->chunk_count_total < 1) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (724:12): [True: 0, False: 173k]
  ------------------
  725|       |
  726|   173k|        if(ctx->chunk_count_total > ctx->chunk_count_limit) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (726:12): [True: 7, False: 173k]
  ------------------
  727|   173k|    }
  728|       |
  729|   273k|    size_t new_usage = ctx->chunk_cache_usage + bytes;
  730|       |
  731|   273k|    if(new_usage < ctx->chunk_cache_usage) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (731:8): [True: 0, False: 273k]
  ------------------
  732|       |
  733|   273k|    if(new_usage > ctx->chunk_cache_limit) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (733:8): [True: 0, False: 273k]
  ------------------
  734|       |
  735|   273k|    ctx->chunk_cache_usage = new_usage;
  736|       |
  737|   273k|    return 0;
  738|   273k|}
spng.c:read_chunk_bytes2:
 1120|  81.5k|{
 1121|  81.5k|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1121:8): [True: 0, False: 81.5k]
  ------------------
 1122|  81.5k|    if(!ctx->cur_chunk_bytes_left || !bytes) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1122:8): [True: 0, False: 81.5k]
  |  Branch (1122:38): [True: 0, False: 81.5k]
  ------------------
 1123|  81.5k|    if(bytes > ctx->cur_chunk_bytes_left) return SPNG_EINTERNAL; /* XXX: more specific error? */
  ------------------
  |  Branch (1123:8): [True: 0, False: 81.5k]
  ------------------
 1124|       |
 1125|  81.5k|    int ret;
 1126|  81.5k|    uint32_t len = bytes;
 1127|       |
 1128|  81.5k|    if(ctx->streaming && len > SPNG_READ_SIZE) len = SPNG_READ_SIZE;
  ------------------
  |  |   30|  81.5k|#define SPNG_READ_SIZE (8192)
  ------------------
                  if(ctx->streaming && len > SPNG_READ_SIZE) len = SPNG_READ_SIZE;
  ------------------
  |  |   30|    973|#define SPNG_READ_SIZE (8192)
  ------------------
  |  Branch (1128:8): [True: 81.5k, False: 0]
  |  Branch (1128:26): [True: 973, False: 80.5k]
  ------------------
 1129|       |
 1130|   164k|    while(bytes)
  ------------------
  |  Branch (1130:11): [True: 83.9k, False: 80.3k]
  ------------------
 1131|  83.9k|    {
 1132|  83.9k|        if(len > bytes) len = bytes;
  ------------------
  |  Branch (1132:12): [True: 77, False: 83.8k]
  ------------------
 1133|       |
 1134|  83.9k|        ret = ctx->read_fn(ctx, ctx->stream_user_ptr, out, len);
 1135|  83.9k|        if(ret) return ret;
  ------------------
  |  Branch (1135:12): [True: 1.16k, False: 82.7k]
  ------------------
 1136|       |
 1137|  82.7k|        if(!ctx->streaming) memcpy(out, ctx->data, len);
  ------------------
  |  Branch (1137:12): [True: 0, False: 82.7k]
  ------------------
 1138|       |
 1139|  82.7k|        ctx->bytes_read += len;
 1140|  82.7k|        if(ctx->bytes_read < len) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (1140:12): [True: 0, False: 82.7k]
  ------------------
 1141|       |
 1142|  82.7k|        if(!ctx->skip_crc) ctx->cur_actual_crc = crc32(ctx->cur_actual_crc, out, len);
  ------------------
  |  Branch (1142:12): [True: 82.7k, False: 0]
  ------------------
 1143|       |
 1144|  82.7k|        ctx->cur_chunk_bytes_left -= len;
 1145|       |
 1146|  82.7k|        out = (char*)out + len;
 1147|  82.7k|        bytes -= len;
 1148|  82.7k|        len = SPNG_READ_SIZE;
  ------------------
  |  |   30|  82.7k|#define SPNG_READ_SIZE (8192)
  ------------------
 1149|  82.7k|    }
 1150|       |
 1151|  80.3k|    return 0;
 1152|  81.5k|}
spng.c:spng__inflate_stream:
 1249|  58.5k|{
 1250|  58.5k|    int ret = spng__inflate_init(ctx, 15);
 1251|  58.5k|    if(ret) return ret;
  ------------------
  |  Branch (1251:8): [True: 0, False: 58.5k]
  ------------------
 1252|       |
 1253|  58.5k|    size_t max = ctx->chunk_cache_limit - ctx->chunk_cache_usage;
 1254|       |
 1255|  58.5k|    if(ctx->max_chunk_size < max) max = ctx->max_chunk_size;
  ------------------
  |  Branch (1255:8): [True: 58.5k, False: 0]
  ------------------
 1256|       |
 1257|  58.5k|    if(extra > max) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (1257:8): [True: 0, False: 58.5k]
  ------------------
 1258|  58.5k|    max -= extra;
 1259|       |
 1260|  58.5k|    uint32_t read_size;
 1261|  58.5k|    size_t size = 8 * 1024;
 1262|  58.5k|    void *t, *buf = spng__malloc(ctx, size);
 1263|       |
 1264|  58.5k|    if(buf == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (1264:8): [True: 0, False: 58.5k]
  ------------------
 1265|       |
 1266|  58.5k|    z_stream *stream = &ctx->zstream;
 1267|       |
 1268|  58.5k|    if(start_buf != NULL && start_len)
  ------------------
  |  Branch (1268:8): [True: 58.5k, False: 0]
  |  Branch (1268:29): [True: 58.4k, False: 119]
  ------------------
 1269|  58.4k|    {
 1270|  58.4k|        stream->avail_in = (uInt)start_len;
 1271|  58.4k|        stream->next_in = start_buf;
 1272|  58.4k|    }
 1273|    119|    else
 1274|    119|    {
 1275|    119|        stream->avail_in = 0;
 1276|    119|        stream->next_in = NULL;
 1277|    119|    }
 1278|       |
 1279|  58.5k|    stream->avail_out = (uInt)size;
 1280|  58.5k|    stream->next_out = buf;
 1281|       |
 1282|  91.7k|    while(ret != Z_STREAM_END)
  ------------------
  |  |  182|  91.7k|#define Z_STREAM_END    1
  ------------------
  |  Branch (1282:11): [True: 91.7k, False: 0]
  ------------------
 1283|  91.7k|    {
 1284|  91.7k|        ret = inflate(stream, Z_NO_FLUSH);
  ------------------
  |  |  172|  91.7k|#define Z_NO_FLUSH      0
  ------------------
 1285|       |
 1286|  91.7k|        if(ret == Z_STREAM_END) break;
  ------------------
  |  |  182|  91.7k|#define Z_STREAM_END    1
  ------------------
  |  Branch (1286:12): [True: 30.1k, False: 61.5k]
  ------------------
 1287|       |
 1288|  61.5k|        if(ret != Z_OK && ret != Z_BUF_ERROR)
  ------------------
  |  |  181|   123k|#define Z_OK            0
  ------------------
                      if(ret != Z_OK && ret != Z_BUF_ERROR)
  ------------------
  |  |  188|  22.9k|#define Z_BUF_ERROR    (-5)
  ------------------
  |  Branch (1288:12): [True: 22.9k, False: 38.6k]
  |  Branch (1288:27): [True: 22.8k, False: 119]
  ------------------
 1289|  22.8k|        {
 1290|  22.8k|            ret = SPNG_EZLIB;
 1291|  22.8k|            goto err;
 1292|  22.8k|        }
 1293|       |
 1294|  38.7k|        if(!stream->avail_out) /* Resize buffer */
  ------------------
  |  Branch (1294:12): [True: 12.8k, False: 25.8k]
  ------------------
 1295|  12.8k|        {
 1296|       |            /* overflow or reached chunk/cache limit */
 1297|  12.8k|            if( (2 > SIZE_MAX / size) || (size > max / 2) )
  ------------------
  |  Branch (1297:17): [True: 0, False: 12.8k]
  |  Branch (1297:42): [True: 0, False: 12.8k]
  ------------------
 1298|      0|            {
 1299|      0|                ret = SPNG_ECHUNK_LIMITS;
 1300|      0|                goto err;
 1301|      0|            }
 1302|       |
 1303|  12.8k|            size *= 2;
 1304|       |
 1305|  12.8k|            t = spng__realloc(ctx, buf, size);
 1306|  12.8k|            if(t == NULL) goto mem;
  ------------------
  |  Branch (1306:16): [True: 0, False: 12.8k]
  ------------------
 1307|       |
 1308|  12.8k|            buf = t;
 1309|       |
 1310|  12.8k|            stream->avail_out = (uInt)size / 2;
 1311|  12.8k|            stream->next_out = (unsigned char*)buf + size / 2;
 1312|  12.8k|        }
 1313|  25.8k|        else if(!stream->avail_in) /* Read more chunk bytes */
  ------------------
  |  Branch (1313:17): [True: 25.8k, False: 0]
  ------------------
 1314|  25.8k|        {
 1315|  25.8k|            read_size = ctx->cur_chunk_bytes_left;
 1316|  25.8k|            if(ctx->streaming && read_size > SPNG_READ_SIZE) read_size = SPNG_READ_SIZE;
  ------------------
  |  |   30|  25.8k|#define SPNG_READ_SIZE (8192)
  ------------------
                          if(ctx->streaming && read_size > SPNG_READ_SIZE) read_size = SPNG_READ_SIZE;
  ------------------
  |  |   30|  17.5k|#define SPNG_READ_SIZE (8192)
  ------------------
  |  Branch (1316:16): [True: 25.8k, False: 0]
  |  Branch (1316:34): [True: 17.5k, False: 8.36k]
  ------------------
 1317|       |
 1318|  25.8k|            ret = read_chunk_bytes(ctx, read_size);
 1319|       |
 1320|  25.8k|            if(ret)
  ------------------
  |  Branch (1320:16): [True: 5.62k, False: 20.2k]
  ------------------
 1321|  5.62k|            {
 1322|  5.62k|                if(!read_size) ret = SPNG_EZLIB;
  ------------------
  |  Branch (1322:20): [True: 4.24k, False: 1.37k]
  ------------------
 1323|       |
 1324|  5.62k|                goto err;
 1325|  5.62k|            }
 1326|       |
 1327|  20.2k|            stream->avail_in = read_size;
 1328|  20.2k|            stream->next_in = ctx->data;
 1329|  20.2k|        }
 1330|  38.7k|    }
 1331|       |
 1332|  30.1k|    size = stream->total_out;
 1333|       |
 1334|  30.1k|    if(!size)
  ------------------
  |  Branch (1334:8): [True: 329, False: 29.8k]
  ------------------
 1335|    329|    {
 1336|    329|        ret = SPNG_EZLIB;
 1337|    329|        goto err;
 1338|    329|    }
 1339|       |
 1340|  29.8k|    size += extra;
 1341|  29.8k|    if(size < extra) goto mem;
  ------------------
  |  Branch (1341:8): [True: 0, False: 29.8k]
  ------------------
 1342|       |
 1343|  29.8k|    t = spng__realloc(ctx, buf, size);
 1344|  29.8k|    if(t == NULL) goto mem;
  ------------------
  |  Branch (1344:8): [True: 0, False: 29.8k]
  ------------------
 1345|       |
 1346|  29.8k|    buf = t;
 1347|       |
 1348|  29.8k|    (void)increase_cache_usage(ctx, size, 0);
 1349|       |
 1350|  29.8k|    *out = buf;
 1351|  29.8k|    *len = size;
 1352|       |
 1353|  29.8k|    return 0;
 1354|       |
 1355|      0|mem:
 1356|      0|    ret = SPNG_EMEM;
 1357|  28.7k|err:
 1358|  28.7k|    spng__free(ctx, buf);
 1359|  28.7k|    return ret;
 1360|      0|}
spng.c:spng__realloc:
  411|   215k|{
  412|   215k|    return ctx->alloc.realloc_fn(ptr, size);
  413|   215k|}
spng.c:text_undo:
 2333|  56.5k|{
 2334|  56.5k|    struct spng_text2 *text = &ctx->text_list[ctx->n_text - 1];
 2335|       |
 2336|  56.5k|    spng__free(ctx, text->keyword);
 2337|  56.5k|    if(text->compression_flag) spng__free(ctx, text->text);
  ------------------
  |  Branch (2337:8): [True: 26.6k, False: 29.8k]
  ------------------
 2338|       |
 2339|  56.5k|    decrease_cache_usage(ctx, text->cache_usage);
 2340|  56.5k|    decrease_cache_usage(ctx, sizeof(struct spng_text2));
 2341|       |
 2342|  56.5k|    text->keyword = NULL;
 2343|  56.5k|    text->text = NULL;
 2344|       |
 2345|  56.5k|    ctx->n_text--;
 2346|  56.5k|}
spng.c:splt_undo:
 2319|  79.1k|{
 2320|  79.1k|    struct spng_splt *splt = &ctx->splt_list[ctx->n_splt - 1];
 2321|       |
 2322|  79.1k|    spng__free(ctx, splt->entries);
 2323|       |
 2324|  79.1k|    decrease_cache_usage(ctx, sizeof(struct spng_splt));
 2325|  79.1k|    decrease_cache_usage(ctx, splt->n_entries * sizeof(struct spng_splt_entry));
 2326|       |
 2327|  79.1k|    splt->entries = NULL;
 2328|       |
 2329|  79.1k|    ctx->n_splt--;
 2330|  79.1k|}
spng.c:decrease_cache_usage:
  741|   272k|{
  742|   272k|    if(ctx == NULL || !usage) return SPNG_EINTERNAL;
  ------------------
  |  Branch (742:8): [True: 0, False: 272k]
  |  Branch (742:23): [True: 126k, False: 146k]
  ------------------
  743|   146k|    if(usage > ctx->chunk_cache_usage) return SPNG_EINTERNAL;
  ------------------
  |  Branch (743:8): [True: 0, False: 146k]
  ------------------
  744|       |
  745|   146k|    ctx->chunk_cache_usage -= usage;
  746|       |
  747|   146k|    return 0;
  748|   146k|}
spng.c:is_critical_chunk:
  751|  1.31M|{
  752|  1.31M|    if(chunk == NULL) return 0;
  ------------------
  |  Branch (752:8): [True: 0, False: 1.31M]
  ------------------
  753|  1.31M|    if((chunk->type[0] & (1 << 5)) == 0) return 1;
  ------------------
  |  Branch (753:8): [True: 43.9k, False: 1.27M]
  ------------------
  754|       |
  755|  1.27M|    return 0;
  756|  1.31M|}
spng.c:check_decode_fmt:
  634|  7.03k|{
  635|  7.03k|    switch(fmt)
  636|  7.03k|    {
  637|      0|        case SPNG_FMT_RGBA8:
  ------------------
  |  Branch (637:9): [True: 0, False: 7.03k]
  ------------------
  638|      0|        case SPNG_FMT_RGBA16:
  ------------------
  |  Branch (638:9): [True: 0, False: 7.03k]
  ------------------
  639|      0|        case SPNG_FMT_RGB8:
  ------------------
  |  Branch (639:9): [True: 0, False: 7.03k]
  ------------------
  640|  7.03k|        case SPNG_FMT_PNG:
  ------------------
  |  Branch (640:9): [True: 7.03k, False: 0]
  ------------------
  641|  7.03k|        case SPNG_FMT_RAW:
  ------------------
  |  Branch (641:9): [True: 0, False: 7.03k]
  ------------------
  642|  7.03k|            return 0;
  643|      0|        case SPNG_FMT_G8:
  ------------------
  |  Branch (643:9): [True: 0, False: 7.03k]
  ------------------
  644|      0|        case SPNG_FMT_GA8:
  ------------------
  |  Branch (644:9): [True: 0, False: 7.03k]
  ------------------
  645|      0|            if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE && ihdr->bit_depth <= 8) return 0;
  ------------------
  |  Branch (645:16): [True: 0, False: 0]
  |  Branch (645:65): [True: 0, False: 0]
  ------------------
  646|      0|            else return SPNG_EFMT;
  647|      0|        case SPNG_FMT_GA16:
  ------------------
  |  Branch (647:9): [True: 0, False: 7.03k]
  ------------------
  648|      0|            if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE && ihdr->bit_depth == 16) return 0;
  ------------------
  |  Branch (648:16): [True: 0, False: 0]
  |  Branch (648:65): [True: 0, False: 0]
  ------------------
  649|      0|            else return SPNG_EFMT;
  650|      0|        default: return SPNG_EFMT;
  ------------------
  |  Branch (650:9): [True: 0, False: 7.03k]
  ------------------
  651|  7.03k|    }
  652|  7.03k|}
spng.c:calculate_image_width:
  655|  7.03k|{
  656|  7.03k|    if(ihdr == NULL || len == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (656:8): [True: 0, False: 7.03k]
  |  Branch (656:24): [True: 0, False: 7.03k]
  ------------------
  657|       |
  658|  7.03k|    size_t res = ihdr->width;
  659|  7.03k|    unsigned bytes_per_pixel;
  660|       |
  661|  7.03k|    switch(fmt)
  662|  7.03k|    {
  663|      0|        case SPNG_FMT_RGBA8:
  ------------------
  |  Branch (663:9): [True: 0, False: 7.03k]
  ------------------
  664|      0|        case SPNG_FMT_GA16:
  ------------------
  |  Branch (664:9): [True: 0, False: 7.03k]
  ------------------
  665|      0|            bytes_per_pixel = 4;
  666|      0|            break;
  667|      0|        case SPNG_FMT_RGBA16:
  ------------------
  |  Branch (667:9): [True: 0, False: 7.03k]
  ------------------
  668|      0|            bytes_per_pixel = 8;
  669|      0|            break;
  670|      0|        case SPNG_FMT_RGB8:
  ------------------
  |  Branch (670:9): [True: 0, False: 7.03k]
  ------------------
  671|      0|            bytes_per_pixel = 3;
  672|      0|            break;
  673|  7.03k|        case SPNG_FMT_PNG:
  ------------------
  |  Branch (673:9): [True: 7.03k, False: 0]
  ------------------
  674|  7.03k|        case SPNG_FMT_RAW:
  ------------------
  |  Branch (674:9): [True: 0, False: 7.03k]
  ------------------
  675|  7.03k|        {
  676|  7.03k|            int ret = calculate_scanline_width(ihdr, ihdr->width, &res);
  677|  7.03k|            if(ret) return ret;
  ------------------
  |  Branch (677:16): [True: 0, False: 7.03k]
  ------------------
  678|       |
  679|  7.03k|            res -= 1; /* exclude filter byte */
  680|  7.03k|            bytes_per_pixel = 1;
  681|  7.03k|            break;
  682|  7.03k|        }
  683|      0|        case SPNG_FMT_G8:
  ------------------
  |  Branch (683:9): [True: 0, False: 7.03k]
  ------------------
  684|      0|            bytes_per_pixel = 1;
  685|      0|            break;
  686|      0|        case SPNG_FMT_GA8:
  ------------------
  |  Branch (686:9): [True: 0, False: 7.03k]
  ------------------
  687|      0|            bytes_per_pixel = 2;
  688|      0|            break;
  689|      0|        default: return SPNG_EINTERNAL;
  ------------------
  |  Branch (689:9): [True: 0, False: 7.03k]
  ------------------
  690|  7.03k|    }
  691|       |
  692|  7.03k|    if(res > SIZE_MAX / bytes_per_pixel) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (692:8): [True: 0, False: 7.03k]
  ------------------
  693|  7.03k|    res = res * bytes_per_pixel;
  694|       |
  695|  7.03k|    *len = res;
  696|       |
  697|  7.03k|    return 0;
  698|  7.03k|}
spng.c:calculate_scanline_width:
  566|  53.9k|{
  567|  53.9k|    if(ihdr == NULL || !width) return SPNG_EINTERNAL;
  ------------------
  |  Branch (567:8): [True: 0, False: 53.9k]
  |  Branch (567:24): [True: 0, False: 53.9k]
  ------------------
  568|       |
  569|  53.9k|    size_t res = num_channels(ihdr) * ihdr->bit_depth;
  570|       |
  571|  53.9k|    if(res > SIZE_MAX / width) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (571:8): [True: 0, False: 53.9k]
  ------------------
  572|  53.9k|    res = res * width;
  573|       |
  574|  53.9k|    res += 15; /* Filter byte + 7 for rounding */
  575|       |
  576|  53.9k|    if(res < 15) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (576:8): [True: 0, False: 53.9k]
  ------------------
  577|       |
  578|  53.9k|    res /= 8;
  579|       |
  580|  53.9k|    if(res > UINT32_MAX) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (580:8): [True: 28, False: 53.9k]
  ------------------
  581|       |
  582|  53.9k|    *scanline_width = res;
  583|       |
  584|  53.9k|    return 0;
  585|  53.9k|}
spng.c:read_idat_bytes:
 1364|  29.8k|{
 1365|  29.8k|    if(ctx == NULL || bytes_read == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1365:8): [True: 0, False: 29.8k]
  |  Branch (1365:23): [True: 0, False: 29.8k]
  ------------------
 1366|  29.8k|    if(memcmp(ctx->current_chunk.type, type_idat, 4)) return SPNG_EIDAT_TOO_SHORT;
  ------------------
  |  Branch (1366:8): [True: 0, False: 29.8k]
  ------------------
 1367|       |
 1368|  29.8k|    int ret;
 1369|  29.8k|    uint32_t len;
 1370|       |
 1371|  50.3k|    while(!ctx->cur_chunk_bytes_left)
  ------------------
  |  Branch (1371:11): [True: 22.3k, False: 27.9k]
  ------------------
 1372|  22.3k|    {
 1373|  22.3k|        ret = read_header(ctx);
 1374|  22.3k|        if(ret) return ret;
  ------------------
  |  Branch (1374:12): [True: 1.76k, False: 20.6k]
  ------------------
 1375|       |
 1376|  20.6k|        if(memcmp(ctx->current_chunk.type, type_idat, 4)) return SPNG_EIDAT_TOO_SHORT;
  ------------------
  |  Branch (1376:12): [True: 115, False: 20.5k]
  ------------------
 1377|  20.6k|    }
 1378|       |
 1379|  27.9k|    if(ctx->streaming)
  ------------------
  |  Branch (1379:8): [True: 27.9k, False: 0]
  ------------------
 1380|  27.9k|    {/* TODO: estimate bytes to read for progressive reads */
 1381|  27.9k|        len = SPNG_READ_SIZE;
  ------------------
  |  |   30|  27.9k|#define SPNG_READ_SIZE (8192)
  ------------------
 1382|  27.9k|        if(len > ctx->cur_chunk_bytes_left) len = ctx->cur_chunk_bytes_left;
  ------------------
  |  Branch (1382:12): [True: 26.5k, False: 1.39k]
  ------------------
 1383|  27.9k|    }
 1384|      0|    else len = ctx->current_chunk.length;
 1385|       |
 1386|  27.9k|    ret = read_chunk_bytes(ctx, len);
 1387|       |
 1388|  27.9k|    *bytes_read = len;
 1389|       |
 1390|  27.9k|    return ret;
 1391|  29.8k|}
spng.c:read_u16:
  442|  3.17M|{
  443|  3.17M|    const unsigned char *data = src;
  444|       |
  445|  3.17M|    return (data[0] & 0xFFU) << 8 | (data[1] & 0xFFU);
  446|  3.17M|}
spng.c:spng__inflate_init:
 1185|  65.3k|{
 1186|  65.3k|    if(ctx->zstream.state) inflateEnd(&ctx->zstream);
  ------------------
  |  Branch (1186:8): [True: 51.6k, False: 13.6k]
  ------------------
 1187|       |
 1188|  65.3k|    ctx->inflate = 1;
 1189|       |
 1190|  65.3k|    ctx->zstream.zalloc = spng__zalloc;
 1191|  65.3k|    ctx->zstream.zfree = spng__zfree;
 1192|  65.3k|    ctx->zstream.opaque = ctx;
 1193|       |
 1194|  65.3k|    if(inflateInit2(&ctx->zstream, window_bits) != Z_OK) return SPNG_EZLIB_INIT;
  ------------------
  |  | 1940|  65.3k|          inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
  |  |  ------------------
  |  |  |  |   44|  65.3k|#define ZLIB_VERSION "1.3.2"
  |  |  ------------------
  |  | 1941|  65.3k|                        (int)sizeof(z_stream))
  ------------------
                  if(inflateInit2(&ctx->zstream, window_bits) != Z_OK) return SPNG_EZLIB_INIT;
  ------------------
  |  |  181|  65.3k|#define Z_OK            0
  ------------------
  |  Branch (1194:8): [True: 0, False: 65.3k]
  ------------------
 1195|       |
 1196|  65.3k|#if ZLIB_VERNUM >= 0x1290 && !defined(SPNG_USE_MINIZ)
 1197|       |
 1198|  65.3k|    int validate = 1;
 1199|       |
 1200|  65.3k|    if(ctx->flags & SPNG_CTX_IGNORE_ADLER32) validate = 0;
  ------------------
  |  Branch (1200:8): [True: 0, False: 65.3k]
  ------------------
 1201|       |
 1202|  65.3k|    if(is_critical_chunk(&ctx->current_chunk))
  ------------------
  |  Branch (1202:8): [True: 6.78k, False: 58.5k]
  ------------------
 1203|  6.78k|    {
 1204|  6.78k|        if(ctx->crc_action_critical == SPNG_CRC_USE) validate = 0;
  ------------------
  |  Branch (1204:12): [True: 0, False: 6.78k]
  ------------------
 1205|  6.78k|    }
 1206|  58.5k|    else /* ancillary */
 1207|  58.5k|    {
 1208|  58.5k|        if(ctx->crc_action_ancillary == SPNG_CRC_USE) validate = 0;
  ------------------
  |  Branch (1208:12): [True: 0, False: 58.5k]
  ------------------
 1209|  58.5k|    }
 1210|       |
 1211|  65.3k|    if(inflateValidate(&ctx->zstream, validate)) return SPNG_EZLIB_INIT;
  ------------------
  |  Branch (1211:8): [True: 0, False: 65.3k]
  ------------------
 1212|       |
 1213|       |#else /* This requires zlib >= 1.2.11 */
 1214|       |#if 0 /* libjpeg-turbo: Silence warning */
 1215|       |    #pragma message ("inflateValidate() not available, SPNG_CTX_IGNORE_ADLER32 will be ignored")
 1216|       |#endif
 1217|       |#endif
 1218|       |
 1219|  65.3k|    return 0;
 1220|  65.3k|}
spng.c:spng__zalloc:
  425|  76.5k|{
  426|  76.5k|    spng_ctx *ctx = opaque;
  427|       |
  428|  76.5k|    if(size > SIZE_MAX / items) return NULL;
  ------------------
  |  Branch (428:8): [True: 0, False: 76.5k]
  ------------------
  429|       |
  430|  76.5k|    size_t len = (size_t)items * size;
  431|       |
  432|  76.5k|    return spng__malloc(ctx, len);
  433|  76.5k|}
spng.c:spng__zfree:
  436|  76.5k|{
  437|  76.5k|    spng_ctx *ctx = opqaue;
  438|  76.5k|    spng__free(ctx, ptr);
  439|  76.5k|}
spng.c:spng__malloc:
  401|   274k|{
  402|   274k|    return ctx->alloc.malloc_fn(size);
  403|   274k|}
spng.c:sample_to_target:
 1717|   201k|{
 1718|   201k|    if(bit_depth == sbits)
  ------------------
  |  Branch (1718:8): [True: 201k, False: 0]
  ------------------
 1719|   201k|    {
 1720|   201k|        if(target == sbits) return sample; /* No scaling */
  ------------------
  |  Branch (1720:12): [True: 201k, False: 0]
  ------------------
 1721|   201k|    }/* bit_depth > sbits */
 1722|      0|    else sample = sample >> (bit_depth - sbits); /* Shift significant bits to bottom */
 1723|       |
 1724|       |    /* Downscale */
 1725|      0|    if(target < sbits) return sample >> (sbits - target);
  ------------------
  |  Branch (1725:8): [True: 0, False: 0]
  ------------------
 1726|       |
 1727|       |    /* Upscale using left bit replication */
 1728|      0|    int8_t shift_amount = target - sbits;
 1729|      0|    uint16_t sample_bits = sample;
 1730|      0|    sample = 0;
 1731|       |
 1732|      0|    while(shift_amount >= 0)
  ------------------
  |  Branch (1732:11): [True: 0, False: 0]
  ------------------
 1733|      0|    {
 1734|      0|        sample = sample | (sample_bits << shift_amount);
 1735|      0|        shift_amount -= sbits;
 1736|      0|    }
 1737|       |
 1738|      0|    int8_t partial = shift_amount + (int8_t)sbits;
 1739|       |
 1740|      0|    if(partial != 0) sample = sample | (sample_bits >> abs(shift_amount));
  ------------------
  |  Branch (1740:8): [True: 0, False: 0]
  ------------------
 1741|       |
 1742|      0|    return sample;
 1743|      0|}
spng.c:read_scanline_bytes:
 1394|   383k|{
 1395|   383k|    if(ctx == NULL || dest == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1395:8): [True: 0, False: 383k]
  |  Branch (1395:23): [True: 0, False: 383k]
  ------------------
 1396|       |
 1397|   383k|    int ret = Z_OK;
  ------------------
  |  |  181|   383k|#define Z_OK            0
  ------------------
 1398|   383k|    uint32_t bytes_read;
 1399|       |
 1400|   383k|    z_stream *zstream = &ctx->zstream;
 1401|       |
 1402|   383k|    zstream->avail_out = (uInt)len;
 1403|   383k|    zstream->next_out = dest;
 1404|       |
 1405|   806k|    while(zstream->avail_out != 0)
  ------------------
  |  Branch (1405:11): [True: 426k, False: 379k]
  ------------------
 1406|   426k|    {
 1407|   426k|        ret = inflate(zstream, Z_NO_FLUSH);
  ------------------
  |  |  172|   426k|#define Z_NO_FLUSH      0
  ------------------
 1408|       |
 1409|   426k|        if(ret == Z_OK) continue;
  ------------------
  |  |  181|   426k|#define Z_OK            0
  ------------------
  |  Branch (1409:12): [True: 401k, False: 25.0k]
  ------------------
 1410|       |
 1411|  25.0k|        if(ret == Z_STREAM_END) /* Reached an end-marker */
  ------------------
  |  |  182|  25.0k|#define Z_STREAM_END    1
  ------------------
  |  Branch (1411:12): [True: 899, False: 24.1k]
  ------------------
 1412|    899|        {
 1413|    899|            if(zstream->avail_out != 0) return SPNG_EIDAT_TOO_SHORT;
  ------------------
  |  Branch (1413:16): [True: 13, False: 886]
  ------------------
 1414|    899|        }
 1415|  24.1k|        else if(ret == Z_BUF_ERROR) /* Read more IDAT bytes */
  ------------------
  |  |  188|  24.1k|#define Z_BUF_ERROR    (-5)
  ------------------
  |  Branch (1415:17): [True: 22.7k, False: 1.34k]
  ------------------
 1416|  22.7k|        {
 1417|  22.7k|            ret = read_idat_bytes(ctx, &bytes_read);
 1418|  22.7k|            if(ret) return ret;
  ------------------
  |  Branch (1418:16): [True: 2.10k, False: 20.6k]
  ------------------
 1419|       |
 1420|  20.6k|            zstream->avail_in = bytes_read;
 1421|  20.6k|            zstream->next_in = ctx->data;
 1422|  20.6k|        }
 1423|  1.34k|        else return SPNG_EIDAT_STREAM;
 1424|  25.0k|    }
 1425|       |
 1426|   379k|    return 0;
 1427|   383k|}
spng.c:calculate_subimages:
  588|  26.9k|{
  589|  26.9k|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (589:8): [True: 0, False: 26.9k]
  ------------------
  590|       |
  591|  26.9k|    struct spng_ihdr *ihdr = &ctx->ihdr;
  592|  26.9k|    struct spng_subimage *sub = ctx->subimage;
  593|       |
  594|  26.9k|    if(ihdr->interlace_method == 1)
  ------------------
  |  Branch (594:8): [True: 3.43k, False: 23.5k]
  ------------------
  595|  3.43k|    {
  596|  3.43k|        sub[0].width = (ihdr->width + 7) >> 3;
  597|  3.43k|        sub[0].height = (ihdr->height + 7) >> 3;
  598|  3.43k|        sub[1].width = (ihdr->width + 3) >> 3;
  599|  3.43k|        sub[1].height = (ihdr->height + 7) >> 3;
  600|  3.43k|        sub[2].width = (ihdr->width + 3) >> 2;
  601|  3.43k|        sub[2].height = (ihdr->height + 3) >> 3;
  602|  3.43k|        sub[3].width = (ihdr->width + 1) >> 2;
  603|  3.43k|        sub[3].height = (ihdr->height + 3) >> 2;
  604|  3.43k|        sub[4].width = (ihdr->width + 1) >> 1;
  605|  3.43k|        sub[4].height = (ihdr->height + 1) >> 2;
  606|  3.43k|        sub[5].width = ihdr->width >> 1;
  607|  3.43k|        sub[5].height = (ihdr->height + 1) >> 1;
  608|  3.43k|        sub[6].width = ihdr->width;
  609|  3.43k|        sub[6].height = ihdr->height >> 1;
  610|  3.43k|    }
  611|  23.5k|    else
  612|  23.5k|    {
  613|  23.5k|        sub[0].width = ihdr->width;
  614|  23.5k|        sub[0].height = ihdr->height;
  615|  23.5k|    }
  616|       |
  617|  26.9k|    int i;
  618|   215k|    for(i=0; i < 7; i++)
  ------------------
  |  Branch (618:14): [True: 188k, False: 26.9k]
  ------------------
  619|   188k|    {
  620|   188k|        if(sub[i].width == 0 || sub[i].height == 0) continue;
  ------------------
  |  Branch (620:12): [True: 141k, False: 47.0k]
  |  Branch (620:33): [True: 105, False: 46.9k]
  ------------------
  621|       |
  622|  46.9k|        int ret = calculate_scanline_width(ihdr, sub[i].width, &sub[i].scanline_width);
  623|  46.9k|        if(ret) return ret;
  ------------------
  |  Branch (623:12): [True: 28, False: 46.8k]
  ------------------
  624|       |
  625|  46.8k|        if(sub[ctx->widest_pass].scanline_width < sub[i].scanline_width) ctx->widest_pass = i;
  ------------------
  |  Branch (625:12): [True: 9.54k, False: 37.3k]
  ------------------
  626|       |
  627|  46.8k|        ctx->last_pass = i;
  628|  46.8k|    }
  629|       |
  630|  26.9k|    return 0;
  631|  26.9k|}
spng.c:num_channels:
  551|  71.1k|{
  552|  71.1k|    switch(ihdr->color_type)
  553|  71.1k|    {
  554|  28.0k|        case SPNG_COLOR_TYPE_TRUECOLOR: return 3;
  ------------------
  |  Branch (554:9): [True: 28.0k, False: 43.0k]
  ------------------
  555|  2.63k|        case SPNG_COLOR_TYPE_GRAYSCALE_ALPHA: return 2;
  ------------------
  |  Branch (555:9): [True: 2.63k, False: 68.4k]
  ------------------
  556|  9.01k|        case SPNG_COLOR_TYPE_TRUECOLOR_ALPHA: return 4;
  ------------------
  |  Branch (556:9): [True: 9.01k, False: 62.0k]
  ------------------
  557|  25.1k|        case SPNG_COLOR_TYPE_GRAYSCALE:
  ------------------
  |  Branch (557:9): [True: 25.1k, False: 45.9k]
  ------------------
  558|  31.3k|        case SPNG_COLOR_TYPE_INDEXED:
  ------------------
  |  Branch (558:9): [True: 6.23k, False: 64.8k]
  ------------------
  559|  31.3k|            return 1;
  560|      0|        default: return 0;
  ------------------
  |  Branch (560:9): [True: 0, False: 71.1k]
  ------------------
  561|  71.1k|    }
  562|  71.1k|}
spng.c:spng__free:
  416|   601k|{
  417|   601k|    ctx->alloc.free_fn(ptr);
  418|   601k|}
spng.c:file_read_fn:
 5032|  1.19M|{
 5033|  1.19M|    FILE *file = user;
 5034|  1.19M|    (void)ctx;
 5035|       |
 5036|  1.19M|    if(fread(data, n, 1, file) != 1)
  ------------------
  |  Branch (5036:8): [True: 26.7k, False: 1.17M]
  ------------------
 5037|  26.7k|    {
 5038|  26.7k|        if(feof(file)) return SPNG_IO_EOF;
  ------------------
  |  Branch (5038:12): [True: 26.7k, False: 0]
  ------------------
 5039|      0|        else return SPNG_IO_ERROR;
 5040|  26.7k|    }
 5041|       |
 5042|  1.17M|    return 0;
 5043|  1.19M|}
spng.c:check_ihdr:
 2035|  27.7k|{
 2036|  27.7k|    if(ihdr->width > spng_u32max || !ihdr->width) return SPNG_EWIDTH;
  ------------------
  |  Branch (2036:8): [True: 217, False: 27.5k]
  |  Branch (2036:37): [True: 7, False: 27.5k]
  ------------------
 2037|  27.5k|    if(ihdr->height > spng_u32max || !ihdr->height) return SPNG_EHEIGHT;
  ------------------
  |  Branch (2037:8): [True: 168, False: 27.3k]
  |  Branch (2037:38): [True: 7, False: 27.3k]
  ------------------
 2038|       |
 2039|  27.3k|    if(ihdr->width > max_width) return SPNG_EUSER_WIDTH;
  ------------------
  |  Branch (2039:8): [True: 0, False: 27.3k]
  ------------------
 2040|  27.3k|    if(ihdr->height > max_height) return SPNG_EUSER_HEIGHT;
  ------------------
  |  Branch (2040:8): [True: 0, False: 27.3k]
  ------------------
 2041|       |
 2042|  27.3k|    switch(ihdr->color_type)
 2043|  27.3k|    {
 2044|  11.1k|        case SPNG_COLOR_TYPE_GRAYSCALE:
  ------------------
  |  Branch (2044:9): [True: 11.1k, False: 16.1k]
  ------------------
 2045|  11.1k|        {
 2046|  11.1k|            if( !(ihdr->bit_depth == 1 || ihdr->bit_depth == 2 ||
  ------------------
  |  Branch (2046:19): [True: 3.38k, False: 7.77k]
  |  Branch (2046:43): [True: 917, False: 6.86k]
  ------------------
 2047|  6.86k|                  ihdr->bit_depth == 4 || ihdr->bit_depth == 8 ||
  ------------------
  |  Branch (2047:19): [True: 1.65k, False: 5.20k]
  |  Branch (2047:43): [True: 3.92k, False: 1.28k]
  ------------------
 2048|  1.28k|                  ihdr->bit_depth == 16) )
  ------------------
  |  Branch (2048:19): [True: 1.19k, False: 91]
  ------------------
 2049|     91|                  return SPNG_EBIT_DEPTH;
 2050|       |
 2051|  11.0k|            break;
 2052|  11.1k|        }
 2053|  11.0k|        case SPNG_COLOR_TYPE_TRUECOLOR:
  ------------------
  |  Branch (2053:9): [True: 7.61k, False: 19.7k]
  ------------------
 2054|  8.33k|        case SPNG_COLOR_TYPE_GRAYSCALE_ALPHA:
  ------------------
  |  Branch (2054:9): [True: 721, False: 26.6k]
  ------------------
 2055|  11.6k|        case SPNG_COLOR_TYPE_TRUECOLOR_ALPHA:
  ------------------
  |  Branch (2055:9): [True: 3.31k, False: 24.0k]
  ------------------
 2056|  11.6k|        {
 2057|  11.6k|            if( !(ihdr->bit_depth == 8 || ihdr->bit_depth == 16) )
  ------------------
  |  Branch (2057:19): [True: 8.34k, False: 3.31k]
  |  Branch (2057:43): [True: 3.24k, False: 63]
  ------------------
 2058|     63|                return SPNG_EBIT_DEPTH;
 2059|       |
 2060|  11.5k|            break;
 2061|  11.6k|        }
 2062|  11.5k|        case SPNG_COLOR_TYPE_INDEXED:
  ------------------
  |  Branch (2062:9): [True: 4.45k, False: 22.8k]
  ------------------
 2063|  4.45k|        {
 2064|  4.45k|            if( !(ihdr->bit_depth == 1 || ihdr->bit_depth == 2 ||
  ------------------
  |  Branch (2064:19): [True: 2.07k, False: 2.38k]
  |  Branch (2064:43): [True: 476, False: 1.91k]
  ------------------
 2065|  1.91k|                  ihdr->bit_depth == 4 || ihdr->bit_depth == 8) )
  ------------------
  |  Branch (2065:19): [True: 1.36k, False: 546]
  |  Branch (2065:43): [True: 483, False: 63]
  ------------------
 2066|     63|                return SPNG_EBIT_DEPTH;
 2067|       |
 2068|  4.39k|            break;
 2069|  4.45k|        }
 2070|  4.39k|        default: return SPNG_ECOLOR_TYPE;
  ------------------
  |  Branch (2070:9): [True: 49, False: 27.2k]
  ------------------
 2071|  27.3k|    }
 2072|       |
 2073|  27.0k|    if(ihdr->compression_method) return SPNG_ECOMPRESSION_METHOD;
  ------------------
  |  Branch (2073:8): [True: 49, False: 27.0k]
  ------------------
 2074|  27.0k|    if(ihdr->filter_method) return SPNG_EFILTER_METHOD;
  ------------------
  |  Branch (2074:8): [True: 42, False: 26.9k]
  ------------------
 2075|       |
 2076|  26.9k|    if(ihdr->interlace_method > 1) return SPNG_EINTERLACE_METHOD;
  ------------------
  |  Branch (2076:8): [True: 35, False: 26.9k]
  ------------------
 2077|       |
 2078|  26.9k|    return 0;
 2079|  26.9k|}
spng.c:check_plte:
 2082|  1.26k|{
 2083|  1.26k|    if(plte == NULL || ihdr == NULL) return 1;
  ------------------
  |  Branch (2083:8): [True: 0, False: 1.26k]
  |  Branch (2083:24): [True: 0, False: 1.26k]
  ------------------
 2084|       |
 2085|  1.26k|    if(plte->n_entries == 0) return 1;
  ------------------
  |  Branch (2085:8): [True: 0, False: 1.26k]
  ------------------
 2086|  1.26k|    if(plte->n_entries > 256) return 1;
  ------------------
  |  Branch (2086:8): [True: 119, False: 1.14k]
  ------------------
 2087|       |
 2088|  1.14k|    if(ihdr->color_type == SPNG_COLOR_TYPE_INDEXED)
  ------------------
  |  Branch (2088:8): [True: 721, False: 420]
  ------------------
 2089|    721|    {
 2090|    721|        if(plte->n_entries > (1U << ihdr->bit_depth)) return 1;
  ------------------
  |  Branch (2090:12): [True: 35, False: 686]
  ------------------
 2091|    721|    }
 2092|       |
 2093|  1.10k|    return 0;
 2094|  1.14k|}
spng.c:check_chrm_int:
 2144|  1.90k|{
 2145|  1.90k|    if(chrm_int == NULL) return 1;
  ------------------
  |  Branch (2145:8): [True: 0, False: 1.90k]
  ------------------
 2146|       |
 2147|  1.90k|    if(chrm_int->white_point_x > spng_u32max ||
  ------------------
  |  Branch (2147:8): [True: 126, False: 1.77k]
  ------------------
 2148|  1.77k|       chrm_int->white_point_y > spng_u32max ||
  ------------------
  |  Branch (2148:8): [True: 119, False: 1.65k]
  ------------------
 2149|  1.65k|       chrm_int->red_x > spng_u32max ||
  ------------------
  |  Branch (2149:8): [True: 203, False: 1.45k]
  ------------------
 2150|  1.45k|       chrm_int->red_y > spng_u32max ||
  ------------------
  |  Branch (2150:8): [True: 161, False: 1.29k]
  ------------------
 2151|  1.29k|       chrm_int->green_x  > spng_u32max ||
  ------------------
  |  Branch (2151:8): [True: 126, False: 1.16k]
  ------------------
 2152|  1.16k|       chrm_int->green_y  > spng_u32max ||
  ------------------
  |  Branch (2152:8): [True: 140, False: 1.02k]
  ------------------
 2153|  1.02k|       chrm_int->blue_x > spng_u32max ||
  ------------------
  |  Branch (2153:8): [True: 84, False: 945]
  ------------------
 2154|  1.23k|       chrm_int->blue_y > spng_u32max) return SPNG_ECHRM;
  ------------------
  |  Branch (2154:8): [True: 280, False: 665]
  ------------------
 2155|       |
 2156|    665|    return 0;
 2157|  1.90k|}
spng.c:check_png_keyword:
 2211|   121k|{
 2212|   121k|    if(str == NULL) return 1;
  ------------------
  |  Branch (2212:8): [True: 0, False: 121k]
  ------------------
 2213|   121k|    size_t len = strlen(str);
 2214|   121k|    const char *end = str + len;
 2215|       |
 2216|   121k|    if(!len) return 1;
  ------------------
  |  Branch (2216:8): [True: 59.9k, False: 61.1k]
  ------------------
 2217|  61.1k|    if(len > 79) return 1;
  ------------------
  |  Branch (2217:8): [True: 0, False: 61.1k]
  ------------------
 2218|  61.1k|    if(str[0] == ' ') return 1; /* Leading space */
  ------------------
  |  Branch (2218:8): [True: 126, False: 61.0k]
  ------------------
 2219|  61.0k|    if(end[-1] == ' ') return 1; /* Trailing space */
  ------------------
  |  Branch (2219:8): [True: 63, False: 60.9k]
  ------------------
 2220|  60.9k|    if(strstr(str, "  ") != NULL) return 1; /* Consecutive spaces */
  ------------------
  |  Branch (2220:8): [True: 77, False: 60.9k]
  ------------------
 2221|       |
 2222|  60.9k|    uint8_t c;
 2223|   236k|    while(str != end)
  ------------------
  |  Branch (2223:11): [True: 179k, False: 56.2k]
  ------------------
 2224|   179k|    {
 2225|   179k|        memcpy(&c, str, 1);
 2226|       |
 2227|   179k|        if( (c >= 32 && c <= 126) || (c >= 161) ) str++;
  ------------------
  |  Branch (2227:14): [True: 175k, False: 4.29k]
  |  Branch (2227:25): [True: 139k, False: 35.9k]
  |  Branch (2227:38): [True: 35.5k, False: 4.66k]
  ------------------
 2228|  4.66k|        else return 1; /* Invalid character */
 2229|   179k|    }
 2230|       |
 2231|  56.2k|    return 0;
 2232|  60.9k|}
spng.c:check_sbit:
 2097|  3.11k|{
 2098|  3.11k|    if(sbit == NULL || ihdr == NULL) return 1;
  ------------------
  |  Branch (2098:8): [True: 0, False: 3.11k]
  |  Branch (2098:24): [True: 0, False: 3.11k]
  ------------------
 2099|       |
 2100|  3.11k|    if(ihdr->color_type == 0)
  ------------------
  |  Branch (2100:8): [True: 1.42k, False: 1.69k]
  ------------------
 2101|  1.42k|    {
 2102|  1.42k|        if(sbit->grayscale_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2102:12): [True: 686, False: 735]
  ------------------
 2103|    735|        if(sbit->grayscale_bits > ihdr->bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2103:12): [True: 707, False: 28]
  ------------------
 2104|    735|    }
 2105|  1.69k|    else if(ihdr->color_type == 2 || ihdr->color_type == 3)
  ------------------
  |  Branch (2105:13): [True: 189, False: 1.50k]
  |  Branch (2105:38): [True: 420, False: 1.08k]
  ------------------
 2106|    609|    {
 2107|    609|        if(sbit->red_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2107:12): [True: 77, False: 532]
  ------------------
 2108|    532|        if(sbit->green_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2108:12): [True: 133, False: 399]
  ------------------
 2109|    399|        if(sbit->blue_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2109:12): [True: 21, False: 378]
  ------------------
 2110|       |
 2111|    378|        uint8_t bit_depth;
 2112|    378|        if(ihdr->color_type == 3) bit_depth = 8;
  ------------------
  |  Branch (2112:12): [True: 245, False: 133]
  ------------------
 2113|    133|        else bit_depth = ihdr->bit_depth;
 2114|       |
 2115|    378|        if(sbit->red_bits > bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2115:12): [True: 70, False: 308]
  ------------------
 2116|    308|        if(sbit->green_bits > bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2116:12): [True: 161, False: 147]
  ------------------
 2117|    147|        if(sbit->blue_bits > bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2117:12): [True: 126, False: 21]
  ------------------
 2118|    147|    }
 2119|  1.08k|    else if(ihdr->color_type == 4)
  ------------------
  |  Branch (2119:13): [True: 189, False: 896]
  ------------------
 2120|    189|    {
 2121|    189|        if(sbit->grayscale_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2121:12): [True: 42, False: 147]
  ------------------
 2122|    147|        if(sbit->alpha_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2122:12): [True: 42, False: 105]
  ------------------
 2123|       |
 2124|    105|        if(sbit->grayscale_bits > ihdr->bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2124:12): [True: 63, False: 42]
  ------------------
 2125|     42|        if(sbit->alpha_bits > ihdr->bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2125:12): [True: 35, False: 7]
  ------------------
 2126|     42|    }
 2127|    896|    else if(ihdr->color_type == 6)
  ------------------
  |  Branch (2127:13): [True: 896, False: 0]
  ------------------
 2128|    896|    {
 2129|    896|        if(sbit->red_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2129:12): [True: 343, False: 553]
  ------------------
 2130|    553|        if(sbit->green_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2130:12): [True: 42, False: 511]
  ------------------
 2131|    511|        if(sbit->blue_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2131:12): [True: 84, False: 427]
  ------------------
 2132|    427|        if(sbit->alpha_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2132:12): [True: 49, False: 378]
  ------------------
 2133|       |
 2134|    378|        if(sbit->red_bits > ihdr->bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2134:12): [True: 56, False: 322]
  ------------------
 2135|    322|        if(sbit->green_bits > ihdr->bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2135:12): [True: 98, False: 224]
  ------------------
 2136|    224|        if(sbit->blue_bits > ihdr->bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2136:12): [True: 91, False: 133]
  ------------------
 2137|    133|        if(sbit->alpha_bits > ihdr->bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2137:12): [True: 70, False: 63]
  ------------------
 2138|    133|    }
 2139|       |
 2140|    119|    return 0;
 2141|  3.11k|}
spng.c:spng__calloc:
  406|  55.0k|{
  407|  55.0k|    return ctx->alloc.calloc_fn(nmemb, size);
  408|  55.0k|}
spng.c:check_phys:
 2160|  4.17k|{
 2161|  4.17k|    if(phys == NULL) return 1;
  ------------------
  |  Branch (2161:8): [True: 0, False: 4.17k]
  ------------------
 2162|       |
 2163|  4.17k|    if(phys->unit_specifier > 1) return SPNG_EPHYS;
  ------------------
  |  Branch (2163:8): [True: 2.23k, False: 1.94k]
  ------------------
 2164|       |
 2165|  1.94k|    if(phys->ppu_x > spng_u32max) return SPNG_EPHYS;
  ------------------
  |  Branch (2165:8): [True: 189, False: 1.75k]
  ------------------
 2166|  1.75k|    if(phys->ppu_y > spng_u32max) return SPNG_EPHYS;
  ------------------
  |  Branch (2166:8): [True: 154, False: 1.60k]
  ------------------
 2167|       |
 2168|  1.60k|    return 0;
 2169|  1.75k|}
spng.c:check_time:
 2172|  5.10k|{
 2173|  5.10k|    if(time == NULL) return 1;
  ------------------
  |  Branch (2173:8): [True: 0, False: 5.10k]
  ------------------
 2174|       |
 2175|  5.10k|    if(time->month == 0 || time->month > 12) return 1;
  ------------------
  |  Branch (2175:8): [True: 3.66k, False: 1.44k]
  |  Branch (2175:28): [True: 133, False: 1.30k]
  ------------------
 2176|  1.30k|    if(time->day == 0 || time->day > 31) return 1;
  ------------------
  |  Branch (2176:8): [True: 112, False: 1.19k]
  |  Branch (2176:26): [True: 77, False: 1.12k]
  ------------------
 2177|  1.12k|    if(time->hour > 23) return 1;
  ------------------
  |  Branch (2177:8): [True: 98, False: 1.02k]
  ------------------
 2178|  1.02k|    if(time->minute > 59) return 1;
  ------------------
  |  Branch (2178:8): [True: 42, False: 980]
  ------------------
 2179|    980|    if(time->second > 60) return 1;
  ------------------
  |  Branch (2179:8): [True: 119, False: 861]
  ------------------
 2180|       |
 2181|    861|    return 0;
 2182|    980|}
spng.c:check_offs:
 2185|    189|{
 2186|    189|    if(offs == NULL) return 1;
  ------------------
  |  Branch (2186:8): [True: 0, False: 189]
  ------------------
 2187|       |
 2188|    189|    if(offs->unit_specifier > 1) return 1;
  ------------------
  |  Branch (2188:8): [True: 105, False: 84]
  ------------------
 2189|       |
 2190|     84|    return 0;
 2191|    189|}
spng.c:check_exif:
 2194|    259|{
 2195|    259|    if(exif == NULL) return 1;
  ------------------
  |  Branch (2195:8): [True: 0, False: 259]
  ------------------
 2196|    259|    if(exif->data == NULL) return 1;
  ------------------
  |  Branch (2196:8): [True: 0, False: 259]
  ------------------
 2197|       |
 2198|    259|    if(exif->length < 4) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2198:8): [True: 42, False: 217]
  ------------------
 2199|    217|    if(exif->length > spng_u32max) return SPNG_ECHUNK_STDLEN;
  ------------------
  |  Branch (2199:8): [True: 0, False: 217]
  ------------------
 2200|       |
 2201|    217|    const uint8_t exif_le[4] = { 73, 73, 42, 0 };
 2202|    217|    const uint8_t exif_be[4] = { 77, 77, 0, 42 };
 2203|       |
 2204|    217|    if(memcmp(exif->data, exif_le, 4) && memcmp(exif->data, exif_be, 4)) return 1;
  ------------------
  |  Branch (2204:8): [True: 210, False: 7]
  |  Branch (2204:42): [True: 203, False: 7]
  ------------------
 2205|       |
 2206|     14|    return 0;
 2207|    217|}

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

crc32_z:
  626|  1.19M|uLong ZEXPORT crc32_z(uLong crc, const unsigned char FAR *buf, z_size_t len) {
  627|       |    /* Return initial CRC, if requested. */
  628|  1.19M|    if (buf == Z_NULL) return 0;
  ------------------
  |  |  216|  1.19M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (628:9): [True: 437k, False: 756k]
  ------------------
  629|       |
  630|       |#ifdef DYNAMIC_CRC_TABLE
  631|       |    z_once(&made, make_crc_table);
  632|       |#endif /* DYNAMIC_CRC_TABLE */
  633|       |
  634|       |    /* Pre-condition the CRC */
  635|   756k|    crc = (~crc) & 0xffffffff;
  636|       |
  637|   756k|#ifdef W
  638|       |
  639|       |    /* If provided enough bytes, do a braided CRC calculation. */
  640|   756k|    if (len >= N * W + W - 1) {
  ------------------
  |  |   64|   756k|#  define N 5
  ------------------
                  if (len >= N * W + W - 1) {
  ------------------
  |  |   90|   756k|#      define W 8
  ------------------
                  if (len >= N * W + W - 1) {
  ------------------
  |  |   90|   756k|#      define W 8
  ------------------
  |  Branch (640:9): [True: 79.3k, False: 677k]
  ------------------
  641|  79.3k|        z_size_t blks;
  642|  79.3k|        z_word_t const *words;
  643|  79.3k|        unsigned endian;
  644|  79.3k|        int k;
  645|       |
  646|       |        /* Compute the CRC up to a z_word_t boundary. */
  647|  79.3k|        while (len && ((z_size_t)buf & (W - 1)) != 0) {
  ------------------
  |  |   90|  79.3k|#      define W 8
  ------------------
  |  Branch (647:16): [True: 79.3k, False: 0]
  |  Branch (647:23): [True: 0, False: 79.3k]
  ------------------
  648|      0|            len--;
  649|      0|            crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  650|      0|        }
  651|       |
  652|       |        /* Compute the CRC on as many N z_word_t blocks as are available. */
  653|  79.3k|        blks = len / (N * W);
  ------------------
  |  |   64|  79.3k|#  define N 5
  ------------------
                      blks = len / (N * W);
  ------------------
  |  |   90|  79.3k|#      define W 8
  ------------------
  654|  79.3k|        len -= blks * N * W;
  ------------------
  |  |   64|  79.3k|#  define N 5
  ------------------
                      len -= blks * N * W;
  ------------------
  |  |   90|  79.3k|#      define W 8
  ------------------
  655|  79.3k|        words = (z_word_t const *)buf;
  656|       |
  657|       |        /* Do endian check at execution time instead of compile time, since ARM
  658|       |           processors can change the endianness at execution time. If the
  659|       |           compiler knows what the endianness will be, it can optimize out the
  660|       |           check and the unused branch. */
  661|  79.3k|        endian = 1;
  662|  79.3k|        if (*(unsigned char *)&endian) {
  ------------------
  |  Branch (662:13): [True: 79.3k, False: 0]
  ------------------
  663|       |            /* Little endian. */
  664|       |
  665|  79.3k|            z_crc_t crc0;
  666|  79.3k|            z_word_t word0;
  667|  79.3k|#if N > 1
  668|  79.3k|            z_crc_t crc1;
  669|  79.3k|            z_word_t word1;
  670|  79.3k|#if N > 2
  671|  79.3k|            z_crc_t crc2;
  672|  79.3k|            z_word_t word2;
  673|  79.3k|#if N > 3
  674|  79.3k|            z_crc_t crc3;
  675|  79.3k|            z_word_t word3;
  676|  79.3k|#if N > 4
  677|  79.3k|            z_crc_t crc4;
  678|  79.3k|            z_word_t word4;
  679|       |#if N > 5
  680|       |            z_crc_t crc5;
  681|       |            z_word_t word5;
  682|       |#endif
  683|  79.3k|#endif
  684|  79.3k|#endif
  685|  79.3k|#endif
  686|  79.3k|#endif
  687|       |
  688|       |            /* Initialize the CRC for each braid. */
  689|  79.3k|            crc0 = crc;
  690|  79.3k|#if N > 1
  691|  79.3k|            crc1 = 0;
  692|  79.3k|#if N > 2
  693|  79.3k|            crc2 = 0;
  694|  79.3k|#if N > 3
  695|  79.3k|            crc3 = 0;
  696|  79.3k|#if N > 4
  697|  79.3k|            crc4 = 0;
  698|       |#if N > 5
  699|       |            crc5 = 0;
  700|       |#endif
  701|  79.3k|#endif
  702|  79.3k|#endif
  703|  79.3k|#endif
  704|  79.3k|#endif
  705|       |
  706|       |            /*
  707|       |              Process the first blks-1 blocks, computing the CRCs on each braid
  708|       |              independently.
  709|       |             */
  710|  5.82M|            while (--blks) {
  ------------------
  |  Branch (710:20): [True: 5.74M, False: 79.3k]
  ------------------
  711|       |                /* Load the word for each braid into registers. */
  712|  5.74M|                word0 = crc0 ^ words[0];
  713|  5.74M|#if N > 1
  714|  5.74M|                word1 = crc1 ^ words[1];
  715|  5.74M|#if N > 2
  716|  5.74M|                word2 = crc2 ^ words[2];
  717|  5.74M|#if N > 3
  718|  5.74M|                word3 = crc3 ^ words[3];
  719|  5.74M|#if N > 4
  720|  5.74M|                word4 = crc4 ^ words[4];
  721|       |#if N > 5
  722|       |                word5 = crc5 ^ words[5];
  723|       |#endif
  724|  5.74M|#endif
  725|  5.74M|#endif
  726|  5.74M|#endif
  727|  5.74M|#endif
  728|  5.74M|                words += N;
  ------------------
  |  |   64|  5.74M|#  define N 5
  ------------------
  729|       |
  730|       |                /* Compute and update the CRC for each word. The loop should
  731|       |                   get unrolled. */
  732|  5.74M|                crc0 = crc_braid_table[0][word0 & 0xff];
  733|  5.74M|#if N > 1
  734|  5.74M|                crc1 = crc_braid_table[0][word1 & 0xff];
  735|  5.74M|#if N > 2
  736|  5.74M|                crc2 = crc_braid_table[0][word2 & 0xff];
  737|  5.74M|#if N > 3
  738|  5.74M|                crc3 = crc_braid_table[0][word3 & 0xff];
  739|  5.74M|#if N > 4
  740|  5.74M|                crc4 = crc_braid_table[0][word4 & 0xff];
  741|       |#if N > 5
  742|       |                crc5 = crc_braid_table[0][word5 & 0xff];
  743|       |#endif
  744|  5.74M|#endif
  745|  5.74M|#endif
  746|  5.74M|#endif
  747|  5.74M|#endif
  748|  45.9M|                for (k = 1; k < W; k++) {
  ------------------
  |  |   90|  45.9M|#      define W 8
  ------------------
  |  Branch (748:29): [True: 40.2M, False: 5.74M]
  ------------------
  749|  40.2M|                    crc0 ^= crc_braid_table[k][(word0 >> (k << 3)) & 0xff];
  750|  40.2M|#if N > 1
  751|  40.2M|                    crc1 ^= crc_braid_table[k][(word1 >> (k << 3)) & 0xff];
  752|  40.2M|#if N > 2
  753|  40.2M|                    crc2 ^= crc_braid_table[k][(word2 >> (k << 3)) & 0xff];
  754|  40.2M|#if N > 3
  755|  40.2M|                    crc3 ^= crc_braid_table[k][(word3 >> (k << 3)) & 0xff];
  756|  40.2M|#if N > 4
  757|  40.2M|                    crc4 ^= crc_braid_table[k][(word4 >> (k << 3)) & 0xff];
  758|       |#if N > 5
  759|       |                    crc5 ^= crc_braid_table[k][(word5 >> (k << 3)) & 0xff];
  760|       |#endif
  761|  40.2M|#endif
  762|  40.2M|#endif
  763|  40.2M|#endif
  764|  40.2M|#endif
  765|  40.2M|                }
  766|  5.74M|            }
  767|       |
  768|       |            /*
  769|       |              Process the last block, combining the CRCs of the N braids at the
  770|       |              same time.
  771|       |             */
  772|  79.3k|            crc = crc_word(crc0 ^ words[0]);
  773|  79.3k|#if N > 1
  774|  79.3k|            crc = crc_word(crc1 ^ words[1] ^ crc);
  775|  79.3k|#if N > 2
  776|  79.3k|            crc = crc_word(crc2 ^ words[2] ^ crc);
  777|  79.3k|#if N > 3
  778|  79.3k|            crc = crc_word(crc3 ^ words[3] ^ crc);
  779|  79.3k|#if N > 4
  780|  79.3k|            crc = crc_word(crc4 ^ words[4] ^ crc);
  781|       |#if N > 5
  782|       |            crc = crc_word(crc5 ^ words[5] ^ crc);
  783|       |#endif
  784|  79.3k|#endif
  785|  79.3k|#endif
  786|  79.3k|#endif
  787|  79.3k|#endif
  788|  79.3k|            words += N;
  ------------------
  |  |   64|  79.3k|#  define N 5
  ------------------
  789|  79.3k|        }
  790|      0|        else {
  791|       |            /* Big endian. */
  792|       |
  793|      0|            z_word_t crc0, word0, comb;
  794|      0|#if N > 1
  795|      0|            z_word_t crc1, word1;
  796|      0|#if N > 2
  797|      0|            z_word_t crc2, word2;
  798|      0|#if N > 3
  799|      0|            z_word_t crc3, word3;
  800|      0|#if N > 4
  801|      0|            z_word_t crc4, word4;
  802|       |#if N > 5
  803|       |            z_word_t crc5, word5;
  804|       |#endif
  805|      0|#endif
  806|      0|#endif
  807|      0|#endif
  808|      0|#endif
  809|       |
  810|       |            /* Initialize the CRC for each braid. */
  811|      0|            crc0 = byte_swap(crc);
  812|      0|#if N > 1
  813|      0|            crc1 = 0;
  814|      0|#if N > 2
  815|      0|            crc2 = 0;
  816|      0|#if N > 3
  817|      0|            crc3 = 0;
  818|      0|#if N > 4
  819|      0|            crc4 = 0;
  820|       |#if N > 5
  821|       |            crc5 = 0;
  822|       |#endif
  823|      0|#endif
  824|      0|#endif
  825|      0|#endif
  826|      0|#endif
  827|       |
  828|       |            /*
  829|       |              Process the first blks-1 blocks, computing the CRCs on each braid
  830|       |              independently.
  831|       |             */
  832|      0|            while (--blks) {
  ------------------
  |  Branch (832:20): [True: 0, False: 0]
  ------------------
  833|       |                /* Load the word for each braid into registers. */
  834|      0|                word0 = crc0 ^ words[0];
  835|      0|#if N > 1
  836|      0|                word1 = crc1 ^ words[1];
  837|      0|#if N > 2
  838|      0|                word2 = crc2 ^ words[2];
  839|      0|#if N > 3
  840|      0|                word3 = crc3 ^ words[3];
  841|      0|#if N > 4
  842|      0|                word4 = crc4 ^ words[4];
  843|       |#if N > 5
  844|       |                word5 = crc5 ^ words[5];
  845|       |#endif
  846|      0|#endif
  847|      0|#endif
  848|      0|#endif
  849|      0|#endif
  850|      0|                words += N;
  ------------------
  |  |   64|      0|#  define N 5
  ------------------
  851|       |
  852|       |                /* Compute and update the CRC for each word. The loop should
  853|       |                   get unrolled. */
  854|      0|                crc0 = crc_braid_big_table[0][word0 & 0xff];
  855|      0|#if N > 1
  856|      0|                crc1 = crc_braid_big_table[0][word1 & 0xff];
  857|      0|#if N > 2
  858|      0|                crc2 = crc_braid_big_table[0][word2 & 0xff];
  859|      0|#if N > 3
  860|      0|                crc3 = crc_braid_big_table[0][word3 & 0xff];
  861|      0|#if N > 4
  862|      0|                crc4 = crc_braid_big_table[0][word4 & 0xff];
  863|       |#if N > 5
  864|       |                crc5 = crc_braid_big_table[0][word5 & 0xff];
  865|       |#endif
  866|      0|#endif
  867|      0|#endif
  868|      0|#endif
  869|      0|#endif
  870|      0|                for (k = 1; k < W; k++) {
  ------------------
  |  |   90|      0|#      define W 8
  ------------------
  |  Branch (870:29): [True: 0, False: 0]
  ------------------
  871|      0|                    crc0 ^= crc_braid_big_table[k][(word0 >> (k << 3)) & 0xff];
  872|      0|#if N > 1
  873|      0|                    crc1 ^= crc_braid_big_table[k][(word1 >> (k << 3)) & 0xff];
  874|      0|#if N > 2
  875|      0|                    crc2 ^= crc_braid_big_table[k][(word2 >> (k << 3)) & 0xff];
  876|      0|#if N > 3
  877|      0|                    crc3 ^= crc_braid_big_table[k][(word3 >> (k << 3)) & 0xff];
  878|      0|#if N > 4
  879|      0|                    crc4 ^= crc_braid_big_table[k][(word4 >> (k << 3)) & 0xff];
  880|       |#if N > 5
  881|       |                    crc5 ^= crc_braid_big_table[k][(word5 >> (k << 3)) & 0xff];
  882|       |#endif
  883|      0|#endif
  884|      0|#endif
  885|      0|#endif
  886|      0|#endif
  887|      0|                }
  888|      0|            }
  889|       |
  890|       |            /*
  891|       |              Process the last block, combining the CRCs of the N braids at the
  892|       |              same time.
  893|       |             */
  894|      0|            comb = crc_word_big(crc0 ^ words[0]);
  895|      0|#if N > 1
  896|      0|            comb = crc_word_big(crc1 ^ words[1] ^ comb);
  897|      0|#if N > 2
  898|      0|            comb = crc_word_big(crc2 ^ words[2] ^ comb);
  899|      0|#if N > 3
  900|      0|            comb = crc_word_big(crc3 ^ words[3] ^ comb);
  901|      0|#if N > 4
  902|      0|            comb = crc_word_big(crc4 ^ words[4] ^ comb);
  903|       |#if N > 5
  904|       |            comb = crc_word_big(crc5 ^ words[5] ^ comb);
  905|       |#endif
  906|      0|#endif
  907|      0|#endif
  908|      0|#endif
  909|      0|#endif
  910|      0|            words += N;
  ------------------
  |  |   64|      0|#  define N 5
  ------------------
  911|      0|            crc = byte_swap(comb);
  912|      0|        }
  913|       |
  914|       |        /*
  915|       |          Update the pointer to the remaining bytes to process.
  916|       |         */
  917|  79.3k|        buf = (unsigned char const *)words;
  918|  79.3k|    }
  919|       |
  920|   756k|#endif /* W */
  921|       |
  922|       |    /* Complete the computation of the CRC on any remaining bytes. */
  923|  1.17M|    while (len >= 8) {
  ------------------
  |  Branch (923:12): [True: 419k, False: 756k]
  ------------------
  924|   419k|        len -= 8;
  925|   419k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  926|   419k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  927|   419k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  928|   419k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  929|   419k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  930|   419k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  931|   419k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  932|   419k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  933|   419k|    }
  934|  3.29M|    while (len) {
  ------------------
  |  Branch (934:12): [True: 2.53M, False: 756k]
  ------------------
  935|  2.53M|        len--;
  936|  2.53M|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  937|  2.53M|    }
  938|       |
  939|       |    /* Return the CRC, post-conditioned. */
  940|   756k|    return crc ^ 0xffffffff;
  941|  1.19M|}
crc32:
  946|  1.19M|uLong ZEXPORT crc32(uLong crc, const unsigned char FAR *buf, uInt len) {
  947|       |    #ifdef HAVE_S390X_VX
  948|       |    return crc32_z_hook(crc, buf, len);
  949|       |    #endif
  950|  1.19M|    return crc32_z(crc, buf, len);
  951|  1.19M|}
crc32.c:crc_word:
  608|   396k|local z_crc_t crc_word(z_word_t data) {
  609|   396k|    int k;
  610|  3.57M|    for (k = 0; k < W; k++)
  ------------------
  |  |   90|  3.57M|#      define W 8
  ------------------
  |  Branch (610:17): [True: 3.17M, False: 396k]
  ------------------
  611|  3.17M|        data = (data >> 8) ^ crc_table[data & 0xff];
  612|   396k|    return (z_crc_t)data;
  613|   396k|}

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

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

inflate_table:
   48|  28.5k|                                unsigned FAR *bits, unsigned short FAR *work) {
   49|  28.5k|    unsigned len;               /* a code's length in bits */
   50|  28.5k|    unsigned sym;               /* index of code symbols */
   51|  28.5k|    unsigned min, max;          /* minimum and maximum code lengths */
   52|  28.5k|    unsigned root;              /* number of index bits for root table */
   53|  28.5k|    unsigned curr;              /* number of index bits for current table */
   54|  28.5k|    unsigned drop;              /* code bits to drop for sub-table */
   55|  28.5k|    int left;                   /* number of prefix codes available */
   56|  28.5k|    unsigned used;              /* code entries in table used */
   57|  28.5k|    unsigned huff;              /* Huffman code */
   58|  28.5k|    unsigned incr;              /* for incrementing code, index */
   59|  28.5k|    unsigned fill;              /* index for replicating entries */
   60|  28.5k|    unsigned low;               /* low bits for current root entry */
   61|  28.5k|    unsigned mask;              /* mask for low root bits */
   62|  28.5k|    code here;                  /* table entry for duplication */
   63|  28.5k|    code FAR *next;             /* next available space in table */
   64|  28.5k|    const unsigned short FAR *base = NULL;  /* base value table to use */
   65|  28.5k|    const unsigned short FAR *extra = NULL; /* extra bits table to use */
   66|  28.5k|    unsigned match = 0;         /* use base and extra for symbol >= match */
   67|  28.5k|    unsigned short count[MAXBITS+1];    /* number of codes of each length */
   68|  28.5k|    unsigned short offs[MAXBITS+1];     /* offsets in table for each length */
   69|  28.5k|    static const unsigned short lbase[31] = { /* Length codes 257..285 base */
   70|  28.5k|        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
   71|  28.5k|        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
   72|  28.5k|    static const unsigned short lext[31] = { /* Length codes 257..285 extra */
   73|  28.5k|        16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
   74|  28.5k|        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 75};
   75|  28.5k|    static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
   76|  28.5k|        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
   77|  28.5k|        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
   78|  28.5k|        8193, 12289, 16385, 24577, 0, 0};
   79|  28.5k|    static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
   80|  28.5k|        16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
   81|  28.5k|        23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
   82|  28.5k|        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|   486k|    for (len = 0; len <= MAXBITS; len++)
  ------------------
  |  |   23|   486k|#define MAXBITS 15
  ------------------
  |  Branch (116:19): [True: 457k, False: 28.5k]
  ------------------
  117|   457k|        count[len] = 0;
  118|  3.00M|    for (sym = 0; sym < codes; sym++)
  ------------------
  |  Branch (118:19): [True: 2.98M, False: 28.5k]
  ------------------
  119|  2.98M|        count[lens[sym]]++;
  120|       |
  121|       |    /* bound code lengths, force root to be within code lengths */
  122|  28.5k|    root = *bits;
  123|   264k|    for (max = MAXBITS; max >= 1; max--)
  ------------------
  |  |   23|  28.5k|#define MAXBITS 15
  ------------------
  |  Branch (123:25): [True: 264k, False: 180]
  ------------------
  124|   264k|        if (count[max] != 0) break;
  ------------------
  |  Branch (124:13): [True: 28.4k, False: 236k]
  ------------------
  125|  28.5k|    if (root > max) root = max;
  ------------------
  |  Branch (125:9): [True: 13.2k, False: 15.3k]
  ------------------
  126|  28.5k|    if (max == 0) {                     /* no symbols to code at all */
  ------------------
  |  Branch (126:9): [True: 180, False: 28.4k]
  ------------------
  127|    180|        here.op = (unsigned char)64;    /* invalid code marker */
  128|    180|        here.bits = (unsigned char)1;
  129|    180|        here.val = (unsigned short)0;
  130|    180|        *(*table)++ = here;             /* make a table to force an error */
  131|    180|        *(*table)++ = here;
  132|    180|        *bits = 1;
  133|    180|        return 0;     /* no symbols, but wait for decoding to report error */
  134|    180|    }
  135|  61.2k|    for (min = 1; min < max; min++)
  ------------------
  |  Branch (135:19): [True: 60.6k, False: 622]
  ------------------
  136|  60.6k|        if (count[min] != 0) break;
  ------------------
  |  Branch (136:13): [True: 27.7k, False: 32.8k]
  ------------------
  137|  28.4k|    if (root < min) root = min;
  ------------------
  |  Branch (137:9): [True: 84, False: 28.3k]
  ------------------
  138|       |
  139|       |    /* check for an over-subscribed or incomplete set of lengths */
  140|  28.4k|    left = 1;
  141|   446k|    for (len = 1; len <= MAXBITS; len++) {
  ------------------
  |  |   23|   446k|#define MAXBITS 15
  ------------------
  |  Branch (141:19): [True: 418k, False: 27.5k]
  ------------------
  142|   418k|        left <<= 1;
  143|   418k|        left -= count[len];
  144|   418k|        if (left < 0) return -1;        /* over-subscribed */
  ------------------
  |  Branch (144:13): [True: 866, False: 418k]
  ------------------
  145|   418k|    }
  146|  27.5k|    if (left > 0 && (type == CODES || max != 1))
  ------------------
  |  Branch (146:9): [True: 881, False: 26.6k]
  |  Branch (146:22): [True: 399, False: 482]
  |  Branch (146:39): [True: 476, False: 6]
  ------------------
  147|    875|        return -1;                      /* incomplete set */
  148|       |
  149|       |    /* generate offsets into symbol table for each length for sorting */
  150|  26.6k|    offs[1] = 0;
  151|   400k|    for (len = 1; len < MAXBITS; len++)
  ------------------
  |  |   23|   400k|#define MAXBITS 15
  ------------------
  |  Branch (151:19): [True: 373k, False: 26.6k]
  ------------------
  152|   373k|        offs[len + 1] = offs[len] + count[len];
  153|       |
  154|       |    /* sort symbols by length, by symbol order within each length */
  155|  2.77M|    for (sym = 0; sym < codes; sym++)
  ------------------
  |  Branch (155:19): [True: 2.74M, False: 26.6k]
  ------------------
  156|  2.74M|        if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
  ------------------
  |  Branch (156:13): [True: 1.26M, False: 1.48M]
  ------------------
  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|  26.6k|    switch (type) {
  ------------------
  |  Branch (190:13): [True: 26.6k, False: 0]
  ------------------
  191|  10.3k|    case CODES:
  ------------------
  |  Branch (191:5): [True: 10.3k, False: 16.3k]
  ------------------
  192|  10.3k|        match = 20;
  193|  10.3k|        break;
  194|  8.34k|    case LENS:
  ------------------
  |  Branch (194:5): [True: 8.34k, False: 18.3k]
  ------------------
  195|  8.34k|        base = lbase;
  196|  8.34k|        extra = lext;
  197|  8.34k|        match = 257;
  198|  8.34k|        break;
  199|  7.99k|    case DISTS:
  ------------------
  |  Branch (199:5): [True: 7.99k, False: 18.6k]
  ------------------
  200|  7.99k|        base = dbase;
  201|  7.99k|        extra = dext;
  202|  26.6k|    }
  203|       |
  204|       |    /* initialize state for loop */
  205|  26.6k|    huff = 0;                   /* starting code */
  206|  26.6k|    sym = 0;                    /* starting code symbol */
  207|  26.6k|    len = min;                  /* starting code length */
  208|  26.6k|    next = *table;              /* current table to fill in */
  209|  26.6k|    curr = root;                /* current table index bits */
  210|  26.6k|    drop = 0;                   /* current bits to drop from code for index */
  211|  26.6k|    low = (unsigned)(-1);       /* trigger new sub-table when len > root */
  212|  26.6k|    used = 1U << root;          /* use root table entries */
  213|  26.6k|    mask = used - 1;            /* mask for comparing low */
  214|       |
  215|       |    /* check available table space */
  216|  26.6k|    if ((type == LENS && used > ENOUGH_LENS) ||
  ------------------
  |  |   49|  8.34k|#define ENOUGH_LENS 852
  ------------------
  |  Branch (216:10): [True: 8.34k, False: 18.3k]
  |  Branch (216:26): [True: 0, False: 8.34k]
  ------------------
  217|  26.6k|        (type == DISTS && used > ENOUGH_DISTS))
  ------------------
  |  |   50|  7.99k|#define ENOUGH_DISTS 592
  ------------------
  |  Branch (217:10): [True: 7.99k, False: 18.6k]
  |  Branch (217:27): [True: 0, False: 7.99k]
  ------------------
  218|      0|        return 1;
  219|       |
  220|       |    /* process all codes and make table entries */
  221|  1.26M|    for (;;) {
  222|       |        /* create table entry */
  223|  1.26M|        here.bits = (unsigned char)(len - drop);
  224|  1.26M|        if (work[sym] + 1U < match) {
  ------------------
  |  Branch (224:13): [True: 1.03M, False: 231k]
  ------------------
  225|  1.03M|            here.op = (unsigned char)0;
  226|  1.03M|            here.val = work[sym];
  227|  1.03M|        }
  228|   231k|        else if (work[sym] >= match) {
  ------------------
  |  Branch (228:18): [True: 222k, False: 8.34k]
  ------------------
  229|   222k|            here.op = (unsigned char)(extra[work[sym] - match]);
  230|   222k|            here.val = base[work[sym] - match];
  231|   222k|        }
  232|  8.34k|        else {
  233|  8.34k|            here.op = (unsigned char)(32 + 64);         /* end of block */
  234|  8.34k|            here.val = 0;
  235|  8.34k|        }
  236|       |
  237|       |        /* replicate for those indices with low len bits equal to huff */
  238|  1.26M|        incr = 1U << (len - drop);
  239|  1.26M|        fill = 1U << curr;
  240|  1.26M|        min = fill;                 /* save offset to next table */
  241|  3.78M|        do {
  242|  3.78M|            fill -= incr;
  243|  3.78M|            next[(huff >> drop) + fill] = here;
  244|  3.78M|        } while (fill != 0);
  ------------------
  |  Branch (244:18): [True: 2.52M, False: 1.26M]
  ------------------
  245|       |
  246|       |        /* backwards increment the len-bit code huff */
  247|  1.26M|        incr = 1U << (len - 1);
  248|  2.49M|        while (huff & incr)
  ------------------
  |  Branch (248:16): [True: 1.23M, False: 1.26M]
  ------------------
  249|  1.23M|            incr >>= 1;
  250|  1.26M|        if (incr != 0) {
  ------------------
  |  Branch (250:13): [True: 1.23M, False: 26.6k]
  ------------------
  251|  1.23M|            huff &= incr - 1;
  252|  1.23M|            huff += incr;
  253|  1.23M|        }
  254|  26.6k|        else
  255|  26.6k|            huff = 0;
  256|       |
  257|       |        /* go to next symbol, update count, len */
  258|  1.26M|        sym++;
  259|  1.26M|        if (--(count[len]) == 0) {
  ------------------
  |  Branch (259:13): [True: 141k, False: 1.12M]
  ------------------
  260|   141k|            if (len == max) break;
  ------------------
  |  Branch (260:17): [True: 26.6k, False: 114k]
  ------------------
  261|   114k|            len = lens[work[sym]];
  262|   114k|        }
  263|       |
  264|       |        /* create new sub-table if needed */
  265|  1.23M|        if (len > root && (huff & mask) != low) {
  ------------------
  |  Branch (265:13): [True: 107k, False: 1.12M]
  |  Branch (265:27): [True: 40.8k, False: 66.3k]
  ------------------
  266|       |            /* if first time, transition to sub-tables */
  267|  40.8k|            if (drop == 0)
  ------------------
  |  Branch (267:17): [True: 6.48k, False: 34.4k]
  ------------------
  268|  6.48k|                drop = root;
  269|       |
  270|       |            /* increment past last table */
  271|  40.8k|            next += min;            /* here min is 1 << curr */
  272|       |
  273|       |            /* determine length of next table */
  274|  40.8k|            curr = len - drop;
  275|  40.8k|            left = (int)(1 << curr);
  276|  46.9k|            while (curr + drop < max) {
  ------------------
  |  Branch (276:20): [True: 36.4k, False: 10.4k]
  ------------------
  277|  36.4k|                left -= count[curr + drop];
  278|  36.4k|                if (left <= 0) break;
  ------------------
  |  Branch (278:21): [True: 30.4k, False: 6.04k]
  ------------------
  279|  6.04k|                curr++;
  280|  6.04k|                left <<= 1;
  281|  6.04k|            }
  282|       |
  283|       |            /* check for enough space */
  284|  40.8k|            used += 1U << curr;
  285|  40.8k|            if ((type == LENS && used > ENOUGH_LENS) ||
  ------------------
  |  |   49|  34.7k|#define ENOUGH_LENS 852
  ------------------
  |  Branch (285:18): [True: 34.7k, False: 6.11k]
  |  Branch (285:34): [True: 0, False: 34.7k]
  ------------------
  286|  40.8k|                (type == DISTS && used > ENOUGH_DISTS))
  ------------------
  |  |   50|  6.11k|#define ENOUGH_DISTS 592
  ------------------
  |  Branch (286:18): [True: 6.11k, False: 34.7k]
  |  Branch (286:35): [True: 0, False: 6.11k]
  ------------------
  287|      0|                return 1;
  288|       |
  289|       |            /* point entry in root table to sub-table */
  290|  40.8k|            low = huff & mask;
  291|  40.8k|            (*table)[low].op = (unsigned char)curr;
  292|  40.8k|            (*table)[low].bits = (unsigned char)root;
  293|  40.8k|            (*table)[low].val = (unsigned short)(next - *table);
  294|  40.8k|        }
  295|  1.23M|    }
  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|  26.6k|    if (huff != 0) {
  ------------------
  |  Branch (300:9): [True: 6, False: 26.6k]
  ------------------
  301|      6|        here.op = (unsigned char)64;            /* invalid code marker */
  302|      6|        here.bits = (unsigned char)(len - drop);
  303|      6|        here.val = (unsigned short)0;
  304|      6|        next[huff] = here;
  305|      6|    }
  306|       |
  307|       |    /* set return parameters */
  308|  26.6k|    *table += used;
  309|  26.6k|    *bits = root;
  310|  26.6k|    return 0;
  311|  26.6k|}
inflate_fixed:
  364|  38.9k|void inflate_fixed(struct inflate_state FAR *state) {
  365|       |#ifdef BUILDFIXED
  366|       |    z_once(&built, buildtables);
  367|       |#endif /* BUILDFIXED */
  368|  38.9k|    state->lencode = lenfix;
  369|  38.9k|    state->lenbits = 9;
  370|  38.9k|    state->distcode = distfix;
  371|  38.9k|    state->distbits = 5;
  372|  38.9k|}

tj3Compress12:
   80|  20.8k|{
   81|  20.8k|  static const char FUNCTION_NAME[] = GET_STRING(tj3Compress, BITS_IN_JSAMPLE);
  ------------------
  |  |   71|  20.8k|#define GET_STRING(name, suffix)  _GET_STRING(name, suffix)
  |  |  ------------------
  |  |  |  |   70|  20.8k|#define _GET_STRING(name, suffix)  #name #suffix
  |  |  ------------------
  ------------------
   82|  20.8k|  int i, retval = 0;
   83|  20.8k|  boolean alloc = TRUE;
  ------------------
  |  |  210|  20.8k|#define TRUE    1
  ------------------
   84|  20.8k|  _JSAMPROW *row_pointer = NULL;
  ------------------
  |  |   46|  20.8k|#define _JSAMPROW  J12SAMPROW
  ------------------
   85|       |
   86|  20.8k|  GET_CINSTANCE(handle)
  ------------------
  |  |  314|  20.8k|  tjinstance *this = (tjinstance *)handle; \
  |  |  315|  20.8k|  j_compress_ptr cinfo = NULL; \
  |  |  316|  20.8k|  \
  |  |  317|  20.8k|  if (!this) { \
  |  |  ------------------
  |  |  |  Branch (317:7): [True: 0, False: 20.8k]
  |  |  ------------------
  |  |  318|      0|    SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): Invalid handle", FUNCTION_NAME); \
  |  |  ------------------
  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  ------------------
  |  |                   SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): Invalid handle", FUNCTION_NAME); \
  |  |  ------------------
  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  319|      0|    return -1; \
  |  |  320|      0|  } \
  |  |  321|  20.8k|  cinfo = &this->cinfo; \
  |  |  322|  20.8k|  this->jerr.warning = FALSE; \
  |  |  ------------------
  |  |  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  323|  20.8k|  this->isInstanceError = FALSE;
  |  |  ------------------
  |  |  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  ------------------
   87|  20.8k|  if ((this->init & COMPRESS) == 0)
  ------------------
  |  Branch (87:7): [True: 0, False: 20.8k]
  ------------------
   88|  20.8k|    THROW("Instance has not been initialized for compression");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
   89|       |
   90|  20.8k|  if (srcBuf == NULL || width <= 0 || pitch < 0 || height <= 0 ||
  ------------------
  |  Branch (90:7): [True: 0, False: 20.8k]
  |  Branch (90:25): [True: 0, False: 20.8k]
  |  Branch (90:39): [True: 0, False: 20.8k]
  |  Branch (90:52): [True: 0, False: 20.8k]
  ------------------
   91|  20.8k|      pixelFormat < 0 || pixelFormat >= TJ_NUMPF || jpegBuf == NULL ||
  ------------------
  |  |  283|  41.6k|#define TJ_NUMPF  12
  ------------------
  |  Branch (91:7): [True: 0, False: 20.8k]
  |  Branch (91:26): [True: 0, False: 20.8k]
  |  Branch (91:53): [True: 0, False: 20.8k]
  ------------------
   92|  20.8k|      jpegSize == NULL)
  ------------------
  |  Branch (92:7): [True: 0, False: 20.8k]
  ------------------
   93|  20.8k|    THROW("Invalid argument");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
   94|       |
   95|  20.8k|  if (!this->lossless && this->quality == -1)
  ------------------
  |  Branch (95:7): [True: 20.8k, False: 0]
  |  Branch (95:26): [True: 0, False: 20.8k]
  ------------------
   96|  20.8k|    THROW("TJPARAM_QUALITY must be specified");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
   97|  20.8k|  if (!this->lossless && this->subsamp == TJSAMP_UNKNOWN)
  ------------------
  |  Branch (97:7): [True: 20.8k, False: 0]
  |  Branch (97:26): [True: 0, False: 20.8k]
  ------------------
   98|  20.8k|    THROW("TJPARAM_SUBSAMP must be specified");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
   99|       |
  100|  20.8k|  if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
  ------------------
  |  Branch (100:7): [True: 20.8k, False: 0]
  ------------------
  101|      0|  else if (pitch < width * tjPixelSize[pixelFormat])
  ------------------
  |  Branch (101:12): [True: 0, False: 0]
  ------------------
  102|  20.8k|    THROW("Invalid argument");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  103|       |
  104|  20.8k|  if ((row_pointer = (_JSAMPROW *)malloc(sizeof(_JSAMPROW) * height)) == NULL)
  ------------------
  |  Branch (104:7): [True: 0, False: 20.8k]
  ------------------
  105|  20.8k|    THROW("Memory allocation failure");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  106|       |
  107|  20.8k|  CATCH_LIBJPEG(this);
  ------------------
  |  |  293|  20.8k|#define CATCH_LIBJPEG(this) { \
  |  |  294|  20.8k|  if (setjmp(this->jerr.setjmp_buffer)) { \
  |  |  295|      0|    /* If we get here, the JPEG code has signaled an error. */ \
  |  |  296|      0|    retval = -1;  goto bailout; \
  |  |  297|      0|  } \
  |  |  298|  20.8k|}
  ------------------
  |  Branch (107:3): [True: 0, False: 20.8k]
  ------------------
  108|       |
  109|  20.8k|  cinfo->image_width = width;
  110|  20.8k|  cinfo->image_height = height;
  111|  20.8k|  cinfo->data_precision = BITS_IN_JSAMPLE;
  ------------------
  |  | 1255|  20.8k|#define BITS_IN_JSAMPLE  12
  ------------------
  112|       |#if BITS_IN_JSAMPLE == 8
  113|       |  if (this->lossless && this->precision >= 2 &&
  114|       |      this->precision <= BITS_IN_JSAMPLE)
  115|       |#else
  116|  20.8k|  if (this->lossless && this->precision >= BITS_IN_JSAMPLE - 3 &&
  ------------------
  |  | 1255|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (116:7): [True: 0, False: 20.8k]
  |  Branch (116:25): [True: 0, False: 0]
  ------------------
  117|      0|      this->precision <= BITS_IN_JSAMPLE)
  ------------------
  |  | 1255|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (117:7): [True: 0, False: 0]
  ------------------
  118|      0|#endif
  119|      0|    cinfo->data_precision = this->precision;
  120|       |
  121|  20.8k|  setCompDefaults(this, pixelFormat, FALSE);
  ------------------
  |  |  207|  20.8k|#define FALSE   0               /* values of boolean */
  ------------------
  122|  20.8k|  if (this->noRealloc) alloc = FALSE;
  ------------------
  |  |  207|  2.95k|#define FALSE   0               /* values of boolean */
  ------------------
  |  Branch (122:7): [True: 2.95k, False: 17.8k]
  ------------------
  123|  20.8k|  jpeg_mem_dest_tj(cinfo, jpegBuf, jpegSize, alloc);
  124|       |
  125|  20.8k|  jpeg_start_compress(cinfo, TRUE);
  ------------------
  |  |  210|  20.8k|#define TRUE    1
  ------------------
  126|  20.8k|  if (this->iccBuf != NULL && this->iccSize != 0)
  ------------------
  |  Branch (126:7): [True: 17.7k, False: 3.05k]
  |  Branch (126:31): [True: 17.7k, False: 0]
  ------------------
  127|  17.7k|    jpeg_write_icc_profile(cinfo, this->iccBuf, (unsigned int)this->iccSize);
  128|  29.6M|  for (i = 0; i < height; i++) {
  ------------------
  |  Branch (128:15): [True: 29.5M, False: 20.8k]
  ------------------
  129|  29.5M|    if (this->bottomUp)
  ------------------
  |  Branch (129:9): [True: 4.33M, False: 25.2M]
  ------------------
  130|  4.33M|      row_pointer[i] = (_JSAMPROW)&srcBuf[(height - i - 1) * (size_t)pitch];
  131|  25.2M|    else
  132|  25.2M|      row_pointer[i] = (_JSAMPROW)&srcBuf[i * (size_t)pitch];
  133|  29.5M|  }
  134|  41.6k|  while (cinfo->next_scanline < cinfo->image_height)
  ------------------
  |  Branch (134:10): [True: 20.8k, False: 20.8k]
  ------------------
  135|  20.8k|    _jpeg_write_scanlines(cinfo, &row_pointer[cinfo->next_scanline],
  ------------------
  |  |   55|  20.8k|#define _jpeg_write_scanlines  jpeg12_write_scanlines
  ------------------
  136|  20.8k|                          cinfo->image_height - cinfo->next_scanline);
  137|  20.8k|  jpeg_finish_compress(cinfo);
  138|       |
  139|  20.8k|bailout:
  140|  20.8k|  if (cinfo->global_state > CSTATE_START && alloc)
  ------------------
  |  |   44|  41.6k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (140:7): [True: 0, False: 20.8k]
  |  Branch (140:45): [True: 0, False: 0]
  ------------------
  141|      0|    (*cinfo->dest->term_destination) (cinfo);
  142|  20.8k|  if (cinfo->global_state > CSTATE_START || retval == -1)
  ------------------
  |  |   44|  41.6k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (142:7): [True: 0, False: 20.8k]
  |  Branch (142:45): [True: 0, False: 20.8k]
  ------------------
  143|      0|    jpeg_abort_compress(cinfo);
  144|  20.8k|  free(row_pointer);
  145|  20.8k|  if (this->jerr.warning) retval = -1;
  ------------------
  |  Branch (145:7): [True: 0, False: 20.8k]
  ------------------
  146|  20.8k|  return retval;
  147|  20.8k|}
_tj3LoadImageFromFileHandle12:
  306|  46.2k|{
  307|  46.2k|  static const char FUNCTION_NAME[] =
  308|  46.2k|    GET_STRING(tj3LoadImage, BITS_IN_JSAMPLE);
  ------------------
  |  |   71|  46.2k|#define GET_STRING(name, suffix)  _GET_STRING(name, suffix)
  |  |  ------------------
  |  |  |  |   70|  46.2k|#define _GET_STRING(name, suffix)  #name #suffix
  |  |  ------------------
  ------------------
  309|       |
  310|  46.2k|  int retval = 0, tempc;
  311|  46.2k|  size_t pitch;
  312|  46.2k|  tjhandle handle2 = NULL;
  313|  46.2k|  tjinstance *this2;
  314|  46.2k|  j_compress_ptr cinfo = NULL;
  315|  46.2k|  cjpeg_source_ptr src = NULL;
  316|  46.2k|  _JSAMPLE *dstBuf = NULL;
  ------------------
  |  |   45|  46.2k|#define _JSAMPLE  J12SAMPLE
  ------------------
  317|  46.2k|  boolean invert;
  318|       |
  319|  46.2k|  GET_TJINSTANCE(handle, NULL)
  ------------------
  |  |  338|  46.2k|  tjinstance *this = (tjinstance *)handle; \
  |  |  339|  46.2k|  \
  |  |  340|  46.2k|  if (!this) { \
  |  |  ------------------
  |  |  |  Branch (340:7): [True: 0, False: 46.2k]
  |  |  ------------------
  |  |  341|      0|    SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): Invalid handle", FUNCTION_NAME); \
  |  |  ------------------
  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  ------------------
  |  |                   SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): Invalid handle", FUNCTION_NAME); \
  |  |  ------------------
  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  342|      0|    return errorReturn; \
  |  |  343|      0|  } \
  |  |  344|  46.2k|  this->jerr.warning = FALSE; \
  |  |  ------------------
  |  |  |  |  207|  46.2k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  345|  46.2k|  this->isInstanceError = FALSE;
  |  |  ------------------
  |  |  |  |  207|  46.2k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  ------------------
  320|       |
  321|  46.2k|  if (!file || !width || align < 1 || !height || !pixelFormat ||
  ------------------
  |  Branch (321:7): [True: 0, False: 46.2k]
  |  Branch (321:16): [True: 0, False: 46.2k]
  |  Branch (321:26): [True: 0, False: 46.2k]
  |  Branch (321:39): [True: 0, False: 46.2k]
  |  Branch (321:50): [True: 0, False: 46.2k]
  ------------------
  322|  46.2k|      *pixelFormat < TJPF_UNKNOWN || *pixelFormat >= TJ_NUMPF)
  ------------------
  |  |  283|  46.2k|#define TJ_NUMPF  12
  ------------------
  |  Branch (322:7): [True: 0, False: 46.2k]
  |  Branch (322:38): [True: 0, False: 46.2k]
  ------------------
  323|  46.2k|    THROW("Invalid argument");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  324|  46.2k|  if ((align & (align - 1)) != 0)
  ------------------
  |  Branch (324:7): [True: 0, False: 46.2k]
  ------------------
  325|  46.2k|    THROW("Alignment must be a power of 2");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  326|       |
  327|       |  /* The instance handle passed to this function is used only for parameter
  328|       |     retrieval.  Create a new temporary instance to avoid interfering with the
  329|       |     libjpeg state of the primary instance. */
  330|  46.2k|  if ((handle2 = tj3Init(TJINIT_COMPRESS)) == NULL) return NULL;
  ------------------
  |  Branch (330:7): [True: 0, False: 46.2k]
  ------------------
  331|  46.2k|  this2 = (tjinstance *)handle2;
  332|  46.2k|  cinfo = &this2->cinfo;
  333|       |
  334|  46.2k|  if ((tempc = getc(file)) < 0 || ungetc(tempc, file) == EOF)
  ------------------
  |  Branch (334:7): [True: 0, False: 46.2k]
  |  Branch (334:35): [True: 0, False: 46.2k]
  ------------------
  335|      0|    THROW_UNIX("Could not read input file")
  ------------------
  |  |  270|      0|#define THROW_UNIX(m) { \
  |  |  271|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s\n%s", FUNCTION_NAME, m, \
  |  |  ------------------
  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  ------------------
  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s\n%s", FUNCTION_NAME, m, \
  |  |  ------------------
  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  272|      0|           strerror(errno)); \
  |  |  273|      0|  this->isInstanceError = TRUE; \
  |  |  ------------------
  |  |  |  |  210|      0|#define TRUE    1
  |  |  ------------------
  |  |  274|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s\n%s", FUNCTION_NAME, m, \
  |  |  ------------------
  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  ------------------
  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s\n%s", FUNCTION_NAME, m, \
  |  |  ------------------
  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  275|      0|           strerror(errno)); \
  |  |  276|      0|  retval = -1;  goto bailout; \
  |  |  277|      0|}
  ------------------
  336|  46.2k|  else if (tempc == EOF)
  ------------------
  |  Branch (336:12): [True: 0, False: 46.2k]
  ------------------
  337|  46.2k|    THROW("Input file contains no data");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  338|       |
  339|  46.2k|  CATCH_LIBJPEG(this2);
  ------------------
  |  |  293|  46.2k|#define CATCH_LIBJPEG(this) { \
  |  |  294|  46.2k|  if (setjmp(this->jerr.setjmp_buffer)) { \
  |  |  295|     21|    /* If we get here, the JPEG code has signaled an error. */ \
  |  |  296|     21|    retval = -1;  goto bailout; \
  |  |  297|     21|  } \
  |  |  298|  46.2k|}
  ------------------
  |  Branch (339:3): [True: 21, False: 46.2k]
  ------------------
  340|       |
  341|  46.2k|  cinfo->data_precision = BITS_IN_JSAMPLE;
  ------------------
  |  | 1255|  46.2k|#define BITS_IN_JSAMPLE  12
  ------------------
  342|  46.2k|  if (*pixelFormat == TJPF_UNKNOWN) cinfo->in_color_space = JCS_UNKNOWN;
  ------------------
  |  Branch (342:7): [True: 0, False: 46.2k]
  ------------------
  343|  46.2k|  else cinfo->in_color_space = pf2cs[*pixelFormat];
  344|  46.2k|  if (tempc == 'B') {
  ------------------
  |  Branch (344:7): [True: 21, False: 46.2k]
  ------------------
  345|     21|    if ((src = jinit_read_bmp(cinfo, FALSE)) == NULL)
  ------------------
  |  |  207|     21|#define FALSE   0               /* values of boolean */
  ------------------
  |  Branch (345:9): [True: 0, False: 21]
  ------------------
  346|     21|      THROW("Could not initialize bitmap loader");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  347|     21|    invert = !this->bottomUp;
  348|  46.2k|  } else if (tempc == 0x89) {
  ------------------
  |  Branch (348:14): [True: 28.3k, False: 17.8k]
  ------------------
  349|       |#if BITS_IN_JSAMPLE == 8
  350|       |    if (this->precision >= 2 && this->precision <= BITS_IN_JSAMPLE)
  351|       |#else
  352|  28.3k|    if (this->precision >= BITS_IN_JSAMPLE - 3 &&
  ------------------
  |  | 1255|  28.3k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (352:9): [True: 0, False: 28.3k]
  ------------------
  353|      0|        this->precision <= BITS_IN_JSAMPLE)
  ------------------
  |  | 1255|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (353:9): [True: 0, False: 0]
  ------------------
  354|      0|#endif
  355|      0|      cinfo->data_precision = this->precision;
  356|  28.3k|    if ((src = _jinit_read_png(cinfo)) == NULL)
  ------------------
  |  |   48|  28.3k|#define _jinit_read_png  j12init_read_png
  ------------------
  |  Branch (356:9): [True: 0, False: 28.3k]
  ------------------
  357|  28.3k|      THROW("Could not initialize PNG loader");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  358|  28.3k|    invert = this->bottomUp;
  359|  28.3k|  } else if (tempc == 'P') {
  ------------------
  |  Branch (359:14): [True: 17.1k, False: 714]
  ------------------
  360|       |#if BITS_IN_JSAMPLE == 8
  361|       |    if (this->precision >= 2 && this->precision <= BITS_IN_JSAMPLE)
  362|       |#else
  363|  17.1k|    if (this->precision >= BITS_IN_JSAMPLE - 3 &&
  ------------------
  |  | 1255|  17.1k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (363:9): [True: 0, False: 17.1k]
  ------------------
  364|      0|        this->precision <= BITS_IN_JSAMPLE)
  ------------------
  |  | 1255|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (364:9): [True: 0, False: 0]
  ------------------
  365|      0|#endif
  366|      0|      cinfo->data_precision = this->precision;
  367|  17.1k|    if ((src = _jinit_read_ppm(cinfo)) == NULL)
  ------------------
  |  |   50|  17.1k|#define _jinit_read_ppm  j12init_read_ppm
  ------------------
  |  Branch (367:9): [True: 0, False: 17.1k]
  ------------------
  368|  17.1k|      THROW("Could not initialize PPM loader");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  369|  17.1k|    invert = this->bottomUp;
  370|  17.1k|  } else
  371|  45.5k|    THROW("Unsupported file type");
  ------------------
  |  |  283|    714|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|    714|#define THROWRV(m, rv) { \
  |  |  |  |  280|    714|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|    714|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|    714|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|    714|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|    714|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|    714|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|    714|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|    714|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|    714|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|    714|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|    714|}
  |  |  |  |  ------------------
  |  |  |  |  282|    714|}
  |  |  ------------------
  ------------------
  372|       |
  373|  45.5k|  if (setjmp(this2->jerr.setjmp_buffer)) {
  ------------------
  |  Branch (373:7): [True: 24.9k, False: 20.5k]
  ------------------
  374|       |    /* If we get here, the JPEG code has signaled an error. */
  375|  24.9k|    retval = -1;  goto bailout;
  376|  24.9k|  }
  377|       |
  378|  20.5k|  cinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
  379|       |
  380|  20.5k|  src->input_file = file;
  381|       |  /* Refuse to load images larger than the specified size. */
  382|  20.5k|  src->max_pixels = this->maxPixels;
  383|  20.5k|  (*src->start_input) (cinfo, src);
  384|  20.5k|  if (tempc == 'B') {
  ------------------
  |  Branch (384:7): [True: 0, False: 20.5k]
  ------------------
  385|      0|    if (cinfo->X_density && cinfo->Y_density) {
  ------------------
  |  Branch (385:9): [True: 0, False: 0]
  |  Branch (385:29): [True: 0, False: 0]
  ------------------
  386|      0|      this->xDensity = cinfo->X_density;
  387|      0|      this->yDensity = cinfo->Y_density;
  388|      0|      this->densityUnits = cinfo->density_unit;
  389|      0|    }
  390|  20.5k|  } else if (tempc == 0x89 && (this->init & COMPRESS) &&
  ------------------
  |  Branch (390:14): [True: 5.68k, False: 14.8k]
  |  Branch (390:31): [True: 5.68k, False: 0]
  ------------------
  391|  5.68k|             (this->saveMarkers == 2 || this->saveMarkers == 4)) {
  ------------------
  |  Branch (391:15): [True: 5.68k, False: 0]
  |  Branch (391:41): [True: 0, False: 0]
  ------------------
  392|  5.68k|    JOCTET *iccBuf = NULL;
  393|  5.68k|    unsigned int iccLen = 0;
  394|       |
  395|  5.68k|    if ((*src->read_icc_profile) (cinfo, src, &iccBuf, &iccLen) && iccBuf &&
  ------------------
  |  Branch (395:9): [True: 20, False: 5.66k]
  |  Branch (395:68): [True: 20, False: 0]
  ------------------
  396|     20|        iccLen)
  ------------------
  |  Branch (396:9): [True: 20, False: 0]
  ------------------
  397|     20|      tj3SetICCProfile(handle, (unsigned char *)iccBuf, iccLen);
  398|  5.68k|  }
  399|  20.5k|  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
  400|       |
  401|  20.5k|  *width = cinfo->image_width;  *height = cinfo->image_height;
  402|  20.5k|  *pixelFormat = cs2pf[cinfo->in_color_space];
  403|       |
  404|  20.5k|  pitch = PAD((*width) * tjPixelSize[*pixelFormat], align);
  ------------------
  |  |   57|  20.5k|#define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
  ------------------
  405|  20.5k|  if (
  406|       |#if ULLONG_MAX > SIZE_MAX
  407|       |      (unsigned long long)pitch * (unsigned long long)(*height) >
  408|       |      (unsigned long long)((size_t)-1) ||
  409|       |#endif
  410|  20.5k|      (dstBuf = (_JSAMPLE *)malloc(pitch * (*height) *
  ------------------
  |  Branch (410:7): [True: 0, False: 20.5k]
  ------------------
  411|  20.5k|                                   sizeof(_JSAMPLE))) == NULL)
  412|  20.5k|    THROW("Memory allocation failure");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  413|       |
  414|  20.5k|  CATCH_LIBJPEG(this2);
  ------------------
  |  |  293|  20.5k|#define CATCH_LIBJPEG(this) { \
  |  |  294|  20.5k|  if (setjmp(this->jerr.setjmp_buffer)) { \
  |  |  295|  8.92k|    /* If we get here, the JPEG code has signaled an error. */ \
  |  |  296|  8.92k|    retval = -1;  goto bailout; \
  |  |  297|  8.92k|  } \
  |  |  298|  20.5k|}
  ------------------
  |  Branch (414:3): [True: 8.92k, False: 11.6k]
  ------------------
  415|       |
  416|  29.8M|  while (cinfo->next_scanline < cinfo->image_height) {
  ------------------
  |  Branch (416:10): [True: 29.8M, False: 11.6k]
  ------------------
  417|  29.8M|    int i, nlines = (*src->get_pixel_rows) (cinfo, src);
  418|       |
  419|  59.7M|    for (i = 0; i < nlines; i++) {
  ------------------
  |  Branch (419:17): [True: 29.8M, False: 29.8M]
  ------------------
  420|  29.8M|      _JSAMPLE *dstptr;
  ------------------
  |  |   45|  29.8M|#define _JSAMPLE  J12SAMPLE
  ------------------
  421|  29.8M|      int row;
  422|       |
  423|  29.8M|      row = cinfo->next_scanline + i;
  424|  29.8M|      if (invert) dstptr = &dstBuf[((*height) - row - 1) * pitch];
  ------------------
  |  Branch (424:11): [True: 4.38M, False: 25.4M]
  ------------------
  425|  25.4M|      else dstptr = &dstBuf[row * pitch];
  426|  29.8M|      memcpy(dstptr, src->_buffer[i],
  ------------------
  |  |   47|  29.8M|#define _buffer  buffer12
  ------------------
  427|  29.8M|             (*width) * tjPixelSize[*pixelFormat] * sizeof(_JSAMPLE));
  428|  29.8M|    }
  429|  29.8M|    cinfo->next_scanline += nlines;
  430|  29.8M|  }
  431|       |
  432|  46.2k|bailout:
  433|  46.2k|  if (src)
  ------------------
  |  Branch (433:7): [True: 45.4k, False: 756]
  ------------------
  434|  45.4k|    (*src->finish_input) (cinfo, src);
  435|  46.2k|  tj3Destroy(handle2);
  436|  46.2k|  if (retval < 0) { free(dstBuf);  dstBuf = NULL; }
  ------------------
  |  Branch (436:7): [True: 34.6k, False: 11.5k]
  ------------------
  437|  46.2k|  return dstBuf;
  438|  11.6k|}

tj3InitVersion:
  584|  52.8k|{
  585|  52.8k|  static const char FUNCTION_NAME[] = "tj3Init";
  586|  52.8k|  tjinstance *this = NULL;
  587|  52.8k|  tjhandle retval = NULL;
  588|       |
  589|  52.8k|  if (initType < 0 || initType >= TJ_NUMINIT || apiVersion < 1000000 ||
  ------------------
  |  |   86|   105k|#define TJ_NUMINIT  3
  ------------------
  |  Branch (589:7): [True: 0, False: 52.8k]
  |  Branch (589:23): [True: 0, False: 52.8k]
  |  Branch (589:49): [True: 0, False: 52.8k]
  ------------------
  590|  52.8k|      apiVersion > 999999999)
  ------------------
  |  Branch (590:7): [True: 0, False: 52.8k]
  ------------------
  591|  52.8k|    THROWG("Invalid argument", NULL);
  ------------------
  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  ------------------
  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  ------------------
  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  ------------------
  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  257|      0|}
  ------------------
  592|       |
  593|  52.8k|  if ((this = (tjinstance *)malloc(sizeof(tjinstance))) == NULL)
  ------------------
  |  Branch (593:7): [True: 0, False: 52.8k]
  ------------------
  594|  52.8k|    THROWG("Memory allocation failure", NULL);
  ------------------
  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  ------------------
  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  ------------------
  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  ------------------
  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  257|      0|}
  ------------------
  595|  52.8k|  memset(this, 0, sizeof(tjinstance));
  596|  52.8k|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
  ------------------
  |  |   42|  52.8k|#define SNPRINTF  snprintf
  ------------------
                SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
  ------------------
  |  |  792|  52.8k|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  ------------------
  597|       |
  598|  52.8k|  this->quality = -1;
  599|  52.8k|  this->subsamp = TJSAMP_UNKNOWN;
  600|  52.8k|  this->jpegWidth = -1;
  601|  52.8k|  this->jpegHeight = -1;
  602|  52.8k|  this->precision = 8;
  603|  52.8k|  this->colorspace = TJCS_DEFAULT;
  604|  52.8k|  this->losslessPSV = 1;
  605|  52.8k|  this->xDensity = 1;
  606|  52.8k|  this->yDensity = 1;
  607|  52.8k|  this->scalingFactor = TJUNSCALED;
  608|  52.8k|  this->saveMarkers = 2;
  609|       |
  610|  52.8k|  this->apiVersion = apiVersion;
  611|  52.8k|  this->numSamp = apiVersion >= 3002000 ? TJ_NUMSAMP : 7;
  ------------------
  |  |  111|  6.60k|#define TJ_NUMSAMP  9
  ------------------
  |  Branch (611:19): [True: 6.60k, False: 46.2k]
  ------------------
  612|       |
  613|  52.8k|  switch (initType) {
  ------------------
  |  Branch (613:11): [True: 52.8k, False: 0]
  ------------------
  614|  52.8k|  case TJINIT_COMPRESS:  return _tjInitCompress(this);
  ------------------
  |  Branch (614:3): [True: 52.8k, False: 0]
  ------------------
  615|      0|  case TJINIT_DECOMPRESS:  return _tjInitDecompress(this);
  ------------------
  |  Branch (615:3): [True: 0, False: 52.8k]
  ------------------
  616|      0|  case TJINIT_TRANSFORM:
  ------------------
  |  Branch (616:3): [True: 0, False: 52.8k]
  ------------------
  617|      0|    retval = _tjInitCompress(this);
  618|      0|    if (!retval) return NULL;
  ------------------
  |  Branch (618:9): [True: 0, False: 0]
  ------------------
  619|      0|    retval = _tjInitDecompress(this);
  620|      0|    return retval;
  621|  52.8k|  }
  622|       |
  623|      0|bailout:
  624|      0|  return retval;
  625|  52.8k|}
tj3Init:
  629|  46.2k|{
  630|  46.2k|  return tj3InitVersion(initType, 3001000);
  631|  46.2k|}
tj3Destroy:
  636|  52.8k|{
  637|  52.8k|  tjinstance *this = (tjinstance *)handle;
  638|  52.8k|  j_compress_ptr cinfo = NULL;
  639|  52.8k|  j_decompress_ptr dinfo = NULL;
  640|       |
  641|  52.8k|  if (!this) return;
  ------------------
  |  Branch (641:7): [True: 0, False: 52.8k]
  ------------------
  642|       |
  643|  52.8k|  cinfo = &this->cinfo;  dinfo = &this->dinfo;
  644|  52.8k|  this->jerr.warning = FALSE;
  ------------------
  |  |  207|  52.8k|#define FALSE   0               /* values of boolean */
  ------------------
  645|  52.8k|  this->isInstanceError = FALSE;
  ------------------
  |  |  207|  52.8k|#define FALSE   0               /* values of boolean */
  ------------------
  646|       |
  647|       |  /* NOTE: jpeg_destroy_*() can never throw a libjpeg error in libjpeg-turbo's
  648|       |     implementation, so this is a belt-and-suspenders measure. */
  649|  52.8k|  if (setjmp(this->jerr.setjmp_buffer)) goto destroy_decompress;
  ------------------
  |  Branch (649:7): [True: 0, False: 52.8k]
  ------------------
  650|  52.8k|  if (this->init & COMPRESS) jpeg_destroy_compress(cinfo);
  ------------------
  |  Branch (650:7): [True: 52.8k, False: 0]
  ------------------
  651|  52.8k|destroy_decompress:
  652|  52.8k|  if (setjmp(this->jerr.setjmp_buffer)) goto bailout;
  ------------------
  |  Branch (652:7): [True: 0, False: 52.8k]
  ------------------
  653|  52.8k|  if (this->init & DECOMPRESS) jpeg_destroy_decompress(dinfo);
  ------------------
  |  Branch (653:7): [True: 0, False: 52.8k]
  ------------------
  654|  52.8k|bailout:
  655|  52.8k|  free(this->iccBuf);
  656|  52.8k|  free(this->decompICCBuf);
  657|  52.8k|  free(this);
  658|  52.8k|}
tj3Set:
  732|   411k|{
  733|   411k|  static const char FUNCTION_NAME[] = "tj3Set";
  734|   411k|  int retval = 0;
  735|       |
  736|   411k|  GET_TJINSTANCE(handle, -1);
  ------------------
  |  |  338|   411k|  tjinstance *this = (tjinstance *)handle; \
  |  |  339|   411k|  \
  |  |  340|   411k|  if (!this) { \
  |  |  ------------------
  |  |  |  Branch (340:7): [True: 0, False: 411k]
  |  |  ------------------
  |  |  341|      0|    SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): Invalid handle", FUNCTION_NAME); \
  |  |  ------------------
  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  ------------------
  |  |                   SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): Invalid handle", FUNCTION_NAME); \
  |  |  ------------------
  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  342|      0|    return errorReturn; \
  |  |  343|      0|  } \
  |  |  344|   411k|  this->jerr.warning = FALSE; \
  |  |  ------------------
  |  |  |  |  207|   411k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  345|   411k|  this->isInstanceError = FALSE;
  |  |  ------------------
  |  |  |  |  207|   411k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  ------------------
  737|       |
  738|   411k|  switch (param) {
  739|      0|  case TJPARAM_STOPONWARNING:
  ------------------
  |  Branch (739:3): [True: 0, False: 411k]
  ------------------
  740|      0|    SET_BOOL_PARAM(jerr.stopOnWarning);
  ------------------
  |  |  724|      0|#define SET_BOOL_PARAM(field) { \
  |  |  725|      0|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (725:7): [True: 0, False: 0]
  |  |  |  Branch (725:20): [True: 0, False: 0]
  |  |  ------------------
  |  |  726|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  727|      0|  this->field = (boolean)value; \
  |  |  728|      0|}
  ------------------
  741|      0|    break;
  742|  46.2k|  case TJPARAM_BOTTOMUP:
  ------------------
  |  Branch (742:3): [True: 46.2k, False: 365k]
  ------------------
  743|  46.2k|    SET_BOOL_PARAM(bottomUp);
  ------------------
  |  |  724|  46.2k|#define SET_BOOL_PARAM(field) { \
  |  |  725|  46.2k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (725:7): [True: 0, False: 46.2k]
  |  |  |  Branch (725:20): [True: 0, False: 46.2k]
  |  |  ------------------
  |  |  726|  46.2k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  727|  46.2k|  this->field = (boolean)value; \
  |  |  728|  46.2k|}
  ------------------
  744|  46.2k|    break;
  745|  46.2k|  case TJPARAM_NOREALLOC:
  ------------------
  |  Branch (745:3): [True: 46.2k, False: 365k]
  ------------------
  746|  46.2k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (746:9): [True: 0, False: 46.2k]
  ------------------
  747|  46.2k|      THROW("TJPARAM_NOREALLOC is not applicable to decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  748|  46.2k|    SET_BOOL_PARAM(noRealloc);
  ------------------
  |  |  724|  46.2k|#define SET_BOOL_PARAM(field) { \
  |  |  725|  46.2k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (725:7): [True: 0, False: 46.2k]
  |  |  |  Branch (725:20): [True: 0, False: 46.2k]
  |  |  ------------------
  |  |  726|  46.2k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  727|  46.2k|  this->field = (boolean)value; \
  |  |  728|  46.2k|}
  ------------------
  749|  46.2k|    break;
  750|  20.8k|  case TJPARAM_QUALITY:
  ------------------
  |  Branch (750:3): [True: 20.8k, False: 390k]
  ------------------
  751|  20.8k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (751:9): [True: 0, False: 20.8k]
  ------------------
  752|  20.8k|      THROW("TJPARAM_QUALITY is not applicable to decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  753|  20.8k|    SET_PARAM(quality, 1, 100);
  ------------------
  |  |  718|  20.8k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|  20.8k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 20.8k]
  |  |  |  Branch (719:28): [True: 20.8k, Folded]
  |  |  |  Branch (719:44): [True: 0, False: 20.8k]
  |  |  ------------------
  |  |  720|  20.8k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|  20.8k|  this->field = value; \
  |  |  722|  20.8k|}
  ------------------
  754|  20.8k|    break;
  755|  20.8k|  case TJPARAM_SUBSAMP:
  ------------------
  |  Branch (755:3): [True: 20.8k, False: 390k]
  ------------------
  756|  20.8k|    SET_PARAM(subsamp, 0, this->numSamp - 1);
  ------------------
  |  |  718|  20.8k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|  20.8k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 20.8k]
  |  |  |  Branch (719:28): [True: 20.8k, False: 0]
  |  |  |  Branch (719:44): [True: 0, False: 20.8k]
  |  |  ------------------
  |  |  720|  20.8k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|  20.8k|  this->field = value; \
  |  |  722|  20.8k|}
  ------------------
  757|  20.8k|    break;
  758|      0|  case TJPARAM_JPEGWIDTH:
  ------------------
  |  Branch (758:3): [True: 0, False: 411k]
  ------------------
  759|      0|    if (!(this->init & DECOMPRESS))
  ------------------
  |  Branch (759:9): [True: 0, False: 0]
  ------------------
  760|      0|      THROW("TJPARAM_JPEGWIDTH is not applicable to compression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  761|      0|    THROW("TJPARAM_JPEGWIDTH is read-only in decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  762|      0|    break;
  763|      0|  case TJPARAM_JPEGHEIGHT:
  ------------------
  |  Branch (763:3): [True: 0, False: 411k]
  ------------------
  764|      0|    if (!(this->init & DECOMPRESS))
  ------------------
  |  Branch (764:9): [True: 0, False: 0]
  ------------------
  765|      0|      THROW("TJPARAM_JPEGHEIGHT is not applicable to compression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  766|      0|    THROW("TJPARAM_JPEGHEIGHT is read-only in decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  767|      0|    break;
  768|      0|  case TJPARAM_PRECISION:
  ------------------
  |  Branch (768:3): [True: 0, False: 411k]
  ------------------
  769|      0|    SET_PARAM(precision, 2, 16);
  ------------------
  |  |  718|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 0]
  |  |  |  Branch (719:28): [True: 0, Folded]
  |  |  |  Branch (719:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  720|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|      0|  this->field = value; \
  |  |  722|      0|}
  ------------------
  770|      0|    break;
  771|  46.2k|  case TJPARAM_COLORSPACE:
  ------------------
  |  Branch (771:3): [True: 46.2k, False: 365k]
  ------------------
  772|  46.2k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (772:9): [True: 0, False: 46.2k]
  ------------------
  773|  46.2k|      THROW("TJPARAM_COLORSPACE is read-only in decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  774|  46.2k|    SET_PARAM(colorspace, TJCS_DEFAULT, TJ_NUMCS - 1);
  ------------------
  |  |  718|  46.2k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|  46.2k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 46.2k]
  |  |  |  Branch (719:28): [True: 46.2k, Folded]
  |  |  |  Branch (719:44): [True: 0, False: 46.2k]
  |  |  ------------------
  |  |  720|  46.2k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|  46.2k|  this->field = value; \
  |  |  722|  46.2k|}
  ------------------
  775|  46.2k|    break;
  776|      0|  case TJPARAM_FASTUPSAMPLE:
  ------------------
  |  Branch (776:3): [True: 0, False: 411k]
  ------------------
  777|      0|    if (!(this->init & DECOMPRESS))
  ------------------
  |  Branch (777:9): [True: 0, False: 0]
  ------------------
  778|      0|      THROW("TJPARAM_FASTUPSAMPLE is not applicable to compression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  779|      0|    SET_BOOL_PARAM(fastUpsample);
  ------------------
  |  |  724|      0|#define SET_BOOL_PARAM(field) { \
  |  |  725|      0|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (725:7): [True: 0, False: 0]
  |  |  |  Branch (725:20): [True: 0, False: 0]
  |  |  ------------------
  |  |  726|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  727|      0|  this->field = (boolean)value; \
  |  |  728|      0|}
  ------------------
  780|      0|    break;
  781|  46.2k|  case TJPARAM_FASTDCT:
  ------------------
  |  Branch (781:3): [True: 46.2k, False: 365k]
  ------------------
  782|  46.2k|    SET_BOOL_PARAM(fastDCT);
  ------------------
  |  |  724|  46.2k|#define SET_BOOL_PARAM(field) { \
  |  |  725|  46.2k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (725:7): [True: 0, False: 46.2k]
  |  |  |  Branch (725:20): [True: 0, False: 46.2k]
  |  |  ------------------
  |  |  726|  46.2k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  727|  46.2k|  this->field = (boolean)value; \
  |  |  728|  46.2k|}
  ------------------
  783|  46.2k|    break;
  784|      0|  case TJPARAM_OPTIMIZE:
  ------------------
  |  Branch (784:3): [True: 0, False: 411k]
  ------------------
  785|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (785:9): [True: 0, False: 0]
  ------------------
  786|      0|      THROW("TJPARAM_OPTIMIZE is not applicable to decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  787|      0|    SET_BOOL_PARAM(optimize);
  ------------------
  |  |  724|      0|#define SET_BOOL_PARAM(field) { \
  |  |  725|      0|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (725:7): [True: 0, False: 0]
  |  |  |  Branch (725:20): [True: 0, False: 0]
  |  |  ------------------
  |  |  726|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  727|      0|  this->field = (boolean)value; \
  |  |  728|      0|}
  ------------------
  788|      0|    break;
  789|  46.2k|  case TJPARAM_PROGRESSIVE:
  ------------------
  |  Branch (789:3): [True: 46.2k, False: 365k]
  ------------------
  790|  46.2k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (790:9): [True: 0, False: 46.2k]
  ------------------
  791|  46.2k|      THROW("TJPARAM_PROGRESSIVE is read-only in decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  792|  46.2k|    SET_BOOL_PARAM(progressive);
  ------------------
  |  |  724|  46.2k|#define SET_BOOL_PARAM(field) { \
  |  |  725|  46.2k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (725:7): [True: 0, False: 46.2k]
  |  |  |  Branch (725:20): [True: 0, False: 46.2k]
  |  |  ------------------
  |  |  726|  46.2k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  727|  46.2k|  this->field = (boolean)value; \
  |  |  728|  46.2k|}
  ------------------
  793|  46.2k|    break;
  794|      0|  case TJPARAM_SCANLIMIT:
  ------------------
  |  Branch (794:3): [True: 0, False: 411k]
  ------------------
  795|      0|    if (!(this->init & DECOMPRESS))
  ------------------
  |  Branch (795:9): [True: 0, False: 0]
  ------------------
  796|      0|      THROW("TJPARAM_SCANLIMIT is not applicable to compression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  797|      0|    SET_PARAM(scanLimit, 0, -1);
  ------------------
  |  |  718|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 0]
  |  |  |  Branch (719:28): [Folded, False: 0]
  |  |  |  Branch (719:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  720|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|      0|  this->field = value; \
  |  |  722|      0|}
  ------------------
  798|      0|    break;
  799|  46.2k|  case TJPARAM_ARITHMETIC:
  ------------------
  |  Branch (799:3): [True: 46.2k, False: 365k]
  ------------------
  800|  46.2k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (800:9): [True: 0, False: 46.2k]
  ------------------
  801|  46.2k|      THROW("TJPARAM_ARITHMETIC is read-only in decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  802|  46.2k|    SET_BOOL_PARAM(arithmetic);
  ------------------
  |  |  724|  46.2k|#define SET_BOOL_PARAM(field) { \
  |  |  725|  46.2k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (725:7): [True: 0, False: 46.2k]
  |  |  |  Branch (725:20): [True: 0, False: 46.2k]
  |  |  ------------------
  |  |  726|  46.2k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  727|  46.2k|  this->field = (boolean)value; \
  |  |  728|  46.2k|}
  ------------------
  803|  46.2k|    break;
  804|      0|  case TJPARAM_LOSSLESS:
  ------------------
  |  Branch (804:3): [True: 0, False: 411k]
  ------------------
  805|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (805:9): [True: 0, False: 0]
  ------------------
  806|      0|      THROW("TJPARAM_LOSSLESS is read-only in decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  807|      0|    SET_BOOL_PARAM(lossless);
  ------------------
  |  |  724|      0|#define SET_BOOL_PARAM(field) { \
  |  |  725|      0|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (725:7): [True: 0, False: 0]
  |  |  |  Branch (725:20): [True: 0, False: 0]
  |  |  ------------------
  |  |  726|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  727|      0|  this->field = (boolean)value; \
  |  |  728|      0|}
  ------------------
  808|      0|    break;
  809|      0|  case TJPARAM_LOSSLESSPSV:
  ------------------
  |  Branch (809:3): [True: 0, False: 411k]
  ------------------
  810|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (810:9): [True: 0, False: 0]
  ------------------
  811|      0|      THROW("TJPARAM_LOSSLESSPSV is read-only in decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  812|      0|    SET_PARAM(losslessPSV, 1, 7);
  ------------------
  |  |  718|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 0]
  |  |  |  Branch (719:28): [True: 0, Folded]
  |  |  |  Branch (719:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  720|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|      0|  this->field = value; \
  |  |  722|      0|}
  ------------------
  813|      0|    break;
  814|      0|  case TJPARAM_LOSSLESSPT:
  ------------------
  |  Branch (814:3): [True: 0, False: 411k]
  ------------------
  815|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (815:9): [True: 0, False: 0]
  ------------------
  816|      0|      THROW("TJPARAM_LOSSLESSPT is read-only in decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  817|      0|    SET_PARAM(losslessPt, 0, 15);
  ------------------
  |  |  718|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 0]
  |  |  |  Branch (719:28): [True: 0, Folded]
  |  |  |  Branch (719:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  720|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|      0|  this->field = value; \
  |  |  722|      0|}
  ------------------
  818|      0|    break;
  819|      0|  case TJPARAM_RESTARTBLOCKS:
  ------------------
  |  Branch (819:3): [True: 0, False: 411k]
  ------------------
  820|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (820:9): [True: 0, False: 0]
  ------------------
  821|      0|      THROW("TJPARAM_RESTARTBLOCKS is not applicable to decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  822|      0|    SET_PARAM(restartIntervalBlocks, 0, 65535);
  ------------------
  |  |  718|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 0]
  |  |  |  Branch (719:28): [True: 0, Folded]
  |  |  |  Branch (719:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  720|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|      0|  this->field = value; \
  |  |  722|      0|}
  ------------------
  823|      0|    if (value != 0) this->restartIntervalRows = 0;
  ------------------
  |  Branch (823:9): [True: 0, False: 0]
  ------------------
  824|      0|    break;
  825|  46.2k|  case TJPARAM_RESTARTROWS:
  ------------------
  |  Branch (825:3): [True: 46.2k, False: 365k]
  ------------------
  826|  46.2k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (826:9): [True: 0, False: 46.2k]
  ------------------
  827|  46.2k|      THROW("TJPARAM_RESTARTROWS is not applicable to decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  828|  46.2k|    SET_PARAM(restartIntervalRows, 0, 65535);
  ------------------
  |  |  718|  46.2k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|  46.2k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 46.2k]
  |  |  |  Branch (719:28): [True: 46.2k, Folded]
  |  |  |  Branch (719:44): [True: 0, False: 46.2k]
  |  |  ------------------
  |  |  720|  46.2k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|  46.2k|  this->field = value; \
  |  |  722|  46.2k|}
  ------------------
  829|  46.2k|    if (value != 0) this->restartIntervalBlocks = 0;
  ------------------
  |  Branch (829:9): [True: 13.2k, False: 33.0k]
  ------------------
  830|  46.2k|    break;
  831|      0|  case TJPARAM_XDENSITY:
  ------------------
  |  Branch (831:3): [True: 0, False: 411k]
  ------------------
  832|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (832:9): [True: 0, False: 0]
  ------------------
  833|      0|      THROW("TJPARAM_XDENSITY is read-only in decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  834|      0|    SET_PARAM(xDensity, 1, 65535);
  ------------------
  |  |  718|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 0]
  |  |  |  Branch (719:28): [True: 0, Folded]
  |  |  |  Branch (719:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  720|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|      0|  this->field = value; \
  |  |  722|      0|}
  ------------------
  835|      0|    break;
  836|      0|  case TJPARAM_YDENSITY:
  ------------------
  |  Branch (836:3): [True: 0, False: 411k]
  ------------------
  837|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (837:9): [True: 0, False: 0]
  ------------------
  838|      0|      THROW("TJPARAM_YDENSITY is read-only in decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  839|      0|    SET_PARAM(yDensity, 1, 65535);
  ------------------
  |  |  718|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 0]
  |  |  |  Branch (719:28): [True: 0, Folded]
  |  |  |  Branch (719:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  720|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|      0|  this->field = value; \
  |  |  722|      0|}
  ------------------
  840|      0|    break;
  841|      0|  case TJPARAM_DENSITYUNITS:
  ------------------
  |  Branch (841:3): [True: 0, False: 411k]
  ------------------
  842|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (842:9): [True: 0, False: 0]
  ------------------
  843|      0|      THROW("TJPARAM_DENSITYUNITS is read-only in decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  844|      0|    SET_PARAM(densityUnits, 0, 2);
  ------------------
  |  |  718|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 0]
  |  |  |  Branch (719:28): [True: 0, Folded]
  |  |  |  Branch (719:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  720|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|      0|  this->field = value; \
  |  |  722|      0|}
  ------------------
  845|      0|    break;
  846|      0|  case TJPARAM_MAXMEMORY:
  ------------------
  |  Branch (846:3): [True: 0, False: 411k]
  ------------------
  847|      0|    SET_PARAM(maxMemory, 0, (int)(min(LONG_MAX / 1048576L, (long)INT_MAX)));
  ------------------
  |  |  718|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 0]
  |  |  |  Branch (719:28): [Folded, False: 0]
  |  |  |  Branch (719:28): [True: 0, Folded]
  |  |  |  Branch (719:44): [True: 0, False: 0]
  |  |  |  Branch (719:52): [Folded, False: 0]
  |  |  ------------------
  |  |  720|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|      0|  this->field = value; \
  |  |  722|      0|}
  ------------------
  848|      0|    break;
  849|  46.2k|  case TJPARAM_MAXPIXELS:
  ------------------
  |  Branch (849:3): [True: 46.2k, False: 365k]
  ------------------
  850|  46.2k|    SET_PARAM(maxPixels, 0, -1);
  ------------------
  |  |  718|  46.2k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|  46.2k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 46.2k]
  |  |  |  Branch (719:28): [Folded, False: 46.2k]
  |  |  |  Branch (719:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  720|  46.2k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|  46.2k|  this->field = value; \
  |  |  722|  46.2k|}
  ------------------
  851|  46.2k|    break;
  852|      0|  case TJPARAM_SAVEMARKERS:
  ------------------
  |  Branch (852:3): [True: 0, False: 411k]
  ------------------
  853|      0|    SET_PARAM(saveMarkers, 0, 4);
  ------------------
  |  |  718|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  719|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (719:7): [True: 0, False: 0]
  |  |  |  Branch (719:28): [True: 0, Folded]
  |  |  |  Branch (719:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  720|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  257|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  282|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  721|      0|  this->field = value; \
  |  |  722|      0|}
  ------------------
  854|      0|    break;
  855|      0|  default:
  ------------------
  |  Branch (855:3): [True: 0, False: 411k]
  ------------------
  856|      0|    THROW("Invalid parameter");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  857|   411k|  }
  858|       |
  859|   411k|bailout:
  860|   411k|  return retval;
  861|   411k|}
tj3Get:
  866|  20.8k|{
  867|  20.8k|  tjinstance *this = (tjinstance *)handle;
  868|  20.8k|  if (!this) return -1;
  ------------------
  |  Branch (868:7): [True: 0, False: 20.8k]
  ------------------
  869|       |
  870|  20.8k|  switch (param) {
  ------------------
  |  Branch (870:11): [True: 20.8k, False: 0]
  ------------------
  871|      0|  case TJPARAM_STOPONWARNING:
  ------------------
  |  Branch (871:3): [True: 0, False: 20.8k]
  ------------------
  872|      0|    return this->jerr.stopOnWarning;
  873|      0|  case TJPARAM_BOTTOMUP:
  ------------------
  |  Branch (873:3): [True: 0, False: 20.8k]
  ------------------
  874|      0|    return this->bottomUp;
  875|  20.8k|  case TJPARAM_NOREALLOC:
  ------------------
  |  Branch (875:3): [True: 20.8k, False: 0]
  ------------------
  876|  20.8k|    return this->noRealloc;
  877|      0|  case TJPARAM_QUALITY:
  ------------------
  |  Branch (877:3): [True: 0, False: 20.8k]
  ------------------
  878|      0|    return this->quality;
  879|      0|  case TJPARAM_SUBSAMP:
  ------------------
  |  Branch (879:3): [True: 0, False: 20.8k]
  ------------------
  880|      0|    return this->subsamp;
  881|      0|  case TJPARAM_JPEGWIDTH:
  ------------------
  |  Branch (881:3): [True: 0, False: 20.8k]
  ------------------
  882|      0|    return this->jpegWidth;
  883|      0|  case TJPARAM_JPEGHEIGHT:
  ------------------
  |  Branch (883:3): [True: 0, False: 20.8k]
  ------------------
  884|      0|    return this->jpegHeight;
  885|      0|  case TJPARAM_PRECISION:
  ------------------
  |  Branch (885:3): [True: 0, False: 20.8k]
  ------------------
  886|      0|    return this->precision;
  887|      0|  case TJPARAM_COLORSPACE:
  ------------------
  |  Branch (887:3): [True: 0, False: 20.8k]
  ------------------
  888|      0|    return this->colorspace;
  889|      0|  case TJPARAM_FASTUPSAMPLE:
  ------------------
  |  Branch (889:3): [True: 0, False: 20.8k]
  ------------------
  890|      0|    return this->fastUpsample;
  891|      0|  case TJPARAM_FASTDCT:
  ------------------
  |  Branch (891:3): [True: 0, False: 20.8k]
  ------------------
  892|      0|    return this->fastDCT;
  893|      0|  case TJPARAM_OPTIMIZE:
  ------------------
  |  Branch (893:3): [True: 0, False: 20.8k]
  ------------------
  894|      0|    return this->optimize;
  895|      0|  case TJPARAM_PROGRESSIVE:
  ------------------
  |  Branch (895:3): [True: 0, False: 20.8k]
  ------------------
  896|      0|    return this->progressive;
  897|      0|  case TJPARAM_SCANLIMIT:
  ------------------
  |  Branch (897:3): [True: 0, False: 20.8k]
  ------------------
  898|      0|    return this->scanLimit;
  899|      0|  case TJPARAM_ARITHMETIC:
  ------------------
  |  Branch (899:3): [True: 0, False: 20.8k]
  ------------------
  900|      0|    return this->arithmetic;
  901|      0|  case TJPARAM_LOSSLESS:
  ------------------
  |  Branch (901:3): [True: 0, False: 20.8k]
  ------------------
  902|      0|    return this->lossless;
  903|      0|  case TJPARAM_LOSSLESSPSV:
  ------------------
  |  Branch (903:3): [True: 0, False: 20.8k]
  ------------------
  904|      0|    return this->losslessPSV;
  905|      0|  case TJPARAM_LOSSLESSPT:
  ------------------
  |  Branch (905:3): [True: 0, False: 20.8k]
  ------------------
  906|      0|    return this->losslessPt;
  907|      0|  case TJPARAM_RESTARTBLOCKS:
  ------------------
  |  Branch (907:3): [True: 0, False: 20.8k]
  ------------------
  908|      0|    return this->restartIntervalBlocks;
  909|      0|  case TJPARAM_RESTARTROWS:
  ------------------
  |  Branch (909:3): [True: 0, False: 20.8k]
  ------------------
  910|      0|    return this->restartIntervalRows;
  911|      0|  case TJPARAM_XDENSITY:
  ------------------
  |  Branch (911:3): [True: 0, False: 20.8k]
  ------------------
  912|      0|    return this->xDensity;
  913|      0|  case TJPARAM_YDENSITY:
  ------------------
  |  Branch (913:3): [True: 0, False: 20.8k]
  ------------------
  914|      0|    return this->yDensity;
  915|      0|  case TJPARAM_DENSITYUNITS:
  ------------------
  |  Branch (915:3): [True: 0, False: 20.8k]
  ------------------
  916|      0|    return this->densityUnits;
  917|      0|  case TJPARAM_MAXMEMORY:
  ------------------
  |  Branch (917:3): [True: 0, False: 20.8k]
  ------------------
  918|      0|    return this->maxMemory;
  919|      0|  case TJPARAM_MAXPIXELS:
  ------------------
  |  Branch (919:3): [True: 0, False: 20.8k]
  ------------------
  920|      0|    return this->maxPixels;
  921|      0|  case TJPARAM_SAVEMARKERS:
  ------------------
  |  Branch (921:3): [True: 0, False: 20.8k]
  ------------------
  922|      0|    return this->saveMarkers;
  923|  20.8k|  }
  924|       |
  925|      0|  return -1;
  926|  20.8k|}
tj3Alloc:
  936|  2.95k|{
  937|  2.95k|  return MALLOC(bytes);
  ------------------
  |  |  520|  2.95k|#define MALLOC(size)  malloc(size)
  ------------------
  938|  2.95k|}
tj3Free:
  949|  54.8k|{
  950|  54.8k|  free(buf);
  951|  54.8k|}
tj3JPEGBufSize:
  962|  20.8k|{
  963|  20.8k|  static const char FUNCTION_NAME[] = "tj3JPEGBufSize";
  964|  20.8k|  unsigned long long retval = 0;
  965|  20.8k|  int mcuw, mcuh, chromasf;
  966|       |
  967|  20.8k|  if (width < 1 || height < 1 || jpegSubsamp < TJSAMP_UNKNOWN ||
  ------------------
  |  Branch (967:7): [True: 0, False: 20.8k]
  |  Branch (967:20): [True: 0, False: 20.8k]
  |  Branch (967:34): [True: 0, False: 20.8k]
  ------------------
  968|  20.8k|      jpegSubsamp >= TJ_NUMSAMP)
  ------------------
  |  |  111|  20.8k|#define TJ_NUMSAMP  9
  ------------------
  |  Branch (968:7): [True: 0, False: 20.8k]
  ------------------
  969|  20.8k|    THROWG("Invalid argument", 0);
  ------------------
  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  ------------------
  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  ------------------
  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  ------------------
  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  257|      0|}
  ------------------
  970|       |
  971|  20.8k|  if (jpegSubsamp == TJSAMP_UNKNOWN)
  ------------------
  |  Branch (971:7): [True: 0, False: 20.8k]
  ------------------
  972|      0|    jpegSubsamp = TJSAMP_444;
  973|       |
  974|       |  /* This allows for rare corner cases in which a JPEG image can actually be
  975|       |     larger than the uncompressed input (we wouldn't mention it if it hadn't
  976|       |     happened before.) */
  977|  20.8k|  mcuw = tjMCUWidth[jpegSubsamp];
  978|  20.8k|  mcuh = tjMCUHeight[jpegSubsamp];
  979|  20.8k|  chromasf = jpegSubsamp == TJSAMP_GRAY ? 0 : 4 * 64 / (mcuw * mcuh);
  ------------------
  |  Branch (979:14): [True: 6.42k, False: 14.4k]
  ------------------
  980|  20.8k|  retval = PAD(width, mcuw) * PAD(height, mcuh) * (2ULL + chromasf) + 2048ULL;
  ------------------
  |  |   57|  20.8k|#define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
  ------------------
                retval = PAD(width, mcuw) * PAD(height, mcuh) * (2ULL + chromasf) + 2048ULL;
  ------------------
  |  |   57|  20.8k|#define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
  ------------------
  981|       |#if ULLONG_MAX > ULONG_MAX
  982|       |  if (retval > (unsigned long long)((unsigned long)-1))
  983|       |    THROWG("Image is too large", 0);
  984|       |#endif
  985|       |
  986|  20.8k|bailout:
  987|  20.8k|  return (size_t)retval;
  988|  20.8k|}
tj3SetICCProfile:
 1225|  17.8k|{
 1226|  17.8k|  static const char FUNCTION_NAME[] = "tj3SetICCProfile";
 1227|  17.8k|  int retval = 0;
 1228|       |
 1229|  17.8k|  GET_TJINSTANCE(handle, -1)
  ------------------
  |  |  338|  17.8k|  tjinstance *this = (tjinstance *)handle; \
  |  |  339|  17.8k|  \
  |  |  340|  17.8k|  if (!this) { \
  |  |  ------------------
  |  |  |  Branch (340:7): [True: 0, False: 17.8k]
  |  |  ------------------
  |  |  341|      0|    SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): Invalid handle", FUNCTION_NAME); \
  |  |  ------------------
  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  ------------------
  |  |                   SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): Invalid handle", FUNCTION_NAME); \
  |  |  ------------------
  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  342|      0|    return errorReturn; \
  |  |  343|      0|  } \
  |  |  344|  17.8k|  this->jerr.warning = FALSE; \
  |  |  ------------------
  |  |  |  |  207|  17.8k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  345|  17.8k|  this->isInstanceError = FALSE;
  |  |  ------------------
  |  |  |  |  207|  17.8k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  ------------------
 1230|  17.8k|  if ((this->init & COMPRESS) == 0)
  ------------------
  |  Branch (1230:7): [True: 0, False: 17.8k]
  ------------------
 1231|  17.8k|    THROW("Instance has not been initialized for compression");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
 1232|       |
 1233|  17.8k|  if (iccBuf == this->iccBuf && iccSize == this->iccSize)
  ------------------
  |  Branch (1233:7): [True: 0, False: 17.8k]
  |  Branch (1233:33): [True: 0, False: 0]
  ------------------
 1234|      0|    return 0;
 1235|       |
 1236|  17.8k|  free(this->iccBuf);
 1237|  17.8k|  this->iccBuf = NULL;
 1238|  17.8k|  this->iccSize = 0;
 1239|  17.8k|  if (iccBuf && iccSize) {
  ------------------
  |  Branch (1239:7): [True: 17.8k, False: 0]
  |  Branch (1239:17): [True: 17.8k, False: 0]
  ------------------
 1240|  17.8k|    if ((this->iccBuf = (unsigned char *)malloc(iccSize)) == NULL)
  ------------------
  |  Branch (1240:9): [True: 0, False: 17.8k]
  ------------------
 1241|  17.8k|      THROW("Memory allocation failure");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
 1242|  17.8k|    memcpy(this->iccBuf, iccBuf, iccSize);
 1243|  17.8k|    this->iccSize = iccSize;
 1244|  17.8k|  }
 1245|       |
 1246|  17.8k|bailout:
 1247|  17.8k|  return retval;
 1248|  17.8k|}
turbojpeg.c:_tjInitCompress:
 1185|  52.8k|{
 1186|  52.8k|  static unsigned char buffer[1];
 1187|  52.8k|  unsigned char *buf = buffer;
 1188|  52.8k|  size_t size = 1;
 1189|       |
 1190|       |  /* This is also straight out of example.c */
 1191|  52.8k|  this->cinfo.err = jpeg_std_error(&this->jerr.pub);
 1192|  52.8k|  this->jerr.pub.error_exit = my_error_exit;
 1193|  52.8k|  this->jerr.pub.output_message = my_output_message;
 1194|  52.8k|  this->jerr.emit_message = this->jerr.pub.emit_message;
 1195|  52.8k|  this->jerr.pub.emit_message = my_emit_message;
 1196|  52.8k|  this->jerr.pub.addon_message_table = turbojpeg_message_table;
 1197|  52.8k|  this->jerr.pub.first_addon_message = JMSG_FIRSTADDONCODE;
 1198|  52.8k|  this->jerr.pub.last_addon_message = JMSG_LASTADDONCODE;
 1199|  52.8k|  this->jerr.tjHandle = (tjhandle)this;
 1200|       |
 1201|  52.8k|  if (setjmp(this->jerr.setjmp_buffer)) {
  ------------------
  |  Branch (1201:7): [True: 0, False: 52.8k]
  ------------------
 1202|       |    /* If we get here, the JPEG code has signaled an error. */
 1203|      0|    free(this);
 1204|      0|    return NULL;
 1205|      0|  }
 1206|       |
 1207|  52.8k|  jpeg_create_compress(&this->cinfo);
  ------------------
  |  |  969|  52.8k|  jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
  |  |  ------------------
  |  |  |  |    4|  52.8k|#define JPEG_LIB_VERSION  62
  |  |  ------------------
  |  |  970|  52.8k|                      (size_t)sizeof(struct jpeg_compress_struct))
  ------------------
 1208|       |  /* Make an initial call so it will create the destination manager */
 1209|  52.8k|  jpeg_mem_dest_tj(&this->cinfo, &buf, &size, 0);
 1210|       |
 1211|  52.8k|  this->init |= COMPRESS;
 1212|  52.8k|  return (tjhandle)this;
 1213|  52.8k|}
turbojpeg.c:my_error_exit:
   81|  33.9k|{
   82|  33.9k|  my_error_ptr myerr = (my_error_ptr)cinfo->err;
   83|       |
   84|  33.9k|  (*cinfo->err->output_message) (cinfo);
   85|  33.9k|  longjmp(myerr->setjmp_buffer, 1);
   86|  33.9k|}
turbojpeg.c:my_output_message:
  149|  33.9k|{
  150|  33.9k|  my_error_ptr myerr = (my_error_ptr)cinfo->err;
  151|  33.9k|  tjinstance *this = (tjinstance *)myerr->tjHandle;
  152|       |
  153|  33.9k|  if (this) {
  ------------------
  |  Branch (153:7): [True: 33.9k, False: 0]
  ------------------
  154|  33.9k|    this->isInstanceError = TRUE;
  ------------------
  |  |  210|  33.9k|#define TRUE    1
  ------------------
  155|  33.9k|    (*cinfo->err->format_message) (cinfo, this->errStr);
  156|  33.9k|  } else
  157|      0|    (*cinfo->err->format_message) (cinfo, errStr);
  158|  33.9k|}
turbojpeg.c:my_emit_message:
   89|  31.9k|{
   90|  31.9k|  my_error_ptr myerr = (my_error_ptr)cinfo->err;
   91|       |
   92|  31.9k|  myerr->emit_message(cinfo, msg_level);
   93|  31.9k|  if (msg_level < 0) {
  ------------------
  |  Branch (93:7): [True: 0, False: 31.9k]
  ------------------
   94|      0|    myerr->warning = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
   95|      0|    if (myerr->stopOnWarning) longjmp(myerr->setjmp_buffer, 1);
  ------------------
  |  Branch (95:9): [True: 0, False: 0]
  ------------------
   96|      0|  }
   97|  31.9k|}
turbojpeg.c:setCompDefaults:
  367|  20.8k|{
  368|  20.8k|  int colorspace = yuv ? TJCS_DEFAULT : this->colorspace;
  ------------------
  |  Branch (368:20): [True: 0, False: 20.8k]
  ------------------
  369|       |
  370|  20.8k|  this->cinfo.in_color_space = pf2cs[pixelFormat];
  371|  20.8k|  this->cinfo.input_components = tjPixelSize[pixelFormat];
  372|  20.8k|  jpeg_set_defaults(&this->cinfo);
  373|       |
  374|  20.8k|  this->cinfo.restart_interval = this->restartIntervalBlocks;
  375|  20.8k|  this->cinfo.restart_in_rows = this->restartIntervalRows;
  376|  20.8k|  this->cinfo.X_density = (UINT16)this->xDensity;
  377|  20.8k|  this->cinfo.Y_density = (UINT16)this->yDensity;
  378|  20.8k|  this->cinfo.density_unit = (UINT8)this->densityUnits;
  379|  20.8k|  this->cinfo.mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
  380|       |
  381|  20.8k|  if (this->lossless && !yuv) {
  ------------------
  |  Branch (381:7): [True: 0, False: 20.8k]
  |  Branch (381:25): [True: 0, False: 0]
  ------------------
  382|      0|#ifdef C_LOSSLESS_SUPPORTED
  383|      0|    jpeg_enable_lossless(&this->cinfo, this->losslessPSV, this->losslessPt);
  384|      0|#endif
  385|      0|    return;
  386|      0|  }
  387|       |
  388|  20.8k|  jpeg_set_quality(&this->cinfo, this->quality, TRUE);
  ------------------
  |  |  210|  20.8k|#define TRUE    1
  ------------------
  389|  20.8k|  this->cinfo.dct_method = this->fastDCT ? JDCT_FASTEST : JDCT_ISLOW;
  ------------------
  |  |  304|  2.95k|#define JDCT_FASTEST  JDCT_IFAST
  ------------------
  |  Branch (389:28): [True: 2.95k, False: 17.8k]
  ------------------
  390|       |
  391|  20.8k|  switch (colorspace) {
  392|  2.83k|  case TJCS_RGB:
  ------------------
  |  Branch (392:3): [True: 2.83k, False: 18.0k]
  ------------------
  393|  2.83k|    jpeg_set_colorspace(&this->cinfo, JCS_RGB);  break;
  394|  2.95k|  case TJCS_YCbCr:
  ------------------
  |  Branch (394:3): [True: 2.95k, False: 17.8k]
  ------------------
  395|  2.95k|    jpeg_set_colorspace(&this->cinfo, JCS_YCbCr);  break;
  396|  2.83k|  case TJCS_GRAY:
  ------------------
  |  Branch (396:3): [True: 2.83k, False: 18.0k]
  ------------------
  397|  2.83k|    jpeg_set_colorspace(&this->cinfo, JCS_GRAYSCALE);  break;
  398|      0|  case TJCS_CMYK:
  ------------------
  |  Branch (398:3): [True: 0, False: 20.8k]
  ------------------
  399|      0|    jpeg_set_colorspace(&this->cinfo, JCS_CMYK);  break;
  400|  2.83k|  case TJCS_YCCK:
  ------------------
  |  Branch (400:3): [True: 2.83k, False: 18.0k]
  ------------------
  401|  2.83k|    jpeg_set_colorspace(&this->cinfo, JCS_YCCK);  break;
  402|  9.37k|  default:
  ------------------
  |  Branch (402:3): [True: 9.37k, False: 11.4k]
  ------------------
  403|  9.37k|    if (this->subsamp == TJSAMP_GRAY)
  ------------------
  |  Branch (403:9): [True: 3.58k, False: 5.78k]
  ------------------
  404|  3.58k|      jpeg_set_colorspace(&this->cinfo, JCS_GRAYSCALE);
  405|  5.78k|    else if (pixelFormat == TJPF_CMYK)
  ------------------
  |  Branch (405:14): [True: 0, False: 5.78k]
  ------------------
  406|      0|      jpeg_set_colorspace(&this->cinfo, JCS_YCCK);
  407|  5.78k|    else
  408|  5.78k|      jpeg_set_colorspace(&this->cinfo, JCS_YCbCr);
  409|  20.8k|  }
  410|       |
  411|  20.8k|  if (this->cinfo.data_precision == 8)
  ------------------
  |  Branch (411:7): [True: 0, False: 20.8k]
  ------------------
  412|      0|    this->cinfo.optimize_coding = this->optimize;
  413|  20.8k|#ifdef C_PROGRESSIVE_SUPPORTED
  414|  20.8k|  if (this->progressive) jpeg_simple_progression(&this->cinfo);
  ------------------
  |  Branch (414:7): [True: 6.42k, False: 14.4k]
  ------------------
  415|  20.8k|#endif
  416|  20.8k|  this->cinfo.arith_code = this->arithmetic;
  417|       |
  418|  20.8k|  this->cinfo.comp_info[0].h_samp_factor = tjMCUWidth[this->subsamp] / 8;
  419|  20.8k|  this->cinfo.comp_info[1].h_samp_factor = 1;
  420|  20.8k|  this->cinfo.comp_info[2].h_samp_factor = 1;
  421|  20.8k|  if (this->cinfo.num_components > 3)
  ------------------
  |  Branch (421:7): [True: 2.83k, False: 18.0k]
  ------------------
  422|  2.83k|    this->cinfo.comp_info[3].h_samp_factor = tjMCUWidth[this->subsamp] / 8;
  423|  20.8k|  this->cinfo.comp_info[0].v_samp_factor = tjMCUHeight[this->subsamp] / 8;
  424|  20.8k|  this->cinfo.comp_info[1].v_samp_factor = 1;
  425|  20.8k|  this->cinfo.comp_info[2].v_samp_factor = 1;
  426|  20.8k|  if (this->cinfo.num_components > 3)
  ------------------
  |  Branch (426:7): [True: 2.83k, False: 18.0k]
  ------------------
  427|  2.83k|    this->cinfo.comp_info[3].v_samp_factor = tjMCUHeight[this->subsamp] / 8;
  428|  20.8k|}

