LLVMFuzzerTestOneInput:
   55|  6.85k|{
   56|  6.85k|  tjhandle handle = NULL;
   57|  6.85k|  short *imgBuf = NULL, *srcBuf;
   58|  6.85k|  unsigned char *dstBuf = NULL;
   59|  6.85k|  int width = 0, height = 0, ti;
   60|  6.85k|  FILE *file = NULL;
   61|  6.85k|  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.85k|    { 0, TJPF_RGB,  TJCS_YCbCr,   TJSAMP_444,  1,  100, 0,  0,  1,    0    },
   66|  6.85k|    { 0, TJPF_BGR,  TJCS_DEFAULT, TJSAMP_422,  0,  90,  0,  0,  0,    0    },
   67|  6.85k|    { 0, TJPF_RGBX, TJCS_RGB,     TJSAMP_420,  0,  75,  0,  1,  0,    1    },
   68|  6.85k|    { 0, TJPF_BGRA, TJCS_DEFAULT, TJSAMP_411,  0,  50,  0,  0,  0,    0    },
   69|  6.85k|    { 0, TJPF_XRGB, TJCS_GRAY,    TJSAMP_GRAY, 0,  25,  0,  0,  0,    0    },
   70|  6.85k|    { 0, TJPF_GRAY, TJCS_DEFAULT, TJSAMP_GRAY, 0,  10,  1,  0,  0,    0    },
   71|  6.85k|    { 1, TJPF_CMYK, TJCS_YCCK,    TJSAMP_440,  0,  1,   1,  1,  0,    1    }
   72|  6.85k|  };
   73|       |
   74|  6.85k|  if ((file = fmemopen((void *)data, size, "r")) == NULL)
  ------------------
  |  Branch (74:7): [True: 0, False: 6.85k]
  ------------------
   75|      0|    goto bailout;
   76|       |
   77|  6.85k|  if ((handle = tj3Init(TJINIT_COMPRESS)) == NULL)
  ------------------
  |  | 1284|  6.85k|#define tj3Init(initType)  tj3InitVersion(initType, TURBOJPEG_VERSION_NUMBER)
  |  |  ------------------
  |  |  |  |   34|  6.85k|#define TURBOJPEG_VERSION_NUMBER  3002000
  |  |  ------------------
  ------------------
  |  Branch (77:7): [True: 0, False: 6.85k]
  ------------------
   78|      0|    goto bailout;
   79|       |
   80|  54.8k|  for (ti = 0; ti < NUMTESTS; ti++) {
  ------------------
  |  |   42|  54.8k|#define NUMTESTS  7
  ------------------
  |  Branch (80:16): [True: 47.9k, False: 6.85k]
  ------------------
   81|  47.9k|    int pf = tests[ti].pf;
   82|  47.9k|    size_t dstSize = 0, maxBufSize, i, sum = 0;
   83|       |
   84|       |    /* Test non-default compression options on specific iterations. */
   85|  47.9k|    tj3Set(handle, TJPARAM_BOTTOMUP, tests[ti].bottomUp);
   86|  47.9k|    tj3Set(handle, TJPARAM_COLORSPACE, tests[ti].colorspace);
   87|  47.9k|    tj3Set(handle, TJPARAM_FASTDCT, tests[ti].fastDCT);
   88|  47.9k|    tj3Set(handle, TJPARAM_PROGRESSIVE, tests[ti].progressive);
   89|  47.9k|    tj3Set(handle, TJPARAM_ARITHMETIC, tests[ti].arithmetic);
   90|  47.9k|    tj3Set(handle, TJPARAM_NOREALLOC, tests[ti].noRealloc);
   91|  47.9k|    tj3Set(handle, TJPARAM_RESTARTROWS, tests[ti].restartRows);
   92|       |
   93|  47.9k|    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|  47.9k|    fseek(file, 0, SEEK_SET);
   97|  47.9k|    if ((imgBuf = _tj3LoadImageFromFileHandle12(handle, file, &width, 1,
  ------------------
  |  Branch (97:9): [True: 36.5k, False: 11.4k]
  ------------------
   98|  47.9k|                                                &height, &pf)) == NULL) {
   99|  36.5k|      if (size < 2)
  ------------------
  |  Branch (99:11): [True: 175, False: 36.4k]
  ------------------
  100|    175|        continue;
  101|       |
  102|       |      /* Derive image dimensions from input data.  Use first 2 bytes to
  103|       |         influence width/height. */
  104|  36.4k|      width = (data[0] % 64) + 8;   /* 8-71 */
  105|  36.4k|      height = (data[1] % 64) + 8;  /* 8-71 */
  106|       |
  107|  36.4k|      size_t required_size = 2 + (size_t)width * height *
  108|  36.4k|                             tjPixelSize[tests[ti].pf] * 2;
  109|  36.4k|      if (size < required_size) {
  ------------------
  |  Branch (109:11): [True: 32.7k, False: 3.64k]
  ------------------
  110|       |        /* Not enough data - try smaller dimensions */
  111|  32.7k|        width = 8;
  112|  32.7k|        height = 8;
  113|  32.7k|        required_size = 2 + (size_t)width * height *
  114|  32.7k|                        tjPixelSize[tests[ti].pf] * 2;
  115|  32.7k|        if (size < required_size)
  ------------------
  |  Branch (115:13): [True: 26.5k, False: 6.19k]
  ------------------
  116|  26.5k|          continue;
  117|  32.7k|      }
  118|       |
  119|       |      /* Skip header bytes. */
  120|  9.84k|      srcBuf = (short *)(data + 2);
  121|  9.84k|    } else
  122|  11.4k|      srcBuf = imgBuf;
  123|       |
  124|  21.2k|    dstSize = maxBufSize = tj3JPEGBufSize(width, height, tests[ti].subsamp);
  125|  21.2k|    if (tj3Get(handle, TJPARAM_NOREALLOC)) {
  ------------------
  |  Branch (125:9): [True: 3.01k, False: 18.2k]
  ------------------
  126|  3.01k|      if ((dstBuf = (unsigned char *)tj3Alloc(dstSize)) == NULL)
  ------------------
  |  Branch (126:11): [True: 0, False: 3.01k]
  ------------------
  127|      0|        goto bailout;
  128|  3.01k|    } else
  129|  18.2k|      dstBuf = NULL;
  130|       |
  131|  21.2k|    if (size >= 34)
  ------------------
  |  Branch (131:9): [True: 17.7k, False: 3.46k]
  ------------------
  132|  17.7k|      tj3SetICCProfile(handle, (unsigned char *)&data[2], 32);
  133|       |
  134|  21.2k|    tj3Set(handle, TJPARAM_SUBSAMP, tests[ti].subsamp);
  135|  21.2k|    tj3Set(handle, TJPARAM_QUALITY, tests[ti].quality);
  136|  21.2k|    if (tj3Compress12(handle, srcBuf, width, 0, height, pf, &dstBuf,
  ------------------
  |  Branch (136:9): [True: 21.2k, False: 3]
  ------------------
  137|  21.2k|                      &dstSize) == 0) {
  138|       |      /* Touch all of the output data in order to catch uninitialized reads
  139|       |         when using MemorySanitizer. */
  140|   336M|      for (i = 0; i < dstSize; i++)
  ------------------
  |  Branch (140:19): [True: 336M, False: 21.2k]
  ------------------
  141|   336M|        sum += dstBuf[i];
  142|  21.2k|    }
  143|       |
  144|  21.2k|    tj3Free(dstBuf);
  145|  21.2k|    dstBuf = NULL;
  146|  21.2k|    tj3Free(imgBuf);
  147|  21.2k|    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|  21.2k|    if (sum > 255 * maxBufSize)
  ------------------
  |  Branch (151:9): [True: 0, False: 21.2k]
  ------------------
  152|      0|      goto bailout;
  153|  21.2k|  }
  154|       |
  155|  6.85k|bailout:
  156|  6.85k|  tj3Free(dstBuf);
  157|  6.85k|  tj3Free(imgBuf);
  158|  6.85k|  if (file) fclose(file);
  ------------------
  |  Branch (158:7): [True: 6.85k, False: 0]
  ------------------
  159|  6.85k|  tj3Destroy(handle);
  160|  6.85k|  return 0;
  161|  6.85k|}

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

rdpng-12.c:rgb_to_cmyk:
   29|  25.3M|{
   30|  25.3M|  double ctmp = 1.0 - ((double)r / (double)maxval);
   31|  25.3M|  double mtmp = 1.0 - ((double)g / (double)maxval);
   32|  25.3M|  double ytmp = 1.0 - ((double)b / (double)maxval);
   33|  25.3M|  double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
  ------------------
  |  |  515|  50.6M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 3.11M, False: 22.1M]
  |  |  |  Branch (515:27): [True: 1.95M, False: 23.3M]
  |  |  |  Branch (515:39): [True: 1.12M, False: 1.99M]
  |  |  ------------------
  ------------------
   34|       |
   35|  25.3M|  if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
  ------------------
  |  Branch (35:7): [True: 15.5M, False: 9.70M]
  ------------------
   36|  9.70M|  else {
   37|  9.70M|    ctmp = (ctmp - ktmp) / (1.0 - ktmp);
   38|  9.70M|    mtmp = (mtmp - ktmp) / (1.0 - ktmp);
   39|  9.70M|    ytmp = (ytmp - ktmp) / (1.0 - ktmp);
   40|  9.70M|  }
   41|  25.3M|  *c = (_JSAMPLE)((double)maxval - ctmp * (double)maxval + 0.5);
   42|  25.3M|  *m = (_JSAMPLE)((double)maxval - mtmp * (double)maxval + 0.5);
   43|  25.3M|  *y = (_JSAMPLE)((double)maxval - ytmp * (double)maxval + 0.5);
   44|  25.3M|  *k = (_JSAMPLE)((double)maxval - ktmp * (double)maxval + 0.5);
   45|  25.3M|}
rdppm-12.c:rgb_to_cmyk:
   29|  20.1M|{
   30|  20.1M|  double ctmp = 1.0 - ((double)r / (double)maxval);
   31|  20.1M|  double mtmp = 1.0 - ((double)g / (double)maxval);
   32|  20.1M|  double ytmp = 1.0 - ((double)b / (double)maxval);
   33|  20.1M|  double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
  ------------------
  |  |  515|  40.2M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 1.58M, False: 18.5M]
  |  |  |  Branch (515:27): [True: 1.01M, False: 19.0M]
  |  |  |  Branch (515:39): [True: 737k, False: 851k]
  |  |  ------------------
  ------------------
   34|       |
   35|  20.1M|  if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
  ------------------
  |  Branch (35:7): [True: 11.7M, False: 8.39M]
  ------------------
   36|  8.39M|  else {
   37|  8.39M|    ctmp = (ctmp - ktmp) / (1.0 - ktmp);
   38|  8.39M|    mtmp = (mtmp - ktmp) / (1.0 - ktmp);
   39|  8.39M|    ytmp = (ytmp - ktmp) / (1.0 - ktmp);
   40|  8.39M|  }
   41|  20.1M|  *c = (_JSAMPLE)((double)maxval - ctmp * (double)maxval + 0.5);
   42|  20.1M|  *m = (_JSAMPLE)((double)maxval - mtmp * (double)maxval + 0.5);
   43|  20.1M|  *y = (_JSAMPLE)((double)maxval - ytmp * (double)maxval + 0.5);
   44|  20.1M|  *k = (_JSAMPLE)((double)maxval - ktmp * (double)maxval + 0.5);
   45|  20.1M|}

jpeg_CreateCompress:
   39|  54.8k|{
   40|  54.8k|  int i;
   41|       |
   42|       |  /* Guard against version mismatches between library and caller. */
   43|  54.8k|  cinfo->mem = NULL;            /* so jpeg_destroy knows mem mgr not called */
   44|  54.8k|  if (version != JPEG_LIB_VERSION)
  ------------------
  |  |    4|  54.8k|#define JPEG_LIB_VERSION  62
  ------------------
  |  Branch (44:7): [True: 0, False: 54.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|  54.8k|  if (structsize != sizeof(struct jpeg_compress_struct))
  ------------------
  |  Branch (46:7): [True: 0, False: 54.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|  54.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|  54.8k|  {
   57|  54.8k|    struct jpeg_error_mgr *err = cinfo->err;
   58|  54.8k|    void *client_data = cinfo->client_data; /* ignore Purify complaint here */
   59|  54.8k|    memset(cinfo, 0, sizeof(struct jpeg_compress_struct));
   60|  54.8k|    cinfo->err = err;
   61|  54.8k|    cinfo->client_data = client_data;
   62|  54.8k|  }
   63|  54.8k|  cinfo->is_decompressor = FALSE;
  ------------------
  |  |  207|  54.8k|#define FALSE   0               /* values of boolean */
  ------------------
   64|       |
   65|       |  /* Initialize a memory manager instance for this object */
   66|  54.8k|  jinit_memory_mgr((j_common_ptr)cinfo);
   67|       |
   68|       |  /* Zero out pointers to permanent structures. */
   69|  54.8k|  cinfo->progress = NULL;
   70|  54.8k|  cinfo->dest = NULL;
   71|       |
   72|  54.8k|  cinfo->comp_info = NULL;
   73|       |
   74|   274k|  for (i = 0; i < NUM_QUANT_TBLS; i++) {
  ------------------
  |  |   68|   274k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (74:15): [True: 219k, False: 54.8k]
  ------------------
   75|   219k|    cinfo->quant_tbl_ptrs[i] = NULL;
   76|       |#if JPEG_LIB_VERSION >= 70
   77|       |    cinfo->q_scale_factor[i] = 100;
   78|       |#endif
   79|   219k|  }
   80|       |
   81|   274k|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|   274k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (81:15): [True: 219k, False: 54.8k]
  ------------------
   82|   219k|    cinfo->dc_huff_tbl_ptrs[i] = NULL;
   83|   219k|    cinfo->ac_huff_tbl_ptrs[i] = NULL;
   84|   219k|  }
   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|  54.8k|  cinfo->script_space = NULL;
   94|       |
   95|  54.8k|  cinfo->input_gamma = 1.0;     /* in case application forgets */
   96|       |
   97|  54.8k|  cinfo->data_precision = BITS_IN_JSAMPLE;
  ------------------
  |  |   34|  54.8k|#define BITS_IN_JSAMPLE  8
  ------------------
   98|       |
   99|       |  /* OK, I'm ready */
  100|  54.8k|  cinfo->global_state = CSTATE_START;
  ------------------
  |  |   44|  54.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|  54.8k|  cinfo->master = (struct jpeg_comp_master *)
  106|  54.8k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  54.8k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  107|  54.8k|                                  sizeof(my_comp_master));
  108|  54.8k|  memset(cinfo->master, 0, sizeof(my_comp_master));
  109|  54.8k|#ifdef WITH_SIMD
  110|  54.8k|  cinfo->master->simd_support = JSIMD_UNDEFINED;
  ------------------
  |  |   49|  54.8k|#define JSIMD_UNDEFINED  ~(JSIMD_MAX * 2U - 1U)
  |  |  ------------------
  |  |  |  |   48|  54.8k|#define JSIMD_MAX        0x100
  |  |  ------------------
  ------------------
  111|  54.8k|#ifndef WITH_SIMDE
  112|  54.8k|  cinfo->master->simd_huffman = 1;
  113|  54.8k|#endif
  114|  54.8k|#endif
  115|  54.8k|}
jpeg_destroy_compress:
  124|  54.8k|{
  125|  54.8k|  jpeg_destroy((j_common_ptr)cinfo); /* use common routine */
  126|  54.8k|}
jpeg_abort_compress:
  136|      3|{
  137|      3|  jpeg_abort((j_common_ptr)cinfo); /* use common routine */
  138|      3|}
jpeg_suppress_tables:
  155|  21.2k|{
  156|  21.2k|  int i;
  157|  21.2k|  JQUANT_TBL *qtbl;
  158|  21.2k|  JHUFF_TBL *htbl;
  159|       |
  160|   106k|  for (i = 0; i < NUM_QUANT_TBLS; i++) {
  ------------------
  |  |   68|   106k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (160:15): [True: 84.9k, False: 21.2k]
  ------------------
  161|  84.9k|    if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL)
  ------------------
  |  Branch (161:9): [True: 42.4k, False: 42.4k]
  ------------------
  162|  42.4k|      qtbl->sent_table = suppress;
  163|  84.9k|  }
  164|       |
  165|   106k|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|   106k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (165:15): [True: 84.9k, False: 21.2k]
  ------------------
  166|  84.9k|    if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL)
  ------------------
  |  Branch (166:9): [True: 42.4k, False: 42.4k]
  ------------------
  167|  42.4k|      htbl->sent_table = suppress;
  168|  84.9k|    if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL)
  ------------------
  |  Branch (168:9): [True: 42.4k, False: 42.4k]
  ------------------
  169|  42.4k|      htbl->sent_table = suppress;
  170|  84.9k|  }
  171|  21.2k|}
jpeg_finish_compress:
  183|  21.2k|{
  184|  21.2k|  JDIMENSION iMCU_row;
  185|       |
  186|  21.2k|  if (cinfo->global_state == CSTATE_SCANNING ||
  ------------------
  |  |   45|  42.4k|#define CSTATE_SCANNING  101    /* start_compress done, write_scanlines OK */
  ------------------
  |  Branch (186:7): [True: 21.2k, False: 0]
  ------------------
  187|  21.2k|      cinfo->global_state == CSTATE_RAW_OK) {
  ------------------
  |  |   46|      0|#define CSTATE_RAW_OK    102    /* start_compress done, write_raw_data OK */
  ------------------
  |  Branch (187:7): [True: 0, False: 0]
  ------------------
  188|       |    /* Terminate first pass */
  189|  21.2k|    if (cinfo->next_scanline < cinfo->image_height)
  ------------------
  |  Branch (189:9): [True: 0, False: 21.2k]
  ------------------
  190|      0|      ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  191|  21.2k|    (*cinfo->master->finish_pass) (cinfo);
  192|  21.2k|  } else if (cinfo->global_state != CSTATE_WRCOEFS)
  ------------------
  |  |   47|      0|#define CSTATE_WRCOEFS   103    /* jpeg_write_coefficients done */
  ------------------
  |  Branch (192:14): [True: 0, False: 0]
  ------------------
  193|      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)))
  ------------------
  194|       |  /* Perform any remaining passes */
  195|   118k|  while (!cinfo->master->is_last_pass) {
  ------------------
  |  Branch (195:10): [True: 96.8k, False: 21.2k]
  ------------------
  196|  96.8k|    (*cinfo->master->prepare_for_pass) (cinfo);
  197|  9.97M|    for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) {
  ------------------
  |  Branch (197:24): [True: 9.87M, False: 96.8k]
  ------------------
  198|  9.87M|      if (cinfo->progress != NULL) {
  ------------------
  |  Branch (198:11): [True: 0, False: 9.87M]
  ------------------
  199|      0|        cinfo->progress->pass_counter = (long)iMCU_row;
  200|      0|        cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows;
  201|      0|        (*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
  202|      0|      }
  203|       |      /* We bypass the main controller and invoke coef controller directly;
  204|       |       * all work is being done from the coefficient buffer.
  205|       |       */
  206|  9.87M|      if (cinfo->data_precision <= 8) {
  ------------------
  |  Branch (206:11): [True: 0, False: 9.87M]
  ------------------
  207|      0|        if (cinfo->coef->compress_data == NULL)
  ------------------
  |  Branch (207:13): [True: 0, False: 0]
  ------------------
  208|      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)))
  ------------------
  209|      0|        if (!(*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE)NULL))
  ------------------
  |  Branch (209:13): [True: 0, False: 0]
  ------------------
  210|      0|          ERREXIT(cinfo, JERR_CANT_SUSPEND);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  211|  9.87M|      } else if (cinfo->data_precision <= 12) {
  ------------------
  |  Branch (211:18): [True: 9.87M, False: 0]
  ------------------
  212|  9.87M|        if (cinfo->coef->compress_data_12 == NULL)
  ------------------
  |  Branch (212:13): [True: 0, False: 9.87M]
  ------------------
  213|      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)))
  ------------------
  214|  9.87M|        if (!(*cinfo->coef->compress_data_12) (cinfo, (J12SAMPIMAGE)NULL))
  ------------------
  |  Branch (214:13): [True: 0, False: 9.87M]
  ------------------
  215|      0|          ERREXIT(cinfo, JERR_CANT_SUSPEND);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  216|  9.87M|      } else {
  217|      0|#ifdef C_LOSSLESS_SUPPORTED
  218|      0|        if (cinfo->coef->compress_data_16 == NULL)
  ------------------
  |  Branch (218:13): [True: 0, False: 0]
  ------------------
  219|      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)))
  ------------------
  220|      0|        if (!(*cinfo->coef->compress_data_16) (cinfo, (J16SAMPIMAGE)NULL))
  ------------------
  |  Branch (220:13): [True: 0, False: 0]
  ------------------
  221|      0|          ERREXIT(cinfo, JERR_CANT_SUSPEND);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  222|       |#else
  223|       |        ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  224|       |#endif
  225|      0|      }
  226|  9.87M|    }
  227|  96.8k|    (*cinfo->master->finish_pass) (cinfo);
  228|  96.8k|  }
  229|       |  /* Write EOI, do final cleanup */
  230|  21.2k|  (*cinfo->marker->write_file_trailer) (cinfo);
  231|  21.2k|  (*cinfo->dest->term_destination) (cinfo);
  232|       |  /* We can use jpeg_abort to release memory and reset global_state */
  233|  21.2k|  jpeg_abort((j_common_ptr)cinfo);
  234|  21.2k|}
jpeg_write_m_header:
  268|  17.7k|{
  269|  17.7k|  if (cinfo->next_scanline != 0 ||
  ------------------
  |  Branch (269:7): [True: 0, False: 17.7k]
  ------------------
  270|  17.7k|      (cinfo->global_state != CSTATE_SCANNING &&
  ------------------
  |  |   45|  35.5k|#define CSTATE_SCANNING  101    /* start_compress done, write_scanlines OK */
  ------------------
  |  Branch (270:8): [True: 0, False: 17.7k]
  ------------------
  271|      0|       cinfo->global_state != CSTATE_RAW_OK &&
  ------------------
  |  |   46|  17.7k|#define CSTATE_RAW_OK    102    /* start_compress done, write_raw_data OK */
  ------------------
  |  Branch (271:8): [True: 0, False: 0]
  ------------------
  272|      0|       cinfo->global_state != CSTATE_WRCOEFS))
  ------------------
  |  |   47|      0|#define CSTATE_WRCOEFS   103    /* jpeg_write_coefficients done */
  ------------------
  |  Branch (272:8): [True: 0, False: 0]
  ------------------
  273|      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)))
  ------------------
  274|       |
  275|  17.7k|  (*cinfo->marker->write_marker_header) (cinfo, marker, datalen);
  276|  17.7k|}
jpeg_write_m_byte:
  280|   818k|{
  281|   818k|  (*cinfo->marker->write_marker_byte) (cinfo, val);
  282|   818k|}

jpeg_start_compress:
   45|  21.2k|{
   46|  21.2k|  if (cinfo->global_state != CSTATE_START)
  ------------------
  |  |   44|  21.2k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (46:7): [True: 0, False: 21.2k]
  ------------------
   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|  21.2k|  if (write_all_tables)
  ------------------
  |  Branch (49:7): [True: 21.2k, False: 0]
  ------------------
   50|  21.2k|    jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */
  ------------------
  |  |  207|  21.2k|#define FALSE   0               /* values of boolean */
  ------------------
   51|       |
   52|       |  /* (Re)initialize error mgr and destination modules */
   53|  21.2k|  (*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
   54|  21.2k|  (*cinfo->dest->init_destination) (cinfo);
   55|       |  /* Perform master selection of active modules */
   56|  21.2k|  jinit_compress_master(cinfo);
   57|       |  /* Set up for the first pass */
   58|  21.2k|  (*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|  21.2k|  cinfo->next_scanline = 0;
   63|  21.2k|  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|  21.2k|#define CSTATE_SCANNING  101    /* start_compress done, write_scanlines OK */
  ------------------
  |  Branch (63:26): [True: 0, False: 21.2k]
  ------------------
   64|  21.2k|}
jpeg12_write_scanlines:
   87|  21.2k|{
   88|  21.2k|#if BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED)
   89|  21.2k|  JDIMENSION row_ctr, rows_left;
   90|       |
   91|  21.2k|#ifdef C_LOSSLESS_SUPPORTED
   92|  21.2k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (92:7): [True: 0, False: 21.2k]
  ------------------
   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|  21.2k|#endif
  102|  21.2k|  {
  103|  21.2k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  21.2k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (103:9): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  }
  106|       |
  107|  21.2k|  if (cinfo->global_state != CSTATE_SCANNING)
  ------------------
  |  |   45|  21.2k|#define CSTATE_SCANNING  101    /* start_compress done, write_scanlines OK */
  ------------------
  |  Branch (107:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  if (cinfo->next_scanline >= cinfo->image_height)
  ------------------
  |  Branch (109:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  if (cinfo->progress != NULL) {
  ------------------
  |  Branch (113:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  if (cinfo->master->call_pass_startup)
  ------------------
  |  Branch (124:7): [True: 5.85k, False: 15.3k]
  ------------------
  125|  5.85k|    (*cinfo->master->pass_startup) (cinfo);
  126|       |
  127|       |  /* Ignore any extra scanlines at bottom of image. */
  128|  21.2k|  rows_left = cinfo->image_height - cinfo->next_scanline;
  129|  21.2k|  if (num_lines > rows_left)
  ------------------
  |  Branch (129:7): [True: 0, False: 21.2k]
  ------------------
  130|      0|    num_lines = rows_left;
  131|       |
  132|  21.2k|  row_ctr = 0;
  133|  21.2k|  if (cinfo->main->_process_data == NULL)
  ------------------
  |  |  140|  21.2k|#define _process_data  process_data_12
  ------------------
  |  Branch (133:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  (*cinfo->main->_process_data) (cinfo, scanlines, &row_ctr, num_lines);
  ------------------
  |  |  140|  21.2k|#define _process_data  process_data_12
  ------------------
  136|  21.2k|  cinfo->next_scanline += row_ctr;
  137|  21.2k|  return row_ctr;
  138|       |#else
  139|       |  ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  140|       |  return 0;
  141|       |#endif
  142|  21.2k|}

jinit_arith_encoder:
  913|  5.85k|{
  914|  5.85k|  arith_entropy_ptr entropy;
  915|  5.85k|  int i;
  916|       |
  917|  5.85k|  entropy = (arith_entropy_ptr)
  918|  5.85k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  5.85k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  919|  5.85k|                                sizeof(arith_entropy_encoder));
  920|  5.85k|  cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
  921|  5.85k|  entropy->pub.start_pass = start_pass;
  922|  5.85k|  entropy->pub.finish_pass = finish_pass;
  923|       |
  924|       |  /* Mark tables unallocated */
  925|  99.5k|  for (i = 0; i < NUM_ARITH_TBLS; i++) {
  ------------------
  |  |   70|  99.5k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (925:15): [True: 93.6k, False: 5.85k]
  ------------------
  926|  93.6k|    entropy->dc_stats[i] = NULL;
  927|  93.6k|    entropy->ac_stats[i] = NULL;
  928|  93.6k|  }
  929|       |
  930|       |  /* Initialize index for fixed probability estimation */
  931|  5.85k|  entropy->fixed_bin[0] = 113;
  932|  5.85k|}
jcarith.c:start_pass:
  829|  55.6k|{
  830|  55.6k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  831|  55.6k|  int ci, tbl;
  832|  55.6k|  jpeg_component_info *compptr;
  833|       |
  834|  55.6k|  if (gather_statistics)
  ------------------
  |  Branch (834:7): [True: 0, False: 55.6k]
  ------------------
  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|  55.6k|  if (cinfo->progressive_mode) {
  ------------------
  |  Branch (844:7): [True: 52.6k, False: 2.92k]
  ------------------
  845|  52.6k|    if (cinfo->Ah == 0) {
  ------------------
  |  Branch (845:9): [True: 26.3k, False: 26.3k]
  ------------------
  846|  26.3k|      if (cinfo->Ss == 0)
  ------------------
  |  Branch (846:11): [True: 2.92k, False: 23.4k]
  ------------------
  847|  2.92k|        entropy->pub.encode_mcu = encode_mcu_DC_first;
  848|  23.4k|      else
  849|  23.4k|        entropy->pub.encode_mcu = encode_mcu_AC_first;
  850|  26.3k|    } else {
  851|  26.3k|      if (cinfo->Ss == 0)
  ------------------
  |  Branch (851:11): [True: 2.92k, False: 23.4k]
  ------------------
  852|  2.92k|        entropy->pub.encode_mcu = encode_mcu_DC_refine;
  853|  23.4k|      else
  854|  23.4k|        entropy->pub.encode_mcu = encode_mcu_AC_refine;
  855|  26.3k|    }
  856|  52.6k|  } else
  857|  2.92k|    entropy->pub.encode_mcu = encode_mcu;
  858|       |
  859|       |  /* Allocate & initialize requested statistics areas */
  860|   134k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (860:16): [True: 79.0k, False: 55.6k]
  ------------------
  861|  79.0k|    compptr = cinfo->cur_comp_info[ci];
  862|       |    /* DC needs no table for refinement scan */
  863|  79.0k|    if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
  ------------------
  |  Branch (863:9): [True: 8.78k, False: 70.2k]
  |  Branch (863:42): [True: 23.4k, False: 46.8k]
  |  Branch (863:60): [True: 11.7k, False: 11.7k]
  ------------------
  864|  20.4k|      tbl = compptr->dc_tbl_no;
  865|  20.4k|      if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
  ------------------
  |  |   70|  20.4k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (865:11): [True: 0, False: 20.4k]
  |  Branch (865:22): [True: 0, False: 20.4k]
  ------------------
  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|  20.4k|      if (entropy->dc_stats[tbl] == NULL)
  ------------------
  |  Branch (867:11): [True: 8.78k, False: 11.7k]
  ------------------
  868|  8.78k|        entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
  869|  8.78k|          ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
  ------------------
  |  |  889|  8.78k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                        ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
  ------------------
  |  |   69|  8.78k|#define DC_STAT_BINS  64
  ------------------
  870|  20.4k|      memset(entropy->dc_stats[tbl], 0, DC_STAT_BINS);
  ------------------
  |  |   69|  20.4k|#define DC_STAT_BINS  64
  ------------------
  871|       |      /* Initialize DC predictions to 0 */
  872|  20.4k|      entropy->last_dc_val[ci] = 0;
  873|  20.4k|      entropy->dc_context[ci] = 0;
  874|  20.4k|    }
  875|       |    /* AC needs no table when not present */
  876|  79.0k|    if (cinfo->progressive_mode == 0 || cinfo->Se) {
  ------------------
  |  Branch (876:9): [True: 8.78k, False: 70.2k]
  |  Branch (876:41): [True: 46.8k, False: 23.4k]
  ------------------
  877|  55.6k|      tbl = compptr->ac_tbl_no;
  878|  55.6k|      if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
  ------------------
  |  |   70|  55.6k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (878:11): [True: 0, False: 55.6k]
  |  Branch (878:22): [True: 0, False: 55.6k]
  ------------------
  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|  55.6k|      if (entropy->ac_stats[tbl] == NULL)
  ------------------
  |  Branch (880:11): [True: 8.78k, False: 46.8k]
  ------------------
  881|  8.78k|        entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
  882|  8.78k|          ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
  ------------------
  |  |  889|  8.78k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                        ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
  ------------------
  |  |   70|  8.78k|#define AC_STAT_BINS  256
  ------------------
  883|  55.6k|      memset(entropy->ac_stats[tbl], 0, AC_STAT_BINS);
  ------------------
  |  |   70|  55.6k|#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|  55.6k|    }
  891|  79.0k|  }
  892|       |
  893|       |  /* Initialize arithmetic encoding variables */
  894|  55.6k|  entropy->c = 0;
  895|  55.6k|  entropy->a = 0x10000L;
  896|  55.6k|  entropy->sc = 0;
  897|  55.6k|  entropy->zc = 0;
  898|  55.6k|  entropy->ct = 11;
  899|  55.6k|  entropy->buffer = -1;  /* empty */
  900|       |
  901|       |  /* Initialize restart stuff */
  902|  55.6k|  entropy->restarts_to_go = cinfo->restart_interval;
  903|  55.6k|  entropy->next_restart_num = 0;
  904|  55.6k|}
jcarith.c:encode_mcu_DC_first:
  369|   871k|{
  370|   871k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  371|   871k|  JBLOCKROW block;
  372|   871k|  unsigned char *st;
  373|   871k|  int blkn, ci, tbl;
  374|   871k|  int v, v2, m;
  375|   871k|  ISHIFT_TEMPS
  376|       |
  377|       |  /* Emit restart marker if needed */
  378|   871k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (378:7): [True: 871k, False: 0]
  ------------------
  379|   871k|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (379:9): [True: 239k, False: 631k]
  ------------------
  380|   239k|      emit_restart(cinfo, entropy->next_restart_num);
  381|   239k|      entropy->restarts_to_go = cinfo->restart_interval;
  382|   239k|      entropy->next_restart_num++;
  383|   239k|      entropy->next_restart_num &= 7;
  384|   239k|    }
  385|   871k|    entropy->restarts_to_go--;
  386|   871k|  }
  387|       |
  388|       |  /* Encode the MCU data blocks */
  389|  6.10M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (389:18): [True: 5.23M, False: 871k]
  ------------------
  390|  5.23M|    block = MCU_data[blkn];
  391|  5.23M|    ci = cinfo->MCU_membership[blkn];
  392|  5.23M|    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.23M|    m = IRIGHT_SHIFT((int)((*block)[0]), cinfo->Al);
  ------------------
  |  |  117|  5.23M|#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.23M|    st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
  403|       |
  404|       |    /* Figure F.4: Encode_DC_DIFF */
  405|  5.23M|    if ((v = m - entropy->last_dc_val[ci]) == 0) {
  ------------------
  |  Branch (405:9): [True: 3.63M, False: 1.59M]
  ------------------
  406|  3.63M|      arith_encode(cinfo, st, 0);
  407|  3.63M|      entropy->dc_context[ci] = 0;      /* zero diff category */
  408|  3.63M|    } else {
  409|  1.59M|      entropy->last_dc_val[ci] = m;
  410|  1.59M|      arith_encode(cinfo, st, 1);
  411|       |      /* Figure F.6: Encoding nonzero value v */
  412|       |      /* Figure F.7: Encoding the sign of v */
  413|  1.59M|      if (v > 0) {
  ------------------
  |  Branch (413:11): [True: 579k, False: 1.01M]
  ------------------
  414|   579k|        arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
  415|   579k|        st += 2;                        /* Table F.4: SP = S0 + 2 */
  416|   579k|        entropy->dc_context[ci] = 4;    /* small positive diff category */
  417|  1.01M|      } else {
  418|  1.01M|        v = -v;
  419|  1.01M|        arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
  420|  1.01M|        st += 3;                        /* Table F.4: SN = S0 + 3 */
  421|  1.01M|        entropy->dc_context[ci] = 8;    /* small negative diff category */
  422|  1.01M|      }
  423|       |      /* Figure F.8: Encoding the magnitude category of v */
  424|  1.59M|      m = 0;
  425|  1.59M|      if (v -= 1) {
  ------------------
  |  Branch (425:11): [True: 1.38M, False: 212k]
  ------------------
  426|  1.38M|        arith_encode(cinfo, st, 1);
  427|  1.38M|        m = 1;
  428|  1.38M|        v2 = v;
  429|  1.38M|        st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
  430|  4.76M|        while (v2 >>= 1) {
  ------------------
  |  Branch (430:16): [True: 3.37M, False: 1.38M]
  ------------------
  431|  3.37M|          arith_encode(cinfo, st, 1);
  432|  3.37M|          m <<= 1;
  433|  3.37M|          st += 1;
  434|  3.37M|        }
  435|  1.38M|      }
  436|  1.59M|      arith_encode(cinfo, st, 0);
  437|       |      /* Section F.1.4.4.1.2: Establish dc_context conditioning category */
  438|  1.59M|      if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
  ------------------
  |  Branch (438:11): [True: 0, False: 1.59M]
  ------------------
  439|      0|        entropy->dc_context[ci] = 0;    /* zero diff category */
  440|  1.59M|      else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
  ------------------
  |  Branch (440:16): [True: 1.21M, False: 377k]
  ------------------
  441|  1.21M|        entropy->dc_context[ci] += 8;   /* large diff category */
  442|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  443|  1.59M|      st += 14;
  444|  4.97M|      while (m >>= 1)
  ------------------
  |  Branch (444:14): [True: 3.37M, False: 1.59M]
  ------------------
  445|  3.37M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (445:33): [True: 2.18M, False: 1.19M]
  ------------------
  446|  1.59M|    }
  447|  5.23M|  }
  448|       |
  449|   871k|  return TRUE;
  ------------------
  |  |  210|   871k|#define TRUE    1
  ------------------
  450|   871k|}
jcarith.c:emit_restart:
  326|  6.48M|{
  327|  6.48M|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  328|  6.48M|  int ci;
  329|  6.48M|  jpeg_component_info *compptr;
  330|       |
  331|  6.48M|  finish_pass(cinfo);
  332|       |
  333|  6.48M|  emit_byte(0xFF, cinfo);
  334|  6.48M|  emit_byte(JPEG_RST0 + restart_num, cinfo);
  ------------------
  |  | 1166|  6.48M|#define JPEG_RST0       0xD0    /* RST0 marker code */
  ------------------
  335|       |
  336|       |  /* Re-initialize statistics areas */
  337|  14.8M|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (337:16): [True: 8.40M, False: 6.48M]
  ------------------
  338|  8.40M|    compptr = cinfo->cur_comp_info[ci];
  339|       |    /* DC needs no table for refinement scan */
  340|  8.40M|    if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
  ------------------
  |  Branch (340:9): [True: 719k, False: 7.68M]
  |  Branch (340:42): [True: 1.91M, False: 5.76M]
  |  Branch (340:60): [True: 959k, False: 959k]
  ------------------
  341|  1.67M|      memset(entropy->dc_stats[compptr->dc_tbl_no], 0, DC_STAT_BINS);
  ------------------
  |  |   69|  1.67M|#define DC_STAT_BINS  64
  ------------------
  342|       |      /* Reset DC predictions to 0 */
  343|  1.67M|      entropy->last_dc_val[ci] = 0;
  344|  1.67M|      entropy->dc_context[ci] = 0;
  345|  1.67M|    }
  346|       |    /* AC needs no table when not present */
  347|  8.40M|    if (cinfo->progressive_mode == 0 || cinfo->Se) {
  ------------------
  |  Branch (347:9): [True: 719k, False: 7.68M]
  |  Branch (347:41): [True: 5.76M, False: 1.91M]
  ------------------
  348|  6.48M|      memset(entropy->ac_stats[compptr->ac_tbl_no], 0, AC_STAT_BINS);
  ------------------
  |  |   70|  6.48M|#define AC_STAT_BINS  256
  ------------------
  349|  6.48M|    }
  350|  8.40M|  }
  351|       |
  352|       |  /* Reset arithmetic encoding variables */
  353|  6.48M|  entropy->c = 0;
  354|  6.48M|  entropy->a = 0x10000L;
  355|  6.48M|  entropy->sc = 0;
  356|  6.48M|  entropy->zc = 0;
  357|  6.48M|  entropy->ct = 11;
  358|  6.48M|  entropy->buffer = -1;  /* empty */
  359|  6.48M|}
jcarith.c:emit_byte:
  124|   107M|{
  125|   107M|  struct jpeg_destination_mgr *dest = cinfo->dest;
  126|       |
  127|   107M|  *dest->next_output_byte++ = (JOCTET)val;
  128|   107M|  if (--dest->free_in_buffer == 0)
  ------------------
  |  Branch (128:7): [True: 3.60k, False: 107M]
  ------------------
  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|   107M|}
jcarith.c:arith_encode:
  226|   995M|{
  227|   995M|  register arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
  228|   995M|  register unsigned char nl, nm;
  229|   995M|  register JLONG qe, temp;
  230|   995M|  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|   995M|  sv = *st;
  236|   995M|  qe = jpeg_aritab[sv & 0x7F];  /* => Qe_Value */
  237|   995M|  nl = qe & 0xFF;  qe >>= 8;    /* Next_Index_LPS + Switch_MPS */
  238|   995M|  nm = qe & 0xFF;  qe >>= 8;    /* Next_Index_MPS */
  239|       |
  240|       |  /* Encode & estimation procedures per sections D.1.4 & D.1.5 */
  241|   995M|  e->a -= qe;
  242|   995M|  if (val != (sv >> 7)) {
  ------------------
  |  Branch (242:7): [True: 281M, False: 713M]
  ------------------
  243|       |    /* Encode the less probable symbol */
  244|   281M|    if (e->a >= qe) {
  ------------------
  |  Branch (244:9): [True: 214M, False: 66.7M]
  ------------------
  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|   214M|      e->c += e->a;
  250|   214M|      e->a = qe;
  251|   214M|    }
  252|   281M|    *st = (sv & 0x80) ^ nl;     /* Estimate_after_LPS */
  253|   713M|  } else {
  254|       |    /* Encode the more probable symbol */
  255|   713M|    if (e->a >= 0x8000L)
  ------------------
  |  Branch (255:9): [True: 415M, False: 298M]
  ------------------
  256|   415M|      return;  /* A >= 0x8000 -> ready, no renormalization required */
  257|   298M|    if (e->a < qe) {
  ------------------
  |  Branch (257:9): [True: 73.3M, False: 225M]
  ------------------
  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|  73.3M|      e->c += e->a;
  262|  73.3M|      e->a = qe;
  263|  73.3M|    }
  264|   298M|    *st = (sv & 0x80) ^ nm;     /* Estimate_after_MPS */
  265|   298M|  }
  266|       |
  267|       |  /* Renormalization & data output per section D.1.6 */
  268|   714M|  do {
  269|   714M|    e->a <<= 1;
  270|   714M|    e->c <<= 1;
  271|   714M|    if (--e->ct == 0) {
  ------------------
  |  Branch (271:9): [True: 87.0M, False: 627M]
  ------------------
  272|       |      /* Another byte is ready for output */
  273|  87.0M|      temp = e->c >> 19;
  274|  87.0M|      if (temp > 0xFF) {
  ------------------
  |  Branch (274:11): [True: 3.46M, False: 83.5M]
  ------------------
  275|       |        /* Handle overflow over all stacked 0xFF bytes */
  276|  3.46M|        if (e->buffer >= 0) {
  ------------------
  |  Branch (276:13): [True: 3.46M, False: 0]
  ------------------
  277|  3.46M|          if (e->zc)
  ------------------
  |  Branch (277:15): [True: 13.6k, False: 3.44M]
  ------------------
  278|  14.2k|            do emit_byte(0x00, cinfo);
  279|  14.2k|            while (--e->zc);
  ------------------
  |  Branch (279:20): [True: 580, False: 13.6k]
  ------------------
  280|  3.46M|          emit_byte(e->buffer + 1, cinfo);
  281|  3.46M|          if (e->buffer + 1 == 0xFF)
  ------------------
  |  Branch (281:15): [True: 13.0k, False: 3.44M]
  ------------------
  282|  13.0k|            emit_byte(0x00, cinfo);
  283|  3.46M|        }
  284|  3.46M|        e->zc += e->sc;  /* carry-over converts stacked 0xFF bytes to 0x00 */
  285|  3.46M|        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.46M|        e->buffer = temp & 0xFF;  /* new output byte, might overflow later */
  290|  83.5M|      } else if (temp == 0xFF) {
  ------------------
  |  Branch (290:18): [True: 593k, False: 83.0M]
  ------------------
  291|   593k|        ++e->sc;  /* stack 0xFF byte (which might overflow later) */
  292|  83.0M|      } else {
  293|       |        /* Output all stacked 0xFF bytes, they will not overflow any more */
  294|  83.0M|        if (e->buffer == 0)
  ------------------
  |  Branch (294:13): [True: 502k, False: 82.5M]
  ------------------
  295|   502k|          ++e->zc;
  296|  82.5M|        else if (e->buffer >= 0) {
  ------------------
  |  Branch (296:18): [True: 80.4M, False: 2.00M]
  ------------------
  297|  80.4M|          if (e->zc)
  ------------------
  |  Branch (297:15): [True: 327k, False: 80.1M]
  ------------------
  298|   413k|            do emit_byte(0x00, cinfo);
  299|   413k|            while (--e->zc);
  ------------------
  |  Branch (299:20): [True: 86.4k, False: 327k]
  ------------------
  300|  80.4M|          emit_byte(e->buffer, cinfo);
  301|  80.4M|        }
  302|  83.0M|        if (e->sc) {
  ------------------
  |  Branch (302:13): [True: 560k, False: 82.4M]
  ------------------
  303|   560k|          if (e->zc)
  ------------------
  |  Branch (303:15): [True: 1.75k, False: 558k]
  ------------------
  304|  1.90k|            do emit_byte(0x00, cinfo);
  305|  1.90k|            while (--e->zc);
  ------------------
  |  Branch (305:20): [True: 154, False: 1.75k]
  ------------------
  306|   572k|          do {
  307|   572k|            emit_byte(0xFF, cinfo);
  308|   572k|            emit_byte(0x00, cinfo);
  309|   572k|          } while (--e->sc);
  ------------------
  |  Branch (309:20): [True: 12.4k, False: 560k]
  ------------------
  310|   560k|        }
  311|  83.0M|        e->buffer = temp & 0xFF;  /* new output byte (can still overflow) */
  312|  83.0M|      }
  313|  87.0M|      e->c &= 0x7FFFFL;
  314|  87.0M|      e->ct += 8;
  315|  87.0M|    }
  316|   714M|  } while (e->a < 0x8000L);
  ------------------
  |  Branch (316:12): [True: 134M, False: 580M]
  ------------------
  317|   580M|}
jcarith.c:encode_mcu_AC_first:
  460|  8.83M|{
  461|  8.83M|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  462|  8.83M|  JBLOCKROW block;
  463|  8.83M|  unsigned char *st;
  464|  8.83M|  int tbl, k, ke;
  465|  8.83M|  int v, v2, m;
  466|       |
  467|       |  /* Emit restart marker if needed */
  468|  8.83M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (468:7): [True: 8.83M, False: 0]
  ------------------
  469|  8.83M|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (469:9): [True: 2.88M, False: 5.95M]
  ------------------
  470|  2.88M|      emit_restart(cinfo, entropy->next_restart_num);
  471|  2.88M|      entropy->restarts_to_go = cinfo->restart_interval;
  472|  2.88M|      entropy->next_restart_num++;
  473|  2.88M|      entropy->next_restart_num &= 7;
  474|  2.88M|    }
  475|  8.83M|    entropy->restarts_to_go--;
  476|  8.83M|  }
  477|       |
  478|       |  /* Encode the MCU data block */
  479|  8.83M|  block = MCU_data[0];
  480|  8.83M|  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|   251M|  for (ke = cinfo->Se; ke > 0; ke--)
  ------------------
  |  Branch (485:24): [True: 244M, False: 6.29M]
  ------------------
  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|   244M|    if ((v = (*block)[jpeg_natural_order[ke]]) >= 0) {
  ------------------
  |  Branch (490:9): [True: 237M, False: 6.77M]
  ------------------
  491|   237M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (491:11): [True: 1.22M, False: 236M]
  ------------------
  492|   237M|    } else {
  493|  6.77M|      v = -v;
  494|  6.77M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (494:11): [True: 1.31M, False: 5.45M]
  ------------------
  495|  6.77M|    }
  496|       |
  497|       |  /* Figure F.5: Encode_AC_Coefficients */
  498|  24.3M|  for (k = cinfo->Ss; k <= ke; k++) {
  ------------------
  |  Branch (498:23): [True: 15.5M, False: 8.83M]
  ------------------
  499|  15.5M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  500|  15.5M|    arith_encode(cinfo, st, 0);         /* EOB decision */
  501|  51.5M|    for (;;) {
  502|  51.5M|      if ((v = (*block)[jpeg_natural_order[k]]) >= 0) {
  ------------------
  |  Branch (502:11): [True: 33.9M, False: 17.6M]
  ------------------
  503|  33.9M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (503:13): [True: 7.59M, False: 26.3M]
  ------------------
  504|  7.59M|          arith_encode(cinfo, st + 1, 1);
  505|  7.59M|          arith_encode(cinfo, entropy->fixed_bin, 0);
  506|  7.59M|          break;
  507|  7.59M|        }
  508|  33.9M|      } else {
  509|  17.6M|        v = -v;
  510|  17.6M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (510:13): [True: 7.94M, False: 9.66M]
  ------------------
  511|  7.94M|          arith_encode(cinfo, st + 1, 1);
  512|  7.94M|          arith_encode(cinfo, entropy->fixed_bin, 1);
  513|  7.94M|          break;
  514|  7.94M|        }
  515|  17.6M|      }
  516|  36.0M|      arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  517|  36.0M|    }
  518|  15.5M|    st += 2;
  519|       |    /* Figure F.8: Encoding the magnitude category of v */
  520|  15.5M|    m = 0;
  521|  15.5M|    if (v -= 1) {
  ------------------
  |  Branch (521:9): [True: 5.66M, False: 9.87M]
  ------------------
  522|  5.66M|      arith_encode(cinfo, st, 1);
  523|  5.66M|      m = 1;
  524|  5.66M|      v2 = v;
  525|  5.66M|      if (v2 >>= 1) {
  ------------------
  |  Branch (525:11): [True: 2.74M, False: 2.91M]
  ------------------
  526|  2.74M|        arith_encode(cinfo, st, 1);
  527|  2.74M|        m <<= 1;
  528|  2.74M|        st = entropy->ac_stats[tbl] +
  529|  2.74M|             (k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
  ------------------
  |  Branch (529:15): [True: 732k, False: 2.01M]
  ------------------
  530|  3.73M|        while (v2 >>= 1) {
  ------------------
  |  Branch (530:16): [True: 990k, False: 2.74M]
  ------------------
  531|   990k|          arith_encode(cinfo, st, 1);
  532|   990k|          m <<= 1;
  533|   990k|          st += 1;
  534|   990k|        }
  535|  2.74M|      }
  536|  5.66M|    }
  537|  15.5M|    arith_encode(cinfo, st, 0);
  538|       |    /* Figure F.9: Encoding the magnitude bit pattern of v */
  539|  15.5M|    st += 14;
  540|  19.2M|    while (m >>= 1)
  ------------------
  |  Branch (540:12): [True: 3.73M, False: 15.5M]
  ------------------
  541|  3.73M|      arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (541:31): [True: 1.19M, False: 2.54M]
  ------------------
  542|  15.5M|  }
  543|       |  /* Encode EOB decision only if k <= cinfo->Se */
  544|  8.83M|  if (k <= cinfo->Se) {
  ------------------
  |  Branch (544:7): [True: 8.08M, False: 747k]
  ------------------
  545|  8.08M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  546|  8.08M|    arith_encode(cinfo, st, 1);
  547|  8.08M|  }
  548|       |
  549|  8.83M|  return TRUE;
  ------------------
  |  |  210|  8.83M|#define TRUE    1
  ------------------
  550|  8.83M|}
jcarith.c:encode_mcu_DC_refine:
  559|   871k|{
  560|   871k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  561|   871k|  unsigned char *st;
  562|   871k|  int Al, blkn;
  563|       |
  564|       |  /* Emit restart marker if needed */
  565|   871k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (565:7): [True: 871k, False: 0]
  ------------------
  566|   871k|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (566:9): [True: 239k, False: 631k]
  ------------------
  567|   239k|      emit_restart(cinfo, entropy->next_restart_num);
  568|   239k|      entropy->restarts_to_go = cinfo->restart_interval;
  569|   239k|      entropy->next_restart_num++;
  570|   239k|      entropy->next_restart_num &= 7;
  571|   239k|    }
  572|   871k|    entropy->restarts_to_go--;
  573|   871k|  }
  574|       |
  575|   871k|  st = entropy->fixed_bin;      /* use fixed probability estimation */
  576|   871k|  Al = cinfo->Al;
  577|       |
  578|       |  /* Encode the MCU data blocks */
  579|  6.10M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (579:18): [True: 5.23M, False: 871k]
  ------------------
  580|       |    /* We simply emit the Al'th bit of the DC coefficient value. */
  581|  5.23M|    arith_encode(cinfo, st, (MCU_data[blkn][0][0] >> Al) & 1);
  582|  5.23M|  }
  583|       |
  584|   871k|  return TRUE;
  ------------------
  |  |  210|   871k|#define TRUE    1
  ------------------
  585|   871k|}
jcarith.c:encode_mcu_AC_refine:
  594|  8.83M|{
  595|  8.83M|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  596|  8.83M|  JBLOCKROW block;
  597|  8.83M|  unsigned char *st;
  598|  8.83M|  int tbl, k, ke, kex;
  599|  8.83M|  int v;
  600|       |
  601|       |  /* Emit restart marker if needed */
  602|  8.83M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (602:7): [True: 8.83M, False: 0]
  ------------------
  603|  8.83M|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (603:9): [True: 2.88M, False: 5.95M]
  ------------------
  604|  2.88M|      emit_restart(cinfo, entropy->next_restart_num);
  605|  2.88M|      entropy->restarts_to_go = cinfo->restart_interval;
  606|  2.88M|      entropy->next_restart_num++;
  607|  2.88M|      entropy->next_restart_num &= 7;
  608|  2.88M|    }
  609|  8.83M|    entropy->restarts_to_go--;
  610|  8.83M|  }
  611|       |
  612|       |  /* Encode the MCU data block */
  613|  8.83M|  block = MCU_data[0];
  614|  8.83M|  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|   427M|  for (ke = cinfo->Se; ke > 0; ke--)
  ------------------
  |  Branch (619:24): [True: 421M, False: 5.98M]
  ------------------
  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|   421M|    if ((v = (*block)[jpeg_natural_order[ke]]) >= 0) {
  ------------------
  |  Branch (624:9): [True: 418M, False: 2.79M]
  ------------------
  625|   418M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (625:11): [True: 1.32M, False: 417M]
  ------------------
  626|   418M|    } else {
  627|  2.79M|      v = -v;
  628|  2.79M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (628:11): [True: 1.52M, False: 1.27M]
  ------------------
  629|  2.79M|    }
  630|       |
  631|       |  /* Establish EOBx (previous stage end-of-block) index */
  632|  27.2M|  for (kex = ke; kex > 0; kex--)
  ------------------
  |  Branch (632:18): [True: 21.2M, False: 6.08M]
  ------------------
  633|  21.2M|    if ((v = (*block)[jpeg_natural_order[kex]]) >= 0) {
  ------------------
  |  Branch (633:9): [True: 14.9M, False: 6.26M]
  ------------------
  634|  14.9M|      if (v >>= cinfo->Ah) break;
  ------------------
  |  Branch (634:11): [True: 1.32M, False: 13.6M]
  ------------------
  635|  14.9M|    } else {
  636|  6.26M|      v = -v;
  637|  6.26M|      if (v >>= cinfo->Ah) break;
  ------------------
  |  Branch (637:11): [True: 1.42M, False: 4.84M]
  ------------------
  638|  6.26M|    }
  639|       |
  640|       |  /* Figure G.10: Encode_AC_Coefficients_SA */
  641|  84.6M|  for (k = cinfo->Ss; k <= ke; k++) {
  ------------------
  |  Branch (641:23): [True: 75.7M, False: 8.83M]
  ------------------
  642|  75.7M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  643|  75.7M|    if (k > kex)
  ------------------
  |  Branch (643:9): [True: 6.24M, False: 69.5M]
  ------------------
  644|  6.24M|      arith_encode(cinfo, st, 0);       /* EOB decision */
  645|   138M|    for (;;) {
  646|   138M|      if ((v = (*block)[jpeg_natural_order[k]]) >= 0) {
  ------------------
  |  Branch (646:11): [True: 93.3M, False: 44.6M]
  ------------------
  647|  93.3M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (647:13): [True: 37.3M, False: 55.9M]
  ------------------
  648|  37.3M|          if (v >> 1)                   /* previously nonzero coef */
  ------------------
  |  Branch (648:15): [True: 22.5M, False: 14.8M]
  ------------------
  649|  22.5M|            arith_encode(cinfo, st + 2, (v & 1));
  650|  14.8M|          else {                        /* newly nonzero coef */
  651|  14.8M|            arith_encode(cinfo, st + 1, 1);
  652|  14.8M|            arith_encode(cinfo, entropy->fixed_bin, 0);
  653|  14.8M|          }
  654|  37.3M|          break;
  655|  37.3M|        }
  656|  93.3M|      } else {
  657|  44.6M|        v = -v;
  658|  44.6M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (658:13): [True: 38.3M, False: 6.32M]
  ------------------
  659|  38.3M|          if (v >> 1)                   /* previously nonzero coef */
  ------------------
  |  Branch (659:15): [True: 23.3M, False: 15.0M]
  ------------------
  660|  23.3M|            arith_encode(cinfo, st + 2, (v & 1));
  661|  15.0M|          else {                        /* newly nonzero coef */
  662|  15.0M|            arith_encode(cinfo, st + 1, 1);
  663|  15.0M|            arith_encode(cinfo, entropy->fixed_bin, 1);
  664|  15.0M|          }
  665|  38.3M|          break;
  666|  38.3M|        }
  667|  44.6M|      }
  668|  62.2M|      arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  669|  62.2M|    }
  670|  75.7M|  }
  671|       |  /* Encode EOB decision only if k <= cinfo->Se */
  672|  8.83M|  if (k <= cinfo->Se) {
  ------------------
  |  Branch (672:7): [True: 7.95M, False: 884k]
  ------------------
  673|  7.95M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  674|  7.95M|    arith_encode(cinfo, st, 1);
  675|  7.95M|  }
  676|       |
  677|  8.83M|  return TRUE;
  ------------------
  |  |  210|  8.83M|#define TRUE    1
  ------------------
  678|  8.83M|}
jcarith.c:encode_mcu:
  687|   550k|{
  688|   550k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  689|   550k|  jpeg_component_info *compptr;
  690|   550k|  JBLOCKROW block;
  691|   550k|  unsigned char *st;
  692|   550k|  int blkn, ci, tbl, k, ke;
  693|   550k|  int v, v2, m;
  694|       |
  695|       |  /* Emit restart marker if needed */
  696|   550k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (696:7): [True: 550k, False: 0]
  ------------------
  697|   550k|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (697:9): [True: 239k, False: 310k]
  ------------------
  698|   239k|      emit_restart(cinfo, entropy->next_restart_num);
  699|   239k|      entropy->restarts_to_go = cinfo->restart_interval;
  700|   239k|      entropy->next_restart_num++;
  701|   239k|      entropy->next_restart_num &= 7;
  702|   239k|    }
  703|   550k|    entropy->restarts_to_go--;
  704|   550k|  }
  705|       |
  706|       |  /* Encode the MCU data blocks */
  707|  3.85M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (707:18): [True: 3.30M, False: 550k]
  ------------------
  708|  3.30M|    block = MCU_data[blkn];
  709|  3.30M|    ci = cinfo->MCU_membership[blkn];
  710|  3.30M|    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.30M|    tbl = compptr->dc_tbl_no;
  715|       |
  716|       |    /* Table F.4: Point to statistics bin S0 for DC coefficient coding */
  717|  3.30M|    st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
  718|       |
  719|       |    /* Figure F.4: Encode_DC_DIFF */
  720|  3.30M|    if ((v = (*block)[0] - entropy->last_dc_val[ci]) == 0) {
  ------------------
  |  Branch (720:9): [True: 1.39M, False: 1.90M]
  ------------------
  721|  1.39M|      arith_encode(cinfo, st, 0);
  722|  1.39M|      entropy->dc_context[ci] = 0;      /* zero diff category */
  723|  1.90M|    } else {
  724|  1.90M|      entropy->last_dc_val[ci] = (*block)[0];
  725|  1.90M|      arith_encode(cinfo, st, 1);
  726|       |      /* Figure F.6: Encoding nonzero value v */
  727|       |      /* Figure F.7: Encoding the sign of v */
  728|  1.90M|      if (v > 0) {
  ------------------
  |  Branch (728:11): [True: 653k, False: 1.25M]
  ------------------
  729|   653k|        arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
  730|   653k|        st += 2;                        /* Table F.4: SP = S0 + 2 */
  731|   653k|        entropy->dc_context[ci] = 4;    /* small positive diff category */
  732|  1.25M|      } else {
  733|  1.25M|        v = -v;
  734|  1.25M|        arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
  735|  1.25M|        st += 3;                        /* Table F.4: SN = S0 + 3 */
  736|  1.25M|        entropy->dc_context[ci] = 8;    /* small negative diff category */
  737|  1.25M|      }
  738|       |      /* Figure F.8: Encoding the magnitude category of v */
  739|  1.90M|      m = 0;
  740|  1.90M|      if (v -= 1) {
  ------------------
  |  Branch (740:11): [True: 1.90M, False: 6.91k]
  ------------------
  741|  1.90M|        arith_encode(cinfo, st, 1);
  742|  1.90M|        m = 1;
  743|  1.90M|        v2 = v;
  744|  1.90M|        st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
  745|  17.2M|        while (v2 >>= 1) {
  ------------------
  |  Branch (745:16): [True: 15.3M, False: 1.90M]
  ------------------
  746|  15.3M|          arith_encode(cinfo, st, 1);
  747|  15.3M|          m <<= 1;
  748|  15.3M|          st += 1;
  749|  15.3M|        }
  750|  1.90M|      }
  751|  1.90M|      arith_encode(cinfo, st, 0);
  752|       |      /* Section F.1.4.4.1.2: Establish dc_context conditioning category */
  753|  1.90M|      if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
  ------------------
  |  Branch (753:11): [True: 0, False: 1.90M]
  ------------------
  754|      0|        entropy->dc_context[ci] = 0;    /* zero diff category */
  755|  1.90M|      else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
  ------------------
  |  Branch (755:16): [True: 1.89M, False: 11.9k]
  ------------------
  756|  1.89M|        entropy->dc_context[ci] += 8;   /* large diff category */
  757|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  758|  1.90M|      st += 14;
  759|  17.2M|      while (m >>= 1)
  ------------------
  |  Branch (759:14): [True: 15.3M, False: 1.90M]
  ------------------
  760|  15.3M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (760:33): [True: 9.42M, False: 5.96M]
  ------------------
  761|  1.90M|    }
  762|       |
  763|       |    /* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */
  764|       |
  765|  3.30M|    tbl = compptr->ac_tbl_no;
  766|       |
  767|       |    /* Establish EOB (end-of-block) index */
  768|   138M|    for (ke = DCTSIZE2 - 1; ke > 0; ke--)
  ------------------
  |  |   67|  3.30M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (768:29): [True: 136M, False: 1.76M]
  ------------------
  769|   136M|      if ((*block)[jpeg_natural_order[ke]]) break;
  ------------------
  |  Branch (769:11): [True: 1.53M, False: 134M]
  ------------------
  770|       |
  771|       |    /* Figure F.5: Encode_AC_Coefficients */
  772|  53.6M|    for (k = 1; k <= ke; k++) {
  ------------------
  |  Branch (772:17): [True: 50.3M, False: 3.30M]
  ------------------
  773|  50.3M|      st = entropy->ac_stats[tbl] + 3 * (k - 1);
  774|  50.3M|      arith_encode(cinfo, st, 0);       /* EOB decision */
  775|  73.0M|      while ((v = (*block)[jpeg_natural_order[k]]) == 0) {
  ------------------
  |  Branch (775:14): [True: 22.7M, False: 50.3M]
  ------------------
  776|  22.7M|        arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  777|  22.7M|      }
  778|  50.3M|      arith_encode(cinfo, st + 1, 1);
  779|       |      /* Figure F.6: Encoding nonzero value v */
  780|       |      /* Figure F.7: Encoding the sign of v */
  781|  50.3M|      if (v > 0) {
  ------------------
  |  Branch (781:11): [True: 24.7M, False: 25.5M]
  ------------------
  782|  24.7M|        arith_encode(cinfo, entropy->fixed_bin, 0);
  783|  25.5M|      } else {
  784|  25.5M|        v = -v;
  785|  25.5M|        arith_encode(cinfo, entropy->fixed_bin, 1);
  786|  25.5M|      }
  787|  50.3M|      st += 2;
  788|       |      /* Figure F.8: Encoding the magnitude category of v */
  789|  50.3M|      m = 0;
  790|  50.3M|      if (v -= 1) {
  ------------------
  |  Branch (790:11): [True: 46.4M, False: 3.89M]
  ------------------
  791|  46.4M|        arith_encode(cinfo, st, 1);
  792|  46.4M|        m = 1;
  793|  46.4M|        v2 = v;
  794|  46.4M|        if (v2 >>= 1) {
  ------------------
  |  Branch (794:13): [True: 43.5M, False: 2.91M]
  ------------------
  795|  43.5M|          arith_encode(cinfo, st, 1);
  796|  43.5M|          m <<= 1;
  797|  43.5M|          st = entropy->ac_stats[tbl] +
  798|  43.5M|               (k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
  ------------------
  |  Branch (798:17): [True: 5.32M, False: 38.1M]
  ------------------
  799|   179M|          while (v2 >>= 1) {
  ------------------
  |  Branch (799:18): [True: 136M, False: 43.5M]
  ------------------
  800|   136M|            arith_encode(cinfo, st, 1);
  801|   136M|            m <<= 1;
  802|   136M|            st += 1;
  803|   136M|          }
  804|  43.5M|        }
  805|  46.4M|      }
  806|  50.3M|      arith_encode(cinfo, st, 0);
  807|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  808|  50.3M|      st += 14;
  809|   230M|      while (m >>= 1)
  ------------------
  |  Branch (809:14): [True: 179M, False: 50.3M]
  ------------------
  810|   179M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (810:33): [True: 81.8M, False: 97.8M]
  ------------------
  811|  50.3M|    }
  812|       |    /* Encode EOB decision only if k <= DCTSIZE2 - 1 */
  813|  3.30M|    if (k <= DCTSIZE2 - 1) {
  ------------------
  |  |   67|  3.30M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (813:9): [True: 2.64M, False: 657k]
  ------------------
  814|  2.64M|      st = entropy->ac_stats[tbl] + 3 * (k - 1);
  815|  2.64M|      arith_encode(cinfo, st, 1);
  816|  2.64M|    }
  817|  3.30M|  }
  818|       |
  819|   550k|  return TRUE;
  ------------------
  |  |  210|   550k|#define TRUE    1
  ------------------
  820|   550k|}
jcarith.c:finish_pass:
  140|  6.53M|{
  141|  6.53M|  arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
  142|  6.53M|  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|  6.53M|  if ((temp = (e->a - 1 + e->c) & 0xFFFF0000UL) < e->c)
  ------------------
  |  Branch (148:7): [True: 4.81M, False: 1.71M]
  ------------------
  149|  4.81M|    e->c = temp + 0x8000L;
  150|  1.71M|  else
  151|  1.71M|    e->c = temp;
  152|       |  /* Send remaining bytes to output */
  153|  6.53M|  e->c <<= e->ct;
  154|  6.53M|  if (e->c & 0xF8000000UL) {
  ------------------
  |  Branch (154:7): [True: 109k, False: 6.42M]
  ------------------
  155|       |    /* One final overflow has to be handled */
  156|   109k|    if (e->buffer >= 0) {
  ------------------
  |  Branch (156:9): [True: 109k, False: 0]
  ------------------
  157|   109k|      if (e->zc)
  ------------------
  |  Branch (157:11): [True: 14.0k, False: 95.3k]
  ------------------
  158|  14.4k|        do emit_byte(0x00, cinfo);
  159|  14.4k|        while (--e->zc);
  ------------------
  |  Branch (159:16): [True: 373, False: 14.0k]
  ------------------
  160|   109k|      emit_byte(e->buffer + 1, cinfo);
  161|   109k|      if (e->buffer + 1 == 0xFF)
  ------------------
  |  Branch (161:11): [True: 421, False: 109k]
  ------------------
  162|    421|        emit_byte(0x00, cinfo);
  163|   109k|    }
  164|   109k|    e->zc += e->sc;  /* carry-over converts stacked 0xFF bytes to 0x00 */
  165|   109k|    e->sc = 0;
  166|  6.42M|  } else {
  167|  6.42M|    if (e->buffer == 0)
  ------------------
  |  Branch (167:9): [True: 65.5k, False: 6.36M]
  ------------------
  168|  65.5k|      ++e->zc;
  169|  6.36M|    else if (e->buffer >= 0) {
  ------------------
  |  Branch (169:14): [True: 1.82M, False: 4.53M]
  ------------------
  170|  1.82M|      if (e->zc)
  ------------------
  |  Branch (170:11): [True: 8.12k, False: 1.82M]
  ------------------
  171|  9.51k|        do emit_byte(0x00, cinfo);
  172|  9.51k|        while (--e->zc);
  ------------------
  |  Branch (172:16): [True: 1.38k, False: 8.12k]
  ------------------
  173|  1.82M|      emit_byte(e->buffer, cinfo);
  174|  1.82M|    }
  175|  6.42M|    if (e->sc) {
  ------------------
  |  Branch (175:9): [True: 4.74k, False: 6.42M]
  ------------------
  176|  4.74k|      if (e->zc)
  ------------------
  |  Branch (176:11): [True: 48, False: 4.69k]
  ------------------
  177|     61|        do emit_byte(0x00, cinfo);
  178|     61|        while (--e->zc);
  ------------------
  |  Branch (178:16): [True: 13, False: 48]
  ------------------
  179|  5.10k|      do {
  180|  5.10k|        emit_byte(0xFF, cinfo);
  181|  5.10k|        emit_byte(0x00, cinfo);
  182|  5.10k|      } while (--e->sc);
  ------------------
  |  Branch (182:16): [True: 357, False: 4.74k]
  ------------------
  183|  4.74k|    }
  184|  6.42M|  }
  185|       |  /* Output final bytes only if they are not 0x00 */
  186|  6.53M|  if (e->c & 0x7FFF800L) {
  ------------------
  |  Branch (186:7): [True: 6.48M, False: 54.9k]
  ------------------
  187|  6.48M|    if (e->zc)  /* output final pending zero bytes */
  ------------------
  |  Branch (187:9): [True: 64.4k, False: 6.41M]
  ------------------
  188|  79.2k|      do emit_byte(0x00, cinfo);
  189|  79.2k|      while (--e->zc);
  ------------------
  |  Branch (189:14): [True: 14.7k, False: 64.4k]
  ------------------
  190|  6.48M|    emit_byte((e->c >> 19) & 0xFF, cinfo);
  191|  6.48M|    if (((e->c >> 19) & 0xFF) == 0xFF)
  ------------------
  |  Branch (191:9): [True: 3.38k, False: 6.48M]
  ------------------
  192|  3.38k|      emit_byte(0x00, cinfo);
  193|  6.48M|    if (e->c & 0x7F800L) {
  ------------------
  |  Branch (193:9): [True: 367k, False: 6.11M]
  ------------------
  194|   367k|      emit_byte((e->c >> 11) & 0xFF, cinfo);
  195|   367k|      if (((e->c >> 11) & 0xFF) == 0xFF)
  ------------------
  |  Branch (195:11): [True: 0, False: 367k]
  ------------------
  196|      0|        emit_byte(0x00, cinfo);
  197|   367k|    }
  198|  6.48M|  }
  199|  6.53M|}

j12init_c_coef_controller:
  437|  21.2k|{
  438|  21.2k|  my_coef_ptr coef;
  439|       |
  440|  21.2k|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  21.2k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (440:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  coef = (my_coef_ptr)
  444|  21.2k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  21.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  445|  21.2k|                                sizeof(my_coef_controller));
  446|  21.2k|  memset(coef, 0, sizeof(my_coef_controller));
  447|  21.2k|  cinfo->coef = (struct jpeg_c_coef_controller *)coef;
  448|  21.2k|  coef->pub.start_pass = start_pass_coef;
  449|       |
  450|       |  /* Create the coefficient buffer. */
  451|  21.2k|  if (need_full_buffer) {
  ------------------
  |  Branch (451:7): [True: 18.3k, False: 2.92k]
  ------------------
  452|  18.3k|#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.3k|    int ci;
  456|  18.3k|    jpeg_component_info *compptr;
  457|       |
  458|  63.3k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (458:46): [True: 45.0k, False: 18.3k]
  ------------------
  459|  45.0k|         ci++, compptr++) {
  460|  45.0k|      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
  461|  45.0k|        ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
  ------------------
  |  |  889|  45.0k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                      ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
  ------------------
  |  |  207|  45.0k|#define FALSE   0               /* values of boolean */
  ------------------
  462|  45.0k|         (JDIMENSION)jround_up((long)compptr->width_in_blocks,
  463|  45.0k|                               (long)compptr->h_samp_factor),
  464|  45.0k|         (JDIMENSION)jround_up((long)compptr->height_in_blocks,
  465|  45.0k|                               (long)compptr->v_samp_factor),
  466|  45.0k|         (JDIMENSION)compptr->v_samp_factor);
  467|  45.0k|    }
  468|       |#else
  469|       |    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  470|       |#endif
  471|  18.3k|  } else {
  472|       |    /* We only need a single-MCU buffer. */
  473|  2.92k|    JBLOCKROW buffer;
  474|  2.92k|    int i;
  475|       |
  476|  2.92k|    buffer = (JBLOCKROW)
  477|  2.92k|      (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  2.92k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  478|  2.92k|                                  C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
  ------------------
  |  |   80|  2.92k|#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on data units/MCU */
  ------------------
  479|  32.1k|    for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
  ------------------
  |  |   80|  32.1k|#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on data units/MCU */
  ------------------
  |  Branch (479:17): [True: 29.2k, False: 2.92k]
  ------------------
  480|  29.2k|      coef->MCU_buffer[i] = buffer + i;
  481|  29.2k|    }
  482|       |    coef->whole_image[0] = NULL; /* flag for no virtual arrays */
  483|  2.92k|  }
  484|  21.2k|}
jccoefct-12.c:start_pass_coef:
  104|   118k|{
  105|   118k|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  106|       |
  107|   118k|  coef->iMCU_row_num = 0;
  108|   118k|  start_iMCU_row(cinfo);
  109|       |
  110|   118k|  switch (pass_mode) {
  111|  2.92k|  case JBUF_PASS_THRU:
  ------------------
  |  Branch (111:3): [True: 2.92k, False: 115k]
  ------------------
  112|  2.92k|    if (coef->whole_image[0] != NULL)
  ------------------
  |  Branch (112:9): [True: 0, False: 2.92k]
  ------------------
  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.92k|    coef->pub._compress_data = compress_data;
  ------------------
  |  |  132|  2.92k|#define _compress_data  compress_data_12
  ------------------
  115|  2.92k|    break;
  116|      0|#ifdef FULL_COEF_BUFFER_SUPPORTED
  117|  18.3k|  case JBUF_SAVE_AND_PASS:
  ------------------
  |  Branch (117:3): [True: 18.3k, False: 99.7k]
  ------------------
  118|  18.3k|    if (coef->whole_image[0] == NULL)
  ------------------
  |  Branch (118:9): [True: 0, False: 18.3k]
  ------------------
  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.3k|    coef->pub._compress_data = compress_first_pass;
  ------------------
  |  |  132|  18.3k|#define _compress_data  compress_data_12
  ------------------
  121|  18.3k|    break;
  122|  96.8k|  case JBUF_CRANK_DEST:
  ------------------
  |  Branch (122:3): [True: 96.8k, False: 21.2k]
  ------------------
  123|  96.8k|    if (coef->whole_image[0] == NULL)
  ------------------
  |  Branch (123:9): [True: 0, False: 96.8k]
  ------------------
  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|  96.8k|    coef->pub._compress_data = compress_output;
  ------------------
  |  |  132|  96.8k|#define _compress_data  compress_data_12
  ------------------
  126|  96.8k|    break;
  127|      0|#endif
  128|      0|  default:
  ------------------
  |  Branch (128:3): [True: 0, False: 118k]
  ------------------
  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|   118k|  }
  132|   118k|}
jccoefct-12.c:start_iMCU_row:
   77|  12.7M|{
   78|  12.7M|  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|  12.7M|  if (cinfo->comps_in_scan > 1) {
  ------------------
  |  Branch (84:7): [True: 3.65M, False: 9.13M]
  ------------------
   85|  3.65M|    coef->MCU_rows_per_iMCU_row = 1;
   86|  9.13M|  } else {
   87|  9.13M|    if (coef->iMCU_row_num < (cinfo->total_iMCU_rows - 1))
  ------------------
  |  Branch (87:9): [True: 8.95M, False: 182k]
  ------------------
   88|  8.95M|      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
   89|   182k|    else
   90|   182k|      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
   91|  9.13M|  }
   92|       |
   93|  12.7M|  coef->mcu_ctr = 0;
   94|  12.7M|  coef->MCU_vert_offset = 0;
   95|  12.7M|}
jccoefct-12.c:compress_data:
  147|   242k|{
  148|   242k|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  149|   242k|  JDIMENSION MCU_col_num;       /* index of current MCU within row */
  150|   242k|  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
  151|   242k|  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
  152|   242k|  int blkn, bi, ci, yindex, yoffset, blockcnt;
  153|   242k|  JDIMENSION ypos, xpos;
  154|   242k|  jpeg_component_info *compptr;
  155|       |
  156|       |  /* Loop to write as much as one whole iMCU row */
  157|   485k|  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
  ------------------
  |  Branch (157:41): [True: 242k, False: 242k]
  ------------------
  158|   242k|       yoffset++) {
  159|   792k|    for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col;
  ------------------
  |  Branch (159:39): [True: 550k, False: 242k]
  ------------------
  160|   550k|         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|   550k|      blkn = 0;
  171|  2.20M|      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (171:20): [True: 1.65M, False: 550k]
  ------------------
  172|  1.65M|        compptr = cinfo->cur_comp_info[ci];
  173|  1.65M|        blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width :
  ------------------
  |  Branch (173:20): [True: 922k, False: 728k]
  ------------------
  174|  1.65M|                                                  compptr->last_col_width;
  175|  1.65M|        xpos = MCU_col_num * compptr->MCU_sample_width;
  176|  1.65M|        ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */
  ------------------
  |  |   66|  1.65M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  177|  3.85M|        for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
  ------------------
  |  Branch (177:26): [True: 2.20M, False: 1.65M]
  ------------------
  178|  2.20M|          if (coef->iMCU_row_num < last_iMCU_row ||
  ------------------
  |  Branch (178:15): [True: 1.17M, False: 1.02M]
  ------------------
  179|  1.99M|              yoffset + yindex < compptr->last_row_height) {
  ------------------
  |  Branch (179:15): [True: 823k, False: 204k]
  ------------------
  180|  1.99M|            (*cinfo->fdct->_forward_DCT) (cinfo, compptr,
  ------------------
  |  |  138|  1.99M|#define _forward_DCT  forward_DCT_12
  ------------------
  181|  1.99M|                                          input_buf[compptr->component_index],
  182|  1.99M|                                          coef->MCU_buffer[blkn],
  183|  1.99M|                                          ypos, xpos, (JDIMENSION)blockcnt);
  184|  1.99M|            if (blockcnt < compptr->MCU_width) {
  ------------------
  |  Branch (184:17): [True: 474k, False: 1.52M]
  ------------------
  185|       |              /* Create some dummy blocks at the right edge of the image. */
  186|   474k|              jzero_far((void *)coef->MCU_buffer[blkn + blockcnt],
  187|   474k|                        (compptr->MCU_width - blockcnt) * sizeof(JBLOCK));
  188|   948k|              for (bi = blockcnt; bi < compptr->MCU_width; bi++) {
  ------------------
  |  Branch (188:35): [True: 474k, False: 474k]
  ------------------
  189|   474k|                coef->MCU_buffer[blkn + bi][0][0] =
  190|   474k|                  coef->MCU_buffer[blkn + bi - 1][0][0];
  191|   474k|              }
  192|   474k|            }
  193|  1.99M|          } else {
  194|       |            /* Create a row of dummy blocks at the bottom of the image. */
  195|   204k|            jzero_far((void *)coef->MCU_buffer[blkn],
  196|   204k|                      compptr->MCU_width * sizeof(JBLOCK));
  197|   612k|            for (bi = 0; bi < compptr->MCU_width; bi++) {
  ------------------
  |  Branch (197:26): [True: 408k, False: 204k]
  ------------------
  198|   408k|              coef->MCU_buffer[blkn + bi][0][0] =
  199|   408k|                coef->MCU_buffer[blkn - 1][0][0];
  200|   408k|            }
  201|   204k|          }
  202|  2.20M|          blkn += compptr->MCU_width;
  203|  2.20M|          ypos += DCTSIZE;
  ------------------
  |  |   66|  2.20M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  204|  2.20M|        }
  205|  1.65M|      }
  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|   550k|      if (!(*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
  ------------------
  |  Branch (212:11): [True: 0, False: 550k]
  ------------------
  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|   550k|    }
  229|       |    /* Completed an MCU row, but perhaps not an iMCU row */
  230|   242k|    coef->mcu_ctr = 0;
  231|   242k|  }
  232|       |  /* Completed the iMCU row, advance counters for next one */
  233|   242k|  coef->iMCU_row_num++;
  234|   242k|  start_iMCU_row(cinfo);
  235|   242k|  return TRUE;
  ------------------
  |  |  210|   242k|#define TRUE    1
  ------------------
  236|   242k|}
jccoefct-12.c:compress_first_pass:
  264|  2.55M|{
  265|  2.55M|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  266|  2.55M|  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
  267|  2.55M|  JDIMENSION blocks_across, MCUs_across, MCUindex;
  268|  2.55M|  int bi, ci, h_samp_factor, block_row, block_rows, ndummy;
  269|  2.55M|  JCOEF lastDC;
  270|  2.55M|  jpeg_component_info *compptr;
  271|  2.55M|  JBLOCKARRAY buffer;
  272|  2.55M|  JBLOCKROW thisblockrow, lastblockrow;
  273|       |
  274|  8.74M|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (274:44): [True: 6.18M, False: 2.55M]
  ------------------
  275|  6.18M|       ci++, compptr++) {
  276|       |    /* Align the virtual buffer for this component. */
  277|  6.18M|    buffer = (*cinfo->mem->access_virt_barray)
  278|  6.18M|      ((j_common_ptr)cinfo, coef->whole_image[ci],
  279|  6.18M|       coef->iMCU_row_num * compptr->v_samp_factor,
  280|  6.18M|       (JDIMENSION)compptr->v_samp_factor, TRUE);
  ------------------
  |  |  210|  6.18M|#define TRUE    1
  ------------------
  281|       |    /* Count non-dummy DCT block rows in this iMCU row. */
  282|  6.18M|    if (coef->iMCU_row_num < last_iMCU_row)
  ------------------
  |  Branch (282:9): [True: 6.14M, False: 44.9k]
  ------------------
  283|  6.14M|      block_rows = compptr->v_samp_factor;
  284|  44.9k|    else {
  285|       |      /* NB: can't use last_row_height here, since may not be set! */
  286|  44.9k|      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
  287|  44.9k|      if (block_rows == 0) block_rows = compptr->v_samp_factor;
  ------------------
  |  Branch (287:11): [True: 40.1k, False: 4.84k]
  ------------------
  288|  44.9k|    }
  289|  6.18M|    blocks_across = compptr->width_in_blocks;
  290|  6.18M|    h_samp_factor = compptr->h_samp_factor;
  291|       |    /* Count number of dummy blocks to be added at the right margin. */
  292|  6.18M|    ndummy = (int)(blocks_across % h_samp_factor);
  293|  6.18M|    if (ndummy > 0)
  ------------------
  |  Branch (293:9): [True: 952k, False: 5.23M]
  ------------------
  294|   952k|      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|  12.8M|    for (block_row = 0; block_row < block_rows; block_row++) {
  ------------------
  |  Branch (298:25): [True: 6.66M, False: 6.18M]
  ------------------
  299|  6.66M|      thisblockrow = buffer[block_row];
  300|  6.66M|      (*cinfo->fdct->_forward_DCT) (cinfo, compptr,
  ------------------
  |  |  138|  6.66M|#define _forward_DCT  forward_DCT_12
  ------------------
  301|  6.66M|                                    input_buf[ci], thisblockrow,
  302|  6.66M|                                    (JDIMENSION)(block_row * DCTSIZE),
  ------------------
  |  |   66|  6.66M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  303|  6.66M|                                    (JDIMENSION)0, blocks_across);
  304|  6.66M|      if (ndummy > 0) {
  ------------------
  |  Branch (304:11): [True: 952k, False: 5.71M]
  ------------------
  305|       |        /* Create dummy blocks at the right edge of the image. */
  306|   952k|        thisblockrow += blocks_across; /* => first dummy block */
  307|   952k|        jzero_far((void *)thisblockrow, ndummy * sizeof(JBLOCK));
  308|   952k|        lastDC = thisblockrow[-1][0];
  309|  2.85M|        for (bi = 0; bi < ndummy; bi++) {
  ------------------
  |  Branch (309:22): [True: 1.90M, False: 952k]
  ------------------
  310|  1.90M|          thisblockrow[bi][0] = lastDC;
  311|  1.90M|        }
  312|   952k|      }
  313|  6.66M|    }
  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.18M|    if (coef->iMCU_row_num == last_iMCU_row) {
  ------------------
  |  Branch (319:9): [True: 44.9k, False: 6.14M]
  ------------------
  320|  44.9k|      blocks_across += ndummy;  /* include lower right corner */
  321|  44.9k|      MCUs_across = blocks_across / h_samp_factor;
  322|  49.8k|      for (block_row = block_rows; block_row < compptr->v_samp_factor;
  ------------------
  |  Branch (322:36): [True: 4.84k, False: 44.9k]
  ------------------
  323|  44.9k|           block_row++) {
  324|  4.84k|        thisblockrow = buffer[block_row];
  325|  4.84k|        lastblockrow = buffer[block_row - 1];
  326|  4.84k|        jzero_far((void *)thisblockrow,
  327|  4.84k|                  (size_t)(blocks_across * sizeof(JBLOCK)));
  328|   817k|        for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
  ------------------
  |  Branch (328:28): [True: 812k, False: 4.84k]
  ------------------
  329|   812k|          lastDC = lastblockrow[h_samp_factor - 1][0];
  330|  1.62M|          for (bi = 0; bi < h_samp_factor; bi++) {
  ------------------
  |  Branch (330:24): [True: 812k, False: 812k]
  ------------------
  331|   812k|            thisblockrow[bi][0] = lastDC;
  332|   812k|          }
  333|   812k|          thisblockrow += h_samp_factor; /* advance to next MCU in row */
  334|   812k|          lastblockrow += h_samp_factor;
  335|   812k|        }
  336|  4.84k|      }
  337|  44.9k|    }
  338|  6.18M|  }
  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.55M|  return compress_output(cinfo, input_buf);
  345|  2.55M|}
jccoefct-12.c:compress_output:
  360|  12.4M|{
  361|  12.4M|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  362|  12.4M|  JDIMENSION MCU_col_num;       /* index of current MCU within row */
  363|  12.4M|  int blkn, ci, xindex, yindex, yoffset;
  364|  12.4M|  JDIMENSION start_col;
  365|  12.4M|  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
  366|  12.4M|  JBLOCKROW buffer_ptr;
  367|  12.4M|  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|  32.1M|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (373:16): [True: 19.6M, False: 12.4M]
  ------------------
  374|  19.6M|    compptr = cinfo->cur_comp_info[ci];
  375|  19.6M|    buffer[ci] = (*cinfo->mem->access_virt_barray)
  376|  19.6M|      ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
  377|  19.6M|       coef->iMCU_row_num * compptr->v_samp_factor,
  378|  19.6M|       (JDIMENSION)compptr->v_samp_factor, FALSE);
  ------------------
  |  |  207|  19.6M|#define FALSE   0               /* values of boolean */
  ------------------
  379|  19.6M|  }
  380|       |
  381|       |  /* Loop to process one whole iMCU row */
  382|  26.7M|  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
  ------------------
  |  Branch (382:41): [True: 14.3M, False: 12.4M]
  ------------------
  383|  14.3M|       yoffset++) {
  384|  52.9M|    for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row;
  ------------------
  |  Branch (384:39): [True: 38.5M, False: 14.3M]
  ------------------
  385|  38.5M|         MCU_col_num++) {
  386|       |      /* Construct list of pointers to DCT blocks belonging to this MCU */
  387|  38.5M|      blkn = 0;                 /* index of current DCT block within MCU */
  388|  94.0M|      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (388:20): [True: 55.4M, False: 38.5M]
  ------------------
  389|  55.4M|        compptr = cinfo->cur_comp_info[ci];
  390|  55.4M|        start_col = MCU_col_num * compptr->MCU_width;
  391|   114M|        for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
  ------------------
  |  Branch (391:26): [True: 58.9M, False: 55.4M]
  ------------------
  392|  58.9M|          buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
  393|   123M|          for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
  ------------------
  |  Branch (393:28): [True: 64.8M, False: 58.9M]
  ------------------
  394|  64.8M|            coef->MCU_buffer[blkn++] = buffer_ptr++;
  395|  64.8M|          }
  396|  58.9M|        }
  397|  55.4M|      }
  398|       |      /* Try to write the MCU. */
  399|       |#ifdef WITH_PROFILE
  400|       |      cinfo->master->start = getTime();
  401|       |#endif
  402|  38.5M|      if (!(*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
  ------------------
  |  Branch (402:11): [True: 0, False: 38.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|  38.5M|    }
  419|       |    /* Completed an MCU row, but perhaps not an iMCU row */
  420|  14.3M|    coef->mcu_ctr = 0;
  421|  14.3M|  }
  422|       |  /* Completed the iMCU row, advance counters for next one */
  423|  12.4M|  coef->iMCU_row_num++;
  424|  12.4M|  start_iMCU_row(cinfo);
  425|  12.4M|  return TRUE;
  ------------------
  |  |  210|  12.4M|#define TRUE    1
  ------------------
  426|  12.4M|}

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

j12init_color_converter:
  418|  21.2k|{
  419|  21.2k|  my_cconvert_ptr cconvert;
  420|       |
  421|  21.2k|#ifdef C_LOSSLESS_SUPPORTED
  422|  21.2k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (422:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|#endif
  432|  21.2k|  {
  433|  21.2k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  21.2k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (433:9): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  }
  436|       |
  437|  21.2k|  cconvert = (my_cconvert_ptr)
  438|  21.2k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  21.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  439|  21.2k|                                sizeof(my_color_converter));
  440|  21.2k|  cinfo->cconvert = (struct jpeg_color_converter *)cconvert;
  441|       |  /* set start_pass to null method until we find out differently */
  442|  21.2k|  cconvert->pub.start_pass = null_method;
  443|       |
  444|       |  /* Make sure input_components agrees with in_color_space */
  445|  21.2k|  switch (cinfo->in_color_space) {
  446|  3.51k|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (446:3): [True: 3.51k, False: 17.7k]
  ------------------
  447|  3.51k|    if (cinfo->input_components != 1)
  ------------------
  |  Branch (447:9): [True: 0, False: 3.51k]
  ------------------
  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.51k|    break;
  450|       |
  451|      0|  case JCS_RGB:
  ------------------
  |  Branch (451:3): [True: 0, False: 21.2k]
  ------------------
  452|  3.01k|  case JCS_EXT_RGB:
  ------------------
  |  Branch (452:3): [True: 3.01k, False: 18.2k]
  ------------------
  453|  5.93k|  case JCS_EXT_RGBX:
  ------------------
  |  Branch (453:3): [True: 2.92k, False: 18.3k]
  ------------------
  454|  8.95k|  case JCS_EXT_BGR:
  ------------------
  |  Branch (454:3): [True: 3.01k, False: 18.2k]
  ------------------
  455|  8.95k|  case JCS_EXT_BGRX:
  ------------------
  |  Branch (455:3): [True: 0, False: 21.2k]
  ------------------
  456|  8.95k|  case JCS_EXT_XBGR:
  ------------------
  |  Branch (456:3): [True: 0, False: 21.2k]
  ------------------
  457|  11.8k|  case JCS_EXT_XRGB:
  ------------------
  |  Branch (457:3): [True: 2.92k, False: 18.3k]
  ------------------
  458|  11.8k|  case JCS_EXT_RGBA:
  ------------------
  |  Branch (458:3): [True: 0, False: 21.2k]
  ------------------
  459|  14.8k|  case JCS_EXT_BGRA:
  ------------------
  |  Branch (459:3): [True: 2.92k, False: 18.3k]
  ------------------
  460|  14.8k|  case JCS_EXT_ABGR:
  ------------------
  |  Branch (460:3): [True: 0, False: 21.2k]
  ------------------
  461|  14.8k|  case JCS_EXT_ARGB:
  ------------------
  |  Branch (461:3): [True: 0, False: 21.2k]
  ------------------
  462|  14.8k|    if (cinfo->input_components != rgb_pixelsize[cinfo->in_color_space])
  ------------------
  |  Branch (462:9): [True: 0, False: 14.8k]
  ------------------
  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.8k|    break;
  465|       |
  466|      0|  case JCS_YCbCr:
  ------------------
  |  Branch (466:3): [True: 0, False: 21.2k]
  ------------------
  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.92k|  case JCS_CMYK:
  ------------------
  |  Branch (471:3): [True: 2.92k, False: 18.3k]
  ------------------
  472|  2.92k|  case JCS_YCCK:
  ------------------
  |  Branch (472:3): [True: 0, False: 21.2k]
  ------------------
  473|  2.92k|    if (cinfo->input_components != 4)
  ------------------
  |  Branch (473:9): [True: 0, False: 2.92k]
  ------------------
  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.92k|    break;
  476|       |
  477|      0|  default:                      /* JCS_UNKNOWN can be anything */
  ------------------
  |  Branch (477:3): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  }
  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|  21.2k|  switch (cinfo->jpeg_color_space) {
  488|  6.44k|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (488:3): [True: 6.44k, False: 14.8k]
  ------------------
  489|  6.44k|#ifdef C_LOSSLESS_SUPPORTED
  490|  6.44k|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (490:9): [True: 0, False: 6.44k]
  ------------------
  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.44k|#endif
  494|  6.44k|    if (cinfo->num_components != 1)
  ------------------
  |  Branch (494:9): [True: 0, False: 6.44k]
  ------------------
  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.44k|    if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (496:9): [True: 3.51k, False: 2.92k]
  ------------------
  497|  3.51k|      cconvert->pub._color_convert = grayscale_convert;
  ------------------
  |  |  151|  3.51k|#define _color_convert  color_convert_12
  ------------------
  498|  2.92k|    else if (IsExtRGB(cinfo->in_color_space)) {
  ------------------
  |  |   78|  2.92k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 2.92k]
  |  |  |  Branch (78:22): [True: 2.92k, False: 0]
  |  |  |  Branch (78:43): [True: 2.92k, 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.92k|      {
  505|  2.92k|        cconvert->pub.start_pass = rgb_ycc_start;
  506|  2.92k|        switch (cinfo->in_color_space) {
  507|      0|        case JCS_EXT_RGB:
  ------------------
  |  Branch (507:9): [True: 0, False: 2.92k]
  ------------------
  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.92k]
  ------------------
  511|      0|        case JCS_EXT_RGBA:
  ------------------
  |  Branch (511:9): [True: 0, False: 2.92k]
  ------------------
  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.92k]
  ------------------
  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.92k]
  ------------------
  518|      0|        case JCS_EXT_BGRA:
  ------------------
  |  Branch (518:9): [True: 0, False: 2.92k]
  ------------------
  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.92k]
  ------------------
  522|      0|        case JCS_EXT_ABGR:
  ------------------
  |  Branch (522:9): [True: 0, False: 2.92k]
  ------------------
  523|      0|          cconvert->pub._color_convert = extxbgr_gray_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  524|      0|          break;
  525|  2.92k|        case JCS_EXT_XRGB:
  ------------------
  |  Branch (525:9): [True: 2.92k, False: 0]
  ------------------
  526|  2.92k|        case JCS_EXT_ARGB:
  ------------------
  |  Branch (526:9): [True: 0, False: 2.92k]
  ------------------
  527|  2.92k|          cconvert->pub._color_convert = extxrgb_gray_convert;
  ------------------
  |  |  151|  2.92k|#define _color_convert  color_convert_12
  ------------------
  528|  2.92k|          break;
  529|      0|        default:
  ------------------
  |  Branch (529:9): [True: 0, False: 2.92k]
  ------------------
  530|      0|          cconvert->pub._color_convert = rgb_gray_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  531|  2.92k|        }
  532|  2.92k|      }
  533|  2.92k|    } 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.44k|    break;
  538|       |
  539|  6.44k|  case JCS_RGB:
  ------------------
  |  Branch (539:3): [True: 2.92k, False: 18.3k]
  ------------------
  540|  2.92k|#ifdef C_LOSSLESS_SUPPORTED
  541|  2.92k|    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.92k]
  ------------------
  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.92k|#endif
  544|  2.92k|    if (cinfo->num_components != 3)
  ------------------
  |  Branch (544:9): [True: 0, False: 2.92k]
  ------------------
  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.92k|    if (rgb_red[cinfo->in_color_space] == 0 &&
  ------------------
  |  Branch (546:9): [True: 2.92k, False: 0]
  ------------------
  547|  2.92k|        rgb_green[cinfo->in_color_space] == 1 &&
  ------------------
  |  Branch (547:9): [True: 2.92k, False: 0]
  ------------------
  548|  2.92k|        rgb_blue[cinfo->in_color_space] == 2 &&
  ------------------
  |  Branch (548:9): [True: 2.92k, False: 0]
  ------------------
  549|  2.92k|        rgb_pixelsize[cinfo->in_color_space] == 3) {
  ------------------
  |  Branch (549:9): [True: 0, False: 2.92k]
  ------------------
  550|      0|      cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  551|  2.92k|    } else if (IsExtRGB(cinfo->in_color_space)) {
  ------------------
  |  |   78|  2.92k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 2.92k]
  |  |  |  Branch (78:22): [True: 2.92k, False: 0]
  |  |  |  Branch (78:43): [True: 2.92k, False: 0]
  |  |  ------------------
  ------------------
  552|  2.92k|      switch (cinfo->in_color_space) {
  553|      0|      case JCS_EXT_RGB:
  ------------------
  |  Branch (553:7): [True: 0, False: 2.92k]
  ------------------
  554|      0|        cconvert->pub._color_convert = extrgb_rgb_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  555|      0|        break;
  556|  2.92k|      case JCS_EXT_RGBX:
  ------------------
  |  Branch (556:7): [True: 2.92k, False: 0]
  ------------------
  557|  2.92k|      case JCS_EXT_RGBA:
  ------------------
  |  Branch (557:7): [True: 0, False: 2.92k]
  ------------------
  558|  2.92k|        cconvert->pub._color_convert = extrgbx_rgb_convert;
  ------------------
  |  |  151|  2.92k|#define _color_convert  color_convert_12
  ------------------
  559|  2.92k|        break;
  560|      0|      case JCS_EXT_BGR:
  ------------------
  |  Branch (560:7): [True: 0, False: 2.92k]
  ------------------
  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.92k]
  ------------------
  564|      0|      case JCS_EXT_BGRA:
  ------------------
  |  Branch (564:7): [True: 0, False: 2.92k]
  ------------------
  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.92k]
  ------------------
  568|      0|      case JCS_EXT_ABGR:
  ------------------
  |  Branch (568:7): [True: 0, False: 2.92k]
  ------------------
  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.92k]
  ------------------
  572|      0|      case JCS_EXT_ARGB:
  ------------------
  |  Branch (572:7): [True: 0, False: 2.92k]
  ------------------
  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.92k]
  ------------------
  576|      0|        cconvert->pub._color_convert = rgb_rgb_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  577|  2.92k|      }
  578|  2.92k|    } 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.92k|    break;
  581|       |
  582|  8.95k|  case JCS_YCbCr:
  ------------------
  |  Branch (582:3): [True: 8.95k, False: 12.2k]
  ------------------
  583|  8.95k|#ifdef C_LOSSLESS_SUPPORTED
  584|  8.95k|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (584:9): [True: 0, False: 8.95k]
  ------------------
  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.95k|#endif
  588|  8.95k|    if (cinfo->num_components != 3)
  ------------------
  |  Branch (588:9): [True: 0, False: 8.95k]
  ------------------
  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.95k|    if (IsExtRGB(cinfo->in_color_space)) {
  ------------------
  |  |   78|  8.95k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 8.95k]
  |  |  |  Branch (78:22): [True: 8.95k, False: 0]
  |  |  |  Branch (78:43): [True: 8.95k, 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.95k|      {
  597|  8.95k|        cconvert->pub.start_pass = rgb_ycc_start;
  598|  8.95k|        switch (cinfo->in_color_space) {
  599|  3.01k|        case JCS_EXT_RGB:
  ------------------
  |  Branch (599:9): [True: 3.01k, False: 5.93k]
  ------------------
  600|  3.01k|          cconvert->pub._color_convert = extrgb_ycc_convert;
  ------------------
  |  |  151|  3.01k|#define _color_convert  color_convert_12
  ------------------
  601|  3.01k|          break;
  602|      0|        case JCS_EXT_RGBX:
  ------------------
  |  Branch (602:9): [True: 0, False: 8.95k]
  ------------------
  603|      0|        case JCS_EXT_RGBA:
  ------------------
  |  Branch (603:9): [True: 0, False: 8.95k]
  ------------------
  604|      0|          cconvert->pub._color_convert = extrgbx_ycc_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  605|      0|          break;
  606|  3.01k|        case JCS_EXT_BGR:
  ------------------
  |  Branch (606:9): [True: 3.01k, False: 5.93k]
  ------------------
  607|  3.01k|          cconvert->pub._color_convert = extbgr_ycc_convert;
  ------------------
  |  |  151|  3.01k|#define _color_convert  color_convert_12
  ------------------
  608|  3.01k|          break;
  609|      0|        case JCS_EXT_BGRX:
  ------------------
  |  Branch (609:9): [True: 0, False: 8.95k]
  ------------------
  610|  2.92k|        case JCS_EXT_BGRA:
  ------------------
  |  Branch (610:9): [True: 2.92k, False: 6.02k]
  ------------------
  611|  2.92k|          cconvert->pub._color_convert = extbgrx_ycc_convert;
  ------------------
  |  |  151|  2.92k|#define _color_convert  color_convert_12
  ------------------
  612|  2.92k|          break;
  613|      0|        case JCS_EXT_XBGR:
  ------------------
  |  Branch (613:9): [True: 0, False: 8.95k]
  ------------------
  614|      0|        case JCS_EXT_ABGR:
  ------------------
  |  Branch (614:9): [True: 0, False: 8.95k]
  ------------------
  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.95k]
  ------------------
  618|      0|        case JCS_EXT_ARGB:
  ------------------
  |  Branch (618:9): [True: 0, False: 8.95k]
  ------------------
  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.95k]
  ------------------
  622|      0|          cconvert->pub._color_convert = rgb_ycc_convert;
  ------------------
  |  |  151|      0|#define _color_convert  color_convert_12
  ------------------
  623|  8.95k|        }
  624|  8.95k|      }
  625|  8.95k|    } 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.95k|    break;
  630|       |
  631|  8.95k|  case JCS_CMYK:
  ------------------
  |  Branch (631:3): [True: 0, False: 21.2k]
  ------------------
  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.92k|  case JCS_YCCK:
  ------------------
  |  Branch (645:3): [True: 2.92k, False: 18.3k]
  ------------------
  646|  2.92k|#ifdef C_LOSSLESS_SUPPORTED
  647|  2.92k|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (647:9): [True: 0, False: 2.92k]
  ------------------
  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.92k|#endif
  651|  2.92k|    if (cinfo->num_components != 4)
  ------------------
  |  Branch (651:9): [True: 0, False: 2.92k]
  ------------------
  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.92k|    if (cinfo->in_color_space == JCS_CMYK) {
  ------------------
  |  Branch (653:9): [True: 2.92k, False: 0]
  ------------------
  654|  2.92k|      cconvert->pub.start_pass = rgb_ycc_start;
  655|  2.92k|      cconvert->pub._color_convert = cmyk_ycck_convert;
  ------------------
  |  |  151|  2.92k|#define _color_convert  color_convert_12
  ------------------
  656|  2.92k|    } 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.92k|    break;
  661|       |
  662|      0|  default:                      /* allow null conversion of JCS_UNKNOWN */
  ------------------
  |  Branch (662:3): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  }
  669|  21.2k|}
jccolor-12.c:null_method:
  407|  6.44k|{
  408|       |  /* no work needed */
  409|  6.44k|}
jccolor-12.c:grayscale_convert:
  319|  3.04M|{
  320|  3.04M|  register _JSAMPROW inptr;
  321|  3.04M|  register _JSAMPROW outptr;
  322|  3.04M|  register JDIMENSION col;
  323|  3.04M|  JDIMENSION num_cols = cinfo->image_width;
  324|  3.04M|  int instride = cinfo->input_components;
  325|       |
  326|  6.08M|  while (--num_rows >= 0) {
  ------------------
  |  Branch (326:10): [True: 3.04M, False: 3.04M]
  ------------------
  327|  3.04M|    inptr = *input_buf++;
  328|  3.04M|    outptr = output_buf[0][output_row];
  329|  3.04M|    output_row++;
  330|  20.7M|    for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (330:19): [True: 17.7M, False: 3.04M]
  ------------------
  331|  17.7M|      outptr[col] = inptr[0];
  332|  17.7M|      inptr += instride;
  333|  17.7M|    }
  334|  3.04M|  }
  335|  3.04M|}
jccolor-12.c:rgb_ycc_start:
  216|  14.8k|{
  217|  14.8k|#if BITS_IN_JSAMPLE != 16
  218|  14.8k|  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
  219|  14.8k|  JLONG *rgb_ycc_tab;
  220|  14.8k|  JLONG i;
  221|       |
  222|       |  /* Allocate and fill in the conversion tables. */
  223|  14.8k|  cconvert->rgb_ycc_tab = rgb_ycc_tab = (JLONG *)
  224|  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 */
  ------------------
  225|  14.8k|                                (TABLE_SIZE * sizeof(JLONG)));
  ------------------
  |  |   90|  14.8k|#define TABLE_SIZE      (8 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  14.8k|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  14.8k|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  226|       |
  227|  60.6M|  for (i = 0; i <= _MAXJSAMPLE; i++) {
  ------------------
  |  |  110|  60.6M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  ------------------
  |  |  |  |   60|  60.6M|#define MAXJ12SAMPLE     4095
  |  |  ------------------
  ------------------
  |  Branch (227:15): [True: 60.6M, False: 14.8k]
  ------------------
  228|  60.6M|    rgb_ycc_tab[i + R_Y_OFF] = FIX(0.29900) * i;
  ------------------
  |  |   81|  60.6M|#define R_Y_OFF         0                       /* offset to R => Y section */
  ------------------
                  rgb_ycc_tab[i + R_Y_OFF] = FIX(0.29900) * i;
  ------------------
  |  |   73|  60.6M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  60.6M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  229|  60.6M|    rgb_ycc_tab[i + G_Y_OFF] = FIX(0.58700) * i;
  ------------------
  |  |   82|  60.6M|#define G_Y_OFF         (1 * (_MAXJSAMPLE + 1)) /* offset to G => Y section */
  |  |  ------------------
  |  |  |  |  110|  60.6M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  60.6M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + G_Y_OFF] = FIX(0.58700) * i;
  ------------------
  |  |   73|  60.6M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  60.6M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  230|  60.6M|    rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i   + ONE_HALF;
  ------------------
  |  |   83|  60.6M|#define B_Y_OFF         (2 * (_MAXJSAMPLE + 1)) /* etc. */
  |  |  ------------------
  |  |  |  |  110|  60.6M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  60.6M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i   + ONE_HALF;
  ------------------
  |  |   73|  60.6M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  60.6M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i   + ONE_HALF;
  ------------------
  |  |   72|  60.6M|#define ONE_HALF        ((JLONG)1 << (SCALEBITS - 1))
  |  |  ------------------
  |  |  |  |   70|  60.6M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  231|  60.6M|    rgb_ycc_tab[i + R_CB_OFF] = (-FIX(0.16874)) * i;
  ------------------
  |  |   84|  60.6M|#define R_CB_OFF        (3 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  60.6M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  60.6M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + R_CB_OFF] = (-FIX(0.16874)) * i;
  ------------------
  |  |   73|  60.6M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  60.6M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  232|  60.6M|    rgb_ycc_tab[i + G_CB_OFF] = (-FIX(0.33126)) * i;
  ------------------
  |  |   85|  60.6M|#define G_CB_OFF        (4 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  60.6M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  60.6M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + G_CB_OFF] = (-FIX(0.33126)) * i;
  ------------------
  |  |   73|  60.6M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  60.6M|#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|  60.6M|    rgb_ycc_tab[i + B_CB_OFF] = FIX(0.50000) * i  + CBCR_OFFSET + ONE_HALF - 1;
  ------------------
  |  |   86|  60.6M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  60.6M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  60.6M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_CB_OFF] = FIX(0.50000) * i  + CBCR_OFFSET + ONE_HALF - 1;
  ------------------
  |  |   73|  60.6M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  60.6M|#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|  60.6M|#define CBCR_OFFSET     ((JLONG)_CENTERJSAMPLE << SCALEBITS)
  |  |  ------------------
  |  |  |  |  111|  60.6M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  60.6M|#define CENTERJ12SAMPLE  2048
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define CBCR_OFFSET     ((JLONG)_CENTERJSAMPLE << SCALEBITS)
  |  |  ------------------
  |  |  |  |   70|  60.6M|#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|  60.6M|#define ONE_HALF        ((JLONG)1 << (SCALEBITS - 1))
  |  |  ------------------
  |  |  |  |   70|  60.6M|#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|  60.6M|    rgb_ycc_tab[i + G_CR_OFF] = (-FIX(0.41869)) * i;
  ------------------
  |  |   88|  60.6M|#define G_CR_OFF        (6 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  60.6M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  60.6M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + G_CR_OFF] = (-FIX(0.41869)) * i;
  ------------------
  |  |   73|  60.6M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  60.6M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  242|  60.6M|    rgb_ycc_tab[i + B_CR_OFF] = (-FIX(0.08131)) * i;
  ------------------
  |  |   89|  60.6M|#define B_CR_OFF        (7 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  60.6M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  60.6M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_CR_OFF] = (-FIX(0.08131)) * i;
  ------------------
  |  |   73|  60.6M|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|  60.6M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  243|  60.6M|  }
  244|       |#else
  245|       |  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  246|       |#endif
  247|  14.8k|}
jccolor-12.c:cmyk_ycck_convert:
  264|  1.93M|{
  265|  1.93M|#if BITS_IN_JSAMPLE != 16
  266|  1.93M|  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
  267|  1.93M|  register int r, g, b;
  268|  1.93M|  register JLONG *ctab = cconvert->rgb_ycc_tab;
  269|  1.93M|  register _JSAMPROW inptr;
  270|  1.93M|  register _JSAMPROW outptr0, outptr1, outptr2, outptr3;
  271|  1.93M|  register JDIMENSION col;
  272|  1.93M|  JDIMENSION num_cols = cinfo->image_width;
  273|       |
  274|  5.78M|  while (--num_rows >= 0) {
  ------------------
  |  Branch (274:10): [True: 3.85M, False: 1.93M]
  ------------------
  275|  3.85M|    inptr = *input_buf++;
  276|  3.85M|    outptr0 = output_buf[0][output_row];
  277|  3.85M|    outptr1 = output_buf[1][output_row];
  278|  3.85M|    outptr2 = output_buf[2][output_row];
  279|  3.85M|    outptr3 = output_buf[3][output_row];
  280|  3.85M|    output_row++;
  281|  40.1M|    for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (281:19): [True: 36.2M, False: 3.85M]
  ------------------
  282|  36.2M|      r = _MAXJSAMPLE - RANGE_LIMIT(inptr[0]);
  ------------------
  |  |  110|  36.2M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  ------------------
  |  |  |  |   60|  36.2M|#define MAXJ12SAMPLE     4095
  |  |  ------------------
  ------------------
                    r = _MAXJSAMPLE - RANGE_LIMIT(inptr[0]);
  ------------------
  |  |   99|  36.2M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
  283|  36.2M|      g = _MAXJSAMPLE - RANGE_LIMIT(inptr[1]);
  ------------------
  |  |  110|  36.2M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  ------------------
  |  |  |  |   60|  36.2M|#define MAXJ12SAMPLE     4095
  |  |  ------------------
  ------------------
                    g = _MAXJSAMPLE - RANGE_LIMIT(inptr[1]);
  ------------------
  |  |   99|  36.2M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
  284|  36.2M|      b = _MAXJSAMPLE - RANGE_LIMIT(inptr[2]);
  ------------------
  |  |  110|  36.2M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  ------------------
  |  |  |  |   60|  36.2M|#define MAXJ12SAMPLE     4095
  |  |  ------------------
  ------------------
                    b = _MAXJSAMPLE - RANGE_LIMIT(inptr[2]);
  ------------------
  |  |   99|  36.2M|#define RANGE_LIMIT(value)  ((value) & 0xFFF)
  ------------------
  285|       |      /* K passes through as-is */
  286|  36.2M|      outptr3[col] = inptr[3];
  287|  36.2M|      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|  36.2M|      outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   81|  36.2M|#define R_Y_OFF         0                       /* offset to R => Y section */
  ------------------
                    outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   82|  36.2M|#define G_Y_OFF         (1 * (_MAXJSAMPLE + 1)) /* offset to G => Y section */
  |  |  ------------------
  |  |  |  |  110|  36.2M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  36.2M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  295|  36.2M|                                 ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   83|  36.2M|#define B_Y_OFF         (2 * (_MAXJSAMPLE + 1)) /* etc. */
  |  |  ------------------
  |  |  |  |  110|  36.2M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  36.2M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  36.2M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
  296|       |      /* Cb */
  297|  36.2M|      outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
  ------------------
  |  |   84|  36.2M|#define R_CB_OFF        (3 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  36.2M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  36.2M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
  ------------------
  |  |   85|  36.2M|#define G_CB_OFF        (4 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  36.2M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  36.2M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  298|  36.2M|                                 ctab[b + B_CB_OFF]) >> SCALEBITS);
  ------------------
  |  |   86|  36.2M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  36.2M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  36.2M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_CB_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  36.2M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
  299|       |      /* Cr */
  300|  36.2M|      outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
  ------------------
  |  |   87|  36.2M|#define R_CR_OFF        B_CB_OFF                /* B=>Cb, R=>Cr are the same */
  |  |  ------------------
  |  |  |  |   86|  36.2M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|  36.2M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   60|  36.2M|#define MAXJ12SAMPLE     4095
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
  ------------------
  |  |   88|  36.2M|#define G_CR_OFF        (6 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  36.2M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  36.2M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  301|  36.2M|                                 ctab[b + B_CR_OFF]) >> SCALEBITS);
  ------------------
  |  |   89|  36.2M|#define B_CR_OFF        (7 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  110|  36.2M|#define _MAXJSAMPLE  MAXJ12SAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  36.2M|#define MAXJ12SAMPLE     4095
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_CR_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  36.2M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
  302|  36.2M|    }
  303|  3.85M|  }
  304|       |#else
  305|       |  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  306|       |#endif
  307|  1.93M|}

j12init_forward_dct:
  672|  21.2k|{
  673|  21.2k|  my_fdct_ptr fdct;
  674|  21.2k|  int i;
  675|       |
  676|  21.2k|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  21.2k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (676:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  fdct = (my_fdct_ptr)
  680|  21.2k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  21.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  681|  21.2k|                                sizeof(my_fdct_controller));
  682|  21.2k|  cinfo->fdct = (struct jpeg_forward_dct *)fdct;
  683|  21.2k|  fdct->pub.start_pass = start_pass_fdctmgr;
  684|       |
  685|       |  /* First determine the DCT... */
  686|  21.2k|  switch (cinfo->dct_method) {
  687|      0|#ifdef DCT_ISLOW_SUPPORTED
  688|  18.2k|  case JDCT_ISLOW:
  ------------------
  |  Branch (688:3): [True: 18.2k, False: 3.01k]
  ------------------
  689|  18.2k|    fdct->pub._forward_DCT = forward_DCT;
  ------------------
  |  |  138|  18.2k|#define _forward_DCT  forward_DCT_12
  ------------------
  690|       |#ifdef WITH_SIMD
  691|       |    if (!jsimd_set_fdct_islow(cinfo, &fdct->dct))
  692|       |#endif
  693|  18.2k|      fdct->dct = _jpeg_fdct_islow;
  ------------------
  |  |  184|  18.2k|#define _jpeg_fdct_islow  jpeg12_fdct_islow
  ------------------
  694|  18.2k|    break;
  695|      0|#endif
  696|      0|#ifdef DCT_IFAST_SUPPORTED
  697|  3.01k|  case JDCT_IFAST:
  ------------------
  |  Branch (697:3): [True: 3.01k, False: 18.2k]
  ------------------
  698|  3.01k|    fdct->pub._forward_DCT = forward_DCT;
  ------------------
  |  |  138|  3.01k|#define _forward_DCT  forward_DCT_12
  ------------------
  699|       |#ifdef WITH_SIMD
  700|       |    if (!jsimd_set_fdct_ifast(cinfo, &fdct->dct))
  701|       |#endif
  702|  3.01k|      fdct->dct = _jpeg_fdct_ifast;
  ------------------
  |  |  185|  3.01k|#define _jpeg_fdct_ifast  jpeg12_fdct_ifast
  ------------------
  703|  3.01k|    break;
  704|      0|#endif
  705|      0|#ifdef DCT_FLOAT_SUPPORTED
  706|      0|  case JDCT_FLOAT:
  ------------------
  |  Branch (706:3): [True: 0, False: 21.2k]
  ------------------
  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: 21.2k]
  ------------------
  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|  21.2k|  }
  718|       |
  719|       |  /* ...then the supporting stages. */
  720|  21.2k|  switch (cinfo->dct_method) {
  721|      0|#ifdef DCT_ISLOW_SUPPORTED
  722|  18.2k|  case JDCT_ISLOW:
  ------------------
  |  Branch (722:3): [True: 18.2k, False: 3.01k]
  ------------------
  723|  18.2k|#endif
  724|  18.2k|#ifdef DCT_IFAST_SUPPORTED
  725|  21.2k|  case JDCT_IFAST:
  ------------------
  |  Branch (725:3): [True: 3.01k, False: 18.2k]
  ------------------
  726|  21.2k|#endif
  727|  21.2k|#if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED)
  728|       |#ifdef WITH_SIMD
  729|       |    if (!jsimd_set_convsamp(cinfo, &fdct->convsamp))
  730|       |#endif
  731|  21.2k|      fdct->convsamp = convsamp;
  732|       |#ifdef WITH_SIMD
  733|       |    if (!jsimd_set_quantize(cinfo, &fdct->quantize))
  734|       |#endif
  735|  21.2k|      fdct->quantize = quantize;
  736|  21.2k|    break;
  737|      0|#endif
  738|      0|#ifdef DCT_FLOAT_SUPPORTED
  739|      0|  case JDCT_FLOAT:
  ------------------
  |  Branch (739:3): [True: 0, False: 21.2k]
  ------------------
  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: 21.2k]
  ------------------
  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|  21.2k|  }
  754|       |
  755|       |  /* Allocate workspace memory */
  756|  21.2k|#ifdef DCT_FLOAT_SUPPORTED
  757|  21.2k|  if (cinfo->dct_method == JDCT_FLOAT)
  ------------------
  |  Branch (757:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  else
  762|  21.2k|#endif
  763|  21.2k|    fdct->workspace = (DCTELEM *)
  764|  21.2k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  21.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  765|  21.2k|                                  sizeof(DCTELEM) * DCTSIZE2);
  ------------------
  |  |   67|  21.2k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  766|       |
  767|       |  /* Mark divisor tables unallocated */
  768|   106k|  for (i = 0; i < NUM_QUANT_TBLS; i++) {
  ------------------
  |  |   68|   106k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (768:15): [True: 84.9k, False: 21.2k]
  ------------------
  769|  84.9k|    fdct->divisors[i] = NULL;
  770|  84.9k|#ifdef DCT_FLOAT_SUPPORTED
  771|       |    fdct->float_divisors[i] = NULL;
  772|  84.9k|#endif
  773|  84.9k|  }
  774|  21.2k|}
jcdctmgr-12.c:start_pass_fdctmgr:
  235|  21.2k|{
  236|  21.2k|  my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
  237|  21.2k|  int ci, qtblno, i;
  238|  21.2k|  jpeg_component_info *compptr;
  239|  21.2k|  JQUANT_TBL *qtbl;
  240|  21.2k|  DCTELEM *dtbl;
  241|       |
  242|  75.0k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (242:44): [True: 53.7k, False: 21.2k]
  ------------------
  243|  53.7k|       ci++, compptr++) {
  244|  53.7k|    qtblno = compptr->quant_tbl_no;
  245|       |    /* Make sure specified quantization table is present */
  246|  53.7k|    if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
  ------------------
  |  |   68|   107k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (246:9): [True: 0, False: 53.7k]
  |  Branch (246:23): [True: 0, False: 53.7k]
  ------------------
  247|  53.7k|        cinfo->quant_tbl_ptrs[qtblno] == NULL)
  ------------------
  |  Branch (247:9): [True: 0, False: 53.7k]
  ------------------
  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|  53.7k|    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|  53.7k|    switch (cinfo->dct_method) {
  253|      0|#ifdef DCT_ISLOW_SUPPORTED
  254|  44.7k|    case JDCT_ISLOW:
  ------------------
  |  Branch (254:5): [True: 44.7k, False: 9.03k]
  ------------------
  255|       |      /* For LL&M IDCT method, divisors are equal to raw quantization
  256|       |       * coefficients multiplied by 8 (to counteract scaling).
  257|       |       */
  258|  44.7k|      if (fdct->divisors[qtblno] == NULL) {
  ------------------
  |  Branch (258:11): [True: 27.1k, False: 17.6k]
  ------------------
  259|  27.1k|        fdct->divisors[qtblno] = (DCTELEM *)
  260|  27.1k|          (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  27.1k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  261|  27.1k|                                      (DCTSIZE2 * 4) * sizeof(DCTELEM));
  ------------------
  |  |   67|  27.1k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  262|  27.1k|      }
  263|  44.7k|      dtbl = fdct->divisors[qtblno];
  264|  2.90M|      for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  2.90M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (264:19): [True: 2.86M, False: 44.7k]
  ------------------
  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.86M|        dtbl[i] = ((DCTELEM)qtbl->quantval[i]) << 3;
  275|  2.86M|#endif
  276|  2.86M|      }
  277|  44.7k|      break;
  278|      0|#endif
  279|      0|#ifdef DCT_IFAST_SUPPORTED
  280|  9.03k|    case JDCT_IFAST:
  ------------------
  |  Branch (280:5): [True: 9.03k, False: 44.7k]
  ------------------
  281|  9.03k|      {
  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|  9.03k|#define CONST_BITS  14
  289|  9.03k|        static const INT16 aanscales[DCTSIZE2] = {
  290|       |          /* precomputed values scaled up by 14 bits */
  291|  9.03k|          16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
  292|  9.03k|          22725, 31521, 29692, 26722, 22725, 17855, 12299,  6270,
  293|  9.03k|          21407, 29692, 27969, 25172, 21407, 16819, 11585,  5906,
  294|  9.03k|          19266, 26722, 25172, 22654, 19266, 15137, 10426,  5315,
  295|  9.03k|          16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
  296|  9.03k|          12873, 17855, 16819, 15137, 12873, 10114,  6967,  3552,
  297|  9.03k|           8867, 12299, 11585, 10426,  8867,  6967,  4799,  2446,
  298|  9.03k|           4520,  6270,  5906,  5315,  4520,  3552,  2446,  1247
  299|  9.03k|        };
  300|  9.03k|        SHIFT_TEMPS
  301|       |
  302|  9.03k|        if (fdct->divisors[qtblno] == NULL) {
  ------------------
  |  Branch (302:13): [True: 6.02k, False: 3.01k]
  ------------------
  303|  6.02k|          fdct->divisors[qtblno] = (DCTELEM *)
  304|  6.02k|            (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  6.02k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  305|  6.02k|                                        (DCTSIZE2 * 4) * sizeof(DCTELEM));
  ------------------
  |  |   67|  6.02k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  306|  6.02k|        }
  307|  9.03k|        dtbl = fdct->divisors[qtblno];
  308|   587k|        for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|   587k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (308:21): [True: 578k, False: 9.03k]
  ------------------
  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|   578k|          dtbl[i] = (DCTELEM)
  325|   578k|            DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
  ------------------
  |  |  216|   578k|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   578k|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  326|   578k|                                  (JLONG)aanscales[i]),
  327|   578k|                    CONST_BITS - 3);
  328|   578k|#endif
  329|   578k|        }
  330|  9.03k|      }
  331|  9.03k|      break;
  332|      0|#endif
  333|      0|#ifdef DCT_FLOAT_SUPPORTED
  334|      0|    case JDCT_FLOAT:
  ------------------
  |  Branch (334:5): [True: 0, False: 53.7k]
  ------------------
  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: 53.7k]
  ------------------
  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|  53.7k|    }
  373|  53.7k|  }
  374|  21.2k|}
jcdctmgr-12.c:forward_DCT:
  503|  8.66M|{
  504|       |  /* This routine is heavily used, so it's worth coding it tightly. */
  505|  8.66M|  my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
  506|  8.66M|  DCTELEM *divisors = fdct->divisors[compptr->quant_tbl_no];
  507|  8.66M|  DCTELEM *workspace;
  508|  8.66M|  JDIMENSION bi;
  509|       |
  510|       |  /* Make sure the compiler doesn't look up these every pass */
  511|  8.66M|  forward_DCT_method_ptr do_dct = fdct->dct;
  512|  8.66M|  convsamp_method_ptr do_convsamp = fdct->convsamp;
  513|  8.66M|  quantize_method_ptr do_quantize = fdct->quantize;
  514|  8.66M|  workspace = fdct->workspace;
  515|       |
  516|  8.66M|  sample_data += start_row;     /* fold in the vertical offset once */
  517|       |
  518|  27.5M|  for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {
  ------------------
  |  |   66|  18.8M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (518:16): [True: 18.8M, False: 8.66M]
  ------------------
  519|       |    /* Load data into workspace, applying unsigned->signed conversion */
  520|       |#ifdef WITH_PROFILE
  521|       |    cinfo->master->start = getTime();
  522|       |#endif
  523|  18.8M|    (*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|  18.8M|    (*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|  18.8M|    (*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|  18.8M|  }
  549|  8.66M|}
jcdctmgr-12.c:convsamp:
  383|  18.8M|{
  384|  18.8M|  register DCTELEM *workspaceptr;
  385|  18.8M|  register _JSAMPROW elemptr;
  386|  18.8M|  register int elemr;
  387|       |
  388|  18.8M|  workspaceptr = workspace;
  389|   169M|  for (elemr = 0; elemr < DCTSIZE; elemr++) {
  ------------------
  |  |   66|   169M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (389:19): [True: 151M, False: 18.8M]
  ------------------
  390|   151M|    elemptr = sample_data[elemr] + start_col;
  391|       |
  392|   151M|#if DCTSIZE == 8                /* unroll the inner loop */
  393|   151M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   151M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   151M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  394|   151M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   151M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   151M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  395|   151M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   151M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   151M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  396|   151M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   151M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   151M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  397|   151M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   151M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   151M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  398|   151M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   151M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   151M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  399|   151M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   151M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   151M|#define CENTERJ12SAMPLE  2048
  |  |  ------------------
  ------------------
  400|   151M|    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
  ------------------
  |  |  111|   151M|#define _CENTERJSAMPLE   CENTERJ12SAMPLE
  |  |  ------------------
  |  |  |  |   61|   151M|#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|   151M|  }
  409|  18.8M|}
jcdctmgr-12.c:quantize:
  418|  18.8M|{
  419|  18.8M|  int i;
  420|  18.8M|  DCTELEM temp;
  421|  18.8M|  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|  18.8M|  register DCTELEM qval;
  452|       |
  453|  1.22G|  for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  1.22G|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (453:15): [True: 1.20G, False: 18.8M]
  ------------------
  454|  1.20G|    qval = divisors[i];
  455|  1.20G|    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.20G|#define DIVIDE_BY(a, b)  if (a >= b) a /= b;  else a = 0
  472|  1.20G|#endif
  473|  1.20G|    if (temp < 0) {
  ------------------
  |  Branch (473:9): [True: 188M, False: 1.02G]
  ------------------
  474|   188M|      temp = -temp;
  475|   188M|      temp += qval >> 1;        /* for rounding */
  476|   188M|      DIVIDE_BY(temp, qval);
  ------------------
  |  |  471|   188M|#define DIVIDE_BY(a, b)  if (a >= b) a /= b;  else a = 0
  |  |  ------------------
  |  |  |  Branch (471:30): [True: 158M, False: 29.9M]
  |  |  ------------------
  ------------------
  477|   188M|      temp = -temp;
  478|  1.02G|    } else {
  479|  1.02G|      temp += qval >> 1;        /* for rounding */
  480|  1.02G|      DIVIDE_BY(temp, qval);
  ------------------
  |  |  471|  1.02G|#define DIVIDE_BY(a, b)  if (a >= b) a /= b;  else a = 0
  |  |  ------------------
  |  |  |  Branch (471:30): [True: 144M, False: 875M]
  |  |  ------------------
  ------------------
  481|  1.02G|    }
  482|  1.20G|    output_ptr[i] = (JCOEF)temp;
  483|  1.20G|  }
  484|       |
  485|  18.8M|#endif
  486|       |
  487|  18.8M|}

jpeg_make_c_derived_tbl:
  224|  77.1k|{
  225|  77.1k|  JHUFF_TBL *htbl;
  226|  77.1k|  c_derived_tbl *dtbl;
  227|  77.1k|  int p, i, l, lastp, si, maxsymbol;
  228|  77.1k|  char huffsize[257];
  229|  77.1k|  unsigned int huffcode[257];
  230|  77.1k|  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|  77.1k|  if (tblno < 0 || tblno >= NUM_HUFF_TBLS)
  ------------------
  |  |   69|  77.1k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (237:7): [True: 0, False: 77.1k]
  |  Branch (237:20): [True: 0, False: 77.1k]
  ------------------
  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|  77.1k|  htbl =
  240|  77.1k|    isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
  ------------------
  |  Branch (240:5): [True: 33.2k, False: 43.8k]
  ------------------
  241|  77.1k|  if (htbl == NULL)
  ------------------
  |  Branch (241:7): [True: 0, False: 77.1k]
  ------------------
  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|  77.1k|  if (*pdtbl == NULL)
  ------------------
  |  Branch (245:7): [True: 45.1k, False: 31.9k]
  ------------------
  246|  45.1k|    *pdtbl = (c_derived_tbl *)
  247|  45.1k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  45.1k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  248|  45.1k|                                  sizeof(c_derived_tbl));
  249|  77.1k|  dtbl = *pdtbl;
  250|       |
  251|       |  /* Figure C.1: make table of Huffman code length for each symbol */
  252|       |
  253|  77.1k|  p = 0;
  254|  1.31M|  for (l = 1; l <= 16; l++) {
  ------------------
  |  Branch (254:15): [True: 1.23M, False: 77.1k]
  ------------------
  255|  1.23M|    i = (int)htbl->bits[l];
  256|  1.23M|    if (i < 0 || p + i > 256)   /* protect against table overrun */
  ------------------
  |  Branch (256:9): [True: 0, False: 1.23M]
  |  Branch (256:18): [True: 0, False: 1.23M]
  ------------------
  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.92M|    while (i--)
  ------------------
  |  Branch (258:12): [True: 687k, False: 1.23M]
  ------------------
  259|   687k|      huffsize[p++] = (char)l;
  260|  1.23M|  }
  261|  77.1k|  huffsize[p] = 0;
  262|  77.1k|  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|  77.1k|  code = 0;
  268|  77.1k|  si = huffsize[0];
  269|  77.1k|  p = 0;
  270|   371k|  while (huffsize[p]) {
  ------------------
  |  Branch (270:10): [True: 294k, False: 77.1k]
  ------------------
  271|   981k|    while (((int)huffsize[p]) == si) {
  ------------------
  |  Branch (271:12): [True: 687k, False: 294k]
  ------------------
  272|   687k|      huffcode[p++] = code;
  273|   687k|      code++;
  274|   687k|    }
  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|   294k|    if (((JLONG)code) >= (((JLONG)1) << si))
  ------------------
  |  Branch (278:9): [True: 0, False: 294k]
  ------------------
  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|   294k|    code <<= 1;
  281|   294k|    si++;
  282|   294k|  }
  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|  77.1k|  memset(dtbl->ehufco, 0, sizeof(dtbl->ehufco));
  292|  77.1k|  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|  77.1k|  maxsymbol = isDC ? (cinfo->master->lossless ? 16 : 15) : 255;
  ------------------
  |  Branch (299:15): [True: 33.2k, False: 43.8k]
  |  Branch (299:23): [True: 0, False: 33.2k]
  ------------------
  300|       |
  301|   764k|  for (p = 0; p < lastp; p++) {
  ------------------
  |  Branch (301:15): [True: 687k, False: 77.1k]
  ------------------
  302|   687k|    i = htbl->huffval[p];
  303|   687k|    if (i < 0 || i > maxsymbol || dtbl->ehufsi[i])
  ------------------
  |  Branch (303:9): [True: 0, False: 687k]
  |  Branch (303:18): [True: 0, False: 687k]
  |  Branch (303:35): [True: 0, False: 687k]
  ------------------
  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|   687k|    dtbl->ehufco[i] = huffcode[p];
  306|   687k|    dtbl->ehufsi[i] = huffsize[p];
  307|   687k|  }
  308|  77.1k|}
jpeg_gen_optimal_table:
  931|  59.2k|{
  932|  59.2k|#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|  59.2k|  UINT8 bits[MAX_CLEN + 2];     /* bits[k] = # of symbols with code length k */
  937|  59.2k|  int bit_pos[MAX_CLEN + 1];    /* # of symbols with smaller code length */
  938|  59.2k|  int codesize[257];            /* codesize[k] = code length of symbol k */
  939|  59.2k|  int nz_index[257];            /* index of nonzero symbol in the original freq
  940|       |                                   array */
  941|  59.2k|  int others[257];              /* next symbol in current branch of tree */
  942|  59.2k|  int c1, c2;
  943|  59.2k|  int p, i, j;
  944|  59.2k|  int num_nz_symbols;
  945|  59.2k|  long v, v2;
  946|       |
  947|       |  /* This algorithm is explained in section K.2 of the JPEG standard */
  948|       |
  949|  59.2k|  memset(bits, 0, sizeof(bits));
  950|  59.2k|  memset(codesize, 0, sizeof(codesize));
  951|  15.2M|  for (i = 0; i < 257; i++)
  ------------------
  |  Branch (951:15): [True: 15.2M, False: 59.2k]
  ------------------
  952|  15.2M|    others[i] = -1;             /* init links to empty */
  953|       |
  954|  59.2k|  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|  59.2k|  num_nz_symbols = 0;
  964|  15.2M|  for (i = 0; i < 257; i++) {
  ------------------
  |  Branch (964:15): [True: 15.2M, False: 59.2k]
  ------------------
  965|  15.2M|    if (freq[i]) {
  ------------------
  |  Branch (965:9): [True: 609k, False: 14.6M]
  ------------------
  966|   609k|      nz_index[num_nz_symbols] = i;
  967|   609k|      freq[num_nz_symbols] = freq[i];
  968|   609k|      num_nz_symbols++;
  969|   609k|    }
  970|  15.2M|  }
  971|       |
  972|       |  /* Huffman's basic algorithm to assign optimal code lengths to symbols */
  973|       |
  974|   609k|  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|   609k|    c1 = -1;
  981|   609k|    c2 = -1;
  982|   609k|    v = 1000000000L;
  983|   609k|    v2 = 1000000000L;
  984|  18.4M|    for (i = 0; i < num_nz_symbols; i++) {
  ------------------
  |  Branch (984:17): [True: 17.8M, False: 609k]
  ------------------
  985|  17.8M|      if (freq[i] <= v2) {
  ------------------
  |  Branch (985:11): [True: 3.86M, False: 13.9M]
  ------------------
  986|  3.86M|        if (freq[i] <= v) {
  ------------------
  |  Branch (986:13): [True: 2.47M, False: 1.39M]
  ------------------
  987|  2.47M|          c2 = c1;
  988|  2.47M|          v2 = v;
  989|  2.47M|          v = freq[i];
  990|  2.47M|          c1 = i;
  991|  2.47M|        } else {
  992|  1.39M|          v2 = freq[i];
  993|  1.39M|          c2 = i;
  994|  1.39M|        }
  995|  3.86M|      }
  996|  17.8M|    }
  997|       |
  998|       |    /* Done if we've merged everything into one frequency */
  999|   609k|    if (c2 < 0)
  ------------------
  |  Branch (999:9): [True: 59.2k, False: 550k]
  ------------------
 1000|  59.2k|      break;
 1001|       |
 1002|       |    /* Else merge the two counts/trees */
 1003|   550k|    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|   550k|    freq[c2] = 1000000001L;
 1008|       |
 1009|       |    /* Increment the codesize of everything in c1's tree branch */
 1010|   550k|    codesize[c1]++;
 1011|  1.68M|    while (others[c1] >= 0) {
  ------------------
  |  Branch (1011:12): [True: 1.13M, False: 550k]
  ------------------
 1012|  1.13M|      c1 = others[c1];
 1013|  1.13M|      codesize[c1]++;
 1014|  1.13M|    }
 1015|       |
 1016|   550k|    others[c1] = c2;            /* chain c2 onto c1's tree branch */
 1017|       |
 1018|       |    /* Increment the codesize of everything in c2's tree branch */
 1019|   550k|    codesize[c2]++;
 1020|  1.81M|    while (others[c2] >= 0) {
  ------------------
  |  Branch (1020:12): [True: 1.26M, False: 550k]
  ------------------
 1021|  1.26M|      c2 = others[c2];
 1022|  1.26M|      codesize[c2]++;
 1023|  1.26M|    }
 1024|   550k|  }
 1025|       |
 1026|       |  /* Now count the number of symbols of each code length */
 1027|   668k|  for (i = 0; i < num_nz_symbols; i++) {
  ------------------
  |  Branch (1027:15): [True: 609k, False: 59.2k]
  ------------------
 1028|       |    /* The JPEG standard seems to think that this can't happen, */
 1029|       |    /* but I'm paranoid... */
 1030|   609k|    if (codesize[i] > MAX_CLEN)
  ------------------
  |  |  932|   609k|#define MAX_CLEN  32            /* assumed maximum initial code length */
  ------------------
  |  Branch (1030:9): [True: 0, False: 609k]
  ------------------
 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|   609k|    bits[codesize[i]]++;
 1034|   609k|  }
 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|  59.2k|  p = 0;
 1042|  1.95M|  for (i = 1; i <= MAX_CLEN; i++) {
  ------------------
  |  |  932|  1.95M|#define MAX_CLEN  32            /* assumed maximum initial code length */
  ------------------
  |  Branch (1042:15): [True: 1.89M, False: 59.2k]
  ------------------
 1043|  1.89M|    bit_pos[i] = p;
 1044|  1.89M|    p += bits[i];
 1045|  1.89M|  }
 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|  1.00M|  for (i = MAX_CLEN; i > 16; i--) {
  ------------------
  |  |  932|  59.2k|#define MAX_CLEN  32            /* assumed maximum initial code length */
  ------------------
  |  Branch (1058:22): [True: 947k, False: 59.2k]
  ------------------
 1059|   953k|    while (bits[i] > 0) {
  ------------------
  |  Branch (1059:12): [True: 5.58k, False: 947k]
  ------------------
 1060|  5.58k|      j = i - 2;                /* find length of new prefix to be used */
 1061|  6.94k|      while (bits[j] == 0)
  ------------------
  |  Branch (1061:14): [True: 1.36k, False: 5.58k]
  ------------------
 1062|  1.36k|        j--;
 1063|       |
 1064|  5.58k|      bits[i] -= 2;             /* remove two symbols */
 1065|  5.58k|      bits[i - 1]++;            /* one goes in this length */
 1066|  5.58k|      bits[j + 1] += 2;         /* two new symbols in this length */
 1067|  5.58k|      bits[j]--;                /* symbol of this length is now a prefix */
 1068|  5.58k|    }
 1069|   947k|  }
 1070|       |
 1071|       |  /* Remove the count for the pseudo-symbol 256 from the largest codelength */
 1072|   743k|  while (bits[i] == 0)          /* find largest codelength still in use */
  ------------------
  |  Branch (1072:10): [True: 684k, False: 59.2k]
  ------------------
 1073|   684k|    i--;
 1074|  59.2k|  bits[i]--;
 1075|       |
 1076|       |  /* Return final symbol counts (only for lengths 0..16) */
 1077|  59.2k|  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|   609k|  for (i = 0; i < num_nz_symbols - 1; i++) {
  ------------------
  |  Branch (1084:15): [True: 550k, False: 59.2k]
  ------------------
 1085|   550k|    htbl->huffval[bit_pos[codesize[i]]] = (UINT8)nz_index[i];
 1086|   550k|    bit_pos[codesize[i]]++;
 1087|   550k|  }
 1088|       |
 1089|       |  /* Set sent_table FALSE so updated table will be written to JPEG file. */
 1090|  59.2k|  htbl->sent_table = FALSE;
  ------------------
  |  |  207|  59.2k|#define FALSE   0               /* values of boolean */
  ------------------
 1091|  59.2k|}
jinit_huff_encoder:
 1145|  11.8k|{
 1146|  11.8k|  huff_entropy_ptr entropy;
 1147|  11.8k|  int i;
 1148|       |
 1149|  11.8k|  entropy = (huff_entropy_ptr)
 1150|  11.8k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  11.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
 1151|  11.8k|                                sizeof(huff_entropy_encoder));
 1152|  11.8k|  cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
 1153|  11.8k|  entropy->pub.start_pass = start_pass_huff;
 1154|       |
 1155|       |  /* Mark tables unallocated */
 1156|  59.3k|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|  59.3k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (1156:15): [True: 47.5k, False: 11.8k]
  ------------------
 1157|  47.5k|    entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;
 1158|  47.5k|#ifdef ENTROPY_OPT_SUPPORTED
 1159|       |    entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL;
 1160|  47.5k|#endif
 1161|  47.5k|  }
 1162|  11.8k|}
jchuff.c:start_pass_huff:
  138|  23.7k|{
  139|  23.7k|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  140|  23.7k|  int ci, dctbl, actbl;
  141|  23.7k|  jpeg_component_info *compptr;
  142|       |
  143|  23.7k|  if (gather_statistics) {
  ------------------
  |  Branch (143:7): [True: 11.8k, False: 11.8k]
  ------------------
  144|  11.8k|#ifdef ENTROPY_OPT_SUPPORTED
  145|  11.8k|    entropy->pub.encode_mcu = encode_mcu_gather;
  146|  11.8k|    entropy->pub.finish_pass = finish_pass_gather;
  147|       |#else
  148|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  149|       |#endif
  150|  11.8k|  } else {
  151|  11.8k|    entropy->pub.encode_mcu = encode_mcu_huff;
  152|  11.8k|    entropy->pub.finish_pass = finish_pass_huff;
  153|  11.8k|  }
  154|       |
  155|  23.7k|#ifdef WITH_SIMD
  156|  23.7k|  entropy->simd = jsimd_set_huff_encode_one_block(cinfo);
  157|  23.7k|#endif
  158|       |
  159|  83.3k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (159:16): [True: 59.5k, False: 23.7k]
  ------------------
  160|  59.5k|    compptr = cinfo->cur_comp_info[ci];
  161|  59.5k|    dctbl = compptr->dc_tbl_no;
  162|  59.5k|    actbl = compptr->ac_tbl_no;
  163|  59.5k|    if (gather_statistics) {
  ------------------
  |  Branch (163:9): [True: 29.7k, False: 29.7k]
  ------------------
  164|  29.7k|#ifdef ENTROPY_OPT_SUPPORTED
  165|       |      /* Check for invalid table indexes */
  166|       |      /* (make_c_derived_tbl does this in the other path) */
  167|  29.7k|      if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS)
  ------------------
  |  |   69|  29.7k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (167:11): [True: 0, False: 29.7k]
  |  Branch (167:24): [True: 0, False: 29.7k]
  ------------------
  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.7k|      if (actbl < 0 || actbl >= NUM_HUFF_TBLS)
  ------------------
  |  |   69|  29.7k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (169:11): [True: 0, False: 29.7k]
  |  Branch (169:24): [True: 0, False: 29.7k]
  ------------------
  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.7k|      if (entropy->dc_count_ptrs[dctbl] == NULL)
  ------------------
  |  Branch (173:11): [True: 20.8k, False: 8.95k]
  ------------------
  174|  20.8k|        entropy->dc_count_ptrs[dctbl] = (long *)
  175|  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 */
  ------------------
  176|  20.8k|                                      257 * sizeof(long));
  177|  29.7k|      memset(entropy->dc_count_ptrs[dctbl], 0, 257 * sizeof(long));
  178|  29.7k|      if (entropy->ac_count_ptrs[actbl] == NULL)
  ------------------
  |  Branch (178:11): [True: 20.8k, False: 8.95k]
  ------------------
  179|  20.8k|        entropy->ac_count_ptrs[actbl] = (long *)
  180|  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 */
  ------------------
  181|  20.8k|                                      257 * sizeof(long));
  182|  29.7k|      memset(entropy->ac_count_ptrs[actbl], 0, 257 * sizeof(long));
  183|  29.7k|#endif
  184|  29.7k|    } 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.7k|      jpeg_make_c_derived_tbl(cinfo, TRUE, dctbl,
  ------------------
  |  |  210|  29.7k|#define TRUE    1
  ------------------
  188|  29.7k|                              &entropy->dc_derived_tbls[dctbl]);
  189|  29.7k|      jpeg_make_c_derived_tbl(cinfo, FALSE, actbl,
  ------------------
  |  |  207|  29.7k|#define FALSE   0               /* values of boolean */
  ------------------
  190|  29.7k|                              &entropy->ac_derived_tbls[actbl]);
  191|  29.7k|    }
  192|       |    /* Initialize DC predictions to 0 */
  193|  59.5k|    entropy->saved.last_dc_val[ci] = 0;
  194|  59.5k|  }
  195|       |
  196|       |  /* Initialize bit buffer to empty */
  197|  23.7k|#ifdef WITH_SIMD
  198|  23.7k|  if (entropy->simd) {
  ------------------
  |  Branch (198:7): [True: 23.7k, False: 0]
  ------------------
  199|  23.7k|    entropy->saved.put_buffer.simd = 0;
  200|  23.7k|    entropy->saved.free_bits = SIMD_BIT_BUF_SIZE;
  ------------------
  |  |   67|  23.7k|#define SIMD_BIT_BUF_SIZE  (sizeof(simd_bit_buf_type) * 8)
  ------------------
  201|  23.7k|  } 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.7k|  entropy->restarts_to_go = cinfo->restart_interval;
  210|  23.7k|  entropy->next_restart_num = 0;
  211|  23.7k|}
jchuff.c:encode_mcu_gather:
  870|  4.21M|{
  871|  4.21M|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  872|  4.21M|  int blkn, ci;
  873|  4.21M|  jpeg_component_info *compptr;
  874|       |
  875|       |  /* Take care of restart intervals if needed */
  876|  4.21M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (876:7): [True: 0, False: 4.21M]
  ------------------
  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|  17.1M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (887:18): [True: 12.9M, False: 4.21M]
  ------------------
  888|  12.9M|    ci = cinfo->MCU_membership[blkn];
  889|  12.9M|    compptr = cinfo->cur_comp_info[ci];
  890|  12.9M|    htest_one_block(cinfo, MCU_data[blkn][0], entropy->saved.last_dc_val[ci],
  891|  12.9M|                    entropy->dc_count_ptrs[compptr->dc_tbl_no],
  892|  12.9M|                    entropy->ac_count_ptrs[compptr->ac_tbl_no]);
  893|  12.9M|    entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0];
  894|  12.9M|  }
  895|       |
  896|  4.21M|  return TRUE;
  ------------------
  |  |  210|  4.21M|#define TRUE    1
  ------------------
  897|  4.21M|}
jchuff.c:htest_one_block:
  797|  12.9M|{
  798|  12.9M|  register int temp;
  799|  12.9M|  register int nbits;
  800|  12.9M|  register int k, r;
  801|  12.9M|  int max_coef_bits = cinfo->data_precision + 2;
  802|       |
  803|       |  /* Encode the DC coefficient difference per section F.1.2.1 */
  804|       |
  805|  12.9M|  temp = block[0] - last_dc_val;
  806|  12.9M|  if (temp < 0)
  ------------------
  |  Branch (806:7): [True: 2.21M, False: 10.7M]
  ------------------
  807|  2.21M|    temp = -temp;
  808|       |
  809|       |  /* Find the number of bits needed for the magnitude of the coefficient */
  810|  12.9M|  nbits = 0;
  811|  51.5M|  while (temp) {
  ------------------
  |  Branch (811:10): [True: 38.5M, False: 12.9M]
  ------------------
  812|  38.5M|    nbits++;
  813|  38.5M|    temp >>= 1;
  814|  38.5M|  }
  815|       |  /* Check for out-of-range coefficient values.
  816|       |   * Since we're encoding a difference, the range limit is twice as much.
  817|       |   */
  818|  12.9M|  if (nbits > max_coef_bits + 1)
  ------------------
  |  Branch (818:7): [True: 0, False: 12.9M]
  ------------------
  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|  12.9M|  dc_counts[nbits]++;
  823|       |
  824|       |  /* Encode the AC coefficients per section F.1.2.2 */
  825|       |
  826|  12.9M|  r = 0;                        /* r = run length of zeros */
  827|       |
  828|   830M|  for (k = 1; k < DCTSIZE2; k++) {
  ------------------
  |  |   67|   830M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (828:15): [True: 817M, False: 12.9M]
  ------------------
  829|   817M|    if ((temp = block[jpeg_natural_order[k]]) == 0) {
  ------------------
  |  Branch (829:9): [True: 640M, False: 177M]
  ------------------
  830|   640M|      r++;
  831|   640M|    } else {
  832|       |      /* if run length > 15, must emit special run-length-16 codes (0xF0) */
  833|   177M|      while (r > 15) {
  ------------------
  |  Branch (833:14): [True: 38.6k, False: 177M]
  ------------------
  834|  38.6k|        ac_counts[0xF0]++;
  835|  38.6k|        r -= 16;
  836|  38.6k|      }
  837|       |
  838|       |      /* Find the number of bits needed for the magnitude of the coefficient */
  839|   177M|      if (temp < 0)
  ------------------
  |  Branch (839:11): [True: 89.8M, False: 87.5M]
  ------------------
  840|  89.8M|        temp = -temp;
  841|       |
  842|       |      /* Find the number of bits needed for the magnitude of the coefficient */
  843|   177M|      nbits = 1;                /* there must be at least one 1 bit */
  844|   969M|      while ((temp >>= 1))
  ------------------
  |  Branch (844:14): [True: 791M, False: 177M]
  ------------------
  845|   791M|        nbits++;
  846|       |      /* Check for out-of-range coefficient values */
  847|   177M|      if (nbits > max_coef_bits)
  ------------------
  |  Branch (847:11): [True: 3, False: 177M]
  ------------------
  848|      3|        ERREXIT(cinfo, JERR_BAD_DCT_COEF);
  ------------------
  |  |  240|      3|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      3|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  849|       |
  850|       |      /* Count Huffman symbol for run length / number of bits */
  851|   177M|      ac_counts[(r << 4) + nbits]++;
  852|       |
  853|   177M|      r = 0;
  854|   177M|    }
  855|   817M|  }
  856|       |
  857|       |  /* If the last coef(s) were zero, emit an end-of-block code */
  858|  12.9M|  if (r > 0)
  ------------------
  |  Branch (858:7): [True: 10.5M, False: 2.45M]
  ------------------
  859|  10.5M|    ac_counts[0]++;
  860|  12.9M|}
jchuff.c:finish_pass_gather:
 1100|  11.8k|{
 1101|  11.8k|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
 1102|  11.8k|  int ci, dctbl, actbl;
 1103|  11.8k|  jpeg_component_info *compptr;
 1104|  11.8k|  JHUFF_TBL **htblptr;
 1105|  11.8k|  boolean did_dc[NUM_HUFF_TBLS];
 1106|  11.8k|  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.8k|  memset(did_dc, 0, sizeof(did_dc));
 1112|  11.8k|  memset(did_ac, 0, sizeof(did_ac));
 1113|       |
 1114|  41.6k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (1114:16): [True: 29.7k, False: 11.8k]
  ------------------
 1115|  29.7k|    compptr = cinfo->cur_comp_info[ci];
 1116|  29.7k|    dctbl = compptr->dc_tbl_no;
 1117|  29.7k|    actbl = compptr->ac_tbl_no;
 1118|  29.7k|    if (!did_dc[dctbl]) {
  ------------------
  |  Branch (1118:9): [True: 20.8k, False: 8.94k]
  ------------------
 1119|  20.8k|      htblptr = &cinfo->dc_huff_tbl_ptrs[dctbl];
 1120|  20.8k|      if (*htblptr == NULL)
  ------------------
  |  Branch (1120:11): [True: 0, False: 20.8k]
  ------------------
 1121|      0|        *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
 1122|  20.8k|      jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[dctbl]);
 1123|  20.8k|      did_dc[dctbl] = TRUE;
  ------------------
  |  |  210|  20.8k|#define TRUE    1
  ------------------
 1124|  20.8k|    }
 1125|  29.7k|    if (!did_ac[actbl]) {
  ------------------
  |  Branch (1125:9): [True: 20.8k, False: 8.94k]
  ------------------
 1126|  20.8k|      htblptr = &cinfo->ac_huff_tbl_ptrs[actbl];
 1127|  20.8k|      if (*htblptr == NULL)
  ------------------
  |  Branch (1127:11): [True: 0, False: 20.8k]
  ------------------
 1128|      0|        *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
 1129|  20.8k|      jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[actbl]);
 1130|  20.8k|      did_ac[actbl] = TRUE;
  ------------------
  |  |  210|  20.8k|#define TRUE    1
  ------------------
 1131|  20.8k|    }
 1132|  29.7k|  }
 1133|  11.8k|}
jchuff.c:encode_mcu_huff:
  677|  4.21M|{
  678|  4.21M|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  679|  4.21M|  working_state state;
  680|  4.21M|  int blkn, ci;
  681|  4.21M|  jpeg_component_info *compptr;
  682|       |
  683|       |  /* Load up working state */
  684|  4.21M|  state.next_output_byte = cinfo->dest->next_output_byte;
  685|  4.21M|  state.free_in_buffer = cinfo->dest->free_in_buffer;
  686|  4.21M|  state.cur = entropy->saved;
  687|  4.21M|  state.cinfo = cinfo;
  688|  4.21M|#ifdef WITH_SIMD
  689|  4.21M|  state.simd = entropy->simd;
  690|  4.21M|#endif
  691|       |
  692|       |  /* Emit restart marker if needed */
  693|  4.21M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (693:7): [True: 0, False: 4.21M]
  ------------------
  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.21M|#ifdef WITH_SIMD
  701|  4.21M|  if (entropy->simd) {
  ------------------
  |  Branch (701:7): [True: 4.21M, False: 0]
  ------------------
  702|  17.1M|    for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (702:20): [True: 12.9M, False: 4.21M]
  ------------------
  703|  12.9M|      ci = cinfo->MCU_membership[blkn];
  704|  12.9M|      compptr = cinfo->cur_comp_info[ci];
  705|  12.9M|      if (!encode_one_block_simd(&state,
  ------------------
  |  Branch (705:11): [True: 0, False: 12.9M]
  ------------------
  706|  12.9M|                                 MCU_data[blkn][0], state.cur.last_dc_val[ci],
  707|  12.9M|                                 entropy->dc_derived_tbls[compptr->dc_tbl_no],
  708|  12.9M|                                 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|  12.9M|      state.cur.last_dc_val[ci] = MCU_data[blkn][0][0];
  712|  12.9M|    }
  713|  4.21M|  } 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.21M|  cinfo->dest->next_output_byte = state.next_output_byte;
  731|  4.21M|  cinfo->dest->free_in_buffer = state.free_in_buffer;
  732|  4.21M|  entropy->saved = state.cur;
  733|       |
  734|       |  /* Update restart-interval state too */
  735|  4.21M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (735:7): [True: 0, False: 4.21M]
  ------------------
  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.21M|  return TRUE;
  ------------------
  |  |  210|  4.21M|#define TRUE    1
  ------------------
  745|  4.21M|}
jchuff.c:flush_bits:
  471|  11.8k|{
  472|  11.8k|  JOCTET _buffer[BUFSIZE], *buffer, temp;
  473|  11.8k|  simd_bit_buf_type put_buffer;  int put_bits;
  474|  11.8k|  int localbuf = 0;
  475|       |
  476|  11.8k|#ifdef WITH_SIMD
  477|  11.8k|  if (state->simd) {
  ------------------
  |  Branch (477:7): [True: 11.8k, False: 0]
  ------------------
  478|  11.8k|    put_bits = SIMD_BIT_BUF_SIZE - state->cur.free_bits;
  ------------------
  |  |   67|  11.8k|#define SIMD_BIT_BUF_SIZE  (sizeof(simd_bit_buf_type) * 8)
  ------------------
  479|  11.8k|    put_buffer = state->cur.put_buffer.simd;
  480|  11.8k|  } 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.8k|  LOAD_BUFFER()
  ------------------
  |  |  439|  11.8k|#define LOAD_BUFFER() { \
  |  |  440|  11.8k|  if (state->free_in_buffer < BUFSIZE) { \
  |  |  ------------------
  |  |  |  |  437|  11.8k|#define BUFSIZE  (DCTSIZE2 * 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   67|  11.8k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (440:7): [True: 141, False: 11.7k]
  |  |  ------------------
  |  |  441|    141|    localbuf = 1; \
  |  |  442|    141|    buffer = _buffer; \
  |  |  443|    141|  } else \
  |  |  444|  11.8k|    buffer = state->next_output_byte; \
  |  |  445|  11.8k|}
  ------------------
  488|       |
  489|  51.6k|  while (put_bits >= 8) {
  ------------------
  |  Branch (489:10): [True: 39.7k, False: 11.8k]
  ------------------
  490|  39.7k|    put_bits -= 8;
  491|  39.7k|    temp = (JOCTET)(put_buffer >> put_bits);
  492|  39.7k|    EMIT_BYTE(temp)
  ------------------
  |  |  344|  39.7k|#define EMIT_BYTE(b) { \
  |  |  345|  39.7k|  buffer[0] = (JOCTET)(b); \
  |  |  346|  39.7k|  buffer[1] = 0; \
  |  |  347|  39.7k|  buffer -= -2 + ((JOCTET)(b) < 0xFF); \
  |  |  348|  39.7k|}
  ------------------
  493|  39.7k|  }
  494|  11.8k|  if (put_bits) {
  ------------------
  |  Branch (494:7): [True: 10.4k, False: 1.42k]
  ------------------
  495|       |    /* fill partial byte with ones */
  496|  10.4k|    temp = (JOCTET)((put_buffer << (8 - put_bits)) | (0xFF >> put_bits));
  497|  10.4k|    EMIT_BYTE(temp)
  ------------------
  |  |  344|  10.4k|#define EMIT_BYTE(b) { \
  |  |  345|  10.4k|  buffer[0] = (JOCTET)(b); \
  |  |  346|  10.4k|  buffer[1] = 0; \
  |  |  347|  10.4k|  buffer -= -2 + ((JOCTET)(b) < 0xFF); \
  |  |  348|  10.4k|}
  ------------------
  498|  10.4k|  }
  499|       |
  500|  11.8k|#ifdef WITH_SIMD
  501|  11.8k|  if (state->simd) {                    /* and reset bit buffer to empty */
  ------------------
  |  Branch (501:7): [True: 11.8k, False: 0]
  ------------------
  502|  11.8k|    state->cur.put_buffer.simd = 0;
  503|  11.8k|    state->cur.free_bits = SIMD_BIT_BUF_SIZE;
  ------------------
  |  |   67|  11.8k|#define SIMD_BIT_BUF_SIZE  (sizeof(simd_bit_buf_type) * 8)
  ------------------
  504|  11.8k|  } 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.8k|  STORE_BUFFER()
  ------------------
  |  |  447|  11.8k|#define STORE_BUFFER() { \
  |  |  448|  11.8k|  if (localbuf) { \
  |  |  ------------------
  |  |  |  Branch (448:7): [True: 141, False: 11.7k]
  |  |  ------------------
  |  |  449|    141|    size_t bytes, bytestocopy; \
  |  |  450|    141|    bytes = buffer - _buffer; \
  |  |  451|    141|    buffer = _buffer; \
  |  |  452|    284|    while (bytes > 0) { \
  |  |  ------------------
  |  |  |  Branch (452:12): [True: 143, False: 141]
  |  |  ------------------
  |  |  453|    143|      bytestocopy = MIN(bytes, state->free_in_buffer); \
  |  |  ------------------
  |  |  |  |  515|    143|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (515:26): [True: 136, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  454|    143|      memcpy(state->next_output_byte, buffer, bytestocopy); \
  |  |  455|    143|      state->next_output_byte += bytestocopy; \
  |  |  456|    143|      buffer += bytestocopy; \
  |  |  457|    143|      state->free_in_buffer -= bytestocopy; \
  |  |  458|    143|      if (state->free_in_buffer == 0) \
  |  |  ------------------
  |  |  |  Branch (458:11): [True: 7, False: 136]
  |  |  ------------------
  |  |  459|    143|        if (!dump_buffer(state)) return FALSE; \
  |  |  ------------------
  |  |  |  |  207|      0|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  |  Branch (459:13): [True: 0, False: 7]
  |  |  ------------------
  |  |  460|    143|      bytes -= bytestocopy; \
  |  |  461|    143|    } \
  |  |  462|  11.7k|  } else { \
  |  |  463|  11.7k|    state->free_in_buffer -= (buffer - state->next_output_byte); \
  |  |  464|  11.7k|    state->next_output_byte = buffer; \
  |  |  465|  11.7k|  } \
  |  |  466|  11.8k|}
  ------------------
  511|       |
  512|  11.8k|  return TRUE;
  ------------------
  |  |  210|  11.8k|#define TRUE    1
  ------------------
  513|  11.8k|}
jchuff.c:dump_buffer:
  325|  4.20k|{
  326|  4.20k|  struct jpeg_destination_mgr *dest = state->cinfo->dest;
  327|       |
  328|  4.20k|  if (!(*dest->empty_output_buffer) (state->cinfo))
  ------------------
  |  Branch (328:7): [True: 0, False: 4.20k]
  ------------------
  329|      0|    return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  330|       |  /* After a successful buffer dump, must reset buffer pointers */
  331|  4.20k|  state->next_output_byte = dest->next_output_byte;
  332|  4.20k|  state->free_in_buffer = dest->free_in_buffer;
  333|  4.20k|  return TRUE;
  ------------------
  |  |  210|  4.20k|#define TRUE    1
  ------------------
  334|  4.20k|}
jchuff.c:encode_one_block_simd:
  523|  12.9M|{
  524|  12.9M|  JOCTET _buffer[BUFSIZE], *buffer;
  525|  12.9M|  int localbuf = 0;
  526|       |
  527|       |#ifdef ZERO_BUFFERS
  528|       |  memset(_buffer, 0, sizeof(_buffer));
  529|       |#endif
  530|       |
  531|  12.9M|  LOAD_BUFFER()
  ------------------
  |  |  439|  12.9M|#define LOAD_BUFFER() { \
  |  |  440|  12.9M|  if (state->free_in_buffer < BUFSIZE) { \
  |  |  ------------------
  |  |  |  |  437|  12.9M|#define BUFSIZE  (DCTSIZE2 * 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   67|  12.9M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (440:7): [True: 409k, False: 12.5M]
  |  |  ------------------
  |  |  441|   409k|    localbuf = 1; \
  |  |  442|   409k|    buffer = _buffer; \
  |  |  443|   409k|  } else \
  |  |  444|  12.9M|    buffer = state->next_output_byte; \
  |  |  445|  12.9M|}
  ------------------
  532|       |
  533|  12.9M|  buffer = state->cinfo->entropy->huff_encode_one_block_simd(state, buffer,
  534|  12.9M|                                                             block,
  535|  12.9M|                                                             last_dc_val,
  536|  12.9M|                                                             dctbl, actbl);
  537|       |
  538|  12.9M|  STORE_BUFFER()
  ------------------
  |  |  447|  12.9M|#define STORE_BUFFER() { \
  |  |  448|  12.9M|  if (localbuf) { \
  |  |  ------------------
  |  |  |  Branch (448:7): [True: 409k, False: 12.5M]
  |  |  ------------------
  |  |  449|   409k|    size_t bytes, bytestocopy; \
  |  |  450|   409k|    bytes = buffer - _buffer; \
  |  |  451|   409k|    buffer = _buffer; \
  |  |  452|   518k|    while (bytes > 0) { \
  |  |  ------------------
  |  |  |  Branch (452:12): [True: 109k, False: 409k]
  |  |  ------------------
  |  |  453|   109k|      bytestocopy = MIN(bytes, state->free_in_buffer); \
  |  |  ------------------
  |  |  |  |  515|   109k|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (515:26): [True: 105k, False: 4.19k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  454|   109k|      memcpy(state->next_output_byte, buffer, bytestocopy); \
  |  |  455|   109k|      state->next_output_byte += bytestocopy; \
  |  |  456|   109k|      buffer += bytestocopy; \
  |  |  457|   109k|      state->free_in_buffer -= bytestocopy; \
  |  |  458|   109k|      if (state->free_in_buffer == 0) \
  |  |  ------------------
  |  |  |  Branch (458:11): [True: 4.19k, False: 105k]
  |  |  ------------------
  |  |  459|   109k|        if (!dump_buffer(state)) return FALSE; \
  |  |  ------------------
  |  |  |  |  207|      0|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  |  Branch (459:13): [True: 0, False: 4.19k]
  |  |  ------------------
  |  |  460|   109k|      bytes -= bytestocopy; \
  |  |  461|   109k|    } \
  |  |  462|  12.5M|  } else { \
  |  |  463|  12.5M|    state->free_in_buffer -= (buffer - state->next_output_byte); \
  |  |  464|  12.5M|    state->next_output_byte = buffer; \
  |  |  465|  12.5M|  } \
  |  |  466|  12.9M|}
  ------------------
  539|       |
  540|  12.9M|  return TRUE;
  ------------------
  |  |  210|  12.9M|#define TRUE    1
  ------------------
  541|  12.9M|}
jchuff.c:finish_pass_huff:
  754|  11.8k|{
  755|  11.8k|  huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
  756|  11.8k|  working_state state;
  757|       |
  758|       |  /* Load up working state ... flush_bits needs it */
  759|  11.8k|  state.next_output_byte = cinfo->dest->next_output_byte;
  760|  11.8k|  state.free_in_buffer = cinfo->dest->free_in_buffer;
  761|  11.8k|  state.cur = entropy->saved;
  762|  11.8k|  state.cinfo = cinfo;
  763|  11.8k|#ifdef WITH_SIMD
  764|  11.8k|  state.simd = entropy->simd;
  765|  11.8k|#endif
  766|       |
  767|       |  /* Flush out the last data */
  768|  11.8k|  if (!flush_bits(&state))
  ------------------
  |  Branch (768:7): [True: 0, False: 11.8k]
  ------------------
  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.8k|  cinfo->dest->next_output_byte = state.next_output_byte;
  773|  11.8k|  cinfo->dest->free_in_buffer = state.free_in_buffer;
  774|  11.8k|  entropy->saved = state.cur;
  775|  11.8k|}

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|   586k|    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|  21.2k|{
   38|       |  /* Initialize master control (includes parameter checking/processing) */
   39|  21.2k|  jinit_c_master_control(cinfo, FALSE /* full compression */);
  ------------------
  |  |  207|  21.2k|#define FALSE   0               /* values of boolean */
  ------------------
   40|       |
   41|       |  /* Preprocessing */
   42|  21.2k|  if (!cinfo->raw_data_in) {
  ------------------
  |  Branch (42:7): [True: 21.2k, False: 0]
  ------------------
   43|  21.2k|    if (cinfo->data_precision <= 8) {
  ------------------
  |  Branch (43:9): [True: 0, False: 21.2k]
  ------------------
   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|  21.2k|    } else if (cinfo->data_precision <= 12) {
  ------------------
  |  Branch (47:16): [True: 21.2k, False: 0]
  ------------------
   48|  21.2k|      j12init_color_converter(cinfo);
   49|  21.2k|      j12init_downsampler(cinfo);
   50|  21.2k|      j12init_c_prep_controller(cinfo,
   51|  21.2k|                                FALSE /* never need full buffer here */);
  ------------------
  |  |  207|  21.2k|#define FALSE   0               /* values of boolean */
  ------------------
   52|  21.2k|    } 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|  21.2k|  }
   63|       |
   64|  21.2k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (64:7): [True: 0, False: 21.2k]
  ------------------
   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|  21.2k|  } else {
   94|  21.2k|#if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED) || \
   95|  21.2k|    defined(DCT_FLOAT_SUPPORTED)
   96|       |    /* Forward DCT */
   97|  21.2k|    if (cinfo->data_precision == 8)
  ------------------
  |  Branch (97:9): [True: 0, False: 21.2k]
  ------------------
   98|      0|      jinit_forward_dct(cinfo);
   99|  21.2k|    else if (cinfo->data_precision == 12)
  ------------------
  |  Branch (99:14): [True: 21.2k, False: 0]
  ------------------
  100|  21.2k|      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|  21.2k|    if (cinfo->arith_code) {
  ------------------
  |  Branch (104:9): [True: 5.85k, False: 15.3k]
  ------------------
  105|  5.85k|#ifdef C_ARITH_CODING_SUPPORTED
  106|  5.85k|      jinit_arith_encoder(cinfo);
  107|       |#else
  108|       |      ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
  109|       |#endif
  110|  15.3k|    } else {
  111|  15.3k|      if (cinfo->progressive_mode) {
  ------------------
  |  Branch (111:11): [True: 3.51k, False: 11.8k]
  ------------------
  112|  3.51k|#ifdef C_PROGRESSIVE_SUPPORTED
  113|  3.51k|        jinit_phuff_encoder(cinfo);
  114|       |#else
  115|       |        ERREXIT(cinfo, JERR_NOT_COMPILED);
  116|       |#endif
  117|  3.51k|      } else
  118|  11.8k|        jinit_huff_encoder(cinfo);
  119|  15.3k|    }
  120|       |
  121|       |    /* Need a full-image coefficient buffer in any multi-pass mode. */
  122|  21.2k|    if (cinfo->data_precision == 12)
  ------------------
  |  Branch (122:9): [True: 21.2k, False: 0]
  ------------------
  123|  21.2k|      j12init_c_coef_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
  ------------------
  |  Branch (123:50): [True: 6.44k, False: 14.8k]
  ------------------
  124|  14.8k|                                                 cinfo->optimize_coding));
  ------------------
  |  Branch (124:50): [True: 11.8k, False: 2.92k]
  ------------------
  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|  21.2k|  }
  132|       |
  133|  21.2k|  if (cinfo->data_precision <= 8)
  ------------------
  |  Branch (133:7): [True: 0, False: 21.2k]
  ------------------
  134|      0|    jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  135|  21.2k|  else if (cinfo->data_precision <= 12)
  ------------------
  |  Branch (135:12): [True: 21.2k, False: 0]
  ------------------
  136|  21.2k|    j12init_c_main_controller(cinfo, FALSE /* never need full buffer here */);
  ------------------
  |  |  207|  21.2k|#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|  21.2k|  jinit_marker_writer(cinfo);
  145|       |
  146|       |  /* We can now tell the memory manager to allocate virtual arrays. */
  147|  21.2k|  (*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|  21.2k|  (*cinfo->marker->write_file_header) (cinfo);
  154|  21.2k|}

j12init_c_main_controller:
  137|  21.2k|{
  138|  21.2k|  my_main_ptr main_ptr;
  139|  21.2k|  int ci;
  140|  21.2k|  jpeg_component_info *compptr;
  141|  21.2k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  21.2k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (141:19): [True: 0, False: 21.2k]
  ------------------
  142|       |
  143|  21.2k|#ifdef C_LOSSLESS_SUPPORTED
  144|  21.2k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (144:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|#endif
  154|  21.2k|  {
  155|  21.2k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  21.2k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (155:9): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  }
  158|       |
  159|  21.2k|  main_ptr = (my_main_ptr)
  160|  21.2k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  21.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  161|  21.2k|                                sizeof(my_main_controller));
  162|  21.2k|  memset(main_ptr, 0, sizeof(my_main_controller));
  163|  21.2k|  cinfo->main = (struct jpeg_c_main_controller *)main_ptr;
  164|  21.2k|  main_ptr->pub.start_pass = start_pass_main;
  165|       |
  166|       |  /* We don't need to create a buffer in raw-data mode. */
  167|  21.2k|  if (cinfo->raw_data_in)
  ------------------
  |  Branch (167:7): [True: 0, False: 21.2k]
  ------------------
  168|      0|    return;
  169|       |
  170|       |  /* Create the buffer.  It holds downsampled data, so each component
  171|       |   * may be of a different size.
  172|       |   */
  173|  21.2k|  if (need_full_buffer) {
  ------------------
  |  Branch (173:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  } else {
  176|       |    /* Allocate a strip buffer for each component */
  177|  75.0k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (177:46): [True: 53.7k, False: 21.2k]
  ------------------
  178|  53.7k|         ci++, compptr++) {
  179|  53.7k|      main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  180|  53.7k|        ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  53.7k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  181|  53.7k|         compptr->width_in_blocks * data_unit,
  182|  53.7k|         (JDIMENSION)(compptr->v_samp_factor * data_unit));
  183|  53.7k|    }
  184|  21.2k|  }
  185|  21.2k|}
jcmainct-12.c:start_pass_main:
   59|  21.2k|{
   60|  21.2k|  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
   61|       |
   62|       |  /* Do nothing in raw-data mode. */
   63|  21.2k|  if (cinfo->raw_data_in)
  ------------------
  |  Branch (63:7): [True: 0, False: 21.2k]
  ------------------
   64|      0|    return;
   65|       |
   66|  21.2k|  if (pass_mode != JBUF_PASS_THRU)
  ------------------
  |  Branch (66:7): [True: 0, False: 21.2k]
  ------------------
   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|  21.2k|  main_ptr->cur_iMCU_row = 0;   /* initialize counters */
   70|  21.2k|  main_ptr->rowgroup_ctr = 0;
   71|  21.2k|  main_ptr->suspended = FALSE;
  ------------------
  |  |  207|  21.2k|#define FALSE   0               /* values of boolean */
  ------------------
   72|  21.2k|  main_ptr->pass_mode = pass_mode;      /* save mode for use by process_data */
   73|  21.2k|  main_ptr->pub._process_data = process_data_simple_main;
  ------------------
  |  |  140|  21.2k|#define _process_data  process_data_12
  ------------------
   74|  21.2k|}
jcmainct-12.c:process_data_simple_main:
   86|  21.2k|{
   87|  21.2k|  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
   88|  21.2k|  JDIMENSION data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  42.4k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (88:26): [True: 0, False: 21.2k]
  ------------------
   89|       |
   90|  2.82M|  while (main_ptr->cur_iMCU_row < cinfo->total_iMCU_rows) {
  ------------------
  |  Branch (90:10): [True: 2.79M, False: 21.2k]
  ------------------
   91|       |    /* Read input data if we haven't filled the main buffer yet */
   92|  2.79M|    if (main_ptr->rowgroup_ctr < data_unit)
  ------------------
  |  Branch (92:9): [True: 2.79M, False: 0]
  ------------------
   93|  2.79M|      (*cinfo->prep->_pre_process_data) (cinfo, input_buf, in_row_ctr,
  ------------------
  |  |  130|  2.79M|#define _pre_process_data  pre_process_data_12
  ------------------
   94|  2.79M|                                         in_rows_avail, main_ptr->buffer,
   95|  2.79M|                                         &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|  2.79M|    if (main_ptr->rowgroup_ctr != data_unit)
  ------------------
  |  Branch (101:9): [True: 0, False: 2.79M]
  ------------------
  102|      0|      return;
  103|       |
  104|       |    /* Send the completed row to the compressor */
  105|  2.79M|    if (!(*cinfo->coef->_compress_data) (cinfo, main_ptr->buffer)) {
  ------------------
  |  |  132|  2.79M|#define _compress_data  compress_data_12
  ------------------
  |  Branch (105:9): [True: 0, False: 2.79M]
  ------------------
  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|  2.79M|    if (main_ptr->suspended) {
  ------------------
  |  Branch (121:9): [True: 0, False: 2.79M]
  ------------------
  122|      0|      (*in_row_ctr)++;
  123|      0|      main_ptr->suspended = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  124|      0|    }
  125|  2.79M|    main_ptr->rowgroup_ctr = 0;
  126|  2.79M|    main_ptr->cur_iMCU_row++;
  127|  2.79M|  }
  128|  21.2k|}

jinit_marker_writer:
  652|  21.2k|{
  653|  21.2k|  my_marker_ptr marker;
  654|       |
  655|       |  /* Create the subobject */
  656|  21.2k|  marker = (my_marker_ptr)
  657|  21.2k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  21.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  658|  21.2k|                                sizeof(my_marker_writer));
  659|  21.2k|  cinfo->marker = (struct jpeg_marker_writer *)marker;
  660|       |  /* Initialize method pointers */
  661|  21.2k|  marker->pub.write_file_header = write_file_header;
  662|  21.2k|  marker->pub.write_frame_header = write_frame_header;
  663|  21.2k|  marker->pub.write_scan_header = write_scan_header;
  664|  21.2k|  marker->pub.write_file_trailer = write_file_trailer;
  665|  21.2k|  marker->pub.write_tables_only = write_tables_only;
  666|  21.2k|  marker->pub.write_marker_header = write_marker_header;
  667|  21.2k|  marker->pub.write_marker_byte = write_marker_byte;
  668|       |  /* Initialize private state */
  669|  21.2k|  marker->last_restart_interval = 0;
  670|  21.2k|}
jcmarker.c:write_file_header:
  476|  21.2k|{
  477|  21.2k|  my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
  478|       |
  479|  21.2k|  emit_marker(cinfo, M_SOI);    /* first the SOI */
  480|       |
  481|       |  /* SOI is defined to reset restart interval to 0 */
  482|  21.2k|  marker->last_restart_interval = 0;
  483|       |
  484|  21.2k|  if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */
  ------------------
  |  Branch (484:7): [True: 15.3k, False: 5.85k]
  ------------------
  485|  15.3k|    emit_jfif_app0(cinfo);
  486|  21.2k|  if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */
  ------------------
  |  Branch (486:7): [True: 5.85k, False: 15.3k]
  ------------------
  487|  5.85k|    emit_adobe_app14(cinfo);
  488|  21.2k|}
jcmarker.c:emit_marker:
  131|   342k|{
  132|   342k|  emit_byte(cinfo, 0xFF);
  133|   342k|  emit_byte(cinfo, (int)mark);
  134|   342k|}
jcmarker.c:emit_byte:
  117|  7.12M|{
  118|  7.12M|  struct jpeg_destination_mgr *dest = cinfo->dest;
  119|       |
  120|  7.12M|  *(dest->next_output_byte)++ = (JOCTET)val;
  121|  7.12M|  if (--dest->free_in_buffer == 0) {
  ------------------
  |  Branch (121:7): [True: 106, False: 7.12M]
  ------------------
  122|    106|    if (!(*dest->empty_output_buffer) (cinfo))
  ------------------
  |  Branch (122:9): [True: 0, False: 106]
  ------------------
  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|    106|  }
  125|  7.12M|}
jcmarker.c:emit_jfif_app0:
  357|  15.3k|{
  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.3k|  emit_marker(cinfo, M_APP0);
  371|       |
  372|  15.3k|  emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */
  373|       |
  374|  15.3k|  emit_byte(cinfo, 0x4A);       /* Identifier: ASCII "JFIF" */
  375|  15.3k|  emit_byte(cinfo, 0x46);
  376|  15.3k|  emit_byte(cinfo, 0x49);
  377|  15.3k|  emit_byte(cinfo, 0x46);
  378|  15.3k|  emit_byte(cinfo, 0);
  379|  15.3k|  emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */
  380|  15.3k|  emit_byte(cinfo, cinfo->JFIF_minor_version);
  381|  15.3k|  emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */
  382|  15.3k|  emit_2bytes(cinfo, (int)cinfo->X_density);
  383|  15.3k|  emit_2bytes(cinfo, (int)cinfo->Y_density);
  384|  15.3k|  emit_byte(cinfo, 0);          /* No thumbnail image */
  385|  15.3k|  emit_byte(cinfo, 0);
  386|  15.3k|}
jcmarker.c:emit_2bytes:
  140|   396k|{
  141|   396k|  emit_byte(cinfo, (value >> 8) & 0xFF);
  142|   396k|  emit_byte(cinfo, value & 0xFF);
  143|   396k|}
jcmarker.c:emit_adobe_app14:
  392|  5.85k|{
  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.85k|  emit_marker(cinfo, M_APP14);
  410|       |
  411|  5.85k|  emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */
  412|       |
  413|  5.85k|  emit_byte(cinfo, 0x41);       /* Identifier: ASCII "Adobe" */
  414|  5.85k|  emit_byte(cinfo, 0x64);
  415|  5.85k|  emit_byte(cinfo, 0x6F);
  416|  5.85k|  emit_byte(cinfo, 0x62);
  417|  5.85k|  emit_byte(cinfo, 0x65);
  418|  5.85k|  emit_2bytes(cinfo, 100);      /* Version */
  419|  5.85k|  emit_2bytes(cinfo, 0);        /* Flags0 */
  420|  5.85k|  emit_2bytes(cinfo, 0);        /* Flags1 */
  421|  5.85k|  switch (cinfo->jpeg_color_space) {
  422|      0|  case JCS_YCbCr:
  ------------------
  |  Branch (422:3): [True: 0, False: 5.85k]
  ------------------
  423|      0|    emit_byte(cinfo, 1);        /* Color transform = 1 */
  424|      0|    break;
  425|  2.92k|  case JCS_YCCK:
  ------------------
  |  Branch (425:3): [True: 2.92k, False: 2.92k]
  ------------------
  426|  2.92k|    emit_byte(cinfo, 2);        /* Color transform = 2 */
  427|  2.92k|    break;
  428|  2.92k|  default:
  ------------------
  |  Branch (428:3): [True: 2.92k, False: 2.92k]
  ------------------
  429|  2.92k|    emit_byte(cinfo, 0);        /* Color transform = 0 */
  430|  2.92k|    break;
  431|  5.85k|  }
  432|  5.85k|}
jcmarker.c:write_frame_header:
  501|  21.2k|{
  502|  21.2k|  int ci, prec = 0;
  503|  21.2k|  boolean is_baseline;
  504|  21.2k|  jpeg_component_info *compptr;
  505|       |
  506|  21.2k|  if (!cinfo->master->lossless) {
  ------------------
  |  Branch (506:7): [True: 21.2k, False: 0]
  ------------------
  507|       |    /* Emit DQT for each quantization table.
  508|       |     * Note that emit_dqt() suppresses any duplicate tables.
  509|       |     */
  510|  75.0k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (510:46): [True: 53.7k, False: 21.2k]
  ------------------
  511|  53.7k|         ci++, compptr++) {
  512|  53.7k|      prec += emit_dqt(cinfo, compptr->quant_tbl_no);
  513|  53.7k|    }
  514|       |    /* now prec is nonzero iff there are any 16-bit quant tables. */
  515|  21.2k|  }
  516|       |
  517|       |  /* Check for a non-baseline specification.
  518|       |   * Note we assume that Huffman table numbers won't be changed later.
  519|       |   */
  520|  21.2k|  if (cinfo->arith_code || cinfo->progressive_mode ||
  ------------------
  |  Branch (520:7): [True: 5.85k, False: 15.3k]
  |  Branch (520:28): [True: 3.51k, False: 11.8k]
  ------------------
  521|  21.2k|      cinfo->master->lossless || cinfo->data_precision != 8) {
  ------------------
  |  Branch (521:7): [True: 0, False: 11.8k]
  |  Branch (521:34): [True: 11.8k, False: 0]
  ------------------
  522|  21.2k|    is_baseline = FALSE;
  ------------------
  |  |  207|  21.2k|#define FALSE   0               /* values of boolean */
  ------------------
  523|  21.2k|  } 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|  21.2k|  if (cinfo->arith_code) {
  ------------------
  |  Branch (538:7): [True: 5.85k, False: 15.3k]
  ------------------
  539|  5.85k|    if (cinfo->progressive_mode)
  ------------------
  |  Branch (539:9): [True: 2.92k, False: 2.92k]
  ------------------
  540|  2.92k|      emit_sof(cinfo, M_SOF10); /* SOF code for progressive arithmetic */
  541|  2.92k|    else
  542|  2.92k|      emit_sof(cinfo, M_SOF9);  /* SOF code for sequential arithmetic */
  543|  15.3k|  } else {
  544|  15.3k|    if (cinfo->progressive_mode)
  ------------------
  |  Branch (544:9): [True: 3.51k, False: 11.8k]
  ------------------
  545|  3.51k|      emit_sof(cinfo, M_SOF2);  /* SOF code for progressive Huffman */
  546|  11.8k|    else if (cinfo->master->lossless)
  ------------------
  |  Branch (546:14): [True: 0, False: 11.8k]
  ------------------
  547|      0|      emit_sof(cinfo, M_SOF3);  /* SOF code for lossless Huffman */
  548|  11.8k|    else if (is_baseline)
  ------------------
  |  Branch (548:14): [True: 0, False: 11.8k]
  ------------------
  549|      0|      emit_sof(cinfo, M_SOF0);  /* SOF code for baseline implementation */
  550|  11.8k|    else
  551|  11.8k|      emit_sof(cinfo, M_SOF1);  /* SOF code for non-baseline Huffman file */
  552|  15.3k|  }
  553|  21.2k|}
jcmarker.c:emit_dqt:
  154|  53.7k|{
  155|  53.7k|  JQUANT_TBL *qtbl = cinfo->quant_tbl_ptrs[index];
  156|  53.7k|  int prec;
  157|  53.7k|  int i;
  158|       |
  159|  53.7k|  if (qtbl == NULL)
  ------------------
  |  Branch (159:7): [True: 0, False: 53.7k]
  ------------------
  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|  53.7k|  prec = 0;
  163|  3.49M|  for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  3.49M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (163:15): [True: 3.44M, False: 53.7k]
  ------------------
  164|  3.44M|    if (qtbl->quantval[i] > 255)
  ------------------
  |  Branch (164:9): [True: 0, False: 3.44M]
  ------------------
  165|      0|      prec = 1;
  166|  3.44M|  }
  167|       |
  168|  53.7k|  if (!qtbl->sent_table) {
  ------------------
  |  Branch (168:7): [True: 33.1k, False: 20.6k]
  ------------------
  169|  33.1k|    emit_marker(cinfo, M_DQT);
  170|       |
  171|  33.1k|    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|  33.1k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (171:24): [True: 0, False: 33.1k]
  ------------------
  172|       |
  173|  33.1k|    emit_byte(cinfo, index + (prec << 4));
  174|       |
  175|  2.15M|    for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  2.15M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (175:17): [True: 2.11M, False: 33.1k]
  ------------------
  176|       |      /* The table entries must be emitted in zigzag order. */
  177|  2.11M|      unsigned int qval = qtbl->quantval[jpeg_natural_order[i]];
  178|  2.11M|      if (prec)
  ------------------
  |  Branch (178:11): [True: 0, False: 2.11M]
  ------------------
  179|      0|        emit_byte(cinfo, (int)(qval >> 8));
  180|  2.11M|      emit_byte(cinfo, (int)(qval & 0xFF));
  181|  2.11M|    }
  182|       |
  183|  33.1k|    qtbl->sent_table = TRUE;
  ------------------
  |  |  210|  33.1k|#define TRUE    1
  ------------------
  184|  33.1k|  }
  185|       |
  186|  53.7k|  return prec;
  187|  53.7k|}
jcmarker.c:emit_sof:
  292|  21.2k|{
  293|  21.2k|  int ci;
  294|  21.2k|  jpeg_component_info *compptr;
  295|       |
  296|  21.2k|  emit_marker(cinfo, code);
  297|       |
  298|  21.2k|  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|  21.2k|  if ((long)cinfo->_jpeg_height > 65535L || (long)cinfo->_jpeg_width > 65535L)
  ------------------
  |  |   31|  21.2k|#define _jpeg_height  image_height
  ------------------
                if ((long)cinfo->_jpeg_height > 65535L || (long)cinfo->_jpeg_width > 65535L)
  ------------------
  |  |   30|  21.2k|#define _jpeg_width  image_width
  ------------------
  |  Branch (301:7): [True: 0, False: 21.2k]
  |  Branch (301:45): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  emit_byte(cinfo, cinfo->data_precision);
  305|  21.2k|  emit_2bytes(cinfo, (int)cinfo->_jpeg_height);
  ------------------
  |  |   31|  21.2k|#define _jpeg_height  image_height
  ------------------
  306|  21.2k|  emit_2bytes(cinfo, (int)cinfo->_jpeg_width);
  ------------------
  |  |   30|  21.2k|#define _jpeg_width  image_width
  ------------------
  307|       |
  308|  21.2k|  emit_byte(cinfo, cinfo->num_components);
  309|       |
  310|  75.0k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (310:44): [True: 53.7k, False: 21.2k]
  ------------------
  311|  53.7k|       ci++, compptr++) {
  312|  53.7k|    emit_byte(cinfo, compptr->component_id);
  313|  53.7k|    emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor);
  314|  53.7k|    emit_byte(cinfo, compptr->quant_tbl_no);
  315|  53.7k|  }
  316|  21.2k|}
jcmarker.c:write_scan_header:
  564|  88.5k|{
  565|  88.5k|  my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
  566|  88.5k|  int i;
  567|  88.5k|  jpeg_component_info *compptr;
  568|       |
  569|  88.5k|  if (cinfo->arith_code) {
  ------------------
  |  Branch (569:7): [True: 55.6k, False: 32.9k]
  ------------------
  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|  55.6k|    emit_dac(cinfo);
  575|  55.6k|  } else {
  576|       |    /* Emit Huffman tables.
  577|       |     * Note that emit_dht() suppresses any duplicate tables.
  578|       |     */
  579|  83.8k|    for (i = 0; i < cinfo->comps_in_scan; i++) {
  ------------------
  |  Branch (579:17): [True: 50.8k, False: 32.9k]
  ------------------
  580|  50.8k|      compptr = cinfo->cur_comp_info[i];
  581|       |      /* DC needs no table for refinement scan */
  582|  50.8k|      if ((cinfo->Ss == 0 && cinfo->Ah == 0) || cinfo->master->lossless)
  ------------------
  |  Branch (582:12): [True: 36.8k, False: 14.0k]
  |  Branch (582:30): [True: 33.2k, False: 3.51k]
  |  Branch (582:49): [True: 0, False: 17.5k]
  ------------------
  583|  33.2k|        emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
  ------------------
  |  |  207|  33.2k|#define FALSE   0               /* values of boolean */
  ------------------
  584|       |      /* AC needs no table when not present, and lossless mode uses only DC
  585|       |         tables. */
  586|  50.8k|      if (cinfo->Se && !cinfo->master->lossless)
  ------------------
  |  Branch (586:11): [True: 43.8k, False: 7.03k]
  |  Branch (586:24): [True: 43.8k, False: 0]
  ------------------
  587|  43.8k|        emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
  ------------------
  |  |  210|  43.8k|#define TRUE    1
  ------------------
  588|  50.8k|    }
  589|  32.9k|  }
  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|  88.5k|  if (cinfo->restart_interval != marker->last_restart_interval) {
  ------------------
  |  Branch (594:7): [True: 5.85k, False: 82.7k]
  ------------------
  595|  5.85k|    emit_dri(cinfo);
  596|  5.85k|    marker->last_restart_interval = cinfo->restart_interval;
  597|  5.85k|  }
  598|       |
  599|  88.5k|  emit_sos(cinfo);
  600|  88.5k|}
jcmarker.c:emit_dac:
  233|  55.6k|{
  234|  55.6k|#ifdef C_ARITH_CODING_SUPPORTED
  235|  55.6k|  char dc_in_use[NUM_ARITH_TBLS];
  236|  55.6k|  char ac_in_use[NUM_ARITH_TBLS];
  237|  55.6k|  int length, i;
  238|  55.6k|  jpeg_component_info *compptr;
  239|       |
  240|   945k|  for (i = 0; i < NUM_ARITH_TBLS; i++)
  ------------------
  |  |   70|   945k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (240:15): [True: 889k, False: 55.6k]
  ------------------
  241|   889k|    dc_in_use[i] = ac_in_use[i] = 0;
  242|       |
  243|   134k|  for (i = 0; i < cinfo->comps_in_scan; i++) {
  ------------------
  |  Branch (243:15): [True: 79.0k, False: 55.6k]
  ------------------
  244|  79.0k|    compptr = cinfo->cur_comp_info[i];
  245|       |    /* DC needs no table for refinement scan */
  246|  79.0k|    if (cinfo->Ss == 0 && cinfo->Ah == 0)
  ------------------
  |  Branch (246:9): [True: 32.1k, False: 46.8k]
  |  Branch (246:27): [True: 20.4k, False: 11.7k]
  ------------------
  247|  20.4k|      dc_in_use[compptr->dc_tbl_no] = 1;
  248|       |    /* AC needs no table when not present */
  249|  79.0k|    if (cinfo->Se)
  ------------------
  |  Branch (249:9): [True: 55.6k, False: 23.4k]
  ------------------
  250|  55.6k|      ac_in_use[compptr->ac_tbl_no] = 1;
  251|  79.0k|  }
  252|       |
  253|  55.6k|  length = 0;
  254|   945k|  for (i = 0; i < NUM_ARITH_TBLS; i++)
  ------------------
  |  |   70|   945k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (254:15): [True: 889k, False: 55.6k]
  ------------------
  255|   889k|    length += dc_in_use[i] + ac_in_use[i];
  256|       |
  257|  55.6k|  if (length) {
  ------------------
  |  Branch (257:7): [True: 52.6k, False: 2.92k]
  ------------------
  258|  52.6k|    emit_marker(cinfo, M_DAC);
  259|       |
  260|  52.6k|    emit_2bytes(cinfo, length * 2 + 2);
  261|       |
  262|   895k|    for (i = 0; i < NUM_ARITH_TBLS; i++) {
  ------------------
  |  |   70|   895k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (262:17): [True: 842k, False: 52.6k]
  ------------------
  263|   842k|      if (dc_in_use[i]) {
  ------------------
  |  Branch (263:11): [True: 8.78k, False: 834k]
  ------------------
  264|  8.78k|        emit_byte(cinfo, i);
  265|  8.78k|        emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i] << 4));
  266|  8.78k|      }
  267|   842k|      if (ac_in_use[i]) {
  ------------------
  |  Branch (267:11): [True: 49.7k, False: 793k]
  ------------------
  268|  49.7k|        emit_byte(cinfo, i + 0x10);
  269|  49.7k|        emit_byte(cinfo, cinfo->arith_ac_K[i]);
  270|  49.7k|      }
  271|   842k|    }
  272|  52.6k|  }
  273|  55.6k|#endif /* C_ARITH_CODING_SUPPORTED */
  274|  55.6k|}
jcmarker.c:emit_dht:
  193|  77.1k|{
  194|  77.1k|  JHUFF_TBL *htbl;
  195|  77.1k|  int length, i;
  196|       |
  197|  77.1k|  if (is_ac) {
  ------------------
  |  Branch (197:7): [True: 43.8k, False: 33.2k]
  ------------------
  198|  43.8k|    htbl = cinfo->ac_huff_tbl_ptrs[index];
  199|  43.8k|    index += 0x10;              /* output index has AC bit set */
  200|  43.8k|  } else {
  201|  33.2k|    htbl = cinfo->dc_huff_tbl_ptrs[index];
  202|  33.2k|  }
  203|       |
  204|  77.1k|  if (htbl == NULL)
  ------------------
  |  Branch (204:7): [True: 0, False: 77.1k]
  ------------------
  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|  77.1k|  if (!htbl->sent_table) {
  ------------------
  |  Branch (207:7): [True: 59.2k, False: 17.8k]
  ------------------
  208|  59.2k|    emit_marker(cinfo, M_DHT);
  209|       |
  210|  59.2k|    length = 0;
  211|  1.00M|    for (i = 1; i <= 16; i++)
  ------------------
  |  Branch (211:17): [True: 947k, False: 59.2k]
  ------------------
  212|   947k|      length += htbl->bits[i];
  213|       |
  214|  59.2k|    emit_2bytes(cinfo, length + 2 + 1 + 16);
  215|  59.2k|    emit_byte(cinfo, index);
  216|       |
  217|  1.00M|    for (i = 1; i <= 16; i++)
  ------------------
  |  Branch (217:17): [True: 947k, False: 59.2k]
  ------------------
  218|   947k|      emit_byte(cinfo, htbl->bits[i]);
  219|       |
  220|   609k|    for (i = 0; i < length; i++)
  ------------------
  |  Branch (220:17): [True: 550k, False: 59.2k]
  ------------------
  221|   550k|      emit_byte(cinfo, htbl->huffval[i]);
  222|       |
  223|  59.2k|    htbl->sent_table = TRUE;
  ------------------
  |  |  210|  59.2k|#define TRUE    1
  ------------------
  224|  59.2k|  }
  225|  77.1k|}
jcmarker.c:emit_dri:
  280|  5.85k|{
  281|  5.85k|  emit_marker(cinfo, M_DRI);
  282|       |
  283|  5.85k|  emit_2bytes(cinfo, 4);        /* fixed length */
  284|       |
  285|  5.85k|  emit_2bytes(cinfo, (int)cinfo->restart_interval);
  286|  5.85k|}
jcmarker.c:emit_sos:
  322|  88.5k|{
  323|  88.5k|  int i, td, ta;
  324|  88.5k|  jpeg_component_info *compptr;
  325|       |
  326|  88.5k|  emit_marker(cinfo, M_SOS);
  327|       |
  328|  88.5k|  emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */
  329|       |
  330|  88.5k|  emit_byte(cinfo, cinfo->comps_in_scan);
  331|       |
  332|   218k|  for (i = 0; i < cinfo->comps_in_scan; i++) {
  ------------------
  |  Branch (332:15): [True: 129k, False: 88.5k]
  ------------------
  333|   129k|    compptr = cinfo->cur_comp_info[i];
  334|   129k|    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|   129k|    td = cinfo->Ss == 0 && cinfo->Ah == 0 ? compptr->dc_tbl_no : 0;
  ------------------
  |  Branch (341:10): [True: 69.0k, False: 60.9k]
  |  Branch (341:28): [True: 53.7k, False: 15.2k]
  ------------------
  342|       |    /* AC needs no table when not present */
  343|   129k|    ta = cinfo->Se ? compptr->ac_tbl_no : 0;
  ------------------
  |  Branch (343:10): [True: 99.4k, False: 30.4k]
  ------------------
  344|       |
  345|   129k|    emit_byte(cinfo, (td << 4) + ta);
  346|   129k|  }
  347|       |
  348|  88.5k|  emit_byte(cinfo, cinfo->Ss);
  349|  88.5k|  emit_byte(cinfo, cinfo->Se);
  350|  88.5k|  emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al);
  351|  88.5k|}
jcmarker.c:write_file_trailer:
  609|  21.2k|{
  610|  21.2k|  emit_marker(cinfo, M_EOI);
  611|  21.2k|}
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|  21.2k|{
  723|  21.2k|  my_master_ptr master = (my_master_ptr)cinfo->master;
  724|  21.2k|  boolean empty_huff_tables = TRUE;
  ------------------
  |  |  210|  21.2k|#define TRUE    1
  ------------------
  725|  21.2k|  int i;
  726|       |
  727|       |#ifdef WITH_PROFILE
  728|       |  master->pub.total_start = getTime();
  729|       |#endif
  730|       |
  731|  21.2k|  master->pub.prepare_for_pass = prepare_for_pass;
  732|  21.2k|  master->pub.pass_startup = pass_startup;
  733|  21.2k|  master->pub.finish_pass = finish_pass_master;
  734|  21.2k|  master->pub.is_last_pass = FALSE;
  ------------------
  |  |  207|  21.2k|#define FALSE   0               /* values of boolean */
  ------------------
  735|       |
  736|  21.2k|  if (cinfo->scan_info != NULL) {
  ------------------
  |  Branch (736:7): [True: 6.44k, False: 14.8k]
  ------------------
  737|  6.44k|#ifdef NEED_SCAN_SCRIPT
  738|  6.44k|    validate_script(cinfo);
  739|       |#else
  740|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  741|       |#endif
  742|  14.8k|  } else {
  743|  14.8k|    cinfo->progressive_mode = FALSE;
  ------------------
  |  |  207|  14.8k|#define FALSE   0               /* values of boolean */
  ------------------
  744|  14.8k|    cinfo->num_scans = 1;
  745|  14.8k|  }
  746|       |
  747|  21.2k|#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|  21.2k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (753:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|#endif
  765|       |
  766|       |  /* Validate parameters, determine derived values */
  767|  21.2k|  initial_setup(cinfo, transcode_only);
  768|       |
  769|  21.2k|  if (cinfo->arith_code)
  ------------------
  |  Branch (769:7): [True: 5.85k, False: 15.3k]
  ------------------
  770|  5.85k|    cinfo->optimize_coding = FALSE;
  ------------------
  |  |  207|  5.85k|#define FALSE   0               /* values of boolean */
  ------------------
  771|  15.3k|  else {
  772|  15.3k|    if (cinfo->master->lossless ||      /*  TEMPORARY HACK ??? */
  ------------------
  |  Branch (772:9): [True: 0, False: 15.3k]
  ------------------
  773|  15.3k|        cinfo->progressive_mode)
  ------------------
  |  Branch (773:9): [True: 3.51k, False: 11.8k]
  ------------------
  774|  3.51k|      cinfo->optimize_coding = TRUE; /* assume default tables no good for
  ------------------
  |  |  210|  3.51k|#define TRUE    1
  ------------------
  775|       |                                        progressive mode or lossless mode */
  776|  15.3k|    for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|  15.3k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (776:17): [True: 15.3k, False: 0]
  ------------------
  777|  15.3k|      if (cinfo->dc_huff_tbl_ptrs[i] != NULL ||
  ------------------
  |  Branch (777:11): [True: 15.3k, False: 0]
  ------------------
  778|  15.3k|          cinfo->ac_huff_tbl_ptrs[i] != NULL) {
  ------------------
  |  Branch (778:11): [True: 0, False: 0]
  ------------------
  779|  15.3k|        empty_huff_tables = FALSE;
  ------------------
  |  |  207|  15.3k|#define FALSE   0               /* values of boolean */
  ------------------
  780|  15.3k|        break;
  781|  15.3k|      }
  782|  15.3k|    }
  783|  15.3k|    if (cinfo->data_precision == 12 && !cinfo->optimize_coding &&
  ------------------
  |  Branch (783:9): [True: 15.3k, False: 0]
  |  Branch (783:40): [True: 0, False: 15.3k]
  ------------------
  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.3k|  }
  788|       |
  789|       |  /* Initialize my private state */
  790|  21.2k|  if (transcode_only) {
  ------------------
  |  Branch (790:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  } else {
  797|       |    /* for normal compression, first pass is always this type: */
  798|  21.2k|    master->pass_type = main_pass;
  799|  21.2k|  }
  800|  21.2k|  master->scan_number = 0;
  801|  21.2k|  master->pass_number = 0;
  802|  21.2k|  if (cinfo->optimize_coding)
  ------------------
  |  Branch (802:7): [True: 15.3k, False: 5.85k]
  ------------------
  803|  15.3k|    master->total_passes = cinfo->num_scans * 2;
  804|  5.85k|  else
  805|  5.85k|    master->total_passes = cinfo->num_scans;
  806|       |
  807|  21.2k|  master->jpeg_version = PACKAGE_NAME " version " VERSION " (build " BUILD ")";
  ------------------
  |  |   17|  21.2k|#define PACKAGE_NAME  "libjpeg-turbo"
  ------------------
  808|  21.2k|}
jcmaster.c:prepare_for_pass:
  579|   118k|{
  580|   118k|  my_master_ptr master = (my_master_ptr)cinfo->master;
  581|       |
  582|   118k|  switch (master->pass_type) {
  583|  21.2k|  case main_pass:
  ------------------
  |  Branch (583:3): [True: 21.2k, False: 96.8k]
  ------------------
  584|       |    /* Initial pass: will collect input data, and do either Huffman
  585|       |     * optimization or data output for the first scan.
  586|       |     */
  587|  21.2k|    select_scan_parameters(cinfo);
  588|  21.2k|    per_scan_setup(cinfo);
  589|  21.2k|    if (!cinfo->raw_data_in) {
  ------------------
  |  Branch (589:9): [True: 21.2k, False: 0]
  ------------------
  590|  21.2k|      (*cinfo->cconvert->start_pass) (cinfo);
  591|  21.2k|      (*cinfo->downsample->start_pass) (cinfo);
  592|  21.2k|      (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU);
  593|  21.2k|    }
  594|  21.2k|    (*cinfo->fdct->start_pass) (cinfo);
  595|  21.2k|    (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding);
  596|  21.2k|    (*cinfo->coef->start_pass) (cinfo,
  597|  21.2k|                                (master->total_passes > 1 ?
  ------------------
  |  Branch (597:34): [True: 18.3k, False: 2.92k]
  ------------------
  598|  18.3k|                                 JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
  599|  21.2k|    (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
  600|  21.2k|    if (cinfo->optimize_coding) {
  ------------------
  |  Branch (600:9): [True: 15.3k, False: 5.85k]
  ------------------
  601|       |      /* No immediate data output; postpone writing frame/scan headers */
  602|  15.3k|      master->pub.call_pass_startup = FALSE;
  ------------------
  |  |  207|  15.3k|#define FALSE   0               /* values of boolean */
  ------------------
  603|  15.3k|    } else {
  604|       |      /* Will write frame/scan headers at first jpeg_write_scanlines call */
  605|  5.85k|      master->pub.call_pass_startup = TRUE;
  ------------------
  |  |  210|  5.85k|#define TRUE    1
  ------------------
  606|  5.85k|    }
  607|  21.2k|    break;
  608|      0|#ifdef ENTROPY_OPT_SUPPORTED
  609|  17.5k|  case huff_opt_pass:
  ------------------
  |  Branch (609:3): [True: 17.5k, False: 100k]
  ------------------
  610|       |    /* Do Huffman optimization for a scan after the first one. */
  611|  17.5k|    select_scan_parameters(cinfo);
  612|  17.5k|    per_scan_setup(cinfo);
  613|  17.5k|    if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code ||
  ------------------
  |  Branch (613:9): [True: 14.0k, False: 3.51k]
  |  Branch (613:27): [True: 0, False: 3.51k]
  |  Branch (613:45): [True: 0, False: 3.51k]
  ------------------
  614|  14.0k|        cinfo->master->lossless) {
  ------------------
  |  Branch (614:9): [True: 0, False: 3.51k]
  ------------------
  615|  14.0k|      (*cinfo->entropy->start_pass) (cinfo, TRUE);
  ------------------
  |  |  210|  14.0k|#define TRUE    1
  ------------------
  616|  14.0k|      (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
  617|  14.0k|      master->pub.call_pass_startup = FALSE;
  ------------------
  |  |  207|  14.0k|#define FALSE   0               /* values of boolean */
  ------------------
  618|  14.0k|      break;
  619|  14.0k|    }
  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.51k|    master->pass_type = output_pass;
  624|  3.51k|    master->pass_number++;
  625|  3.51k|    FALLTHROUGH                 /*FALLTHROUGH*/
  ------------------
  |  |   41|  3.51k|#define FALLTHROUGH  __attribute__((fallthrough));
  ------------------
  626|  3.51k|#endif
  627|  82.7k|  case output_pass:
  ------------------
  |  Branch (627:3): [True: 79.2k, False: 38.8k]
  ------------------
  628|       |    /* Do a data-output pass. */
  629|       |    /* We need not repeat per-scan setup if prior optimization pass did it. */
  630|  82.7k|    if (!cinfo->optimize_coding) {
  ------------------
  |  Branch (630:9): [True: 49.7k, False: 32.9k]
  ------------------
  631|  49.7k|      select_scan_parameters(cinfo);
  632|  49.7k|      per_scan_setup(cinfo);
  633|  49.7k|    }
  634|  82.7k|    (*cinfo->entropy->start_pass) (cinfo, FALSE);
  ------------------
  |  |  207|  82.7k|#define FALSE   0               /* values of boolean */
  ------------------
  635|  82.7k|    (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
  636|       |    /* We emit frame/scan headers now */
  637|  82.7k|    if (master->scan_number == 0)
  ------------------
  |  Branch (637:9): [True: 15.3k, False: 67.3k]
  ------------------
  638|  15.3k|      (*cinfo->marker->write_frame_header) (cinfo);
  639|  82.7k|    (*cinfo->marker->write_scan_header) (cinfo);
  640|  82.7k|    master->pub.call_pass_startup = FALSE;
  ------------------
  |  |  207|  82.7k|#define FALSE   0               /* values of boolean */
  ------------------
  641|  82.7k|    break;
  642|      0|  default:
  ------------------
  |  Branch (642:3): [True: 0, False: 118k]
  ------------------
  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|   118k|  }
  645|       |
  646|   118k|  master->pub.is_last_pass = (master->pass_number == master->total_passes - 1);
  647|       |
  648|       |  /* Set up progress monitor's pass info if present */
  649|   118k|  if (cinfo->progress != NULL) {
  ------------------
  |  Branch (649:7): [True: 0, False: 118k]
  ------------------
  650|      0|    cinfo->progress->completed_passes = master->pass_number;
  651|      0|    cinfo->progress->total_passes = master->total_passes;
  652|      0|  }
  653|   118k|}
jcmaster.c:select_scan_parameters:
  444|  88.5k|{
  445|  88.5k|  int ci;
  446|       |
  447|  88.5k|#ifdef NEED_SCAN_SCRIPT
  448|  88.5k|  if (cinfo->scan_info != NULL) {
  ------------------
  |  Branch (448:7): [True: 73.7k, False: 14.8k]
  ------------------
  449|       |    /* Prepare for current scan --- the script is already validated */
  450|  73.7k|    my_master_ptr master = (my_master_ptr)cinfo->master;
  451|  73.7k|    const jpeg_scan_info *scanptr = cinfo->scan_info + master->scan_number;
  452|       |
  453|  73.7k|    cinfo->comps_in_scan = scanptr->comps_in_scan;
  454|   165k|    for (ci = 0; ci < scanptr->comps_in_scan; ci++) {
  ------------------
  |  Branch (454:18): [True: 91.3k, False: 73.7k]
  ------------------
  455|  91.3k|      cinfo->cur_comp_info[ci] =
  456|  91.3k|        &cinfo->comp_info[scanptr->component_index[ci]];
  457|  91.3k|    }
  458|  73.7k|    cinfo->Ss = scanptr->Ss;
  459|  73.7k|    cinfo->Se = scanptr->Se;
  460|  73.7k|    cinfo->Ah = scanptr->Ah;
  461|  73.7k|    cinfo->Al = scanptr->Al;
  462|  73.7k|  } else
  463|  14.8k|#endif
  464|  14.8k|  {
  465|       |    /* Prepare for single sequential-JPEG scan containing all components */
  466|  14.8k|    if (cinfo->num_components > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  14.8k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (466:9): [True: 0, False: 14.8k]
  ------------------
  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.8k|               MAX_COMPS_IN_SCAN);
  469|  14.8k|    cinfo->comps_in_scan = cinfo->num_components;
  470|  53.3k|    for (ci = 0; ci < cinfo->num_components; ci++) {
  ------------------
  |  Branch (470:18): [True: 38.5k, False: 14.8k]
  ------------------
  471|  38.5k|      cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
  472|  38.5k|    }
  473|  14.8k|    if (!cinfo->master->lossless) {
  ------------------
  |  Branch (473:9): [True: 14.8k, False: 0]
  ------------------
  474|  14.8k|      cinfo->Ss = 0;
  475|  14.8k|      cinfo->Se = DCTSIZE2 - 1;
  ------------------
  |  |   67|  14.8k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  476|  14.8k|      cinfo->Ah = 0;
  477|  14.8k|      cinfo->Al = 0;
  478|  14.8k|    }
  479|  14.8k|  }
  480|  88.5k|}
jcmaster.c:per_scan_setup:
  487|  88.5k|{
  488|  88.5k|  int ci, mcublks, tmp;
  489|  88.5k|  jpeg_component_info *compptr;
  490|  88.5k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  88.5k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (490:19): [True: 0, False: 88.5k]
  ------------------
  491|       |
  492|  88.5k|  if (cinfo->comps_in_scan == 1) {
  ------------------
  |  Branch (492:7): [True: 70.8k, False: 17.7k]
  ------------------
  493|       |
  494|       |    /* Noninterleaved (single-component) scan */
  495|  70.8k|    compptr = cinfo->cur_comp_info[0];
  496|       |
  497|       |    /* Overall image size in MCUs */
  498|  70.8k|    cinfo->MCUs_per_row = compptr->width_in_blocks;
  499|  70.8k|    cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
  500|       |
  501|       |    /* For noninterleaved scan, always one block per MCU */
  502|  70.8k|    compptr->MCU_width = 1;
  503|  70.8k|    compptr->MCU_height = 1;
  504|  70.8k|    compptr->MCU_blocks = 1;
  505|  70.8k|    compptr->MCU_sample_width = data_unit;
  506|  70.8k|    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|  70.8k|    tmp = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
  511|  70.8k|    if (tmp == 0) tmp = compptr->v_samp_factor;
  ------------------
  |  Branch (511:9): [True: 51.4k, False: 19.3k]
  ------------------
  512|  70.8k|    compptr->last_row_height = tmp;
  513|       |
  514|       |    /* Prepare array describing MCU composition */
  515|  70.8k|    cinfo->blocks_in_MCU = 1;
  516|  70.8k|    cinfo->MCU_membership[0] = 0;
  517|       |
  518|  70.8k|  } else {
  519|       |
  520|       |    /* Interleaved (multi-component) scan */
  521|  17.7k|    if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  17.7k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (521:9): [True: 0, False: 17.7k]
  |  Branch (521:38): [True: 0, False: 17.7k]
  ------------------
  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.7k|               MAX_COMPS_IN_SCAN);
  524|       |
  525|       |    /* Overall image size in MCUs */
  526|  17.7k|    cinfo->MCUs_per_row = (JDIMENSION)
  527|  17.7k|      jdiv_round_up((long)cinfo->_jpeg_width,
  ------------------
  |  |   30|  17.7k|#define _jpeg_width  image_width
  ------------------
  528|  17.7k|                    (long)(cinfo->max_h_samp_factor * data_unit));
  529|  17.7k|    cinfo->MCU_rows_in_scan = (JDIMENSION)
  530|  17.7k|      jdiv_round_up((long)cinfo->_jpeg_height,
  ------------------
  |  |   31|  17.7k|#define _jpeg_height  image_height
  ------------------
  531|  17.7k|                    (long)(cinfo->max_v_samp_factor * data_unit));
  532|       |
  533|  17.7k|    cinfo->blocks_in_MCU = 0;
  534|       |
  535|  76.7k|    for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (535:18): [True: 59.0k, False: 17.7k]
  ------------------
  536|  59.0k|      compptr = cinfo->cur_comp_info[ci];
  537|       |      /* Sampling factors give # of blocks of component in each MCU */
  538|  59.0k|      compptr->MCU_width = compptr->h_samp_factor;
  539|  59.0k|      compptr->MCU_height = compptr->v_samp_factor;
  540|  59.0k|      compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
  541|  59.0k|      compptr->MCU_sample_width = compptr->MCU_width * data_unit;
  542|       |      /* Figure number of non-dummy blocks in last MCU column & row */
  543|  59.0k|      tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
  544|  59.0k|      if (tmp == 0) tmp = compptr->MCU_width;
  ------------------
  |  Branch (544:11): [True: 51.3k, False: 7.69k]
  ------------------
  545|  59.0k|      compptr->last_col_width = tmp;
  546|  59.0k|      tmp = (int)(compptr->height_in_blocks % compptr->MCU_height);
  547|  59.0k|      if (tmp == 0) tmp = compptr->MCU_height;
  ------------------
  |  Branch (547:11): [True: 46.9k, False: 12.1k]
  ------------------
  548|  59.0k|      compptr->last_row_height = tmp;
  549|       |      /* Prepare array describing MCU composition */
  550|  59.0k|      mcublks = compptr->MCU_blocks;
  551|  59.0k|      if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU)
  ------------------
  |  |   80|  59.0k|#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on data units/MCU */
  ------------------
  |  Branch (551:11): [True: 0, False: 59.0k]
  ------------------
  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|   150k|      while (mcublks-- > 0) {
  ------------------
  |  Branch (553:14): [True: 91.3k, False: 59.0k]
  ------------------
  554|  91.3k|        cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
  555|  91.3k|      }
  556|  59.0k|    }
  557|       |
  558|  17.7k|  }
  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|  88.5k|  if (cinfo->restart_in_rows > 0) {
  ------------------
  |  Branch (562:7): [True: 55.6k, False: 32.9k]
  ------------------
  563|  55.6k|    long nominal = (long)cinfo->restart_in_rows * (long)cinfo->MCUs_per_row;
  564|  55.6k|    cinfo->restart_interval = (unsigned int)MIN(nominal, 65535L);
  ------------------
  |  |  515|  55.6k|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 55.6k, False: 0]
  |  |  ------------------
  ------------------
  565|  55.6k|  }
  566|  88.5k|}
jcmaster.c:pass_startup:
  668|  5.85k|{
  669|  5.85k|  cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */
  ------------------
  |  |  207|  5.85k|#define FALSE   0               /* values of boolean */
  ------------------
  670|       |
  671|  5.85k|  (*cinfo->marker->write_frame_header) (cinfo);
  672|  5.85k|  (*cinfo->marker->write_scan_header) (cinfo);
  673|  5.85k|}
jcmaster.c:finish_pass_master:
  682|   118k|{
  683|   118k|  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|   118k|  (*cinfo->entropy->finish_pass) (cinfo);
  689|       |
  690|       |  /* Update state for next pass */
  691|   118k|  switch (master->pass_type) {
  ------------------
  |  Branch (691:11): [True: 118k, False: 0]
  ------------------
  692|  21.2k|  case main_pass:
  ------------------
  |  Branch (692:3): [True: 21.2k, False: 96.8k]
  ------------------
  693|       |    /* next pass is either output of scan 0 (after optimization)
  694|       |     * or output of scan 1 (if no optimization).
  695|       |     */
  696|  21.2k|    master->pass_type = output_pass;
  697|  21.2k|    if (!cinfo->optimize_coding)
  ------------------
  |  Branch (697:9): [True: 5.85k, False: 15.3k]
  ------------------
  698|  5.85k|      master->scan_number++;
  699|  21.2k|    break;
  700|  14.0k|  case huff_opt_pass:
  ------------------
  |  Branch (700:3): [True: 14.0k, False: 103k]
  ------------------
  701|       |    /* next pass is always output of current scan */
  702|  14.0k|    master->pass_type = output_pass;
  703|  14.0k|    break;
  704|  82.7k|  case output_pass:
  ------------------
  |  Branch (704:3): [True: 82.7k, False: 35.3k]
  ------------------
  705|       |    /* next pass is either optimization or output of next scan */
  706|  82.7k|    if (cinfo->optimize_coding)
  ------------------
  |  Branch (706:9): [True: 32.9k, False: 49.7k]
  ------------------
  707|  32.9k|      master->pass_type = huff_opt_pass;
  708|  82.7k|    master->scan_number++;
  709|  82.7k|    break;
  710|   118k|  }
  711|       |
  712|   118k|  master->pass_number++;
  713|   118k|}
jcmaster.c:validate_script:
  280|  6.44k|{
  281|  6.44k|  const jpeg_scan_info *scanptr;
  282|  6.44k|  int scanno, ncomps, ci, thisi;
  283|  6.44k|  int Ss, Se, Ah, Al;
  284|  6.44k|  boolean component_sent[MAX_COMPONENTS];
  285|  6.44k|#ifdef C_PROGRESSIVE_SUPPORTED
  286|  6.44k|  int coefi, *last_bitpos_ptr;
  287|  6.44k|  int last_bitpos[MAX_COMPONENTS][DCTSIZE2];
  288|       |  /* -1 until that coefficient has been seen; then last Al for it */
  289|  6.44k|#endif
  290|       |
  291|  6.44k|  if (cinfo->num_scans <= 0)
  ------------------
  |  Branch (291:7): [True: 0, False: 6.44k]
  ------------------
  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.44k|  scanptr = cinfo->scan_info;
  300|  6.44k|  if (scanptr->Ss != 0 && scanptr->Se == 0) {
  ------------------
  |  Branch (300:7): [True: 0, False: 6.44k]
  |  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.44k|  else if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2 - 1) {
  ------------------
  |  |   67|  6.44k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (313:12): [True: 0, False: 6.44k]
  |  Branch (313:32): [True: 6.44k, False: 0]
  ------------------
  314|  6.44k|#ifdef C_PROGRESSIVE_SUPPORTED
  315|  6.44k|    cinfo->progressive_mode = TRUE;
  ------------------
  |  |  210|  6.44k|#define TRUE    1
  ------------------
  316|  6.44k|    cinfo->master->lossless = FALSE;
  ------------------
  |  |  207|  6.44k|#define FALSE   0               /* values of boolean */
  ------------------
  317|  6.44k|    last_bitpos_ptr = &last_bitpos[0][0];
  318|  21.6k|    for (ci = 0; ci < cinfo->num_components; ci++)
  ------------------
  |  Branch (318:18): [True: 15.2k, False: 6.44k]
  ------------------
  319|   989k|      for (coefi = 0; coefi < DCTSIZE2; coefi++)
  ------------------
  |  |   67|   989k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (319:23): [True: 974k, False: 15.2k]
  ------------------
  320|   974k|        *last_bitpos_ptr++ = -1;
  321|       |#else
  322|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  323|       |#endif
  324|  6.44k|  } 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|  80.2k|  for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) {
  ------------------
  |  Branch (330:20): [True: 73.7k, False: 6.44k]
  ------------------
  331|       |    /* Validate component indexes */
  332|  73.7k|    ncomps = scanptr->comps_in_scan;
  333|  73.7k|    if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  73.7k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (333:9): [True: 0, False: 73.7k]
  |  Branch (333:24): [True: 0, False: 73.7k]
  ------------------
  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|   165k|    for (ci = 0; ci < ncomps; ci++) {
  ------------------
  |  Branch (335:18): [True: 91.3k, False: 73.7k]
  ------------------
  336|  91.3k|      thisi = scanptr->component_index[ci];
  337|  91.3k|      if (thisi < 0 || thisi >= cinfo->num_components)
  ------------------
  |  Branch (337:11): [True: 0, False: 91.3k]
  |  Branch (337:24): [True: 0, False: 91.3k]
  ------------------
  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|  91.3k|      if (ci > 0 && thisi <= scanptr->component_index[ci - 1])
  ------------------
  |  Branch (340:11): [True: 17.5k, False: 73.7k]
  |  Branch (340:21): [True: 0, False: 17.5k]
  ------------------
  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|  91.3k|    }
  343|       |    /* Validate progression parameters */
  344|  73.7k|    Ss = scanptr->Ss;
  345|  73.7k|    Se = scanptr->Se;
  346|  73.7k|    Ah = scanptr->Ah;
  347|  73.7k|    Al = scanptr->Al;
  348|  73.7k|    if (cinfo->progressive_mode) {
  ------------------
  |  Branch (348:9): [True: 73.7k, False: 0]
  ------------------
  349|  73.7k|#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|  73.7k|      int max_Ah_Al = cinfo->data_precision == 12 ? 13 : 10;
  ------------------
  |  Branch (357:23): [True: 73.7k, False: 0]
  ------------------
  358|       |
  359|  73.7k|      if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
  ------------------
  |  |   67|   147k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
                    if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
  ------------------
  |  |   67|   147k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (359:11): [True: 0, False: 73.7k]
  |  Branch (359:21): [True: 0, False: 73.7k]
  |  Branch (359:39): [True: 0, False: 73.7k]
  |  Branch (359:50): [True: 0, False: 73.7k]
  ------------------
  360|  73.7k|          Ah < 0 || Ah > max_Ah_Al || Al < 0 || Al > max_Ah_Al)
  ------------------
  |  Branch (360:11): [True: 0, False: 73.7k]
  |  Branch (360:21): [True: 0, False: 73.7k]
  |  Branch (360:39): [True: 0, False: 73.7k]
  |  Branch (360:49): [True: 0, False: 73.7k]
  ------------------
  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|  73.7k|      if (Ss == 0) {
  ------------------
  |  Branch (362:11): [True: 12.8k, False: 60.9k]
  ------------------
  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|  60.9k|      } else {
  366|  60.9k|        if (ncomps != 1)        /* AC scans must be for only one component */
  ------------------
  |  Branch (366:13): [True: 0, False: 60.9k]
  ------------------
  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|  60.9k|      }
  369|   165k|      for (ci = 0; ci < ncomps; ci++) {
  ------------------
  |  Branch (369:20): [True: 91.3k, False: 73.7k]
  ------------------
  370|  91.3k|        last_bitpos_ptr = &last_bitpos[scanptr->component_index[ci]][0];
  371|  91.3k|        if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */
  ------------------
  |  Branch (371:13): [True: 60.9k, False: 30.4k]
  |  Branch (371:24): [True: 0, False: 60.9k]
  ------------------
  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.99M|        for (coefi = Ss; coefi <= Se; coefi++) {
  ------------------
  |  Branch (373:26): [True: 2.90M, False: 91.3k]
  ------------------
  374|  2.90M|          if (last_bitpos_ptr[coefi] < 0) {
  ------------------
  |  Branch (374:15): [True: 974k, False: 1.93M]
  ------------------
  375|       |            /* first scan of this coefficient */
  376|   974k|            if (Ah != 0)
  ------------------
  |  Branch (376:17): [True: 0, False: 974k]
  ------------------
  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.93M|          } else {
  379|       |            /* not first scan */
  380|  1.93M|            if (Ah != last_bitpos_ptr[coefi] || Al != Ah - 1)
  ------------------
  |  Branch (380:17): [True: 0, False: 1.93M]
  |  Branch (380:49): [True: 0, False: 1.93M]
  ------------------
  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.93M|          }
  383|  2.90M|          last_bitpos_ptr[coefi] = Al;
  384|  2.90M|        }
  385|  91.3k|      }
  386|  73.7k|#endif
  387|  73.7k|    } 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|  73.7k|  }
  416|       |
  417|       |  /* Now verify that everything got sent. */
  418|  6.44k|  if (cinfo->progressive_mode) {
  ------------------
  |  Branch (418:7): [True: 6.44k, False: 0]
  ------------------
  419|  6.44k|#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.6k|    for (ci = 0; ci < cinfo->num_components; ci++) {
  ------------------
  |  Branch (425:18): [True: 15.2k, False: 6.44k]
  ------------------
  426|  15.2k|      if (last_bitpos[ci][0] < 0)
  ------------------
  |  Branch (426:11): [True: 0, False: 15.2k]
  ------------------
  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|  15.2k|    }
  429|  6.44k|#endif
  430|  6.44k|  } 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.44k|}
jcmaster.c:initial_setup:
  166|  21.2k|{
  167|  21.2k|  int ci;
  168|  21.2k|  jpeg_component_info *compptr;
  169|  21.2k|  long samplesperrow;
  170|  21.2k|  JDIMENSION jd_samplesperrow;
  171|  21.2k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  21.2k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (171:19): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0 ||
  ------------------
  |  |   31|  21.2k|#define _jpeg_height  image_height
  ------------------
                if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0 ||
  ------------------
  |  |   30|  21.2k|#define _jpeg_width  image_width
  ------------------
  |  Branch (181:7): [True: 0, False: 21.2k]
  |  Branch (181:35): [True: 0, False: 21.2k]
  ------------------
  182|  21.2k|      cinfo->num_components <= 0 || cinfo->input_components <= 0)
  ------------------
  |  Branch (182:7): [True: 0, False: 21.2k]
  |  Branch (182:37): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  if ((long)cinfo->_jpeg_height > (long)JPEG_MAX_DIMENSION ||
  ------------------
  |  |   31|  21.2k|#define _jpeg_height  image_height
  ------------------
                if ((long)cinfo->_jpeg_height > (long)JPEG_MAX_DIMENSION ||
  ------------------
  |  |  158|  42.4k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (186:7): [True: 0, False: 21.2k]
  ------------------
  187|  21.2k|      (long)cinfo->_jpeg_width > (long)JPEG_MAX_DIMENSION)
  ------------------
  |  |   30|  21.2k|#define _jpeg_width  image_width
  ------------------
                    (long)cinfo->_jpeg_width > (long)JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  21.2k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (187:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  samplesperrow = (long)cinfo->image_width * (long)cinfo->input_components;
  192|  21.2k|  jd_samplesperrow = (JDIMENSION)samplesperrow;
  193|  21.2k|  if ((long)jd_samplesperrow != samplesperrow)
  ------------------
  |  Branch (193:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|#ifdef C_LOSSLESS_SUPPORTED
  200|  21.2k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (200:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|#endif
  205|  21.2k|  {
  206|  21.2k|    if (cinfo->data_precision != 8 && cinfo->data_precision != 12)
  ------------------
  |  Branch (206:9): [True: 21.2k, False: 0]
  |  Branch (206:39): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  }
  209|       |
  210|       |  /* Check that number of components won't exceed internal array sizes */
  211|  21.2k|  if (cinfo->num_components > MAX_COMPONENTS)
  ------------------
  |  |   30|  21.2k|#define MAX_COMPONENTS  10      /* maximum number of image components */
  ------------------
  |  Branch (211:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|             MAX_COMPONENTS);
  214|       |
  215|       |  /* Compute maximum sampling factors; check factor validity */
  216|  21.2k|  cinfo->max_h_samp_factor = 1;
  217|  21.2k|  cinfo->max_v_samp_factor = 1;
  218|  75.0k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (218:44): [True: 53.7k, False: 21.2k]
  ------------------
  219|  53.7k|       ci++, compptr++) {
  220|  53.7k|    if (compptr->h_samp_factor <= 0 ||
  ------------------
  |  Branch (220:9): [True: 0, False: 53.7k]
  ------------------
  221|  53.7k|        compptr->h_samp_factor > MAX_SAMP_FACTOR ||
  ------------------
  |  |   72|   107k|#define MAX_SAMP_FACTOR     4   /* JPEG limit on sampling factors */
  ------------------
  |  Branch (221:9): [True: 0, False: 53.7k]
  ------------------
  222|  53.7k|        compptr->v_samp_factor <= 0 ||
  ------------------
  |  Branch (222:9): [True: 0, False: 53.7k]
  ------------------
  223|  53.7k|        compptr->v_samp_factor > MAX_SAMP_FACTOR)
  ------------------
  |  |   72|  53.7k|#define MAX_SAMP_FACTOR     4   /* JPEG limit on sampling factors */
  ------------------
  |  Branch (223:9): [True: 0, False: 53.7k]
  ------------------
  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|  53.7k|    cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
  ------------------
  |  |  513|  53.7k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 17.7k, False: 36.0k]
  |  |  ------------------
  ------------------
  226|  53.7k|                                   compptr->h_samp_factor);
  227|  53.7k|    cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
  ------------------
  |  |  513|  53.7k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 11.7k, False: 42.0k]
  |  |  ------------------
  ------------------
  228|  53.7k|                                   compptr->v_samp_factor);
  229|  53.7k|  }
  230|       |
  231|       |  /* Compute dimensions of components */
  232|  75.0k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (232:44): [True: 53.7k, False: 21.2k]
  ------------------
  233|  53.7k|       ci++, compptr++) {
  234|       |    /* Fill in the correct component_index value; don't rely on application */
  235|  53.7k|    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|  53.7k|    compptr->DCT_scaled_size = data_unit;
  241|  53.7k|#endif
  242|       |    /* Size in data units */
  243|  53.7k|    compptr->width_in_blocks = (JDIMENSION)
  244|  53.7k|      jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
  ------------------
  |  |   30|  53.7k|#define _jpeg_width  image_width
  ------------------
  245|  53.7k|                    (long)(cinfo->max_h_samp_factor * data_unit));
  246|  53.7k|    compptr->height_in_blocks = (JDIMENSION)
  247|  53.7k|      jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
  ------------------
  |  |   31|  53.7k|#define _jpeg_height  image_height
  ------------------
  248|  53.7k|                    (long)(cinfo->max_v_samp_factor * data_unit));
  249|       |    /* Size in samples */
  250|  53.7k|    compptr->downsampled_width = (JDIMENSION)
  251|  53.7k|      jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
  ------------------
  |  |   30|  53.7k|#define _jpeg_width  image_width
  ------------------
  252|  53.7k|                    (long)cinfo->max_h_samp_factor);
  253|  53.7k|    compptr->downsampled_height = (JDIMENSION)
  254|  53.7k|      jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
  ------------------
  |  |   31|  53.7k|#define _jpeg_height  image_height
  ------------------
  255|  53.7k|                    (long)cinfo->max_v_samp_factor);
  256|       |    /* Mark component needed (this flag isn't actually used for compression) */
  257|  53.7k|    compptr->component_needed = TRUE;
  ------------------
  |  |  210|  53.7k|#define TRUE    1
  ------------------
  258|  53.7k|  }
  259|       |
  260|       |  /* Compute number of fully interleaved MCU rows (number of times that
  261|       |   * main controller will call coefficient or difference controller).
  262|       |   */
  263|  21.2k|  cinfo->total_iMCU_rows = (JDIMENSION)
  264|  21.2k|    jdiv_round_up((long)cinfo->_jpeg_height,
  ------------------
  |  |   31|  21.2k|#define _jpeg_height  image_height
  ------------------
  265|  21.2k|                  (long)(cinfo->max_v_samp_factor * data_unit));
  266|  21.2k|}

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

jpeg_add_quant_table:
   38|  84.9k|{
   39|  84.9k|  JQUANT_TBL **qtblptr;
   40|  84.9k|  int i;
   41|  84.9k|  long temp;
   42|       |
   43|       |  /* Safety check to ensure start_compress not called yet. */
   44|  84.9k|  if (cinfo->global_state != CSTATE_START)
  ------------------
  |  |   44|  84.9k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (44:7): [True: 0, False: 84.9k]
  ------------------
   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|  84.9k|  if (which_tbl < 0 || which_tbl >= NUM_QUANT_TBLS)
  ------------------
  |  |   68|  84.9k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (47:7): [True: 0, False: 84.9k]
  |  Branch (47:24): [True: 0, False: 84.9k]
  ------------------
   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|  84.9k|  qtblptr = &cinfo->quant_tbl_ptrs[which_tbl];
   51|       |
   52|  84.9k|  if (*qtblptr == NULL)
  ------------------
  |  Branch (52:7): [True: 7.41k, False: 77.5k]
  ------------------
   53|  7.41k|    *qtblptr = jpeg_alloc_quant_table((j_common_ptr)cinfo);
   54|       |
   55|  5.52M|  for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  5.52M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (55:15): [True: 5.43M, False: 84.9k]
  ------------------
   56|  5.43M|    temp = ((long)basic_table[i] * scale_factor + 50L) / 100L;
   57|       |    /* limit the values to the valid range */
   58|  5.43M|    if (temp <= 0L) temp = 1L;
  ------------------
  |  Branch (58:9): [True: 385k, False: 5.05M]
  ------------------
   59|  5.43M|    if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */
  ------------------
  |  Branch (59:9): [True: 0, False: 5.43M]
  ------------------
   60|  5.43M|    if (force_baseline && temp > 255L)
  ------------------
  |  Branch (60:9): [True: 5.43M, False: 0]
  |  Branch (60:27): [True: 691k, False: 4.74M]
  ------------------
   61|   691k|      temp = 255L;              /* limit to baseline range if requested */
   62|  5.43M|    (*qtblptr)->quantval[i] = (UINT16)temp;
   63|  5.43M|  }
   64|       |
   65|       |  /* Initialize sent_table FALSE so table will be written to JPEG file. */
   66|  84.9k|  (*qtblptr)->sent_table = FALSE;
  ------------------
  |  |  207|  84.9k|#define FALSE   0               /* values of boolean */
  ------------------
   67|  84.9k|}
jpeg_set_linear_quality:
  122|  42.4k|{
  123|       |  /* Set up two quantization tables using the specified scaling */
  124|  42.4k|  jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
  125|  42.4k|                       scale_factor, force_baseline);
  126|  42.4k|  jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
  127|  42.4k|                       scale_factor, force_baseline);
  128|  42.4k|}
jpeg_quality_scaling:
  137|  42.4k|{
  138|       |  /* Safety limit on quality factor.  Convert 0 to 1 to avoid zero divide. */
  139|  42.4k|  if (quality <= 0) quality = 1;
  ------------------
  |  Branch (139:7): [True: 0, False: 42.4k]
  ------------------
  140|  42.4k|  if (quality > 100) quality = 100;
  ------------------
  |  Branch (140:7): [True: 0, False: 42.4k]
  ------------------
  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|  42.4k|  if (quality < 50)
  ------------------
  |  Branch (148:7): [True: 9.37k, False: 33.1k]
  ------------------
  149|  9.37k|    quality = 5000 / quality;
  150|  33.1k|  else
  151|  33.1k|    quality = 200 - quality * 2;
  152|       |
  153|  42.4k|  return quality;
  154|  42.4k|}
jpeg_set_quality:
  164|  42.4k|{
  165|       |  /* Convert user 0-100 rating to percentage scaling */
  166|  42.4k|  quality = jpeg_quality_scaling(quality);
  167|       |
  168|       |  /* Set up standard quality tables */
  169|  42.4k|  jpeg_set_linear_quality(cinfo, quality, force_baseline);
  170|  42.4k|}
jpeg_set_defaults:
  185|  21.2k|{
  186|  21.2k|  int i;
  187|       |
  188|       |  /* Safety check to ensure start_compress not called yet. */
  189|  21.2k|  if (cinfo->global_state != CSTATE_START)
  ------------------
  |  |   44|  21.2k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (189:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  if (cinfo->comp_info == NULL)
  ------------------
  |  Branch (196:7): [True: 3.70k, False: 17.5k]
  ------------------
  197|  3.70k|    cinfo->comp_info = (jpeg_component_info *)
  198|  3.70k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  3.70k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  199|  3.70k|                                  MAX_COMPONENTS * sizeof(jpeg_component_info));
  ------------------
  |  |   30|  3.70k|#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|  21.2k|  jpeg_set_quality(cinfo, 75, TRUE);
  ------------------
  |  |  210|  21.2k|#define TRUE    1
  ------------------
  209|       |  /* Set up two Huffman tables */
  210|  21.2k|  std_huff_tables((j_common_ptr)cinfo);
  211|       |
  212|       |  /* Initialize default arithmetic coding conditioning */
  213|   361k|  for (i = 0; i < NUM_ARITH_TBLS; i++) {
  ------------------
  |  |   70|   361k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (213:15): [True: 339k, False: 21.2k]
  ------------------
  214|   339k|    cinfo->arith_dc_L[i] = 0;
  215|   339k|    cinfo->arith_dc_U[i] = 1;
  216|   339k|    cinfo->arith_ac_K[i] = 5;
  217|   339k|  }
  218|       |
  219|       |  /* Default is no multiple-scan output */
  220|  21.2k|  cinfo->scan_info = NULL;
  221|  21.2k|  cinfo->num_scans = 0;
  222|       |
  223|       |  /* Default is lossy output */
  224|  21.2k|  cinfo->master->lossless = FALSE;
  ------------------
  |  |  207|  21.2k|#define FALSE   0               /* values of boolean */
  ------------------
  225|       |
  226|       |  /* Expect normal source image, not raw downsampled data */
  227|  21.2k|  cinfo->raw_data_in = FALSE;
  ------------------
  |  |  207|  21.2k|#define FALSE   0               /* values of boolean */
  ------------------
  228|       |
  229|       |  /* Use Huffman coding, not arithmetic coding, by default */
  230|  21.2k|  cinfo->arith_code = FALSE;
  ------------------
  |  |  207|  21.2k|#define FALSE   0               /* values of boolean */
  ------------------
  231|       |
  232|       |  /* By default, don't do extra passes to optimize entropy coding */
  233|  21.2k|  cinfo->optimize_coding = FALSE;
  ------------------
  |  |  207|  21.2k|#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|  21.2k|  if (cinfo->data_precision == 12)
  ------------------
  |  Branch (239:7): [True: 21.2k, False: 0]
  ------------------
  240|  21.2k|    cinfo->optimize_coding = TRUE;
  ------------------
  |  |  210|  21.2k|#define TRUE    1
  ------------------
  241|       |
  242|       |  /* By default, use the simpler non-cosited sampling alignment */
  243|  21.2k|  cinfo->CCIR601_sampling = FALSE;
  ------------------
  |  |  207|  21.2k|#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|  21.2k|  cinfo->smoothing_factor = 0;
  252|       |
  253|       |  /* DCT algorithm preference */
  254|  21.2k|  cinfo->dct_method = JDCT_DEFAULT;
  ------------------
  |  |  301|  21.2k|#define JDCT_DEFAULT  JDCT_ISLOW
  ------------------
  255|       |
  256|       |  /* No restart markers */
  257|  21.2k|  cinfo->restart_interval = 0;
  258|  21.2k|  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|  21.2k|  cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */
  270|  21.2k|  cinfo->JFIF_minor_version = 1;
  271|  21.2k|  cinfo->density_unit = 0;      /* Pixel size is unknown by default */
  272|  21.2k|  cinfo->X_density = 1;         /* Pixel aspect ratio is square by default */
  273|  21.2k|  cinfo->Y_density = 1;
  274|       |
  275|       |  /* Choose JPEG colorspace based on input space, set defaults accordingly */
  276|       |
  277|  21.2k|  jpeg_default_colorspace(cinfo);
  278|  21.2k|}
jpeg_default_colorspace:
  287|  21.2k|{
  288|  21.2k|  switch (cinfo->in_color_space) {
  289|  3.51k|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (289:3): [True: 3.51k, False: 17.7k]
  ------------------
  290|  3.51k|    jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
  291|  3.51k|    break;
  292|      0|  case JCS_RGB:
  ------------------
  |  Branch (292:3): [True: 0, False: 21.2k]
  ------------------
  293|  3.01k|  case JCS_EXT_RGB:
  ------------------
  |  Branch (293:3): [True: 3.01k, False: 18.2k]
  ------------------
  294|  5.93k|  case JCS_EXT_RGBX:
  ------------------
  |  Branch (294:3): [True: 2.92k, False: 18.3k]
  ------------------
  295|  8.95k|  case JCS_EXT_BGR:
  ------------------
  |  Branch (295:3): [True: 3.01k, False: 18.2k]
  ------------------
  296|  8.95k|  case JCS_EXT_BGRX:
  ------------------
  |  Branch (296:3): [True: 0, False: 21.2k]
  ------------------
  297|  8.95k|  case JCS_EXT_XBGR:
  ------------------
  |  Branch (297:3): [True: 0, False: 21.2k]
  ------------------
  298|  11.8k|  case JCS_EXT_XRGB:
  ------------------
  |  Branch (298:3): [True: 2.92k, False: 18.3k]
  ------------------
  299|  11.8k|  case JCS_EXT_RGBA:
  ------------------
  |  Branch (299:3): [True: 0, False: 21.2k]
  ------------------
  300|  14.8k|  case JCS_EXT_BGRA:
  ------------------
  |  Branch (300:3): [True: 2.92k, False: 18.3k]
  ------------------
  301|  14.8k|  case JCS_EXT_ABGR:
  ------------------
  |  Branch (301:3): [True: 0, False: 21.2k]
  ------------------
  302|  14.8k|  case JCS_EXT_ARGB:
  ------------------
  |  Branch (302:3): [True: 0, False: 21.2k]
  ------------------
  303|  14.8k|#ifdef C_LOSSLESS_SUPPORTED
  304|  14.8k|    if (cinfo->master->lossless)
  ------------------
  |  Branch (304:9): [True: 0, False: 14.8k]
  ------------------
  305|      0|      jpeg_set_colorspace(cinfo, JCS_RGB);
  306|  14.8k|    else
  307|  14.8k|#endif
  308|  14.8k|      jpeg_set_colorspace(cinfo, JCS_YCbCr);
  309|  14.8k|    break;
  310|      0|  case JCS_YCbCr:
  ------------------
  |  Branch (310:3): [True: 0, False: 21.2k]
  ------------------
  311|      0|    jpeg_set_colorspace(cinfo, JCS_YCbCr);
  312|      0|    break;
  313|  2.92k|  case JCS_CMYK:
  ------------------
  |  Branch (313:3): [True: 2.92k, False: 18.3k]
  ------------------
  314|  2.92k|    jpeg_set_colorspace(cinfo, JCS_CMYK); /* By default, no translation */
  315|  2.92k|    break;
  316|      0|  case JCS_YCCK:
  ------------------
  |  Branch (316:3): [True: 0, False: 21.2k]
  ------------------
  317|      0|    jpeg_set_colorspace(cinfo, JCS_YCCK);
  318|      0|    break;
  319|      0|  case JCS_UNKNOWN:
  ------------------
  |  Branch (319:3): [True: 0, False: 21.2k]
  ------------------
  320|      0|    jpeg_set_colorspace(cinfo, JCS_UNKNOWN);
  321|      0|    break;
  322|      0|  default:
  ------------------
  |  Branch (322:3): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  }
  325|  21.2k|}
jpeg_set_colorspace:
  334|  42.4k|{
  335|  42.4k|  jpeg_component_info *compptr;
  336|  42.4k|  int ci;
  337|       |
  338|  42.4k|#define SET_COMP(index, id, hsamp, vsamp, quant, dctbl, actbl) \
  339|  42.4k|  (compptr = &cinfo->comp_info[index], \
  340|  42.4k|   compptr->component_id = (id), \
  341|  42.4k|   compptr->h_samp_factor = (hsamp), \
  342|  42.4k|   compptr->v_samp_factor = (vsamp), \
  343|  42.4k|   compptr->quant_tbl_no = (quant), \
  344|  42.4k|   compptr->dc_tbl_no = (dctbl), \
  345|  42.4k|   compptr->ac_tbl_no = (actbl) )
  346|       |
  347|       |  /* Safety check to ensure start_compress not called yet. */
  348|  42.4k|  if (cinfo->global_state != CSTATE_START)
  ------------------
  |  |   44|  42.4k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (348:7): [True: 0, False: 42.4k]
  ------------------
  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|  42.4k|  cinfo->jpeg_color_space = colorspace;
  356|       |
  357|  42.4k|  cinfo->write_JFIF_header = FALSE; /* No marker for non-JFIF colorspaces */
  ------------------
  |  |  207|  42.4k|#define FALSE   0               /* values of boolean */
  ------------------
  358|  42.4k|  cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */
  ------------------
  |  |  207|  42.4k|#define FALSE   0               /* values of boolean */
  ------------------
  359|       |
  360|  42.4k|  switch (colorspace) {
  361|  9.96k|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (361:3): [True: 9.96k, False: 32.5k]
  ------------------
  362|  9.96k|    cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
  ------------------
  |  |  210|  9.96k|#define TRUE    1
  ------------------
  363|  9.96k|    cinfo->num_components = 1;
  364|       |    /* JFIF specifies component ID 1 */
  365|  9.96k|    SET_COMP(0, 1, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  9.96k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  9.96k|   compptr->component_id = (id), \
  |  |  341|  9.96k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  9.96k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  9.96k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  9.96k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  9.96k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  366|  9.96k|    break;
  367|  2.92k|  case JCS_RGB:
  ------------------
  |  Branch (367:3): [True: 2.92k, False: 39.5k]
  ------------------
  368|  2.92k|    cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */
  ------------------
  |  |  210|  2.92k|#define TRUE    1
  ------------------
  369|  2.92k|    cinfo->num_components = 3;
  370|  2.92k|    SET_COMP(0, 0x52 /* 'R' */, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  2.92k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.92k|   compptr->component_id = (id), \
  |  |  341|  2.92k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.92k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.92k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.92k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.92k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  371|  2.92k|    SET_COMP(1, 0x47 /* 'G' */, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  2.92k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.92k|   compptr->component_id = (id), \
  |  |  341|  2.92k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.92k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.92k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.92k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.92k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  372|  2.92k|    SET_COMP(2, 0x42 /* 'B' */, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  2.92k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.92k|   compptr->component_id = (id), \
  |  |  341|  2.92k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.92k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.92k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.92k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.92k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  373|  2.92k|    break;
  374|  23.7k|  case JCS_YCbCr:
  ------------------
  |  Branch (374:3): [True: 23.7k, False: 18.7k]
  ------------------
  375|  23.7k|    cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
  ------------------
  |  |  210|  23.7k|#define TRUE    1
  ------------------
  376|  23.7k|    cinfo->num_components = 3;
  377|       |    /* JFIF specifies component IDs 1,2,3 */
  378|       |    /* We default to 2x2 subsamples of chrominance */
  379|  23.7k|    SET_COMP(0, 1, 2, 2, 0, 0, 0);
  ------------------
  |  |  339|  23.7k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  23.7k|   compptr->component_id = (id), \
  |  |  341|  23.7k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  23.7k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  23.7k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  23.7k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  23.7k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  380|  23.7k|    SET_COMP(1, 2, 1, 1, 1, 1, 1);
  ------------------
  |  |  339|  23.7k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  23.7k|   compptr->component_id = (id), \
  |  |  341|  23.7k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  23.7k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  23.7k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  23.7k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  23.7k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  381|  23.7k|    SET_COMP(2, 3, 1, 1, 1, 1, 1);
  ------------------
  |  |  339|  23.7k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  23.7k|   compptr->component_id = (id), \
  |  |  341|  23.7k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  23.7k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  23.7k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  23.7k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  23.7k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  382|  23.7k|    break;
  383|  2.92k|  case JCS_CMYK:
  ------------------
  |  Branch (383:3): [True: 2.92k, False: 39.5k]
  ------------------
  384|  2.92k|    cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */
  ------------------
  |  |  210|  2.92k|#define TRUE    1
  ------------------
  385|  2.92k|    cinfo->num_components = 4;
  386|  2.92k|    SET_COMP(0, 0x43 /* 'C' */, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  2.92k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.92k|   compptr->component_id = (id), \
  |  |  341|  2.92k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.92k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.92k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.92k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.92k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  387|  2.92k|    SET_COMP(1, 0x4D /* 'M' */, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  2.92k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.92k|   compptr->component_id = (id), \
  |  |  341|  2.92k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.92k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.92k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.92k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.92k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  388|  2.92k|    SET_COMP(2, 0x59 /* 'Y' */, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  2.92k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.92k|   compptr->component_id = (id), \
  |  |  341|  2.92k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.92k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.92k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.92k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.92k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  389|  2.92k|    SET_COMP(3, 0x4B /* 'K' */, 1, 1, 0, 0, 0);
  ------------------
  |  |  339|  2.92k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.92k|   compptr->component_id = (id), \
  |  |  341|  2.92k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.92k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.92k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.92k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.92k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  390|  2.92k|    break;
  391|  2.92k|  case JCS_YCCK:
  ------------------
  |  Branch (391:3): [True: 2.92k, False: 39.5k]
  ------------------
  392|  2.92k|    cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */
  ------------------
  |  |  210|  2.92k|#define TRUE    1
  ------------------
  393|  2.92k|    cinfo->num_components = 4;
  394|  2.92k|    SET_COMP(0, 1, 2, 2, 0, 0, 0);
  ------------------
  |  |  339|  2.92k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.92k|   compptr->component_id = (id), \
  |  |  341|  2.92k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.92k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.92k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.92k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.92k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  395|  2.92k|    SET_COMP(1, 2, 1, 1, 1, 1, 1);
  ------------------
  |  |  339|  2.92k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.92k|   compptr->component_id = (id), \
  |  |  341|  2.92k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.92k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.92k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.92k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.92k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  396|  2.92k|    SET_COMP(2, 3, 1, 1, 1, 1, 1);
  ------------------
  |  |  339|  2.92k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.92k|   compptr->component_id = (id), \
  |  |  341|  2.92k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.92k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.92k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.92k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.92k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  397|  2.92k|    SET_COMP(3, 4, 2, 2, 0, 0, 0);
  ------------------
  |  |  339|  2.92k|  (compptr = &cinfo->comp_info[index], \
  |  |  340|  2.92k|   compptr->component_id = (id), \
  |  |  341|  2.92k|   compptr->h_samp_factor = (hsamp), \
  |  |  342|  2.92k|   compptr->v_samp_factor = (vsamp), \
  |  |  343|  2.92k|   compptr->quant_tbl_no = (quant), \
  |  |  344|  2.92k|   compptr->dc_tbl_no = (dctbl), \
  |  |  345|  2.92k|   compptr->ac_tbl_no = (actbl) )
  ------------------
  398|  2.92k|    break;
  399|      0|  case JCS_UNKNOWN:
  ------------------
  |  Branch (399:3): [True: 0, False: 42.4k]
  ------------------
  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: 42.4k]
  ------------------
  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|  42.4k|  }
  411|  42.4k|}
jpeg_simple_progression:
  478|  6.44k|{
  479|  6.44k|  int ncomps = cinfo->num_components;
  480|  6.44k|  int nscans;
  481|  6.44k|  jpeg_scan_info *scanptr;
  482|       |
  483|       |  /* Safety check to ensure start_compress not called yet. */
  484|  6.44k|  if (cinfo->global_state != CSTATE_START)
  ------------------
  |  |   44|  6.44k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (484:7): [True: 0, False: 6.44k]
  ------------------
  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.44k|#ifdef C_LOSSLESS_SUPPORTED
  488|  6.44k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (488:7): [True: 0, False: 6.44k]
  ------------------
  489|      0|    cinfo->master->lossless = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  490|      0|    jpeg_default_colorspace(cinfo);
  491|      0|  }
  492|  6.44k|#endif
  493|       |
  494|       |  /* Figure space needed for script.  Calculation must match code below! */
  495|  6.44k|  if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
  ------------------
  |  Branch (495:7): [True: 0, False: 6.44k]
  |  Branch (495:22): [True: 0, False: 0]
  ------------------
  496|       |    /* Custom script for YCbCr color images. */
  497|      0|    nscans = 10;
  498|  6.44k|  } else {
  499|       |    /* All-purpose script for other color spaces. */
  500|  6.44k|    if (ncomps > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  6.44k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (500:9): [True: 0, False: 6.44k]
  ------------------
  501|      0|      nscans = 6 * ncomps;      /* 2 DC + 4 AC scans per component */
  502|  6.44k|    else
  503|  6.44k|      nscans = 2 + 4 * ncomps;  /* 2 DC scans; 4 AC scans per component */
  504|  6.44k|  }
  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.44k|  if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) {
  ------------------
  |  Branch (513:7): [True: 3.70k, False: 2.73k]
  |  Branch (513:38): [True: 2.73k, False: 0]
  ------------------
  514|  6.44k|    cinfo->script_space_size = MAX(nscans, 10);
  ------------------
  |  |  513|  6.44k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 2.92k, False: 3.51k]
  |  |  ------------------
  ------------------
  515|  6.44k|    cinfo->script_space = (jpeg_scan_info *)
  516|  6.44k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  6.44k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  517|  6.44k|                        cinfo->script_space_size * sizeof(jpeg_scan_info));
  518|  6.44k|  }
  519|  6.44k|  scanptr = cinfo->script_space;
  520|  6.44k|  cinfo->scan_info = scanptr;
  521|  6.44k|  cinfo->num_scans = nscans;
  522|       |
  523|  6.44k|  if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
  ------------------
  |  Branch (523:7): [True: 0, False: 6.44k]
  |  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.44k|  } else {
  544|       |    /* All-purpose script for other color spaces. */
  545|       |    /* Successive approximation first pass */
  546|  6.44k|    scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
  547|  6.44k|    scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2);
  548|  6.44k|    scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2);
  549|       |    /* Successive approximation second pass */
  550|  6.44k|    scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1);
  551|       |    /* Successive approximation final pass */
  552|  6.44k|    scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
  553|  6.44k|    scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
  554|  6.44k|  }
  555|  6.44k|}
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|  43.3k|    for (ci = 0; ci < ncomps; ci++)
  ------------------
  |  Branch (457:18): [True: 30.4k, False: 12.8k]
  ------------------
  458|  30.4k|      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|  86.6k|  for (ci = 0; ci < ncomps; ci++) {
  ------------------
  |  Branch (436:16): [True: 60.9k, False: 25.7k]
  ------------------
  437|  60.9k|    scanptr->comps_in_scan = 1;
  438|  60.9k|    scanptr->component_index[0] = ci;
  439|  60.9k|    scanptr->Ss = Ss;
  440|  60.9k|    scanptr->Se = Se;
  441|  60.9k|    scanptr->Ah = Ah;
  442|  60.9k|    scanptr->Al = Al;
  443|  60.9k|    scanptr++;
  444|  60.9k|  }
  445|  25.7k|  return scanptr;
  446|  25.7k|}

jinit_phuff_encoder:
 1081|  3.51k|{
 1082|  3.51k|  phuff_entropy_ptr entropy;
 1083|  3.51k|  int i;
 1084|       |
 1085|  3.51k|  entropy = (phuff_entropy_ptr)
 1086|  3.51k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  3.51k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
 1087|  3.51k|                                sizeof(phuff_entropy_encoder));
 1088|  3.51k|  cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
 1089|  3.51k|  entropy->pub.start_pass = start_pass_phuff;
 1090|       |
 1091|       |  /* Mark tables unallocated */
 1092|  17.5k|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|  17.5k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (1092:15): [True: 14.0k, False: 3.51k]
  ------------------
 1093|  14.0k|    entropy->derived_tbls[i] = NULL;
 1094|  14.0k|    entropy->count_ptrs[i] = NULL;
 1095|  14.0k|  }
 1096|       |  entropy->bit_buffer = NULL;   /* needed only in AC refinement scan */
 1097|  3.51k|}
jcphuff.c:start_pass_phuff:
  179|  38.6k|{
  180|  38.6k|  phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
  181|  38.6k|  boolean is_DC_band;
  182|  38.6k|  int ci, tbl;
  183|  38.6k|  jpeg_component_info *compptr;
  184|       |
  185|  38.6k|  entropy->cinfo = cinfo;
  186|  38.6k|  entropy->gather_statistics = gather_statistics;
  187|       |
  188|  38.6k|  is_DC_band = (cinfo->Ss == 0);
  189|       |
  190|       |  /* We assume jcmaster.c already validated the scan parameters. */
  191|       |
  192|       |  /* Select execution routines */
  193|  38.6k|  if (cinfo->Ah == 0) {
  ------------------
  |  Branch (193:7): [True: 21.1k, False: 17.5k]
  ------------------
  194|  21.1k|    if (is_DC_band)
  ------------------
  |  Branch (194:9): [True: 7.03k, False: 14.0k]
  ------------------
  195|  7.03k|      entropy->pub.encode_mcu = encode_mcu_DC_first;
  196|  14.0k|    else
  197|  14.0k|      entropy->pub.encode_mcu = encode_mcu_AC_first;
  198|  21.1k|#ifdef WITH_SIMD
  199|  21.1k|    if (!jsimd_set_encode_mcu_AC_first_prepare(cinfo,
  ------------------
  |  Branch (199:9): [True: 0, False: 21.1k]
  ------------------
  200|  21.1k|                                               &entropy->AC_first_prepare))
  201|      0|#endif
  202|      0|      entropy->AC_first_prepare = encode_mcu_AC_first_prepare;
  203|  21.1k|  } else {
  204|  17.5k|    if (is_DC_band)
  ------------------
  |  Branch (204:9): [True: 3.51k, False: 14.0k]
  ------------------
  205|  3.51k|      entropy->pub.encode_mcu = encode_mcu_DC_refine;
  206|  14.0k|    else {
  207|  14.0k|      entropy->pub.encode_mcu = encode_mcu_AC_refine;
  208|  14.0k|#ifdef WITH_SIMD
  209|  14.0k|      if (!jsimd_set_encode_mcu_AC_refine_prepare(cinfo,
  ------------------
  |  Branch (209:11): [True: 0, False: 14.0k]
  ------------------
  210|  14.0k|                                                  &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.0k|      if (entropy->bit_buffer == NULL)
  ------------------
  |  Branch (214:11): [True: 3.51k, False: 10.5k]
  ------------------
  215|  3.51k|        entropy->bit_buffer = (char *)
  216|  3.51k|          (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  3.51k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  217|  3.51k|                                      MAX_CORR_BITS);
  ------------------
  |  |  106|  3.51k|#define MAX_CORR_BITS  1000     /* Max # of correction bits I can buffer */
  ------------------
  218|  14.0k|    }
  219|  17.5k|  }
  220|  38.6k|  if (gather_statistics)
  ------------------
  |  Branch (220:7): [True: 17.5k, False: 21.1k]
  ------------------
  221|  17.5k|    entropy->pub.finish_pass = finish_pass_gather_phuff;
  222|  21.1k|  else
  223|  21.1k|    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|  77.3k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (228:16): [True: 38.6k, False: 38.6k]
  ------------------
  229|  38.6k|    compptr = cinfo->cur_comp_info[ci];
  230|       |    /* Initialize DC predictions to 0 */
  231|  38.6k|    entropy->last_dc_val[ci] = 0;
  232|       |    /* Get table index */
  233|  38.6k|    if (is_DC_band) {
  ------------------
  |  Branch (233:9): [True: 10.5k, False: 28.1k]
  ------------------
  234|  10.5k|      if (cinfo->Ah != 0)       /* DC refinement needs no table */
  ------------------
  |  Branch (234:11): [True: 3.51k, False: 7.03k]
  ------------------
  235|  3.51k|        continue;
  236|  7.03k|      tbl = compptr->dc_tbl_no;
  237|  28.1k|    } else {
  238|  28.1k|      entropy->ac_tbl_no = tbl = compptr->ac_tbl_no;
  239|  28.1k|    }
  240|  35.1k|    if (gather_statistics) {
  ------------------
  |  Branch (240:9): [True: 17.5k, False: 17.5k]
  ------------------
  241|       |      /* Check for invalid table index */
  242|       |      /* (make_c_derived_tbl does this in the other path) */
  243|  17.5k|      if (tbl < 0 || tbl >= NUM_HUFF_TBLS)
  ------------------
  |  |   69|  17.5k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (243:11): [True: 0, False: 17.5k]
  |  Branch (243:22): [True: 0, False: 17.5k]
  ------------------
  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.5k|      if (entropy->count_ptrs[tbl] == NULL)
  ------------------
  |  Branch (247:11): [True: 3.51k, False: 14.0k]
  ------------------
  248|  3.51k|        entropy->count_ptrs[tbl] = (long *)
  249|  3.51k|          (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  3.51k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  250|  3.51k|                                      257 * sizeof(long));
  251|  17.5k|      memset(entropy->count_ptrs[tbl], 0, 257 * sizeof(long));
  252|  17.5k|    } 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.5k|      jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl,
  256|  17.5k|                              &entropy->derived_tbls[tbl]);
  257|  17.5k|    }
  258|  35.1k|  }
  259|       |
  260|       |  /* Initialize AC stuff */
  261|  38.6k|  entropy->EOBRUN = 0;
  262|  38.6k|  entropy->BE = 0;
  263|       |
  264|       |  /* Initialize bit buffer to empty */
  265|  38.6k|  entropy->put_buffer = 0;
  266|  38.6k|  entropy->put_bits = 0;
  267|       |
  268|       |  /* Initialize restart stuff */
  269|  38.6k|  entropy->restarts_to_go = cinfo->restart_interval;
  270|  38.6k|  entropy->next_restart_num = 0;
  271|  38.6k|}
jcphuff.c:encode_mcu_DC_first:
  457|  1.95M|{
  458|  1.95M|  phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
  459|  1.95M|  register int temp, temp2, temp3;
  460|  1.95M|  register int nbits;
  461|  1.95M|  int blkn, ci;
  462|  1.95M|  int Al = cinfo->Al;
  463|  1.95M|  JBLOCKROW block;
  464|  1.95M|  jpeg_component_info *compptr;
  465|  1.95M|  ISHIFT_TEMPS
  466|  1.95M|  int max_coef_bits = cinfo->data_precision + 2;
  467|       |
  468|  1.95M|  entropy->next_output_byte = cinfo->dest->next_output_byte;
  469|  1.95M|  entropy->free_in_buffer = cinfo->dest->free_in_buffer;
  470|       |
  471|       |  /* Emit restart marker if needed */
  472|  1.95M|  if (cinfo->restart_interval)
  ------------------
  |  Branch (472:7): [True: 0, False: 1.95M]
  ------------------
  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|  3.90M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (477:18): [True: 1.95M, False: 1.95M]
  ------------------
  478|  1.95M|    block = MCU_data[blkn];
  479|  1.95M|    ci = cinfo->MCU_membership[blkn];
  480|  1.95M|    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|  1.95M|    temp2 = IRIGHT_SHIFT((int)((*block)[0]), Al);
  ------------------
  |  |  121|  1.95M|#define IRIGHT_SHIFT(x, shft)   ((x) >> (shft))
  ------------------
  486|       |
  487|       |    /* DC differences are figured on the point-transformed values. */
  488|  1.95M|    temp = temp2 - entropy->last_dc_val[ci];
  489|  1.95M|    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|  1.95M|    temp3 = temp >> (CHAR_BIT * sizeof(int) - 1);
  499|  1.95M|    temp ^= temp3;
  500|  1.95M|    temp -= temp3;              /* temp is abs value of input */
  501|       |    /* For a negative input, want temp2 = bitwise complement of abs(input) */
  502|  1.95M|    temp2 = temp ^ temp3;
  503|       |
  504|       |    /* Find the number of bits needed for the magnitude of the coefficient */
  505|  1.95M|    nbits = JPEG_NBITS(temp);
  ------------------
  |  |   41|  1.95M|#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|  1.95M|    if (nbits > max_coef_bits + 1)
  ------------------
  |  Branch (509:9): [True: 0, False: 1.95M]
  ------------------
  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|  1.95M|    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|  1.95M|    if (nbits)                  /* emit_bits rejects calls with size 0 */
  ------------------
  |  Branch (517:9): [True: 1.01M, False: 937k]
  ------------------
  518|  1.01M|      emit_bits(entropy, (unsigned int)temp2, nbits);
  519|  1.95M|  }
  520|       |
  521|  1.95M|  cinfo->dest->next_output_byte = entropy->next_output_byte;
  522|  1.95M|  cinfo->dest->free_in_buffer = entropy->free_in_buffer;
  523|       |
  524|       |  /* Update restart-interval state too */
  525|  1.95M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (525:7): [True: 0, False: 1.95M]
  ------------------
  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|  1.95M|  return TRUE;
  ------------------
  |  |  210|  1.95M|#define TRUE    1
  ------------------
  535|  1.95M|}
jcphuff.c:emit_eobrun:
  398|  19.4M|{
  399|  19.4M|  register int temp, nbits;
  400|       |
  401|  19.4M|  if (entropy->EOBRUN > 0) {    /* if there is any pending EOBRUN */
  ------------------
  |  Branch (401:7): [True: 2.58M, False: 16.8M]
  ------------------
  402|  2.58M|    temp = entropy->EOBRUN;
  403|  2.58M|    nbits = JPEG_NBITS_NONZERO(temp) - 1;
  ------------------
  |  |   42|  2.58M|#define JPEG_NBITS_NONZERO(x)  JPEG_NBITS(x)
  |  |  ------------------
  |  |  |  |   41|  2.58M|#define JPEG_NBITS(x)          (jpeg_nbits_table[x])
  |  |  ------------------
  ------------------
  404|       |    /* safety check: shouldn't happen given limited correction-bit buffer */
  405|  2.58M|    if (nbits > 14)
  ------------------
  |  Branch (405:9): [True: 0, False: 2.58M]
  ------------------
  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.58M|    emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4);
  409|  2.58M|    if (nbits)
  ------------------
  |  Branch (409:9): [True: 345k, False: 2.23M]
  ------------------
  410|   345k|      emit_bits(entropy, entropy->EOBRUN, nbits);
  411|       |
  412|  2.58M|    entropy->EOBRUN = 0;
  413|       |
  414|       |    /* Emit any buffered correction bits */
  415|  2.58M|    emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE);
  416|  2.58M|    entropy->BE = 0;
  417|  2.58M|  }
  418|  19.4M|}
jcphuff.c:emit_buffered_bits:
  380|  20.6M|{
  381|  20.6M|  if (entropy->gather_statistics)
  ------------------
  |  Branch (381:7): [True: 10.3M, False: 10.3M]
  ------------------
  382|  10.3M|    return;                     /* no real work */
  383|       |
  384|  32.1M|  while (nbits > 0) {
  ------------------
  |  Branch (384:10): [True: 21.7M, False: 10.3M]
  ------------------
  385|  21.7M|    emit_bits(entropy, (unsigned int)(*bufstart), 1);
  386|  21.7M|    bufstart++;
  387|  21.7M|    nbits--;
  388|  21.7M|  }
  389|  10.3M|}
jcphuff.c:flush_bits:
  350|  21.1k|{
  351|  21.1k|  emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */
  352|  21.1k|  entropy->put_buffer = 0;     /* and reset bit-buffer to empty */
  353|  21.1k|  entropy->put_bits = 0;
  354|  21.1k|}
jcphuff.c:dump_buffer:
  290|    504|{
  291|    504|  struct jpeg_destination_mgr *dest = entropy->cinfo->dest;
  292|       |
  293|    504|  if (!(*dest->empty_output_buffer) (entropy->cinfo))
  ------------------
  |  Branch (293:7): [True: 0, False: 504]
  ------------------
  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|    504|  entropy->next_output_byte = dest->next_output_byte;
  297|    504|  entropy->free_in_buffer = dest->free_in_buffer;
  298|    504|}
jcphuff.c:emit_symbol:
  363|  39.8M|{
  364|  39.8M|  if (entropy->gather_statistics)
  ------------------
  |  Branch (364:7): [True: 19.9M, False: 19.9M]
  ------------------
  365|  19.9M|    entropy->count_ptrs[tbl_no][symbol]++;
  366|  19.9M|  else {
  367|  19.9M|    c_derived_tbl *tbl = entropy->derived_tbls[tbl_no];
  368|  19.9M|    emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]);
  369|  19.9M|  }
  370|  39.8M|}
jcphuff.c:emit_bits:
  312|  79.1M|{
  313|       |  /* This routine is heavily used, so it's worth coding tightly. */
  314|  79.1M|  register size_t put_buffer = (size_t)code;
  315|  79.1M|  register int put_bits = entropy->put_bits;
  316|       |
  317|       |  /* if size is 0, caller used an invalid Huffman table entry */
  318|  79.1M|  if (size == 0)
  ------------------
  |  Branch (318:7): [True: 0, False: 79.1M]
  ------------------
  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|  79.1M|  if (entropy->gather_statistics)
  ------------------
  |  Branch (321:7): [True: 18.2M, False: 60.9M]
  ------------------
  322|  18.2M|    return;                     /* do nothing if we're only getting stats */
  323|       |
  324|  60.9M|  put_buffer &= (((size_t)1) << size) - 1; /* mask off any extra bits in code */
  325|       |
  326|  60.9M|  put_bits += size;             /* new number of bits in buffer */
  327|       |
  328|  60.9M|  put_buffer <<= 24 - put_bits; /* align incoming bits */
  329|       |
  330|  60.9M|  put_buffer |= entropy->put_buffer; /* and merge with old buffer contents */
  331|       |
  332|  74.4M|  while (put_bits >= 8) {
  ------------------
  |  Branch (332:10): [True: 13.4M, False: 60.9M]
  ------------------
  333|  13.4M|    int c = (int)((put_buffer >> 16) & 0xFF);
  334|       |
  335|  13.4M|    emit_byte(entropy, c);
  ------------------
  |  |  280|  13.4M|#define emit_byte(entropy, val) { \
  |  |  281|  13.4M|  *(entropy)->next_output_byte++ = (JOCTET)(val); \
  |  |  282|  13.4M|  if (--(entropy)->free_in_buffer == 0) \
  |  |  ------------------
  |  |  |  Branch (282:7): [True: 493, False: 13.4M]
  |  |  ------------------
  |  |  283|  13.4M|    dump_buffer(entropy); \
  |  |  284|  13.4M|}
  ------------------
  336|  13.4M|    if (c == 0xFF) {            /* need to stuff a zero byte? */
  ------------------
  |  Branch (336:9): [True: 93.7k, False: 13.3M]
  ------------------
  337|  93.7k|      emit_byte(entropy, 0);
  ------------------
  |  |  280|  93.7k|#define emit_byte(entropy, val) { \
  |  |  281|  93.7k|  *(entropy)->next_output_byte++ = (JOCTET)(val); \
  |  |  282|  93.7k|  if (--(entropy)->free_in_buffer == 0) \
  |  |  ------------------
  |  |  |  Branch (282:7): [True: 11, False: 93.7k]
  |  |  ------------------
  |  |  283|  93.7k|    dump_buffer(entropy); \
  |  |  284|  93.7k|}
  ------------------
  338|  93.7k|    }
  339|  13.4M|    put_buffer <<= 8;
  340|  13.4M|    put_bits -= 8;
  341|  13.4M|  }
  342|       |
  343|  60.9M|  entropy->put_buffer = put_buffer; /* update variables */
  344|  60.9M|  entropy->put_bits = put_bits;
  345|  60.9M|}
jcphuff.c:encode_mcu_AC_first:
  637|  3.90M|{
  638|  3.90M|  phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
  639|  3.90M|  register int temp, temp2;
  640|  3.90M|  register int nbits, r;
  641|  3.90M|  int Sl = cinfo->Se - cinfo->Ss + 1;
  642|  3.90M|  int Al = cinfo->Al;
  643|  3.90M|  UJCOEF values_unaligned[2 * DCTSIZE2 + 15];
  644|  3.90M|  UJCOEF *values;
  645|  3.90M|  const UJCOEF *cvalue;
  646|  3.90M|  size_t zerobits;
  647|  3.90M|  size_t bits[8 / SIZEOF_SIZE_T];
  648|  3.90M|  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|  3.90M|  entropy->next_output_byte = cinfo->dest->next_output_byte;
  656|  3.90M|  entropy->free_in_buffer = cinfo->dest->free_in_buffer;
  657|       |
  658|       |  /* Emit restart marker if needed */
  659|  3.90M|  if (cinfo->restart_interval)
  ------------------
  |  Branch (659:7): [True: 0, False: 3.90M]
  ------------------
  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|  3.90M|#ifdef WITH_SIMD
  664|  3.90M|  cvalue = values = (UJCOEF *)PAD((JUINTPTR)values_unaligned, 16);
  ------------------
  |  |  124|  3.90M|#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|  3.90M|  entropy->AC_first_prepare(MCU_data[0][0], jpeg_natural_order + cinfo->Ss,
  672|  3.90M|                            Sl, Al, values, bits);
  673|       |
  674|  3.90M|  zerobits = bits[0];
  675|       |#if SIZEOF_SIZE_T == 4
  676|       |  zerobits |= bits[1];
  677|       |#endif
  678|       |
  679|       |  /* Emit any pending EOBRUN */
  680|  3.90M|  if (zerobits && (entropy->EOBRUN > 0))
  ------------------
  |  Branch (680:7): [True: 2.01M, False: 1.88M]
  |  Branch (680:19): [True: 1.28M, False: 730k]
  ------------------
  681|  1.28M|    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|  3.90M|  ENCODE_COEFS_AC_FIRST((void)0;);
  ------------------
  |  |  603|  3.90M|#define ENCODE_COEFS_AC_FIRST(label) { \
  |  |  604|  21.1M|  while (zerobits) { \
  |  |  ------------------
  |  |  |  Branch (604:10): [True: 17.2M, False: 3.90M]
  |  |  ------------------
  |  |  605|  17.2M|    r = count_zeroes(&zerobits); \
  |  |  606|  17.2M|    cvalue += r; \
  |  |  607|  17.2M|label \
  |  |  608|  17.2M|    temp  = cvalue[0]; \
  |  |  609|  17.2M|    temp2 = cvalue[DCTSIZE2]; \
  |  |  ------------------
  |  |  |  |   67|  17.2M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  |  |  ------------------
  |  |  610|  17.2M|    \
  |  |  611|  17.2M|    /* if run length > 15, must emit special run-length-16 codes (0xF0) */ \
  |  |  612|  17.2M|    while (r > 15) { \
  |  |  ------------------
  |  |  |  Branch (612:12): [True: 17.3k, False: 17.2M]
  |  |  ------------------
  |  |  613|  17.3k|      emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); \
  |  |  614|  17.3k|      r -= 16; \
  |  |  615|  17.3k|    } \
  |  |  616|  17.2M|    \
  |  |  617|  17.2M|    /* Find the number of bits needed for the magnitude of the coefficient */ \
  |  |  618|  17.2M|    nbits = JPEG_NBITS_NONZERO(temp);  /* there must be at least one 1 bit */ \
  |  |  ------------------
  |  |  |  |   42|  17.2M|#define JPEG_NBITS_NONZERO(x)  JPEG_NBITS(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  17.2M|#define JPEG_NBITS(x)          (jpeg_nbits_table[x])
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  619|  17.2M|    /* Check for out-of-range coefficient values */ \
  |  |  620|  17.2M|    if (nbits > max_coef_bits) \
  |  |  ------------------
  |  |  |  Branch (620:9): [True: 0, False: 17.2M]
  |  |  ------------------
  |  |  621|  17.2M|      ERREXIT(cinfo, JERR_BAD_DCT_COEF); \
  |  |  ------------------
  |  |  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  |  |  ------------------
  |  |  622|  17.2M|    \
  |  |  623|  17.2M|    /* Count/emit Huffman symbol for run length / number of bits */ \
  |  |  624|  17.2M|    emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); \
  |  |  625|  17.2M|    \
  |  |  626|  17.2M|    /* Emit that number of bits of the value, if positive, */ \
  |  |  627|  17.2M|    /* or the complement of its magnitude, if negative. */ \
  |  |  628|  17.2M|    emit_bits(entropy, (unsigned int)temp2, nbits); \
  |  |  629|  17.2M|    \
  |  |  630|  17.2M|    cvalue++; \
  |  |  631|  17.2M|    zerobits >>= 1; \
  |  |  632|  17.2M|  } \
  |  |  633|  3.90M|}
  ------------------
  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|  3.90M|  if (cvalue < (values + Sl)) { /* If there are trailing zeroes, */
  ------------------
  |  Branch (704:7): [True: 3.14M, False: 756k]
  ------------------
  705|  3.14M|    entropy->EOBRUN++;          /* count an EOB */
  706|  3.14M|    if (entropy->EOBRUN == 0x7FFF)
  ------------------
  |  Branch (706:9): [True: 0, False: 3.14M]
  ------------------
  707|      0|      emit_eobrun(entropy);     /* force it out to avoid overflow */
  708|  3.14M|  }
  709|       |
  710|  3.90M|  cinfo->dest->next_output_byte = entropy->next_output_byte;
  711|  3.90M|  cinfo->dest->free_in_buffer = entropy->free_in_buffer;
  712|       |
  713|       |  /* Update restart-interval state too */
  714|  3.90M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (714:7): [True: 0, False: 3.90M]
  ------------------
  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|  3.90M|  return TRUE;
  ------------------
  |  |  210|  3.90M|#define TRUE    1
  ------------------
  724|  3.90M|}
jcphuff.c:count_zeroes:
  149|  78.6M|{
  150|  78.6M|#if defined(HAVE_BUILTIN_CTZL)
  151|  78.6M|  int result;
  152|  78.6M|  result = __builtin_ctzl(*x);
  153|  78.6M|  *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|  78.6M|  return (int)result;
  170|  78.6M|}
jcphuff.c:encode_mcu_DC_refine:
  735|   976k|{
  736|   976k|  phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
  737|   976k|  register int temp;
  738|   976k|  int blkn;
  739|   976k|  int Al = cinfo->Al;
  740|   976k|  JBLOCKROW block;
  741|       |
  742|   976k|  entropy->next_output_byte = cinfo->dest->next_output_byte;
  743|   976k|  entropy->free_in_buffer = cinfo->dest->free_in_buffer;
  744|       |
  745|       |  /* Emit restart marker if needed */
  746|   976k|  if (cinfo->restart_interval)
  ------------------
  |  Branch (746:7): [True: 0, False: 976k]
  ------------------
  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|  1.95M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (751:18): [True: 976k, False: 976k]
  ------------------
  752|   976k|    block = MCU_data[blkn];
  753|       |
  754|       |    /* We simply emit the Al'th bit of the DC coefficient value. */
  755|   976k|    temp = (*block)[0];
  756|   976k|    emit_bits(entropy, (unsigned int)(temp >> Al), 1);
  757|   976k|  }
  758|       |
  759|   976k|  cinfo->dest->next_output_byte = entropy->next_output_byte;
  760|   976k|  cinfo->dest->free_in_buffer = entropy->free_in_buffer;
  761|       |
  762|       |  /* Update restart-interval state too */
  763|   976k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (763:7): [True: 0, False: 976k]
  ------------------
  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|   976k|  return TRUE;
  ------------------
  |  |  210|   976k|#define TRUE    1
  ------------------
  773|   976k|}
jcphuff.c:encode_mcu_AC_refine:
  907|  3.90M|{
  908|  3.90M|  phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
  909|  3.90M|  register int temp, r, idx;
  910|  3.90M|  char *BR_buffer;
  911|  3.90M|  unsigned int BR;
  912|  3.90M|  int Sl = cinfo->Se - cinfo->Ss + 1;
  913|  3.90M|  int Al = cinfo->Al;
  914|  3.90M|  UJCOEF absvalues_unaligned[DCTSIZE2 + 15];
  915|  3.90M|  UJCOEF *absvalues;
  916|  3.90M|  const UJCOEF *cabsvalue, *EOBPTR;
  917|  3.90M|  size_t zerobits, signbits;
  918|  3.90M|  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|  3.90M|  entropy->next_output_byte = cinfo->dest->next_output_byte;
  926|  3.90M|  entropy->free_in_buffer = cinfo->dest->free_in_buffer;
  927|       |
  928|       |  /* Emit restart marker if needed */
  929|  3.90M|  if (cinfo->restart_interval)
  ------------------
  |  Branch (929:7): [True: 0, False: 3.90M]
  ------------------
  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|  3.90M|#ifdef WITH_SIMD
  934|  3.90M|  cabsvalue = absvalues = (UJCOEF *)PAD((JUINTPTR)absvalues_unaligned, 16);
  ------------------
  |  |  124|  3.90M|#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|  3.90M|  EOBPTR = absvalues +
  942|  3.90M|    entropy->AC_refine_prepare(MCU_data[0][0], jpeg_natural_order + cinfo->Ss,
  943|  3.90M|                               Sl, Al, absvalues, bits);
  944|       |
  945|       |  /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */
  946|       |
  947|  3.90M|  r = 0;                        /* r = run length of zeros */
  948|  3.90M|  BR = 0;                       /* BR = count of buffered bits added now */
  949|  3.90M|  BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */
  950|       |
  951|  3.90M|  zerobits = bits[0];
  952|  3.90M|#if SIZEOF_SIZE_T == 8
  953|  3.90M|  signbits = bits[1];
  954|       |#else
  955|       |  signbits = bits[2];
  956|       |#endif
  957|  3.90M|  ENCODE_COEFS_AC_REFINE((void)0;);
  ------------------
  |  |  850|  3.90M|#define ENCODE_COEFS_AC_REFINE(label) { \
  |  |  851|  65.3M|  while (zerobits) { \
  |  |  ------------------
  |  |  |  Branch (851:10): [True: 61.4M, False: 3.90M]
  |  |  ------------------
  |  |  852|  61.4M|    idx = count_zeroes(&zerobits); \
  |  |  853|  61.4M|    r += idx; \
  |  |  854|  61.4M|    cabsvalue += idx; \
  |  |  855|  61.4M|    signbits >>= idx; \
  |  |  856|  61.4M|label \
  |  |  857|  61.4M|    /* Emit any required ZRLs, but not if they can be folded into EOB */ \
  |  |  858|  61.6M|    while (r > 15 && (cabsvalue <= EOBPTR)) { \
  |  |  ------------------
  |  |  |  Branch (858:12): [True: 965k, False: 60.6M]
  |  |  |  Branch (858:22): [True: 163k, False: 801k]
  |  |  ------------------
  |  |  859|   163k|      /* emit any pending EOBRUN and the BE correction bits */ \
  |  |  860|   163k|      emit_eobrun(entropy); \
  |  |  861|   163k|      /* Emit ZRL */ \
  |  |  862|   163k|      emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); \
  |  |  863|   163k|      r -= 16; \
  |  |  864|   163k|      /* Emit buffered correction bits that must be associated with ZRL */ \
  |  |  865|   163k|      emit_buffered_bits(entropy, BR_buffer, BR); \
  |  |  866|   163k|      BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ \
  |  |  867|   163k|      BR = 0; \
  |  |  868|   163k|    } \
  |  |  869|  61.4M|    \
  |  |  870|  61.4M|    temp = *cabsvalue++; \
  |  |  871|  61.4M|    \
  |  |  872|  61.4M|    /* If the coef was previously nonzero, it only needs a correction bit. \
  |  |  873|  61.4M|     * NOTE: a straight translation of the spec's figure G.7 would suggest \
  |  |  874|  61.4M|     * that we also need to test r > 15.  But if r > 15, we can only get here \
  |  |  875|  61.4M|     * if k > EOB, which implies that this coefficient is not 1. \
  |  |  876|  61.4M|     */ \
  |  |  877|  61.4M|    if (temp > 1) { \
  |  |  ------------------
  |  |  |  Branch (877:9): [True: 43.5M, False: 17.9M]
  |  |  ------------------
  |  |  878|  43.5M|      /* The correction bit is the next bit of the absolute value. */ \
  |  |  879|  43.5M|      BR_buffer[BR++] = (char)(temp & 1); \
  |  |  880|  43.5M|      signbits >>= 1; \
  |  |  881|  43.5M|      zerobits >>= 1; \
  |  |  882|  43.5M|      continue; \
  |  |  883|  43.5M|    } \
  |  |  884|  61.4M|    \
  |  |  885|  61.4M|    /* Emit any pending EOBRUN and the BE correction bits */ \
  |  |  886|  61.4M|    emit_eobrun(entropy); \
  |  |  887|  17.9M|    \
  |  |  888|  17.9M|    /* Count/emit Huffman symbol for run length / number of bits */ \
  |  |  889|  17.9M|    emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); \
  |  |  890|  17.9M|    \
  |  |  891|  17.9M|    /* Emit output bit for newly-nonzero coef */ \
  |  |  892|  17.9M|    temp = signbits & 1; /* ((*block)[jpeg_natural_order_start[k]] < 0) ? 0 : 1 */ \
  |  |  893|  17.9M|    emit_bits(entropy, (unsigned int)temp, 1); \
  |  |  894|  17.9M|    \
  |  |  895|  17.9M|    /* Emit buffered correction bits that must be associated with this code */ \
  |  |  896|  17.9M|    emit_buffered_bits(entropy, BR_buffer, BR); \
  |  |  897|  17.9M|    BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ \
  |  |  898|  17.9M|    BR = 0; \
  |  |  899|  17.9M|    r = 0;                      /* reset zero run length */ \
  |  |  900|  17.9M|    signbits >>= 1; \
  |  |  901|  17.9M|    zerobits >>= 1; \
  |  |  902|  17.9M|  } \
  |  |  903|  3.90M|}
  ------------------
  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|  3.90M|  r |= (int)((absvalues + Sl) - cabsvalue);
  977|       |
  978|  3.90M|  if (r > 0 || BR > 0) {        /* If there are trailing zeroes, */
  ------------------
  |  Branch (978:7): [True: 3.51M, False: 393k]
  |  Branch (978:16): [True: 131k, False: 262k]
  ------------------
  979|  3.64M|    entropy->EOBRUN++;          /* count an EOB */
  980|  3.64M|    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|  3.64M|    if (entropy->EOBRUN == 0x7FFF ||
  ------------------
  |  Branch (985:9): [True: 0, False: 3.64M]
  ------------------
  986|  3.64M|        entropy->BE > (MAX_CORR_BITS - DCTSIZE2 + 1))
  ------------------
  |  |  106|  3.64M|#define MAX_CORR_BITS  1000     /* Max # of correction bits I can buffer */
  ------------------
                      entropy->BE > (MAX_CORR_BITS - DCTSIZE2 + 1))
  ------------------
  |  |   67|  3.64M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (986:9): [True: 746, False: 3.64M]
  ------------------
  987|    746|      emit_eobrun(entropy);
  988|  3.64M|  }
  989|       |
  990|  3.90M|  cinfo->dest->next_output_byte = entropy->next_output_byte;
  991|  3.90M|  cinfo->dest->free_in_buffer = entropy->free_in_buffer;
  992|       |
  993|       |  /* Update restart-interval state too */
  994|  3.90M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (994:7): [True: 0, False: 3.90M]
  ------------------
  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|  3.90M|  return TRUE;
  ------------------
  |  |  210|  3.90M|#define TRUE    1
  ------------------
 1004|  3.90M|}
jcphuff.c:finish_pass_gather_phuff:
 1034|  17.5k|{
 1035|  17.5k|  phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
 1036|  17.5k|  boolean is_DC_band;
 1037|  17.5k|  int ci, tbl;
 1038|  17.5k|  jpeg_component_info *compptr;
 1039|  17.5k|  JHUFF_TBL **htblptr;
 1040|  17.5k|  boolean did[NUM_HUFF_TBLS];
 1041|       |
 1042|       |  /* Flush out buffered data (all we care about is counting the EOB symbol) */
 1043|  17.5k|  emit_eobrun(entropy);
 1044|       |
 1045|  17.5k|  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.5k|  memset(did, 0, sizeof(did));
 1051|       |
 1052|  35.1k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (1052:16): [True: 17.5k, False: 17.5k]
  ------------------
 1053|  17.5k|    compptr = cinfo->cur_comp_info[ci];
 1054|  17.5k|    if (is_DC_band) {
  ------------------
  |  Branch (1054:9): [True: 3.51k, False: 14.0k]
  ------------------
 1055|  3.51k|      if (cinfo->Ah != 0)       /* DC refinement needs no table */
  ------------------
  |  Branch (1055:11): [True: 0, False: 3.51k]
  ------------------
 1056|      0|        continue;
 1057|  3.51k|      tbl = compptr->dc_tbl_no;
 1058|  14.0k|    } else {
 1059|  14.0k|      tbl = compptr->ac_tbl_no;
 1060|  14.0k|    }
 1061|  17.5k|    if (!did[tbl]) {
  ------------------
  |  Branch (1061:9): [True: 17.5k, False: 0]
  ------------------
 1062|  17.5k|      if (is_DC_band)
  ------------------
  |  Branch (1062:11): [True: 3.51k, False: 14.0k]
  ------------------
 1063|  3.51k|        htblptr = &cinfo->dc_huff_tbl_ptrs[tbl];
 1064|  14.0k|      else
 1065|  14.0k|        htblptr = &cinfo->ac_huff_tbl_ptrs[tbl];
 1066|  17.5k|      if (*htblptr == NULL)
  ------------------
  |  Branch (1066:11): [True: 0, False: 17.5k]
  ------------------
 1067|      0|        *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
 1068|  17.5k|      jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]);
 1069|  17.5k|      did[tbl] = TRUE;
  ------------------
  |  |  210|  17.5k|#define TRUE    1
  ------------------
 1070|  17.5k|    }
 1071|  17.5k|  }
 1072|  17.5k|}
jcphuff.c:finish_pass_phuff:
 1013|  21.1k|{
 1014|  21.1k|  phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
 1015|       |
 1016|  21.1k|  entropy->next_output_byte = cinfo->dest->next_output_byte;
 1017|  21.1k|  entropy->free_in_buffer = cinfo->dest->free_in_buffer;
 1018|       |
 1019|       |  /* Flush out any buffered data */
 1020|  21.1k|  emit_eobrun(entropy);
 1021|  21.1k|  flush_bits(entropy);
 1022|       |
 1023|  21.1k|  cinfo->dest->next_output_byte = entropy->next_output_byte;
 1024|  21.1k|  cinfo->dest->free_in_buffer = entropy->free_in_buffer;
 1025|  21.1k|}

j12init_c_prep_controller:
  356|  21.2k|{
  357|  21.2k|  my_prep_ptr prep;
  358|  21.2k|  int ci;
  359|  21.2k|  jpeg_component_info *compptr;
  360|  21.2k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  21.2k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (360:19): [True: 0, False: 21.2k]
  ------------------
  361|       |
  362|  21.2k|#ifdef C_LOSSLESS_SUPPORTED
  363|  21.2k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (363:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|#endif
  373|  21.2k|  {
  374|  21.2k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  21.2k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (374:9): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  }
  377|       |
  378|  21.2k|  if (need_full_buffer)         /* safety check */
  ------------------
  |  Branch (378:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  prep = (my_prep_ptr)
  382|  21.2k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  21.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  383|  21.2k|                                sizeof(my_prep_controller));
  384|  21.2k|  cinfo->prep = (struct jpeg_c_prep_controller *)prep;
  385|  21.2k|  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|  21.2k|  if (cinfo->downsample->need_context_rows) {
  ------------------
  |  Branch (391:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  } else {
  400|       |    /* No context, just make it tall enough for one row group */
  401|  21.2k|    prep->pub._pre_process_data = pre_process_data;
  ------------------
  |  |  130|  21.2k|#define _pre_process_data  pre_process_data_12
  ------------------
  402|  75.0k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (402:46): [True: 53.7k, False: 21.2k]
  ------------------
  403|  53.7k|         ci++, compptr++) {
  404|  53.7k|      prep->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  405|  53.7k|        ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  53.7k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  406|  53.7k|         (JDIMENSION)(((long)compptr->width_in_blocks * data_unit *
  407|  53.7k|                       cinfo->max_h_samp_factor) / compptr->h_samp_factor),
  408|  53.7k|         (JDIMENSION)cinfo->max_v_samp_factor);
  409|  53.7k|    }
  410|  21.2k|  }
  411|  21.2k|}
jcprepct-12.c:start_pass_prep:
   90|  21.2k|{
   91|  21.2k|  my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
   92|       |
   93|  21.2k|  if (pass_mode != JBUF_PASS_THRU)
  ------------------
  |  Branch (93:7): [True: 0, False: 21.2k]
  ------------------
   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|  21.2k|  prep->rows_to_go = cinfo->image_height;
   98|       |  /* Mark the conversion buffer empty */
   99|  21.2k|  prep->next_buf_row = 0;
  100|  21.2k|#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|  21.2k|  prep->this_row_group = 0;
  105|       |  /* Set next_buf_stop to stop after two row groups have been read in. */
  106|  21.2k|  prep->next_buf_stop = 2 * cinfo->max_v_samp_factor;
  107|  21.2k|#endif
  108|  21.2k|}
jcprepct-12.c:expand_bottom_edge:
  119|  42.9k|{
  120|  42.9k|  register int row;
  121|       |
  122|   270k|  for (row = input_rows; row < output_rows; row++) {
  ------------------
  |  Branch (122:26): [True: 228k, False: 42.9k]
  ------------------
  123|   228k|    _jcopy_sample_rows(image_data, input_rows - 1, image_data, row, 1,
  ------------------
  |  |  181|   228k|#define _jcopy_sample_rows  j12copy_sample_rows
  ------------------
  124|   228k|                       num_cols);
  125|   228k|  }
  126|  42.9k|}
jcprepct-12.c:pre_process_data:
  143|  2.79M|{
  144|  2.79M|  my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
  145|  2.79M|  int numrows, ci;
  146|  2.79M|  JDIMENSION inrows;
  147|  2.79M|  jpeg_component_info *compptr;
  148|  2.79M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  2.79M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (148:19): [True: 0, False: 2.79M]
  ------------------
  149|       |
  150|  25.1M|  while (*in_row_ctr < in_rows_avail &&
  ------------------
  |  Branch (150:10): [True: 25.1M, False: 8.42k]
  ------------------
  151|  25.1M|         *out_row_group_ctr < out_row_groups_avail) {
  ------------------
  |  Branch (151:10): [True: 22.3M, False: 2.77M]
  ------------------
  152|       |    /* Do color conversion to fill the conversion buffer. */
  153|  22.3M|    inrows = in_rows_avail - *in_row_ctr;
  154|  22.3M|    numrows = cinfo->max_v_samp_factor - prep->next_buf_row;
  155|  22.3M|    numrows = (int)MIN((JDIMENSION)numrows, inrows);
  ------------------
  |  |  515|  22.3M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 22.3M, False: 21.2k]
  |  |  ------------------
  ------------------
  156|       |#ifdef WITH_PROFILE
  157|       |    cinfo->master->start = getTime();
  158|       |#endif
  159|  22.3M|    (*cinfo->cconvert->_color_convert) (cinfo, input_buf + *in_row_ctr,
  ------------------
  |  |  151|  22.3M|#define _color_convert  color_convert_12
  ------------------
  160|  22.3M|                                        prep->color_buf,
  161|  22.3M|                                        (JDIMENSION)prep->next_buf_row,
  162|  22.3M|                                        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|  22.3M|    *in_row_ctr += numrows;
  169|  22.3M|    prep->next_buf_row += numrows;
  170|  22.3M|    prep->rows_to_go -= numrows;
  171|       |    /* If at bottom of image, pad to fill the conversion buffer. */
  172|  22.3M|    if (prep->rows_to_go == 0 &&
  ------------------
  |  Branch (172:9): [True: 21.2k, False: 22.3M]
  ------------------
  173|  21.2k|        prep->next_buf_row < cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (173:9): [True: 2.11k, False: 19.1k]
  ------------------
  174|  9.49k|      for (ci = 0; ci < cinfo->num_components; ci++) {
  ------------------
  |  Branch (174:20): [True: 7.38k, False: 2.11k]
  ------------------
  175|  7.38k|        expand_bottom_edge(prep->color_buf[ci], cinfo->image_width,
  176|  7.38k|                           prep->next_buf_row, cinfo->max_v_samp_factor);
  177|  7.38k|      }
  178|  2.11k|      prep->next_buf_row = cinfo->max_v_samp_factor;
  179|  2.11k|    }
  180|       |    /* If we've filled the conversion buffer, empty it. */
  181|  22.3M|    if (prep->next_buf_row == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (181:9): [True: 22.3M, False: 0]
  ------------------
  182|       |#ifdef WITH_PROFILE
  183|       |      cinfo->master->start = getTime();
  184|       |#endif
  185|  22.3M|      (*cinfo->downsample->_downsample) (cinfo,
  ------------------
  |  |  136|  22.3M|#define _downsample  downsample_12
  ------------------
  186|  22.3M|                                         prep->color_buf, (JDIMENSION)0,
  187|  22.3M|                                         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|  22.3M|      prep->next_buf_row = 0;
  194|  22.3M|      (*out_row_group_ctr)++;
  195|  22.3M|    }
  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|  22.3M|    if (prep->rows_to_go == 0 && *out_row_group_ctr < out_row_groups_avail) {
  ------------------
  |  Branch (199:9): [True: 21.2k, False: 22.3M]
  |  Branch (199:34): [True: 12.8k, False: 8.42k]
  ------------------
  200|  48.3k|      for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (200:48): [True: 35.5k, False: 12.8k]
  ------------------
  201|  35.5k|           ci++, compptr++) {
  202|  35.5k|        expand_bottom_edge(output_buf[ci],
  203|  35.5k|                           compptr->width_in_blocks * data_unit,
  204|  35.5k|                           (int)(*out_row_group_ctr * compptr->v_samp_factor),
  205|  35.5k|                           (int)(out_row_groups_avail * compptr->v_samp_factor));
  206|  35.5k|      }
  207|  12.8k|      *out_row_group_ctr = out_row_groups_avail;
  208|  12.8k|      break;                    /* can exit outer loop without test */
  209|  12.8k|    }
  210|  22.3M|  }
  211|  2.79M|}

j12init_downsampler:
  468|  21.2k|{
  469|  21.2k|  my_downsample_ptr downsample;
  470|  21.2k|  int ci;
  471|  21.2k|  jpeg_component_info *compptr;
  472|  21.2k|#ifdef INPUT_SMOOTHING_SUPPORTED
  473|  21.2k|  boolean smoothok = TRUE;
  ------------------
  |  |  210|  21.2k|#define TRUE    1
  ------------------
  474|  21.2k|#endif
  475|       |
  476|  21.2k|#ifdef C_LOSSLESS_SUPPORTED
  477|  21.2k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (477:7): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|#endif
  487|  21.2k|  {
  488|  21.2k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  21.2k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (488:9): [True: 0, False: 21.2k]
  ------------------
  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|  21.2k|  }
  491|       |
  492|  21.2k|  downsample = (my_downsample_ptr)
  493|  21.2k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  21.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  494|  21.2k|                                sizeof(my_downsampler));
  495|  21.2k|  cinfo->downsample = (struct jpeg_downsampler *)downsample;
  496|  21.2k|  downsample->pub.start_pass = start_pass_downsample;
  497|  21.2k|  downsample->pub._downsample = sep_downsample;
  ------------------
  |  |  136|  21.2k|#define _downsample  downsample_12
  ------------------
  498|  21.2k|  downsample->pub.need_context_rows = FALSE;
  ------------------
  |  |  207|  21.2k|#define FALSE   0               /* values of boolean */
  ------------------
  499|       |
  500|  21.2k|  if (cinfo->CCIR601_sampling)
  ------------------
  |  Branch (500:7): [True: 0, False: 21.2k]
  ------------------
  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|  75.0k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (504:44): [True: 53.7k, False: 21.2k]
  ------------------
  505|  53.7k|       ci++, compptr++) {
  506|  53.7k|    if (compptr->h_samp_factor == cinfo->max_h_samp_factor &&
  ------------------
  |  Branch (506:9): [True: 36.0k, False: 17.7k]
  ------------------
  507|  36.0k|        compptr->v_samp_factor == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (507:9): [True: 30.2k, False: 5.85k]
  ------------------
  508|  30.2k|#ifdef INPUT_SMOOTHING_SUPPORTED
  509|  30.2k|      if (cinfo->smoothing_factor) {
  ------------------
  |  Branch (509:11): [True: 0, False: 30.2k]
  ------------------
  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|  30.2k|#endif
  514|  30.2k|        downsample->methods[ci] = fullsize_downsample;
  515|  30.2k|    } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
  ------------------
  |  Branch (515:16): [True: 11.8k, False: 11.7k]
  ------------------
  516|  11.8k|               compptr->v_samp_factor == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (516:16): [True: 6.02k, False: 5.85k]
  ------------------
  517|  6.02k|#ifdef INPUT_SMOOTHING_SUPPORTED
  518|  6.02k|      smoothok = FALSE;
  ------------------
  |  |  207|  6.02k|#define FALSE   0               /* values of boolean */
  ------------------
  519|  6.02k|#endif
  520|       |#ifdef WITH_SIMD
  521|       |      if (jsimd_set_h2v1_downsample(cinfo))
  522|       |        downsample->methods[ci] = jsimd_h2v1_downsample;
  523|       |      else
  524|       |#endif
  525|  6.02k|        downsample->methods[ci] = h2v1_downsample;
  526|  17.5k|    } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
  ------------------
  |  Branch (526:16): [True: 5.85k, False: 11.7k]
  ------------------
  527|  5.85k|               compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (527:16): [True: 5.85k, False: 0]
  ------------------
  528|  5.85k|#ifdef INPUT_SMOOTHING_SUPPORTED
  529|  5.85k|      if (cinfo->smoothing_factor) {
  ------------------
  |  Branch (529:11): [True: 0, False: 5.85k]
  ------------------
  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.85k|#endif
  534|  5.85k|      {
  535|       |#ifdef WITH_SIMD
  536|       |        if (jsimd_set_h2v2_downsample(cinfo))
  537|       |          downsample->methods[ci] = jsimd_h2v2_downsample;
  538|       |        else
  539|       |#endif
  540|  5.85k|          downsample->methods[ci] = h2v2_downsample;
  541|  5.85k|      }
  542|  11.7k|    } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 &&
  ------------------
  |  Branch (542:16): [True: 11.7k, False: 0]
  ------------------
  543|  11.7k|               (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) {
  ------------------
  |  Branch (543:16): [True: 11.7k, False: 0]
  ------------------
  544|  11.7k|#ifdef INPUT_SMOOTHING_SUPPORTED
  545|  11.7k|      smoothok = FALSE;
  ------------------
  |  |  207|  11.7k|#define FALSE   0               /* values of boolean */
  ------------------
  546|  11.7k|#endif
  547|  11.7k|      downsample->methods[ci] = int_downsample;
  548|  11.7k|    } 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|  53.7k|  }
  551|       |
  552|  21.2k|#ifdef INPUT_SMOOTHING_SUPPORTED
  553|  21.2k|  if (cinfo->smoothing_factor && !smoothok)
  ------------------
  |  Branch (553:7): [True: 0, False: 21.2k]
  |  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|  21.2k|#endif
  556|  21.2k|}
jcsample-12.c:start_pass_downsample:
   89|  21.2k|{
   90|       |  /* no work for now */
   91|  21.2k|}
jcsample-12.c:sep_downsample:
  130|  22.3M|{
  131|  22.3M|  my_downsample_ptr downsample = (my_downsample_ptr)cinfo->downsample;
  132|  22.3M|  int ci;
  133|  22.3M|  jpeg_component_info *compptr;
  134|  22.3M|  _JSAMPARRAY in_ptr, out_ptr;
  ------------------
  |  |  114|  22.3M|#define _JSAMPARRAY  J12SAMPARRAY
  ------------------
  135|       |
  136|  77.4M|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (136:44): [True: 55.1M, False: 22.3M]
  ------------------
  137|  55.1M|       ci++, compptr++) {
  138|  55.1M|    in_ptr = input_buf[ci] + in_row_index;
  139|  55.1M|    out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor);
  140|  55.1M|    (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr);
  141|  55.1M|  }
  142|  22.3M|}
jcsample-12.c:expand_right_edge:
  102|  55.1M|{
  103|  55.1M|  register _JSAMPROW ptr;
  104|  55.1M|  register _JSAMPLE pixval;
  105|  55.1M|  register int count;
  106|  55.1M|  int row;
  107|  55.1M|  int numcols = (int)(output_cols - input_cols);
  108|       |
  109|  55.1M|  if (numcols > 0) {
  ------------------
  |  Branch (109:7): [True: 54.5M, False: 554k]
  ------------------
  110|   122M|    for (row = 0; row < num_rows; row++) {
  ------------------
  |  Branch (110:19): [True: 67.9M, False: 54.5M]
  ------------------
  111|  67.9M|      ptr = image_data[row] + input_cols;
  112|  67.9M|      pixval = ptr[-1];
  113|   794M|      for (count = numcols; count > 0; count--)
  ------------------
  |  Branch (113:29): [True: 726M, False: 67.9M]
  ------------------
  114|   726M|        *ptr++ = pixval;
  115|  67.9M|    }
  116|  54.5M|  }
  117|  55.1M|}
jcsample-12.c:fullsize_downsample:
  203|  31.9M|{
  204|  31.9M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  31.9M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (204:19): [True: 0, False: 31.9M]
  ------------------
  205|       |
  206|       |  /* Copy the data */
  207|  31.9M|  _jcopy_sample_rows(input_data, 0, output_data, 0, cinfo->max_v_samp_factor,
  ------------------
  |  |  181|  31.9M|#define _jcopy_sample_rows  j12copy_sample_rows
  ------------------
  208|  31.9M|                     cinfo->image_width);
  209|       |  /* Edge-expand */
  210|  31.9M|  expand_right_edge(output_data, cinfo->max_v_samp_factor, cinfo->image_width,
  211|  31.9M|                    compptr->width_in_blocks * data_unit);
  212|  31.9M|}
jcsample-12.c:h2v1_downsample:
  230|  7.71M|{
  231|  7.71M|  int outrow;
  232|  7.71M|  JDIMENSION outcol;
  233|  7.71M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  7.71M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (233:19): [True: 0, False: 7.71M]
  ------------------
  234|  7.71M|  JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
  235|  7.71M|  register _JSAMPROW inptr, outptr;
  236|  7.71M|  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|  7.71M|  expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
  243|  7.71M|                    output_cols * 2);
  244|       |
  245|  15.4M|  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  ------------------
  |  Branch (245:20): [True: 7.71M, False: 7.71M]
  ------------------
  246|  7.71M|    outptr = output_data[outrow];
  247|  7.71M|    inptr = input_data[outrow];
  248|  7.71M|    bias = 0;                   /* bias = 0,1,0,1,... for successive samples */
  249|  96.7M|    for (outcol = 0; outcol < output_cols; outcol++) {
  ------------------
  |  Branch (249:22): [True: 89.0M, False: 7.71M]
  ------------------
  250|  89.0M|      *outptr++ = (_JSAMPLE)((inptr[0] + inptr[1] + bias) >> 1);
  251|  89.0M|      bias ^= 1;                /* 0=>1, 1=>0 */
  252|  89.0M|      inptr += 2;
  253|  89.0M|    }
  254|  7.71M|  }
  255|  7.71M|}
jcsample-12.c:h2v2_downsample:
  267|  3.85M|{
  268|  3.85M|  int inrow, outrow;
  269|  3.85M|  JDIMENSION outcol;
  270|  3.85M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  3.85M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (270:19): [True: 0, False: 3.85M]
  ------------------
  271|  3.85M|  JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
  272|  3.85M|  register _JSAMPROW inptr0, inptr1, outptr;
  273|  3.85M|  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|  3.85M|  expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
  280|  3.85M|                    output_cols * 2);
  281|       |
  282|  3.85M|  inrow = 0;
  283|  7.71M|  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  ------------------
  |  Branch (283:20): [True: 3.85M, False: 3.85M]
  ------------------
  284|  3.85M|    outptr = output_data[outrow];
  285|  3.85M|    inptr0 = input_data[inrow];
  286|  3.85M|    inptr1 = input_data[inrow + 1];
  287|  3.85M|    bias = 1;                   /* bias = 1,2,1,2,... for successive samples */
  288|  49.4M|    for (outcol = 0; outcol < output_cols; outcol++) {
  ------------------
  |  Branch (288:22): [True: 45.5M, False: 3.85M]
  ------------------
  289|  45.5M|      *outptr++ = (_JSAMPLE)
  290|  45.5M|        ((inptr0[0] + inptr0[1] + inptr1[0] + inptr1[1] + bias) >> 2);
  291|  45.5M|      bias ^= 3;                /* 1=>2, 2=>1 */
  292|  45.5M|      inptr0 += 2;  inptr1 += 2;
  293|  45.5M|    }
  294|  3.85M|    inrow += 2;
  295|  3.85M|  }
  296|  3.85M|}
jcsample-12.c:int_downsample:
  155|  11.5M|{
  156|  11.5M|  int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v;
  157|  11.5M|  JDIMENSION outcol, outcol_h;  /* outcol_h == outcol*h_expand */
  158|  11.5M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  11.5M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (158:19): [True: 0, False: 11.5M]
  ------------------
  159|  11.5M|  JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
  160|  11.5M|  _JSAMPROW inptr, outptr;
  ------------------
  |  |  113|  11.5M|#define _JSAMPROW  J12SAMPROW
  ------------------
  161|  11.5M|  JLONG outvalue;
  162|       |
  163|  11.5M|  h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor;
  164|  11.5M|  v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor;
  165|  11.5M|  numpix = h_expand * v_expand;
  166|  11.5M|  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|  11.5M|  expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
  173|  11.5M|                    output_cols * h_expand);
  174|       |
  175|  11.5M|  inrow = 0;
  176|  23.1M|  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  ------------------
  |  Branch (176:20): [True: 11.5M, False: 11.5M]
  ------------------
  177|  11.5M|    outptr = output_data[outrow];
  178|   148M|    for (outcol = 0, outcol_h = 0; outcol < output_cols;
  ------------------
  |  Branch (178:36): [True: 137M, False: 11.5M]
  ------------------
  179|   137M|         outcol++, outcol_h += h_expand) {
  180|   137M|      outvalue = 0;
  181|   336M|      for (v = 0; v < v_expand; v++) {
  ------------------
  |  Branch (181:19): [True: 199M, False: 137M]
  ------------------
  182|   199M|        inptr = input_data[inrow + v] + outcol_h;
  183|   622M|        for (h = 0; h < h_expand; h++) {
  ------------------
  |  Branch (183:21): [True: 423M, False: 199M]
  ------------------
  184|   423M|          outvalue += (JLONG)(*inptr++);
  185|   423M|        }
  186|   199M|      }
  187|   137M|      *outptr++ = (_JSAMPLE)((outvalue + numpix2) / numpix);
  188|   137M|    }
  189|  11.5M|    inrow += v_expand;
  190|  11.5M|  }
  191|  11.5M|}

jpeg_mem_dest_tj:
  164|  76.1k|{
  165|  76.1k|  boolean reused = FALSE;
  ------------------
  |  |  207|  76.1k|#define FALSE   0               /* values of boolean */
  ------------------
  166|  76.1k|  my_mem_dest_ptr dest;
  167|       |
  168|  76.1k|  if (outbuffer == NULL || outsize == NULL)     /* sanity check */
  ------------------
  |  Branch (168:7): [True: 0, False: 76.1k]
  |  Branch (168:28): [True: 0, False: 76.1k]
  ------------------
  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|  76.1k|  if (cinfo->dest == NULL) {    /* first time for this JPEG object? */
  ------------------
  |  Branch (174:7): [True: 54.8k, False: 21.2k]
  ------------------
  175|  54.8k|    cinfo->dest = (struct jpeg_destination_mgr *)
  176|  54.8k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  54.8k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  177|  54.8k|                                  sizeof(my_mem_destination_mgr));
  178|  54.8k|    dest = (my_mem_dest_ptr)cinfo->dest;
  179|  54.8k|    dest->newbuffer = NULL;
  180|  54.8k|    dest->buffer = NULL;
  181|  54.8k|  } else if (cinfo->dest->init_destination != init_mem_destination) {
  ------------------
  |  Branch (181:14): [True: 0, False: 21.2k]
  ------------------
  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|  76.1k|  dest = (my_mem_dest_ptr)cinfo->dest;
  189|  76.1k|  dest->pub.init_destination = init_mem_destination;
  190|  76.1k|  dest->pub.empty_output_buffer = empty_mem_output_buffer;
  191|  76.1k|  dest->pub.term_destination = term_mem_destination;
  192|  76.1k|  if (dest->buffer == *outbuffer && *outbuffer != NULL && alloc)
  ------------------
  |  Branch (192:7): [True: 0, False: 76.1k]
  |  Branch (192:37): [True: 0, False: 0]
  |  Branch (192:59): [True: 0, False: 0]
  ------------------
  193|      0|    reused = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  194|  76.1k|  dest->outbuffer = outbuffer;
  195|  76.1k|  dest->outsize = outsize;
  196|  76.1k|  dest->alloc = alloc;
  197|       |
  198|  76.1k|  if (*outbuffer == NULL || (*outsize == 0 && !reused)) {
  ------------------
  |  Branch (198:7): [True: 18.2k, False: 57.8k]
  |  Branch (198:30): [True: 0, False: 57.8k]
  |  Branch (198:47): [True: 0, False: 0]
  ------------------
  199|  18.2k|    if (alloc) {
  ------------------
  |  Branch (199:9): [True: 18.2k, False: 0]
  ------------------
  200|       |      /* Allocate initial buffer */
  201|  18.2k|      dest->newbuffer = *outbuffer = (unsigned char *)MALLOC(OUTPUT_BUF_SIZE);
  ------------------
  |  |  520|  18.2k|#define MALLOC(size)  malloc(size)
  ------------------
  202|  18.2k|      if (dest->newbuffer == NULL)
  ------------------
  |  Branch (202:11): [True: 0, False: 18.2k]
  ------------------
  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|  18.2k|      *outsize = OUTPUT_BUF_SIZE;
  ------------------
  |  |   34|  18.2k|#define OUTPUT_BUF_SIZE  4096   /* choose an efficiently fwrite'able size */
  ------------------
  205|  18.2k|    } 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|  18.2k|  } else
  208|  57.8k|    dest->newbuffer = *outbuffer;
  209|       |
  210|  76.1k|  dest->pub.next_output_byte = dest->buffer = *outbuffer;
  211|  76.1k|  if (!reused)
  ------------------
  |  Branch (211:7): [True: 76.1k, False: 0]
  ------------------
  212|  76.1k|    dest->bufsize = *outsize;
  213|  76.1k|  dest->pub.free_in_buffer = dest->bufsize;
  214|  76.1k|}
jdatadst-tj.c:init_mem_destination:
   60|  21.2k|{
   61|       |  /* no work necessary here */
   62|  21.2k|}
jdatadst-tj.c:empty_mem_output_buffer:
   90|  8.42k|{
   91|  8.42k|  size_t nextsize;
   92|  8.42k|  JOCTET *nextbuffer;
   93|  8.42k|  my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
   94|       |
   95|  8.42k|  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.42k]
  ------------------
   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.42k|  if (dest->bufsize > SIZE_MAX / 2)
  ------------------
  |  Branch (107:7): [True: 0, False: 8.42k]
  ------------------
  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.42k|  nextsize = dest->bufsize * 2;
  110|  8.42k|  nextbuffer = (JOCTET *)MALLOC(nextsize);
  ------------------
  |  |  520|  8.42k|#define MALLOC(size)  malloc(size)
  ------------------
  111|       |
  112|  8.42k|  if (nextbuffer == NULL)
  ------------------
  |  Branch (112:7): [True: 0, False: 8.42k]
  ------------------
  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.42k|  memcpy(nextbuffer, dest->buffer, dest->bufsize);
  116|       |
  117|  8.42k|  free(dest->newbuffer);
  118|       |
  119|  8.42k|  dest->newbuffer = nextbuffer;
  120|       |
  121|  8.42k|  dest->pub.next_output_byte = nextbuffer + dest->bufsize;
  122|  8.42k|  dest->pub.free_in_buffer = dest->bufsize;
  123|       |
  124|  8.42k|  dest->buffer = nextbuffer;
  125|  8.42k|  dest->bufsize = nextsize;
  126|       |
  127|  8.42k|  return TRUE;
  ------------------
  |  |  210|  8.42k|#define TRUE    1
  ------------------
  128|  8.42k|}
jdatadst-tj.c:term_mem_destination:
  142|  21.2k|{
  143|  21.2k|  my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
  144|       |
  145|  21.2k|  if (dest->alloc) *dest->outbuffer = dest->buffer;
  ------------------
  |  Branch (145:7): [True: 18.2k, False: 3.01k]
  ------------------
  146|  21.2k|  *dest->outsize = dest->bufsize - dest->pub.free_in_buffer;
  147|  21.2k|}

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

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

jpeg12_fdct_islow:
  144|  14.9M|{
  145|  14.9M|  JLONG tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
  146|  14.9M|  JLONG tmp10, tmp11, tmp12, tmp13;
  147|  14.9M|  JLONG z1, z2, z3, z4, z5;
  148|  14.9M|  DCTELEM *dataptr;
  149|  14.9M|  int ctr;
  150|  14.9M|  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|  14.9M|  dataptr = data;
  157|   134M|  for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
  ------------------
  |  |   66|  14.9M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (157:27): [True: 119M, False: 14.9M]
  ------------------
  158|   119M|    tmp0 = dataptr[0] + dataptr[7];
  159|   119M|    tmp7 = dataptr[0] - dataptr[7];
  160|   119M|    tmp1 = dataptr[1] + dataptr[6];
  161|   119M|    tmp6 = dataptr[1] - dataptr[6];
  162|   119M|    tmp2 = dataptr[2] + dataptr[5];
  163|   119M|    tmp5 = dataptr[2] - dataptr[5];
  164|   119M|    tmp3 = dataptr[3] + dataptr[4];
  165|   119M|    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|   119M|    tmp10 = tmp0 + tmp3;
  172|   119M|    tmp13 = tmp0 - tmp3;
  173|   119M|    tmp11 = tmp1 + tmp2;
  174|   119M|    tmp12 = tmp1 - tmp2;
  175|       |
  176|   119M|    dataptr[0] = (DCTELEM)LEFT_SHIFT(tmp10 + tmp11, PASS1_BITS);
  ------------------
  |  |   85|   119M|#define LEFT_SHIFT(a, b)  ((JLONG)((unsigned long)(a) << (b)))
  ------------------
  177|   119M|    dataptr[4] = (DCTELEM)LEFT_SHIFT(tmp10 - tmp11, PASS1_BITS);
  ------------------
  |  |   85|   119M|#define LEFT_SHIFT(a, b)  ((JLONG)((unsigned long)(a) << (b)))
  ------------------
  178|       |
  179|   119M|    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  180|   119M|    dataptr[2] = (DCTELEM)DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
  ------------------
  |  |  216|   119M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   119M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  181|   119M|                                  CONST_BITS - PASS1_BITS);
  182|   119M|    dataptr[6] = (DCTELEM)DESCALE(z1 + MULTIPLY(tmp12, -FIX_1_847759065),
  ------------------
  |  |  216|   119M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   119M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  183|   119M|                                  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|   119M|    z1 = tmp4 + tmp7;
  191|   119M|    z2 = tmp5 + tmp6;
  192|   119M|    z3 = tmp4 + tmp6;
  193|   119M|    z4 = tmp5 + tmp7;
  194|   119M|    z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  195|       |
  196|   119M|    tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  197|   119M|    tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  198|   119M|    tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  199|   119M|    tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  200|   119M|    z1 = MULTIPLY(z1, -FIX_0_899976223); /* sqrt(2) * ( c7-c3) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  201|   119M|    z2 = MULTIPLY(z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  202|   119M|    z3 = MULTIPLY(z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  203|   119M|    z4 = MULTIPLY(z4, -FIX_0_390180644); /* sqrt(2) * ( c5-c3) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  204|       |
  205|   119M|    z3 += z5;
  206|   119M|    z4 += z5;
  207|       |
  208|   119M|    dataptr[7] = (DCTELEM)DESCALE(tmp4 + z1 + z3, CONST_BITS - PASS1_BITS);
  ------------------
  |  |  216|   119M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   119M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  209|   119M|    dataptr[5] = (DCTELEM)DESCALE(tmp5 + z2 + z4, CONST_BITS - PASS1_BITS);
  ------------------
  |  |  216|   119M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   119M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  210|   119M|    dataptr[3] = (DCTELEM)DESCALE(tmp6 + z2 + z3, CONST_BITS - PASS1_BITS);
  ------------------
  |  |  216|   119M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   119M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  211|   119M|    dataptr[1] = (DCTELEM)DESCALE(tmp7 + z1 + z4, CONST_BITS - PASS1_BITS);
  ------------------
  |  |  216|   119M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   119M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  212|       |
  213|   119M|    dataptr += DCTSIZE;         /* advance pointer to next row */
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  214|   119M|  }
  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|  14.9M|  dataptr = data;
  222|   134M|  for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
  ------------------
  |  |   66|  14.9M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (222:27): [True: 119M, False: 14.9M]
  ------------------
  223|   119M|    tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  224|   119M|    tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  225|   119M|    tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  226|   119M|    tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  227|   119M|    tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  228|   119M|    tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  229|   119M|    tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  230|   119M|    tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
  ------------------
  |  |   66|   119M|#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|   119M|    tmp10 = tmp0 + tmp3;
  237|   119M|    tmp13 = tmp0 - tmp3;
  238|   119M|    tmp11 = tmp1 + tmp2;
  239|   119M|    tmp12 = tmp1 - tmp2;
  240|       |
  241|   119M|    dataptr[DCTSIZE * 0] = (DCTELEM)DESCALE(tmp10 + tmp11, PASS1_BITS);
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  dataptr[DCTSIZE * 0] = (DCTELEM)DESCALE(tmp10 + tmp11, PASS1_BITS);
  ------------------
  |  |  216|   119M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   119M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  242|   119M|    dataptr[DCTSIZE * 4] = (DCTELEM)DESCALE(tmp10 - tmp11, PASS1_BITS);
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  dataptr[DCTSIZE * 4] = (DCTELEM)DESCALE(tmp10 - tmp11, PASS1_BITS);
  ------------------
  |  |  216|   119M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   119M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  243|       |
  244|   119M|    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  245|   119M|    dataptr[DCTSIZE * 2] =
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  246|   119M|      (DCTELEM)DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
  ------------------
  |  |  216|   119M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   119M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  247|   119M|                       CONST_BITS + PASS1_BITS);
  248|   119M|    dataptr[DCTSIZE * 6] =
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  249|   119M|      (DCTELEM)DESCALE(z1 + MULTIPLY(tmp12, -FIX_1_847759065),
  ------------------
  |  |  216|   119M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   119M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  250|   119M|                       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|   119M|    z1 = tmp4 + tmp7;
  258|   119M|    z2 = tmp5 + tmp6;
  259|   119M|    z3 = tmp4 + tmp6;
  260|   119M|    z4 = tmp5 + tmp7;
  261|   119M|    z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  262|       |
  263|   119M|    tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  264|   119M|    tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  265|   119M|    tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  266|   119M|    tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  267|   119M|    z1 = MULTIPLY(z1, -FIX_0_899976223); /* sqrt(2) * ( c7-c3) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  268|   119M|    z2 = MULTIPLY(z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  269|   119M|    z3 = MULTIPLY(z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  270|   119M|    z4 = MULTIPLY(z4, -FIX_0_390180644); /* sqrt(2) * ( c5-c3) */
  ------------------
  |  |  134|   119M|#define MULTIPLY(var, const)  ((var) * (const))
  ------------------
  271|       |
  272|   119M|    z3 += z5;
  273|   119M|    z4 += z5;
  274|       |
  275|   119M|    dataptr[DCTSIZE * 7] = (DCTELEM)DESCALE(tmp4 + z1 + z3,
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  dataptr[DCTSIZE * 7] = (DCTELEM)DESCALE(tmp4 + z1 + z3,
  ------------------
  |  |  216|   119M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   119M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  276|   119M|                                            CONST_BITS + PASS1_BITS);
  277|   119M|    dataptr[DCTSIZE * 5] = (DCTELEM)DESCALE(tmp5 + z2 + z4,
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  dataptr[DCTSIZE * 5] = (DCTELEM)DESCALE(tmp5 + z2 + z4,
  ------------------
  |  |  216|   119M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   119M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  278|   119M|                                            CONST_BITS + PASS1_BITS);
  279|   119M|    dataptr[DCTSIZE * 3] = (DCTELEM)DESCALE(tmp6 + z2 + z3,
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  dataptr[DCTSIZE * 3] = (DCTELEM)DESCALE(tmp6 + z2 + z3,
  ------------------
  |  |  216|   119M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   119M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  280|   119M|                                            CONST_BITS + PASS1_BITS);
  281|   119M|    dataptr[DCTSIZE * 1] = (DCTELEM)DESCALE(tmp7 + z1 + z4,
  ------------------
  |  |   66|   119M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
                  dataptr[DCTSIZE * 1] = (DCTELEM)DESCALE(tmp7 + z1 + z4,
  ------------------
  |  |  216|   119M|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   119M|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  282|   119M|                                            CONST_BITS + PASS1_BITS);
  283|       |
  284|   119M|    dataptr++;                  /* advance pointer to next column */
  285|   119M|  }
  286|  14.9M|}

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

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

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

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

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

j12init_read_png:
  705|  31.9k|{
  706|  31.9k|  png_source_ptr source;
  707|       |
  708|       |#if BITS_IN_JSAMPLE == 8
  709|       |  if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  710|       |#else
  711|  31.9k|  if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  ------------------
  |  |   12|  63.9k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (711:7): [True: 0, False: 31.9k]
  ------------------
  712|  31.9k|      cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  ------------------
  |  |   12|  31.9k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (712:7): [True: 0, False: 31.9k]
  ------------------
  713|      0|#endif
  714|      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)))
  ------------------
  715|       |
  716|       |  /* Create module interface object */
  717|  31.9k|  source = (png_source_ptr)
  718|  31.9k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  31.9k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  719|  31.9k|                                sizeof(png_source_struct));
  720|       |  /* Fill in method ptrs, except get_pixel_rows which start_input sets */
  721|  31.9k|  source->pub.start_input = start_input_png;
  722|  31.9k|  source->pub.read_icc_profile = read_icc_profile_png;
  723|  31.9k|  source->pub.finish_input = finish_input_png;
  724|  31.9k|  source->pub.max_pixels = 0;
  725|       |
  726|  31.9k|  return (cjpeg_source_ptr)source;
  727|  31.9k|}
rdpng-12.c:start_input_png:
  472|  31.9k|{
  473|  31.9k|  png_source_ptr source = (png_source_ptr)sinfo;
  474|  31.9k|  struct spng_ihdr ihdr;
  475|  31.9k|  int png_components = 3;
  476|  31.9k|  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|  31.9k|  source->ctx = spng_ctx_new(0);
  487|  31.9k|#endif
  488|  31.9k|  if (!source->ctx)
  ------------------
  |  Branch (488:7): [True: 0, False: 31.9k]
  ------------------
  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|  31.9k|  TRY_SPNG(spng_set_png_file(source->ctx, sinfo->input_file));
  ------------------
  |  |   33|  31.9k|#define TRY_SPNG(f) { \
  |  |   34|  31.9k|  int __spng_error = (f); \
  |  |   35|  31.9k|  if (__spng_error) \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 0, False: 31.9k]
  |  |  ------------------
  |  |   36|  31.9k|    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|  31.9k|}
  ------------------
  492|       |
  493|  31.9k|  TRY_SPNG(spng_get_ihdr(source->ctx, &ihdr));
  ------------------
  |  |   33|  31.9k|#define TRY_SPNG(f) { \
  |  |   34|  31.9k|  int __spng_error = (f); \
  |  |   35|  31.9k|  if (__spng_error) \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 1.35k, False: 30.6k]
  |  |  ------------------
  |  |   36|  31.9k|    ERREXITS(cinfo, JERR_PNG_LIBSPNG, spng_strerror(__spng_error)); \
  |  |  ------------------
  |  |  |  |  274|  1.35k|  ((cinfo)->err->msg_code = (code), \
  |  |  |  |  275|  1.35k|   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX - 1), \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|  1.35k|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  276|  1.35k|   (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|  1.35k|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  277|  1.35k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  |  |  ------------------
  |  |   37|  31.9k|}
  ------------------
  494|       |
  495|  31.9k|  if (ihdr.width > JPEG_MAX_DIMENSION || ihdr.height > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  63.9k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
                if (ihdr.width > JPEG_MAX_DIMENSION || ihdr.height > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  28.2k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (495:7): [True: 3.71k, False: 28.2k]
  |  Branch (495:42): [True: 1.31k, False: 26.9k]
  ------------------
  496|  3.66k|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, JPEG_MAX_DIMENSION);
  ------------------
  |  |  243|  3.66k|  ((cinfo)->err->msg_code = (code), \
  |  |  244|  3.66k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|  3.66k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  497|  31.9k|  if (ihdr.bit_depth != 8 && ihdr.bit_depth != 16)
  ------------------
  |  Branch (497:7): [True: 12.4k, False: 19.5k]
  |  Branch (497:30): [True: 6.44k, False: 5.97k]
  ------------------
  498|  6.44k|    ERREXIT(cinfo, JERR_PNG_BADDEPTH);
  ------------------
  |  |  240|  6.44k|  ((cinfo)->err->msg_code = (code), \
  |  |  241|  6.44k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  499|  31.9k|  if (sinfo->max_pixels &&
  ------------------
  |  Branch (499:7): [True: 20.5k, False: 11.4k]
  ------------------
  500|  20.5k|      (unsigned long long)ihdr.width * ihdr.height > sinfo->max_pixels)
  ------------------
  |  Branch (500:7): [True: 266, False: 20.2k]
  ------------------
  501|    266|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
  ------------------
  |  |  243|    266|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    266|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    266|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  502|       |
  503|  31.9k|  cinfo->image_width = (JDIMENSION)ihdr.width;
  504|  31.9k|  cinfo->image_height = (JDIMENSION)ihdr.height;
  505|  31.9k|  source->png_bit_depth = ihdr.bit_depth;
  506|  31.9k|  source->png_color_type = ihdr.color_type;
  507|       |
  508|       |  /* initialize flags to most common settings */
  509|  31.9k|  use_raw_buffer = FALSE;       /* do we map input buffer onto I/O buffer? */
  ------------------
  |  |  207|  31.9k|#define FALSE   0               /* values of boolean */
  ------------------
  510|       |
  511|  31.9k|  switch (ihdr.color_type) {
  512|  1.63k|  case SPNG_COLOR_TYPE_GRAYSCALE_ALPHA:
  ------------------
  |  Branch (512:3): [True: 1.63k, False: 30.3k]
  ------------------
  513|  8.13k|  case SPNG_COLOR_TYPE_GRAYSCALE:
  ------------------
  |  Branch (513:3): [True: 6.50k, False: 25.4k]
  ------------------
  514|  8.13k|    if (cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (514:9): [True: 0, False: 8.13k]
  ------------------
  515|  8.13k|        cinfo->in_color_space == JCS_RGB)
  ------------------
  |  Branch (515:9): [True: 0, False: 8.13k]
  ------------------
  516|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  517|  8.13k|    TRACEMS3(cinfo, 1, JTRC_PNG_GRAYSCALE, ihdr.width, ihdr.height,
  ------------------
  |  |  309|  8.13k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  8.13k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 8.13k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  8.13k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  8.13k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  8.13k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  518|  8.13k|             ihdr.bit_depth);
  519|  8.13k|    if (cinfo->in_color_space == JCS_GRAYSCALE) {
  ------------------
  |  Branch (519:9): [True: 1.16k, False: 6.97k]
  ------------------
  520|  1.16k|      if (ihdr.color_type == SPNG_COLOR_TYPE_GRAYSCALE &&
  ------------------
  |  Branch (520:11): [True: 929, False: 233]
  ------------------
  521|    929|          cinfo->data_precision == ihdr.bit_depth) {
  ------------------
  |  Branch (521:11): [True: 0, False: 929]
  ------------------
  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|  1.16k|        source->pub.get_pixel_rows = get_gray_row;
  526|  6.97k|    } else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  6.97k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 6.97k]
  |  |  |  Branch (78:22): [True: 5.81k, False: 1.16k]
  |  |  |  Branch (78:43): [True: 5.81k, False: 0]
  |  |  ------------------
  ------------------
  527|  5.81k|      source->pub.get_pixel_rows = get_gray_rgb_row;
  528|  1.16k|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (528:14): [True: 1.16k, False: 0]
  ------------------
  529|  1.16k|        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|  8.13k|    if (ihdr.color_type == SPNG_COLOR_TYPE_GRAYSCALE_ALPHA) {
  ------------------
  |  Branch (532:9): [True: 1.63k, False: 6.50k]
  ------------------
  533|  1.63k|      png_components = 2;
  534|  1.63k|      source->png_alpha = 1;
  535|  6.50k|    } else {
  536|  6.50k|      png_components = 1;
  537|  6.50k|      source->png_alpha = 0;
  538|  6.50k|    }
  539|  8.13k|    break;
  540|       |
  541|  8.50k|  case SPNG_COLOR_TYPE_TRUECOLOR:
  ------------------
  |  Branch (541:3): [True: 8.50k, False: 23.4k]
  ------------------
  542|  11.4k|  case SPNG_COLOR_TYPE_TRUECOLOR_ALPHA:
  ------------------
  |  Branch (542:3): [True: 2.89k, False: 29.0k]
  ------------------
  543|  11.4k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (543:9): [True: 0, False: 11.4k]
  ------------------
  544|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  545|  11.4k|    TRACEMS3(cinfo, 1, JTRC_PNG_TRUECOLOR, ihdr.width, ihdr.height,
  ------------------
  |  |  309|  11.4k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  11.4k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 11.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  11.4k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  11.4k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  11.4k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  546|  11.4k|             ihdr.bit_depth);
  547|  11.4k|    if (ihdr.color_type == SPNG_COLOR_TYPE_TRUECOLOR &&
  ------------------
  |  Branch (547:9): [True: 8.50k, False: 2.89k]
  ------------------
  548|  8.50k|        cinfo->data_precision == ihdr.bit_depth &&
  ------------------
  |  Branch (548:9): [True: 0, False: 8.50k]
  ------------------
  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|  11.4k|    } else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  11.4k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 11.4k]
  |  |  |  Branch (78:22): [True: 8.14k, False: 3.25k]
  |  |  |  Branch (78:43): [True: 8.14k, False: 0]
  |  |  ------------------
  ------------------
  558|  8.14k|      source->pub.get_pixel_rows = get_rgb_row;
  559|  3.25k|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (559:14): [True: 1.62k, False: 1.62k]
  ------------------
  560|  1.62k|      source->pub.get_pixel_rows = get_rgb_cmyk_row;
  561|  1.62k|    else
  562|  1.62k|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|  1.62k|  ((cinfo)->err->msg_code = (code), \
  |  |  241|  1.62k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  563|  11.4k|    if (ihdr.color_type == SPNG_COLOR_TYPE_TRUECOLOR_ALPHA) {
  ------------------
  |  Branch (563:9): [True: 2.48k, False: 8.91k]
  ------------------
  564|  2.48k|      png_components = 4;
  565|  2.48k|      source->png_alpha = 1;
  566|  8.91k|    } else {
  567|  8.91k|      png_components = 3;
  568|  8.91k|      source->png_alpha = 0;
  569|  8.91k|    }
  570|  11.4k|    break;
  571|       |
  572|    714|  case SPNG_COLOR_TYPE_INDEXED:
  ------------------
  |  Branch (572:3): [True: 714, False: 31.2k]
  ------------------
  573|    714|  {
  574|    714|    int i, gray = 1;
  575|       |
  576|    714|    TRACEMS3(cinfo, 1, JTRC_PNG_INDEXED, ihdr.width, ihdr.height,
  ------------------
  |  |  309|    714|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|    714|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 714]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|    714|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|    714|           (cinfo)->err->msg_code = (code); \
  |  |  312|    714|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  577|    714|             ihdr.bit_depth);
  578|    714|    TRY_SPNG(spng_get_plte(source->ctx, &source->colormap));
  ------------------
  |  |   33|    714|#define TRY_SPNG(f) { \
  |  |   34|    714|  int __spng_error = (f); \
  |  |   35|    714|  if (__spng_error) \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 287, False: 427]
  |  |  ------------------
  |  |   36|    714|    ERREXITS(cinfo, JERR_PNG_LIBSPNG, spng_strerror(__spng_error)); \
  |  |  ------------------
  |  |  |  |  274|    287|  ((cinfo)->err->msg_code = (code), \
  |  |  |  |  275|    287|   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX - 1), \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|    287|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  276|    287|   (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|    287|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  277|    287|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  |  |  ------------------
  |  |   37|    714|}
  ------------------
  579|    714|    if (source->png_bit_depth != 8 || source->colormap.n_entries > 256)
  ------------------
  |  Branch (579:9): [True: 287, False: 427]
  |  Branch (579:39): [True: 0, False: 427]
  ------------------
  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|  64.5k|    for (i = 0; i < (int)source->colormap.n_entries; i++) {
  ------------------
  |  Branch (582:17): [True: 63.8k, False: 714]
  ------------------
  583|  63.8k|      if (source->colormap.entries[i].red !=
  ------------------
  |  Branch (583:11): [True: 55.1k, False: 8.74k]
  ------------------
  584|  63.8k|          source->colormap.entries[i].green ||
  585|  8.74k|          source->colormap.entries[i].green !=
  ------------------
  |  Branch (585:11): [True: 1.21k, False: 7.52k]
  ------------------
  586|  8.74k|          source->colormap.entries[i].blue)
  587|  56.3k|        gray = 0;
  588|  63.8k|    }
  589|       |
  590|    714|    if ((cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (590:10): [True: 287, False: 427]
  ------------------
  591|    427|         cinfo->in_color_space == JCS_RGB) && gray)
  ------------------
  |  Branch (591:10): [True: 0, False: 427]
  |  Branch (591:47): [True: 0, False: 0]
  ------------------
  592|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  593|    714|    else if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (593:14): [True: 0, False: 714]
  ------------------
  594|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  595|    714|    if (cinfo->in_color_space == JCS_GRAYSCALE && !gray)
  ------------------
  |  Branch (595:9): [True: 61, False: 653]
  |  Branch (595:51): [True: 51, False: 10]
  ------------------
  596|     51|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|     51|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     51|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  597|       |
  598|    714|    source->pub.get_pixel_rows = get_indexed_row;
  599|    714|    png_components = 1;
  600|    714|    source->png_alpha = 0;
  601|    714|    break;
  602|  8.50k|  }
  603|       |
  604|      0|  default:
  ------------------
  |  Branch (604:3): [True: 0, False: 31.9k]
  ------------------
  605|      0|    ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  606|  31.9k|  }
  607|       |
  608|  18.2k|  if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  18.2k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 18.2k]
  |  |  |  Branch (78:22): [True: 14.2k, False: 4.02k]
  |  |  |  Branch (78:43): [True: 14.2k, False: 0]
  |  |  ------------------
  ------------------
  609|  14.2k|    cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
  610|  4.02k|  else if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (610:12): [True: 1.17k, False: 2.85k]
  ------------------
  611|  1.17k|    cinfo->input_components = 1;
  612|  2.85k|  else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (612:12): [True: 2.85k, False: 0]
  ------------------
  613|  2.85k|    cinfo->input_components = 4;
  614|       |
  615|       |  /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */
  616|  18.2k|  source->buffer_width =
  617|  18.2k|    (size_t)ihdr.width * png_components * source->png_bit_depth / 8;
  618|  18.2k|  source->iobuffer = (unsigned char *)
  619|  18.2k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  18.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  620|  18.2k|                                source->buffer_width);
  621|       |
  622|       |  /* Create compressor input buffer. */
  623|  18.2k|  if (use_raw_buffer) {
  ------------------
  |  Branch (623:7): [True: 0, False: 18.2k]
  ------------------
  624|       |    /* For unscaled raw-input case, we can just map it onto the I/O buffer. */
  625|       |    /* Synthesize a _JSAMPARRAY pointer structure */
  626|      0|    source->pixrow = (_JSAMPROW)source->iobuffer;
  627|      0|    source->pub._buffer = &source->pixrow;
  ------------------
  |  |  210|      0|#define _buffer  buffer12
  ------------------
  628|      0|    source->pub.buffer_height = 1;
  629|  18.2k|  } else {
  630|  18.2k|    unsigned int maxval = source->png_bit_depth == 16 ? 65535 : 255;
  ------------------
  |  Branch (630:27): [True: 5.32k, False: 12.9k]
  ------------------
  631|  18.2k|    size_t val, half_maxval;
  632|       |
  633|       |    /* Need to translate anyway, so make a separate sample buffer. */
  634|  18.2k|    source->pub._buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  ------------------
  |  |  210|  18.2k|#define _buffer  buffer12
  ------------------
  635|  18.2k|      ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  18.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  636|  18.2k|       (JDIMENSION)ihdr.width * cinfo->input_components, (JDIMENSION)1);
  637|  18.2k|    source->pub.buffer_height = 1;
  638|       |
  639|       |    /* Compute the rescaling array. */
  640|  18.2k|    source->rescale = (_JSAMPLE *)
  641|  18.2k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  18.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  642|  18.2k|                                  (maxval + 1L) * sizeof(_JSAMPLE));
  643|  18.2k|    memset(source->rescale, 0, (maxval + 1L) * sizeof(_JSAMPLE));
  644|  18.2k|    half_maxval = maxval / 2;
  645|   352M|    for (val = 0; val <= maxval; val++) {
  ------------------
  |  Branch (645:19): [True: 352M, False: 18.2k]
  ------------------
  646|       |      /* The multiplication here must be done in 32 bits to avoid overflow */
  647|   352M|      source->rescale[val] =
  648|   352M|        (_JSAMPLE)((val * ((1 << cinfo->data_precision) - 1) + half_maxval) /
  649|   352M|                   maxval);
  650|   352M|    }
  651|  18.2k|  }
  652|       |
  653|  18.2k|  TRY_SPNG(spng_decode_image(source->ctx, NULL, 0, SPNG_FMT_PNG,
  ------------------
  |  |   33|  18.2k|#define TRY_SPNG(f) { \
  |  |   34|  18.2k|  int __spng_error = (f); \
  |  |   35|  18.2k|  if (__spng_error) \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 10.6k, False: 7.66k]
  |  |  ------------------
  |  |   36|  18.2k|    ERREXITS(cinfo, JERR_PNG_LIBSPNG, spng_strerror(__spng_error)); \
  |  |  ------------------
  |  |  |  |  274|  10.6k|  ((cinfo)->err->msg_code = (code), \
  |  |  |  |  275|  10.6k|   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX - 1), \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|  10.6k|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  276|  10.6k|   (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|  10.6k|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  277|  10.6k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  |  |  ------------------
  |  |   37|  18.2k|}
  ------------------
  654|  18.2k|                             SPNG_DECODE_PROGRESSIVE));
  655|  18.2k|}
rdpng-12.c:get_raw_row:
   75|   844k|{
   76|   844k|  png_source_ptr source = (png_source_ptr)sinfo;
   77|   844k|  int spng_error;
   78|       |
   79|   844k|  spng_error = spng_decode_row(source->ctx, source->iobuffer,
   80|   844k|                               source->buffer_width);
   81|   844k|  if (spng_error && spng_error != SPNG_EOI)
  ------------------
  |  Branch (81:7): [True: 6.14k, False: 838k]
  |  Branch (81:21): [True: 3.85k, False: 2.28k]
  ------------------
   82|  3.85k|    ERREXITS(cinfo, JERR_PNG_LIBSPNG, spng_strerror(spng_error)); \
  ------------------
  |  |  274|  3.85k|  ((cinfo)->err->msg_code = (code), \
  |  |  275|  3.85k|   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX - 1), \
  |  |  ------------------
  |  |  |  |  800|  3.85k|#define JMSG_STR_PARM_MAX  80
  |  |  ------------------
  |  |  276|  3.85k|   (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
  |  |  ------------------
  |  |  |  |  800|  3.85k|#define JMSG_STR_PARM_MAX  80
  |  |  ------------------
  |  |  277|  3.85k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   83|   844k|  return 1;
   84|   844k|}
rdpng-12.c:get_gray_row:
  102|  40.8k|{
  103|  40.8k|  png_source_ptr source = (png_source_ptr)sinfo;
  104|  40.8k|  register _JSAMPROW ptr;
  105|  40.8k|  register _JSAMPLE *rescale = source->rescale;
  106|  40.8k|  JDIMENSION col;
  107|       |
  108|  40.8k|  get_raw_row(cinfo, sinfo);
  109|  40.8k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  40.8k|#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|  40.8k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (119:7): [True: 15.9k, False: 24.8k]
  ------------------
  120|  15.9k|    register unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  121|   543k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (121:36): [True: 527k, False: 15.9k]
  ------------------
  122|   527k|      *ptr++ = rescale[*bufferptr++];
  123|   527k|      bufferptr += source->png_alpha;
  124|   527k|    }
  125|  24.8k|  } else {
  126|  24.8k|    register unsigned char *bufferptr = source->iobuffer;
  127|  5.09M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (127:36): [True: 5.06M, False: 24.8k]
  ------------------
  128|  5.06M|      *ptr++ = rescale[*bufferptr++];
  129|  5.06M|      bufferptr += source->png_alpha;
  130|  5.06M|    }
  131|  24.8k|  }
  132|  40.8k|  return 1;
  133|  40.8k|}
rdpng-12.c:get_gray_rgb_row:
  141|   204k|{
  142|   204k|  png_source_ptr source = (png_source_ptr)sinfo;
  143|   204k|  register _JSAMPROW ptr;
  144|   204k|  register _JSAMPLE *rescale = source->rescale;
  145|   204k|  JDIMENSION col;
  146|   204k|  register int rindex = rgb_red[cinfo->in_color_space];
  147|   204k|  register int gindex = rgb_green[cinfo->in_color_space];
  148|   204k|  register int bindex = rgb_blue[cinfo->in_color_space];
  149|   204k|  register int aindex = alpha_index[cinfo->in_color_space];
  150|   204k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  151|       |
  152|   204k|  get_raw_row(cinfo, sinfo);
  153|   204k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|   204k|#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|   204k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (164:7): [True: 79.8k, False: 124k]
  ------------------
  165|  79.8k|    register unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  166|  79.8k|    if (aindex >= 0)
  ------------------
  |  Branch (166:9): [True: 15.9k, False: 63.9k]
  ------------------
  167|  15.9k|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |   87|  15.9k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |   88|   543k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (88:34): [True: 527k, False: 15.9k]
  |  |  ------------------
  |  |   89|   527k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |   90|   527k|    alpha_set_op \
  |  |   91|   527k|    ptr += ps; \
  |  |   92|   527k|    pointer_op \
  |  |   93|   527k|  } \
  |  |   94|  15.9k|}
  ------------------
  168|  79.8k|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;,
  169|  79.8k|                         bufferptr += source->png_alpha;)
  170|  63.9k|    else
  171|  63.9k|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++], {},
  ------------------
  |  |   87|  63.9k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |   88|  2.17M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (88:34): [True: 2.10M, False: 63.9k]
  |  |  ------------------
  |  |   89|  2.10M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |   90|  2.10M|    alpha_set_op \
  |  |   91|  2.10M|    ptr += ps; \
  |  |   92|  2.10M|    pointer_op \
  |  |   93|  2.10M|  } \
  |  |   94|  63.9k|}
  ------------------
  172|  79.8k|                         bufferptr += source->png_alpha;)
  173|   124k|  } else {
  174|   124k|    register unsigned char *bufferptr = source->iobuffer;
  175|   124k|    if (aindex >= 0)
  ------------------
  |  Branch (175:9): [True: 24.6k, False: 99.8k]
  ------------------
  176|  24.6k|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |   87|  24.6k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |   88|  5.09M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (88:34): [True: 5.06M, False: 24.6k]
  |  |  ------------------
  |  |   89|  5.06M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |   90|  5.06M|    alpha_set_op \
  |  |   91|  5.06M|    ptr += ps; \
  |  |   92|  5.06M|    pointer_op \
  |  |   93|  5.06M|  } \
  |  |   94|  24.6k|}
  ------------------
  177|   124k|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;,
  178|   124k|                         bufferptr += source->png_alpha;)
  179|  99.8k|    else
  180|  99.8k|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++], {},
  ------------------
  |  |   87|  99.8k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |   88|  20.3M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (88:34): [True: 20.2M, False: 99.8k]
  |  |  ------------------
  |  |   89|  20.2M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |   90|  20.2M|    alpha_set_op \
  |  |   91|  20.2M|    ptr += ps; \
  |  |   92|  20.2M|    pointer_op \
  |  |   93|  20.2M|  } \
  |  |   94|  99.8k|}
  ------------------
  181|   124k|                         bufferptr += source->png_alpha;)
  182|   124k|  }
  183|   204k|  return 1;
  184|   204k|}
rdpng-12.c:get_gray_cmyk_row:
  192|  40.8k|{
  193|  40.8k|  png_source_ptr source = (png_source_ptr)sinfo;
  194|  40.8k|  register _JSAMPROW ptr;
  195|  40.8k|  register _JSAMPLE *rescale = source->rescale;
  196|  40.8k|  JDIMENSION col;
  197|       |
  198|  40.8k|  get_raw_row(cinfo, sinfo);
  199|  40.8k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  40.8k|#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|  40.8k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (212:7): [True: 15.9k, False: 24.8k]
  ------------------
  213|  15.9k|    unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  214|   543k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (214:36): [True: 527k, False: 15.9k]
  ------------------
  215|   527k|      _JSAMPLE gray = rescale[*bufferptr++];
  ------------------
  |  |  108|   527k|#define _JSAMPLE  J12SAMPLE
  ------------------
  216|   527k|      bufferptr += source->png_alpha;
  217|   527k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  218|   527k|                  ptr + 1, ptr + 2, ptr + 3);
  219|   527k|      ptr += 4;
  220|   527k|    }
  221|  24.8k|  } else {
  222|  24.8k|    register unsigned char *bufferptr = source->iobuffer;
  223|  5.09M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (223:36): [True: 5.06M, False: 24.8k]
  ------------------
  224|  5.06M|      _JSAMPLE gray = rescale[*bufferptr++];
  ------------------
  |  |  108|  5.06M|#define _JSAMPLE  J12SAMPLE
  ------------------
  225|  5.06M|      bufferptr += source->png_alpha;
  226|  5.06M|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  227|  5.06M|                  ptr + 1, ptr + 2, ptr + 3);
  228|  5.06M|      ptr += 4;
  229|  5.06M|    }
  230|  24.8k|  }
  231|  40.8k|  return 1;
  232|  40.8k|}
rdpng-12.c:get_rgb_row:
  252|   456k|{
  253|   456k|  png_source_ptr source = (png_source_ptr)sinfo;
  254|   456k|  register _JSAMPROW ptr;
  255|   456k|  register _JSAMPLE *rescale = source->rescale;
  256|   456k|  JDIMENSION col;
  257|   456k|  register int rindex = rgb_red[cinfo->in_color_space];
  258|   456k|  register int gindex = rgb_green[cinfo->in_color_space];
  259|   456k|  register int bindex = rgb_blue[cinfo->in_color_space];
  260|   456k|  register int aindex = alpha_index[cinfo->in_color_space];
  261|   456k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  262|       |
  263|   456k|  get_raw_row(cinfo, sinfo);
  264|   456k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|   456k|#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|   456k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (275:7): [True: 277k, False: 179k]
  ------------------
  276|   277k|    unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  277|   277k|    if (aindex >= 0)
  ------------------
  |  Branch (277:9): [True: 55.5k, False: 222k]
  ------------------
  278|  55.5k|      RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  235|  55.5k|#define RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |  236|  7.16M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (236:34): [True: 7.11M, False: 55.5k]
  |  |  ------------------
  |  |  237|  7.11M|    ptr[rindex] = read_op; \
  |  |  238|  7.11M|    ptr[gindex] = read_op; \
  |  |  239|  7.11M|    ptr[bindex] = read_op; \
  |  |  240|  7.11M|    alpha_set_op \
  |  |  241|  7.11M|    pointer_op \
  |  |  242|  7.11M|    ptr += ps; \
  |  |  243|  7.11M|  } \
  |  |  244|  55.5k|}
  ------------------
  279|   277k|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;,
  280|   277k|                    bufferptr += source->png_alpha;)
  281|   222k|    else
  282|   222k|      RGB_READ_LOOP(rescale[*bufferptr++], {},
  ------------------
  |  |  235|   222k|#define RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |  236|  28.6M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (236:34): [True: 28.4M, False: 222k]
  |  |  ------------------
  |  |  237|  28.4M|    ptr[rindex] = read_op; \
  |  |  238|  28.4M|    ptr[gindex] = read_op; \
  |  |  239|  28.4M|    ptr[bindex] = read_op; \
  |  |  240|  28.4M|    alpha_set_op \
  |  |  241|  28.4M|    pointer_op \
  |  |  242|  28.4M|    ptr += ps; \
  |  |  243|  28.4M|  } \
  |  |  244|   222k|}
  ------------------
  283|   277k|                    bufferptr += source->png_alpha;)
  284|   277k|  } else {
  285|   179k|    register unsigned char *bufferptr = source->iobuffer;
  286|   179k|    if (aindex >= 0)
  ------------------
  |  Branch (286:9): [True: 35.5k, False: 143k]
  ------------------
  287|  35.5k|      RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  235|  35.5k|#define RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |  236|  8.76M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (236:34): [True: 8.72M, False: 35.5k]
  |  |  ------------------
  |  |  237|  8.72M|    ptr[rindex] = read_op; \
  |  |  238|  8.72M|    ptr[gindex] = read_op; \
  |  |  239|  8.72M|    ptr[bindex] = read_op; \
  |  |  240|  8.72M|    alpha_set_op \
  |  |  241|  8.72M|    pointer_op \
  |  |  242|  8.72M|    ptr += ps; \
  |  |  243|  8.72M|  } \
  |  |  244|  35.5k|}
  ------------------
  288|   179k|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;,
  289|   179k|                    bufferptr += source->png_alpha;)
  290|   143k|    else
  291|   143k|      RGB_READ_LOOP(rescale[*bufferptr++], {},
  ------------------
  |  |  235|   143k|#define RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |  236|  35.0M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (236:34): [True: 34.9M, False: 143k]
  |  |  ------------------
  |  |  237|  34.9M|    ptr[rindex] = read_op; \
  |  |  238|  34.9M|    ptr[gindex] = read_op; \
  |  |  239|  34.9M|    ptr[bindex] = read_op; \
  |  |  240|  34.9M|    alpha_set_op \
  |  |  241|  34.9M|    pointer_op \
  |  |  242|  34.9M|    ptr += ps; \
  |  |  243|  34.9M|  } \
  |  |  244|   143k|}
  ------------------
  292|   179k|                    bufferptr += source->png_alpha;)
  293|   179k|  }
  294|   456k|  return 1;
  295|   456k|}
rdpng-12.c:get_rgb_cmyk_row:
  303|  91.3k|{
  304|  91.3k|  png_source_ptr source = (png_source_ptr)sinfo;
  305|  91.3k|  register _JSAMPROW ptr;
  306|  91.3k|  register _JSAMPLE *rescale = source->rescale;
  307|  91.3k|  JDIMENSION col;
  308|       |
  309|  91.3k|  get_raw_row(cinfo, sinfo);
  310|  91.3k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  91.3k|#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|  91.3k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (324:7): [True: 55.5k, False: 35.8k]
  ------------------
  325|  55.5k|    unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  326|  7.16M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (326:36): [True: 7.11M, False: 55.5k]
  ------------------
  327|  7.11M|      _JSAMPLE r = rescale[*bufferptr++];
  ------------------
  |  |  108|  7.11M|#define _JSAMPLE  J12SAMPLE
  ------------------
  328|  7.11M|      _JSAMPLE g = rescale[*bufferptr++];
  ------------------
  |  |  108|  7.11M|#define _JSAMPLE  J12SAMPLE
  ------------------
  329|  7.11M|      _JSAMPLE b = rescale[*bufferptr++];
  ------------------
  |  |  108|  7.11M|#define _JSAMPLE  J12SAMPLE
  ------------------
  330|  7.11M|      bufferptr += source->png_alpha;
  331|  7.11M|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  332|  7.11M|                  ptr + 2, ptr + 3);
  333|  7.11M|      ptr += 4;
  334|  7.11M|    }
  335|  55.5k|  } else {
  336|  35.8k|    register unsigned char *bufferptr = source->iobuffer;
  337|  8.76M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (337:36): [True: 8.72M, False: 35.8k]
  ------------------
  338|  8.72M|      _JSAMPLE r = rescale[*bufferptr++];
  ------------------
  |  |  108|  8.72M|#define _JSAMPLE  J12SAMPLE
  ------------------
  339|  8.72M|      _JSAMPLE g = rescale[*bufferptr++];
  ------------------
  |  |  108|  8.72M|#define _JSAMPLE  J12SAMPLE
  ------------------
  340|  8.72M|      _JSAMPLE b = rescale[*bufferptr++];
  ------------------
  |  |  108|  8.72M|#define _JSAMPLE  J12SAMPLE
  ------------------
  341|  8.72M|      bufferptr += source->png_alpha;
  342|  8.72M|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  343|  8.72M|                  ptr + 2, ptr + 3);
  344|  8.72M|      ptr += 4;
  345|  8.72M|    }
  346|  35.8k|  }
  347|  91.3k|  return 1;
  348|  91.3k|}
rdpng-12.c:get_indexed_row:
  353|  9.83k|{
  354|       |/* This version is for reading 8-bit-per-channel indexed-color PNG files and
  355|       | * converting to extended RGB or CMYK.
  356|       | */
  357|  9.83k|  png_source_ptr source = (png_source_ptr)sinfo;
  358|  9.83k|  register _JSAMPROW ptr;
  359|  9.83k|  register JSAMPLE *bufferptr = (JSAMPLE *)source->iobuffer;
  360|  9.83k|  register _JSAMPLE *rescale = source->rescale;
  361|  9.83k|  JDIMENSION col;
  362|       |
  363|  9.83k|  get_raw_row(cinfo, sinfo);
  364|  9.83k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  9.83k|#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|  9.83k|  {
  410|  9.83k|    if (cinfo->in_color_space == JCS_GRAYSCALE) {
  ------------------
  |  Branch (410:9): [True: 25, False: 9.80k]
  ------------------
  411|    204|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (411:38): [True: 179, False: 25]
  ------------------
  412|    179|        JSAMPLE index = *bufferptr++;
  413|       |
  414|    179|        if (index >= source->colormap.n_entries)
  ------------------
  |  Branch (414:13): [True: 5, False: 174]
  ------------------
  415|      5|          ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  ------------------
  |  |  240|      5|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      5|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  416|    179|        *ptr++ = rescale[source->colormap.entries[index].red];
  417|    179|      }
  418|  9.80k|    } else if (cinfo->in_color_space == JCS_CMYK) {
  ------------------
  |  Branch (418:16): [True: 8.27k, False: 1.53k]
  ------------------
  419|  3.87M|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (419:38): [True: 3.87M, False: 8.27k]
  ------------------
  420|  3.87M|        JSAMPLE index = *bufferptr++;
  421|       |
  422|  3.87M|        if (index >= source->colormap.n_entries)
  ------------------
  |  Branch (422:13): [True: 23, False: 3.87M]
  ------------------
  423|     23|          ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  ------------------
  |  |  240|     23|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     23|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  424|  3.87M|        rgb_to_cmyk((1 << cinfo->data_precision) - 1,
  425|  3.87M|                    rescale[source->colormap.entries[index].red],
  426|  3.87M|                    rescale[source->colormap.entries[index].green],
  427|  3.87M|                    rescale[source->colormap.entries[index].blue], ptr,
  428|  3.87M|                    ptr + 1, ptr + 2, ptr + 3);
  429|  3.87M|        ptr += 4;
  430|  3.87M|      }
  431|  8.27k|    } else {
  432|  1.53k|      register int rindex = rgb_red[cinfo->in_color_space];
  433|  1.53k|      register int gindex = rgb_green[cinfo->in_color_space];
  434|  1.53k|      register int bindex = rgb_blue[cinfo->in_color_space];
  435|  1.53k|      register int aindex = alpha_index[cinfo->in_color_space];
  436|  1.53k|      register int ps = rgb_pixelsize[cinfo->in_color_space];
  437|       |
  438|   166k|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (438:38): [True: 165k, False: 1.53k]
  ------------------
  439|   165k|        JSAMPLE index = *bufferptr++;
  440|       |
  441|   165k|        if (index >= source->colormap.n_entries)
  ------------------
  |  Branch (441:13): [True: 175, False: 164k]
  ------------------
  442|    175|          ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  ------------------
  |  |  240|    175|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    175|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  443|   165k|        ptr[rindex] = rescale[source->colormap.entries[index].red];
  444|   165k|        ptr[gindex] = rescale[source->colormap.entries[index].green];
  445|   165k|        ptr[bindex] = rescale[source->colormap.entries[index].blue];
  446|   165k|        if (aindex >= 0)
  ------------------
  |  Branch (446:13): [True: 33.2k, False: 131k]
  ------------------
  447|  33.2k|          ptr[aindex] = (1 << cinfo->data_precision) - 1;
  448|   165k|        ptr += ps;
  449|   165k|      }
  450|  1.53k|    }
  451|  9.83k|  }
  452|  9.83k|  return 1;
  453|  9.83k|}
rdpng-12.c:read_icc_profile_png:
  665|  7.66k|{
  666|  7.66k|  png_source_ptr source = (png_source_ptr)sinfo;
  667|  7.66k|  struct spng_iccp iccp;
  668|       |
  669|  7.66k|  if (!icc_data_ptr || !icc_data_len)
  ------------------
  |  Branch (669:7): [True: 0, False: 7.66k]
  |  Branch (669:24): [True: 0, False: 7.66k]
  ------------------
  670|      0|    ERREXIT(cinfo, JERR_BUFFER_SIZE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  671|       |
  672|  7.66k|  if (source->ctx && spng_get_iccp(source->ctx, &iccp) == 0) {
  ------------------
  |  Branch (672:7): [True: 7.66k, False: 0]
  |  Branch (672:22): [True: 7, False: 7.66k]
  ------------------
  673|      7|    *icc_data_ptr = (JOCTET *)iccp.profile;
  674|      7|    *icc_data_len = (unsigned int)iccp.profile_len;
  675|      7|    return TRUE;
  ------------------
  |  |  210|      7|#define TRUE    1
  ------------------
  676|      7|  }
  677|       |
  678|  7.66k|  return FALSE;
  ------------------
  |  |  207|  7.66k|#define FALSE   0               /* values of boolean */
  ------------------
  679|  7.66k|}
rdpng-12.c:finish_input_png:
  688|  31.9k|{
  689|  31.9k|  png_source_ptr source = (png_source_ptr)sinfo;
  690|       |
  691|  31.9k|  if (source->ctx) {
  ------------------
  |  Branch (691:7): [True: 31.9k, False: 0]
  ------------------
  692|  31.9k|    spng_decode_chunks(source->ctx);
  693|  31.9k|    spng_ctx_free(source->ctx);
  694|       |    source->ctx = NULL;
  695|  31.9k|  }
  696|  31.9k|}

j12init_read_ppm:
  924|  15.3k|{
  925|  15.3k|  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|  15.3k|  if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  ------------------
  |  |   12|  30.7k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (930:7): [True: 0, False: 15.3k]
  ------------------
  931|  15.3k|      cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  ------------------
  |  |   12|  15.3k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (931:7): [True: 0, False: 15.3k]
  ------------------
  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|  15.3k|  source = (ppm_source_ptr)
  937|  15.3k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  15.3k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  938|  15.3k|                                sizeof(ppm_source_struct));
  939|       |  /* Fill in method ptrs, except get_pixel_rows which start_input sets */
  940|  15.3k|  source->pub.start_input = start_input_ppm;
  941|  15.3k|  source->pub.read_icc_profile = read_icc_profile_ppm;
  942|  15.3k|  source->pub.finish_input = finish_input_ppm;
  943|  15.3k|  source->pub.max_pixels = 0;
  944|       |
  945|  15.3k|  return (cjpeg_source_ptr)source;
  946|  15.3k|}
rdppm-12.c:start_input_ppm:
  703|  15.3k|{
  704|  15.3k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  705|  15.3k|  int c;
  706|  15.3k|  unsigned int w, h, maxval;
  707|  15.3k|  boolean need_iobuffer, use_raw_buffer, need_rescale;
  708|       |
  709|  15.3k|  if (getc(source->pub.input_file) != 'P')
  ------------------
  |  Branch (709:7): [True: 0, False: 15.3k]
  ------------------
  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|  15.3k|  c = getc(source->pub.input_file); /* subformat discriminator character */
  713|       |
  714|       |  /* detect unsupported variants (ie, PBM) before trying to read header */
  715|  15.3k|  switch (c) {
  716|  1.47k|  case '2':                     /* it's a text-format PGM file */
  ------------------
  |  Branch (716:3): [True: 1.47k, False: 13.9k]
  ------------------
  717|  3.06k|  case '3':                     /* it's a text-format PPM file */
  ------------------
  |  Branch (717:3): [True: 1.58k, False: 13.7k]
  ------------------
  718|  11.2k|  case '5':                     /* it's a raw-format PGM file */
  ------------------
  |  Branch (718:3): [True: 8.22k, False: 7.15k]
  ------------------
  719|  15.3k|  case '6':                     /* it's a raw-format PPM file */
  ------------------
  |  Branch (719:3): [True: 4.05k, False: 11.3k]
  ------------------
  720|  15.3k|    break;
  721|     35|  default:
  ------------------
  |  Branch (721:3): [True: 35, False: 15.3k]
  ------------------
  722|     35|    ERREXIT(cinfo, JERR_PPM_NOT);
  ------------------
  |  |  240|     35|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     35|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  723|     35|    break;
  724|  15.3k|  }
  725|       |
  726|       |  /* fetch the remaining header info */
  727|  15.3k|  w = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  728|  15.3k|  h = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  729|  15.3k|  maxval = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  730|       |
  731|  15.3k|  if (w <= 0 || h <= 0 || maxval <= 0) /* error check */
  ------------------
  |  Branch (731:7): [True: 1.17k, False: 14.1k]
  |  Branch (731:17): [True: 14, False: 14.1k]
  |  Branch (731:27): [True: 14, False: 14.1k]
  ------------------
  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|  15.3k|  if (w > JPEG_MAX_DIMENSION || h > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  30.6k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
                if (w > JPEG_MAX_DIMENSION || h > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  14.1k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (733:7): [True: 1.21k, False: 14.1k]
  |  Branch (733:33): [True: 14, False: 14.1k]
  ------------------
  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|  15.3k|  if (sinfo->max_pixels && (unsigned long long)w * h > sinfo->max_pixels)
  ------------------
  |  Branch (735:7): [True: 14.1k, False: 1.22k]
  |  Branch (735:28): [True: 245, False: 13.8k]
  ------------------
  736|    245|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
  ------------------
  |  |  243|    245|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    245|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    245|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  737|       |
  738|  15.3k|  cinfo->image_width = (JDIMENSION)w;
  739|  15.3k|  cinfo->image_height = (JDIMENSION)h;
  740|  15.3k|  source->maxval = maxval;
  741|       |
  742|       |  /* initialize flags to most common settings */
  743|  15.3k|  need_iobuffer = TRUE;         /* do we need an I/O buffer? */
  ------------------
  |  |  210|  15.3k|#define TRUE    1
  ------------------
  744|  15.3k|  use_raw_buffer = FALSE;       /* do we map input buffer onto I/O buffer? */
  ------------------
  |  |  207|  15.3k|#define FALSE   0               /* values of boolean */
  ------------------
  745|  15.3k|  need_rescale = TRUE;          /* do we need a rescale array? */
  ------------------
  |  |  210|  15.3k|#define TRUE    1
  ------------------
  746|       |
  747|  15.3k|  switch (c) {
  ------------------
  |  Branch (747:11): [True: 13.8k, False: 1.47k]
  ------------------
  748|  1.07k|  case '2':                     /* it's a text-format PGM file */
  ------------------
  |  Branch (748:3): [True: 1.07k, False: 14.2k]
  ------------------
  749|  1.07k|    if (cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (749:9): [True: 0, False: 1.07k]
  ------------------
  750|  1.07k|        cinfo->in_color_space == JCS_RGB)
  ------------------
  |  Branch (750:9): [True: 0, False: 1.07k]
  ------------------
  751|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  752|  1.07k|    TRACEMS3(cinfo, 1, JTRC_PGM_TEXT, w, h, maxval);
  ------------------
  |  |  309|  1.07k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.07k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.07k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  1.07k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  1.07k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  1.07k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  753|  1.07k|    if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (753:9): [True: 153, False: 918]
  ------------------
  754|    153|      source->pub.get_pixel_rows = get_text_gray_row;
  755|    918|    else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|    918|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 918]
  |  |  |  Branch (78:22): [True: 765, False: 153]
  |  |  |  Branch (78:43): [True: 765, False: 0]
  |  |  ------------------
  ------------------
  756|    765|      source->pub.get_pixel_rows = get_text_gray_rgb_row;
  757|    153|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (757:14): [True: 153, False: 0]
  ------------------
  758|    153|      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.07k|    need_iobuffer = FALSE;
  ------------------
  |  |  207|  1.07k|#define FALSE   0               /* values of boolean */
  ------------------
  762|  1.07k|    break;
  763|       |
  764|  1.21k|  case '3':                     /* it's a text-format PPM file */
  ------------------
  |  Branch (764:3): [True: 1.21k, False: 14.1k]
  ------------------
  765|  1.21k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (765:9): [True: 0, False: 1.21k]
  ------------------
  766|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  767|  1.21k|    TRACEMS3(cinfo, 1, JTRC_PPM_TEXT, w, h, maxval);
  ------------------
  |  |  309|  1.21k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.21k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.21k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  1.21k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  1.21k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  1.21k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  768|  1.21k|    if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  1.21k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 1.21k]
  |  |  |  Branch (78:22): [True: 865, False: 346]
  |  |  |  Branch (78:43): [True: 865, False: 0]
  |  |  ------------------
  ------------------
  769|    865|      source->pub.get_pixel_rows = get_text_rgb_row;
  770|    346|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (770:14): [True: 173, False: 173]
  ------------------
  771|    173|      source->pub.get_pixel_rows = get_text_rgb_cmyk_row;
  772|    173|    else
  773|    173|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    173|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    173|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  774|  1.21k|    need_iobuffer = FALSE;
  ------------------
  |  |  207|  1.21k|#define FALSE   0               /* values of boolean */
  ------------------
  775|  1.21k|    break;
  776|       |
  777|  7.83k|  case '5':                     /* it's a raw-format PGM file */
  ------------------
  |  Branch (777:3): [True: 7.83k, False: 7.51k]
  ------------------
  778|  7.83k|    if (cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (778:9): [True: 0, False: 7.83k]
  ------------------
  779|  7.83k|        cinfo->in_color_space == JCS_RGB)
  ------------------
  |  Branch (779:9): [True: 0, False: 7.83k]
  ------------------
  780|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  781|  7.83k|    TRACEMS3(cinfo, 1, JTRC_PGM, w, h, maxval);
  ------------------
  |  |  309|  7.83k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  7.83k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 7.83k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  7.83k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  7.83k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  7.83k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  782|  7.83k|    if (maxval > 255) {
  ------------------
  |  Branch (782:9): [True: 1.14k, False: 6.68k]
  ------------------
  783|  1.14k|      if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (783:11): [True: 164, False: 984]
  ------------------
  784|    164|        source->pub.get_pixel_rows = get_word_gray_row;
  785|    984|      else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|    984|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 984]
  |  |  |  Branch (78:22): [True: 820, False: 164]
  |  |  |  Branch (78:43): [True: 820, False: 0]
  |  |  ------------------
  ------------------
  786|    820|        source->pub.get_pixel_rows = get_word_gray_rgb_row;
  787|    164|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (787:16): [True: 164, False: 0]
  ------------------
  788|    164|        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|  6.68k|    } else {
  800|  6.68k|      if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (800:11): [True: 955, False: 5.73k]
  ------------------
  801|    955|        source->pub.get_pixel_rows = get_scaled_gray_row;
  802|  5.73k|      else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  5.73k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 5.73k]
  |  |  |  Branch (78:22): [True: 4.77k, False: 955]
  |  |  |  Branch (78:43): [True: 4.77k, False: 0]
  |  |  ------------------
  ------------------
  803|  4.77k|        source->pub.get_pixel_rows = get_gray_rgb_row;
  804|    955|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (804:16): [True: 955, False: 0]
  ------------------
  805|    955|        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|  6.68k|    }
  809|  7.83k|    break;
  810|       |
  811|  3.75k|  case '6':                     /* it's a raw-format PPM file */
  ------------------
  |  Branch (811:3): [True: 3.75k, False: 11.5k]
  ------------------
  812|  3.75k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (812:9): [True: 0, False: 3.75k]
  ------------------
  813|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  814|  3.75k|    TRACEMS3(cinfo, 1, JTRC_PPM, w, h, maxval);
  ------------------
  |  |  309|  3.75k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  3.75k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 3.75k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  3.75k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  3.75k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  3.75k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  815|  3.75k|    if (maxval > 255) {
  ------------------
  |  Branch (815:9): [True: 1.75k, False: 2.00k]
  ------------------
  816|  1.75k|      if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  1.75k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 1.75k]
  |  |  |  Branch (78:22): [True: 1.25k, False: 502]
  |  |  |  Branch (78:43): [True: 1.25k, False: 0]
  |  |  ------------------
  ------------------
  817|  1.25k|        source->pub.get_pixel_rows = get_word_rgb_row;
  818|    502|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (818:16): [True: 251, False: 251]
  ------------------
  819|    251|        source->pub.get_pixel_rows = get_word_rgb_cmyk_row;
  820|    251|      else
  821|    251|        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    251|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    251|   (*(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.00k|    } else {
  836|  2.00k|      if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  2.00k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 2.00k]
  |  |  |  Branch (78:22): [True: 1.43k, False: 572]
  |  |  |  Branch (78:43): [True: 1.43k, False: 0]
  |  |  ------------------
  ------------------
  837|  1.43k|        source->pub.get_pixel_rows = get_rgb_row;
  838|    572|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (838:16): [True: 286, False: 286]
  ------------------
  839|    286|        source->pub.get_pixel_rows = get_rgb_cmyk_row;
  840|    286|      else
  841|    286|        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    286|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    286|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  842|  2.00k|    }
  843|  3.75k|    break;
  844|  15.3k|  }
  845|       |
  846|  13.1k|  if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  13.1k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 13.1k]
  |  |  |  Branch (78:22): [True: 9.91k, False: 3.25k]
  |  |  |  Branch (78:43): [True: 9.91k, False: 0]
  |  |  ------------------
  ------------------
  847|  9.91k|    cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
  848|  3.25k|  else if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (848:12): [True: 1.27k, False: 1.98k]
  ------------------
  849|  1.27k|    cinfo->input_components = 1;
  850|  1.98k|  else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (850:12): [True: 1.98k, False: 0]
  ------------------
  851|  1.98k|    cinfo->input_components = 4;
  852|       |
  853|       |  /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */
  854|  13.1k|  if (need_iobuffer) {
  ------------------
  |  Branch (854:7): [True: 11.0k, False: 2.10k]
  ------------------
  855|  11.0k|    if (c == '6')
  ------------------
  |  Branch (855:9): [True: 3.22k, False: 7.83k]
  ------------------
  856|  3.22k|      source->buffer_width = (size_t)w * 3 * (maxval <= 255 ? 1 : 2);
  ------------------
  |  Branch (856:47): [True: 1.71k, False: 1.50k]
  ------------------
  857|  7.83k|    else
  858|  7.83k|      source->buffer_width = (size_t)w * (maxval <= 255 ? 1 : 2);
  ------------------
  |  Branch (858:43): [True: 6.68k, False: 1.14k]
  ------------------
  859|  11.0k|    source->iobuffer = (unsigned char *)
  860|  11.0k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  11.0k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  861|  11.0k|                                  source->buffer_width);
  862|  11.0k|  }
  863|       |
  864|       |  /* Create compressor input buffer. */
  865|  13.1k|  if (use_raw_buffer) {
  ------------------
  |  Branch (865:7): [True: 0, False: 13.1k]
  ------------------
  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|  13.1k|  } else {
  872|       |    /* Need to translate anyway, so make a separate sample buffer. */
  873|  13.1k|    source->pub._buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  ------------------
  |  |  210|  13.1k|#define _buffer  buffer12
  ------------------
  874|  13.1k|      ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  13.1k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  875|  13.1k|       (JDIMENSION)w * cinfo->input_components, (JDIMENSION)1);
  876|  13.1k|    source->pub.buffer_height = 1;
  877|  13.1k|  }
  878|       |
  879|       |  /* Compute the rescaling array if required. */
  880|  13.1k|  if (need_rescale) {
  ------------------
  |  Branch (880:7): [True: 13.1k, False: 0]
  ------------------
  881|  13.1k|    size_t val, half_maxval;
  882|       |
  883|       |    /* On 16-bit-int machines we have to be careful of maxval = 65535 */
  884|  13.1k|    source->rescale = (_JSAMPLE *)
  885|  13.1k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  13.1k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  886|  13.1k|                                  (MAX(maxval, 255) + 1L) * sizeof(_JSAMPLE));
  ------------------
  |  |  513|  13.1k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 3.54k, False: 9.62k]
  |  |  ------------------
  ------------------
  887|  13.1k|    memset(source->rescale, 0, (MAX(maxval, 255) + 1L) * sizeof(_JSAMPLE));
  ------------------
  |  |  513|  13.1k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 3.54k, False: 9.62k]
  |  |  ------------------
  ------------------
  888|  13.1k|    half_maxval = (size_t)maxval / 2;
  889|  28.4M|    for (val = 0; val <= (size_t)maxval; val++) {
  ------------------
  |  Branch (889:19): [True: 28.4M, False: 13.1k]
  ------------------
  890|       |      /* The multiplication here must be done in 32 bits to avoid overflow */
  891|  28.4M|      source->rescale[val] =
  892|  28.4M|        (_JSAMPLE)((val * ((1 << cinfo->data_precision) - 1) + half_maxval) /
  893|  28.4M|                   maxval);
  894|  28.4M|    }
  895|  13.1k|  }
  896|  13.1k|}
rdppm-12.c:read_pbm_integer:
   92|   121k|{
   93|   121k|  register int ch;
   94|   121k|  register unsigned int val;
   95|       |
   96|       |  /* Skip any leading whitespace */
   97|   129k|  do {
   98|   129k|    ch = pbm_getc(infile);
   99|   129k|    if (ch == EOF)
  ------------------
  |  Branch (99:9): [True: 2.58k, False: 126k]
  ------------------
  100|  2.58k|      ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|  2.58k|  ((cinfo)->err->msg_code = (code), \
  |  |  241|  2.58k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  101|   129k|  } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
  ------------------
  |  Branch (101:12): [True: 3.83k, False: 125k]
  |  Branch (101:25): [True: 1.00k, False: 124k]
  |  Branch (101:39): [True: 3.93k, False: 120k]
  |  Branch (101:53): [True: 1.85k, False: 118k]
  ------------------
  102|       |
  103|   121k|  if (ch < '0' || ch > '9')
  ------------------
  |  Branch (103:7): [True: 2.74k, False: 118k]
  |  Branch (103:19): [True: 149, False: 118k]
  ------------------
  104|    305|    ERREXIT(cinfo, JERR_PPM_NONNUMERIC);
  ------------------
  |  |  240|    305|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    305|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  105|       |
  106|   121k|  val = ch - '0';
  107|   158k|  while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') {
  ------------------
  |  Branch (107:10): [True: 94.9k, False: 63.4k]
  |  Branch (107:44): [True: 37.2k, False: 57.6k]
  ------------------
  108|  37.2k|    val *= 10;
  109|  37.2k|    val += ch - '0';
  110|  37.2k|    if (val > maxval)
  ------------------
  |  Branch (110:9): [True: 145, False: 37.1k]
  ------------------
  111|    145|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    145|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    145|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  112|  37.2k|  }
  113|       |
  114|   121k|  return val;
  115|   121k|}
rdppm-12.c:pbm_getc:
   73|   284k|{
   74|   284k|  register int ch;
   75|       |
   76|   284k|  ch = getc(infile);
   77|   284k|  if (ch == '#') {
  ------------------
  |  Branch (77:7): [True: 3.43k, False: 281k]
  ------------------
   78|  48.5k|    do {
   79|  48.5k|      ch = getc(infile);
   80|  48.5k|    } while (ch != '\n' && ch != EOF);
  ------------------
  |  Branch (80:14): [True: 45.5k, False: 3.07k]
  |  Branch (80:28): [True: 45.1k, False: 363]
  ------------------
   81|  3.43k|  }
   82|   284k|  return ch;
   83|   284k|}
rdppm-12.c:get_text_gray_row:
  133|  1.38k|{
  134|  1.38k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  135|  1.38k|  FILE *infile = source->pub.input_file;
  136|  1.38k|  register _JSAMPROW ptr;
  137|  1.38k|  register _JSAMPLE *rescale = source->rescale;
  138|  1.38k|  JDIMENSION col;
  139|  1.38k|  unsigned int maxval = source->maxval;
  140|       |
  141|  1.38k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  1.38k|#define _buffer  buffer12
  ------------------
  142|  3.82k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (142:34): [True: 2.44k, False: 1.38k]
  ------------------
  143|  2.44k|    *ptr++ = rescale[read_pbm_integer(cinfo, infile, maxval)];
  144|  2.44k|  }
  145|  1.38k|  return 1;
  146|  1.38k|}
rdppm-12.c:get_text_gray_rgb_row:
  161|  6.90k|{
  162|  6.90k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  163|  6.90k|  FILE *infile = source->pub.input_file;
  164|  6.90k|  register _JSAMPROW ptr;
  165|  6.90k|  register _JSAMPLE *rescale = source->rescale;
  166|  6.90k|  JDIMENSION col;
  167|  6.90k|  unsigned int maxval = source->maxval;
  168|  6.90k|  register int rindex = rgb_red[cinfo->in_color_space];
  169|  6.90k|  register int gindex = rgb_green[cinfo->in_color_space];
  170|  6.90k|  register int bindex = rgb_blue[cinfo->in_color_space];
  171|  6.90k|  register int aindex = alpha_index[cinfo->in_color_space];
  172|  6.90k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  173|       |
  174|  6.90k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  6.90k|#define _buffer  buffer12
  ------------------
  175|  6.90k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (175:7): [True: 1.13k, False: 5.77k]
  ------------------
  176|  1.13k|    if (aindex >= 0)
  ------------------
  |  Branch (176:9): [True: 226, False: 904]
  ------------------
  177|    226|      GRAY_RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
  ------------------
  |  |  149|    226|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|    774|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 548, False: 226]
  |  |  ------------------
  |  |  151|    548|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|    548|    alpha_set_op \
  |  |  153|    548|    ptr += ps; \
  |  |  154|    548|  } \
  |  |  155|    226|}
  ------------------
  178|  1.13k|                         ptr[aindex] = (_JSAMPLE)maxval;)
  179|    904|    else
  180|    904|      GRAY_RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
  ------------------
  |  |  149|    904|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  3.09k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 2.19k, False: 904]
  |  |  ------------------
  |  |  151|  2.19k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  2.19k|    alpha_set_op \
  |  |  153|  2.19k|    ptr += ps; \
  |  |  154|  2.19k|  } \
  |  |  155|    904|}
  ------------------
  181|  5.77k|  } else {
  182|  5.77k|    if (aindex >= 0)
  ------------------
  |  Branch (182:9): [True: 1.15k, False: 4.61k]
  ------------------
  183|  1.15k|      GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
  ------------------
  |  |  149|  1.15k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  3.05k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 1.89k, False: 1.15k]
  |  |  ------------------
  |  |  151|  1.89k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  1.89k|    alpha_set_op \
  |  |  153|  1.89k|    ptr += ps; \
  |  |  154|  1.89k|  } \
  |  |  155|  1.15k|}
  ------------------
  184|  5.77k|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  185|  4.61k|    else
  186|  4.61k|      GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
  ------------------
  |  |  149|  4.61k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  12.2k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 7.59k, False: 4.61k]
  |  |  ------------------
  |  |  151|  7.59k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  7.59k|    alpha_set_op \
  |  |  153|  7.59k|    ptr += ps; \
  |  |  154|  7.59k|  } \
  |  |  155|  4.61k|}
  ------------------
  187|  5.77k|  }
  188|  6.90k|  return 1;
  189|  6.90k|}
rdppm-12.c:get_text_gray_cmyk_row:
  196|  1.38k|{
  197|  1.38k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  198|  1.38k|  FILE *infile = source->pub.input_file;
  199|  1.38k|  register _JSAMPROW ptr;
  200|  1.38k|  register _JSAMPLE *rescale = source->rescale;
  201|  1.38k|  JDIMENSION col;
  202|  1.38k|  unsigned int maxval = source->maxval;
  203|       |
  204|  1.38k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  1.38k|#define _buffer  buffer12
  ------------------
  205|  1.38k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (205:7): [True: 226, False: 1.15k]
  ------------------
  206|    774|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (206:36): [True: 548, False: 226]
  ------------------
  207|    548|      _JSAMPLE gray = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  108|    548|#define _JSAMPLE  J12SAMPLE
  ------------------
  208|    548|      rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
  209|    548|      ptr += 4;
  210|    548|    }
  211|  1.15k|  } else {
  212|  3.05k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (212:36): [True: 1.89k, False: 1.15k]
  ------------------
  213|  1.89k|      _JSAMPLE gray = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  108|  1.89k|#define _JSAMPLE  J12SAMPLE
  ------------------
  214|  1.89k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  215|  1.89k|                  ptr + 1, ptr + 2, ptr + 3);
  216|  1.89k|      ptr += 4;
  217|  1.89k|    }
  218|  1.15k|  }
  219|  1.38k|  return 1;
  220|  1.38k|}
rdppm-12.c:get_text_rgb_row:
  236|  7.18k|{
  237|  7.18k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  238|  7.18k|  FILE *infile = source->pub.input_file;
  239|  7.18k|  register _JSAMPROW ptr;
  240|  7.18k|  register _JSAMPLE *rescale = source->rescale;
  241|  7.18k|  JDIMENSION col;
  242|  7.18k|  unsigned int maxval = source->maxval;
  243|  7.18k|  register int rindex = rgb_red[cinfo->in_color_space];
  244|  7.18k|  register int gindex = rgb_green[cinfo->in_color_space];
  245|  7.18k|  register int bindex = rgb_blue[cinfo->in_color_space];
  246|  7.18k|  register int aindex = alpha_index[cinfo->in_color_space];
  247|  7.18k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  248|       |
  249|  7.18k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  7.18k|#define _buffer  buffer12
  ------------------
  250|  7.18k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (250:7): [True: 1.36k, False: 5.81k]
  ------------------
  251|  1.36k|    if (aindex >= 0)
  ------------------
  |  Branch (251:9): [True: 273, False: 1.09k]
  ------------------
  252|    273|      RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
  ------------------
  |  |  223|    273|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  1.72k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 1.44k, False: 273]
  |  |  ------------------
  |  |  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|    273|}
  ------------------
  253|  1.36k|                    ptr[aindex] = (_JSAMPLE)maxval;)
  254|  1.09k|    else
  255|  1.09k|      RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
  ------------------
  |  |  223|  1.09k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  6.88k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 5.78k, False: 1.09k]
  |  |  ------------------
  |  |  225|  5.78k|    ptr[rindex] = read_op; \
  |  |  226|  5.78k|    ptr[gindex] = read_op; \
  |  |  227|  5.78k|    ptr[bindex] = read_op; \
  |  |  228|  5.78k|    alpha_set_op \
  |  |  229|  5.78k|    ptr += ps; \
  |  |  230|  5.78k|  } \
  |  |  231|  1.09k|}
  ------------------
  256|  5.81k|  } else {
  257|  5.81k|    if (aindex >= 0)
  ------------------
  |  Branch (257:9): [True: 1.16k, False: 4.65k]
  ------------------
  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.14k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 1.98k, False: 1.16k]
  |  |  ------------------
  |  |  225|  1.98k|    ptr[rindex] = read_op; \
  |  |  226|  1.98k|    ptr[gindex] = read_op; \
  |  |  227|  1.98k|    ptr[bindex] = read_op; \
  |  |  228|  1.98k|    alpha_set_op \
  |  |  229|  1.98k|    ptr += ps; \
  |  |  230|  1.98k|  } \
  |  |  231|  1.16k|}
  ------------------
  259|  5.81k|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  260|  4.65k|    else
  261|  4.65k|      RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
  ------------------
  |  |  223|  4.65k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  12.5k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 7.93k, False: 4.65k]
  |  |  ------------------
  |  |  225|  7.93k|    ptr[rindex] = read_op; \
  |  |  226|  7.93k|    ptr[gindex] = read_op; \
  |  |  227|  7.93k|    ptr[bindex] = read_op; \
  |  |  228|  7.93k|    alpha_set_op \
  |  |  229|  7.93k|    ptr += ps; \
  |  |  230|  7.93k|  } \
  |  |  231|  4.65k|}
  ------------------
  262|  5.81k|  }
  263|  7.18k|  return 1;
  264|  7.18k|}
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: 273, False: 1.16k]
  ------------------
  281|  1.72k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (281:36): [True: 1.44k, False: 273]
  ------------------
  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.14k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (289:36): [True: 1.98k, False: 1.16k]
  ------------------
  290|  1.98k|      _JSAMPLE r = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  108|  1.98k|#define _JSAMPLE  J12SAMPLE
  ------------------
  291|  1.98k|      _JSAMPLE g = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  108|  1.98k|#define _JSAMPLE  J12SAMPLE
  ------------------
  292|  1.98k|      _JSAMPLE b = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  108|  1.98k|#define _JSAMPLE  J12SAMPLE
  ------------------
  293|  1.98k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  294|  1.98k|                  ptr + 2, ptr + 3);
  295|  1.98k|      ptr += 4;
  296|  1.98k|    }
  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: 82, False: 34.5k]
  ------------------
  500|     82|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     82|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     82|   (*(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.6k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (503:34): [True: 35.9k, False: 34.6k]
  ------------------
  504|  35.9k|    register unsigned int temp;
  505|  35.9k|    temp  = (*bufferptr++) << 8;
  506|  35.9k|    temp |= (*bufferptr++);
  507|  35.9k|    if (temp > maxval)
  ------------------
  |  Branch (507:9): [True: 66, False: 35.9k]
  ------------------
  508|     66|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     66|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     66|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  509|  35.9k|    *ptr++ = rescale[temp];
  510|  35.9k|  }
  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: 410, False: 172k]
  ------------------
  532|    410|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    410|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    410|   (*(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|   353k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (535:34): [True: 179k, False: 173k]
  ------------------
  536|   179k|    register unsigned int temp;
  537|   179k|    temp  = (*bufferptr++) << 8;
  538|   179k|    temp |= (*bufferptr++);
  539|   179k|    if (temp > maxval)
  ------------------
  |  Branch (539:9): [True: 330, False: 179k]
  ------------------
  540|    330|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    330|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    330|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  541|   179k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = rescale[temp];
  542|   179k|    if (aindex >= 0)
  ------------------
  |  Branch (542:9): [True: 35.9k, False: 143k]
  ------------------
  543|  35.9k|      ptr[aindex] = (1 << cinfo->data_precision) - 1;
  544|   179k|    ptr += ps;
  545|   179k|  }
  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: 82, False: 34.5k]
  ------------------
  562|     82|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     82|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     82|   (*(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: 290, False: 34.3k]
  ------------------
  566|  1.06k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (566:36): [True: 777, False: 290]
  ------------------
  567|    777|      register unsigned int gray;
  568|    777|      gray  = (*bufferptr++) << 8;
  569|    777|      gray |= (*bufferptr++);
  570|    777|      if (gray > maxval)
  ------------------
  |  Branch (570:11): [True: 20, False: 757]
  ------------------
  571|     20|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     20|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     20|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  572|    777|      rgb_to_cmyk(maxval, (_JSAMPLE)gray, (_JSAMPLE)gray, (_JSAMPLE)gray, ptr,
  573|    777|                  ptr + 1, ptr + 2, ptr + 3);
  574|    777|      ptr += 4;
  575|    777|    }
  576|  34.3k|  } else {
  577|  69.5k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (577:36): [True: 35.2k, False: 34.3k]
  ------------------
  578|  35.2k|      register unsigned int temp;
  579|  35.2k|      _JSAMPLE gray;
  ------------------
  |  |  108|  35.2k|#define _JSAMPLE  J12SAMPLE
  ------------------
  580|  35.2k|      temp  = (*bufferptr++) << 8;
  581|  35.2k|      temp |= (*bufferptr++);
  582|  35.2k|      if (temp > maxval)
  ------------------
  |  Branch (582:11): [True: 46, False: 35.1k]
  ------------------
  583|     46|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     46|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     46|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  584|  35.2k|      gray = rescale[temp];
  585|  35.2k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  586|  35.2k|                  ptr + 1, ptr + 2, ptr + 3);
  587|  35.2k|      ptr += 4;
  588|  35.2k|    }
  589|  34.3k|  }
  590|  34.6k|  return 1;
  591|  34.6k|}
rdppm-12.c:get_scaled_gray_row:
  305|  2.96M|{
  306|  2.96M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  307|  2.96M|  register _JSAMPROW ptr;
  308|  2.96M|  register unsigned char *bufferptr;
  309|  2.96M|  register _JSAMPLE *rescale = source->rescale;
  310|  2.96M|  JDIMENSION col;
  311|       |
  312|  2.96M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  2.96M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (312:7): [True: 68, False: 2.96M]
  ------------------
  313|     68|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     68|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     68|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  314|  2.96M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  2.96M|#define _buffer  buffer12
  ------------------
  315|  2.96M|  bufferptr = source->iobuffer;
  316|  18.4M|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (316:34): [True: 15.4M, False: 2.96M]
  ------------------
  317|  15.4M|    *ptr++ = rescale[*bufferptr++];
  318|  15.4M|  }
  319|  2.96M|  return 1;
  320|  2.96M|}
rdppm-12.c:get_gray_rgb_row:
  327|  14.8M|{
  328|  14.8M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  329|  14.8M|  register _JSAMPROW ptr;
  330|  14.8M|  register unsigned char *bufferptr;
  331|  14.8M|  register _JSAMPLE *rescale = source->rescale;
  332|  14.8M|  JDIMENSION col;
  333|  14.8M|  unsigned int maxval = source->maxval;
  334|  14.8M|  register int rindex = rgb_red[cinfo->in_color_space];
  335|  14.8M|  register int gindex = rgb_green[cinfo->in_color_space];
  336|  14.8M|  register int bindex = rgb_blue[cinfo->in_color_space];
  337|  14.8M|  register int aindex = alpha_index[cinfo->in_color_space];
  338|  14.8M|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  339|       |
  340|  14.8M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  14.8M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (340:7): [True: 340, False: 14.8M]
  ------------------
  341|    340|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    340|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    340|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  342|  14.8M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  14.8M|#define _buffer  buffer12
  ------------------
  343|  14.8M|  bufferptr = source->iobuffer;
  344|  14.8M|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (344:7): [True: 0, False: 14.8M]
  ------------------
  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|  14.8M|  } else {
  350|  14.8M|    if (aindex >= 0)
  ------------------
  |  Branch (350:9): [True: 2.96M, False: 11.8M]
  ------------------
  351|  2.96M|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  149|  2.96M|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  18.4M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 15.4M, False: 2.96M]
  |  |  ------------------
  |  |  151|  15.4M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  15.4M|    alpha_set_op \
  |  |  153|  15.4M|    ptr += ps; \
  |  |  154|  15.4M|  } \
  |  |  155|  2.96M|}
  ------------------
  352|  14.8M|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  353|  11.8M|    else
  354|  11.8M|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++], {})
  ------------------
  |  |  149|  11.8M|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  73.6M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 61.8M, False: 11.8M]
  |  |  ------------------
  |  |  151|  61.8M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  61.8M|    alpha_set_op \
  |  |  153|  61.8M|    ptr += ps; \
  |  |  154|  61.8M|  } \
  |  |  155|  11.8M|}
  ------------------
  355|  14.8M|  }
  356|  14.8M|  return 1;
  357|  14.8M|}
rdppm-12.c:get_gray_cmyk_row:
  364|  2.96M|{
  365|  2.96M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  366|  2.96M|  register _JSAMPROW ptr;
  367|  2.96M|  register unsigned char *bufferptr;
  368|  2.96M|  register _JSAMPLE *rescale = source->rescale;
  369|  2.96M|  JDIMENSION col;
  370|  2.96M|  unsigned int maxval = source->maxval;
  371|       |
  372|  2.96M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  2.96M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (372:7): [True: 68, False: 2.96M]
  ------------------
  373|     68|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     68|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     68|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  374|  2.96M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  2.96M|#define _buffer  buffer12
  ------------------
  375|  2.96M|  bufferptr = source->iobuffer;
  376|  2.96M|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (376:7): [True: 0, False: 2.96M]
  ------------------
  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|  2.96M|  } else {
  383|  18.4M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (383:36): [True: 15.4M, False: 2.96M]
  ------------------
  384|  15.4M|      _JSAMPLE gray = rescale[*bufferptr++];
  ------------------
  |  |  108|  15.4M|#define _JSAMPLE  J12SAMPLE
  ------------------
  385|  15.4M|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  386|  15.4M|                  ptr + 1, ptr + 2, ptr + 3);
  387|  15.4M|      ptr += 4;
  388|  15.4M|    }
  389|  2.96M|  }
  390|  2.96M|  return 1;
  391|  2.96M|}
rdppm-12.c:get_word_rgb_row:
  597|  15.7k|{
  598|  15.7k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  599|  15.7k|  register _JSAMPROW ptr;
  600|  15.7k|  register unsigned char *bufferptr;
  601|  15.7k|  register _JSAMPLE *rescale = source->rescale;
  602|  15.7k|  JDIMENSION col;
  603|  15.7k|  unsigned int maxval = source->maxval;
  604|  15.7k|  register int rindex = rgb_red[cinfo->in_color_space];
  605|  15.7k|  register int gindex = rgb_green[cinfo->in_color_space];
  606|  15.7k|  register int bindex = rgb_blue[cinfo->in_color_space];
  607|  15.7k|  register int aindex = alpha_index[cinfo->in_color_space];
  608|  15.7k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  609|       |
  610|  15.7k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  15.7k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (610:7): [True: 540, False: 15.2k]
  ------------------
  611|    540|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    540|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    540|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  612|  15.7k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  15.7k|#define _buffer  buffer12
  ------------------
  613|  15.7k|  bufferptr = source->iobuffer;
  614|  40.5k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (614:34): [True: 24.7k, False: 15.7k]
  ------------------
  615|  24.7k|    register unsigned int temp;
  616|  24.7k|    temp  = (*bufferptr++) << 8;
  617|  24.7k|    temp |= (*bufferptr++);
  618|  24.7k|    if (temp > maxval)
  ------------------
  |  Branch (618:9): [True: 220, False: 24.5k]
  ------------------
  619|    220|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    220|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    220|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  620|  24.7k|    ptr[rindex] = rescale[temp];
  621|  24.7k|    temp  = (*bufferptr++) << 8;
  622|  24.7k|    temp |= (*bufferptr++);
  623|  24.7k|    if (temp > maxval)
  ------------------
  |  Branch (623:9): [True: 210, False: 24.5k]
  ------------------
  624|    210|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    210|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    210|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  625|  24.7k|    ptr[gindex] = rescale[temp];
  626|  24.7k|    temp  = (*bufferptr++) << 8;
  627|  24.7k|    temp |= (*bufferptr++);
  628|  24.7k|    if (temp > maxval)
  ------------------
  |  Branch (628:9): [True: 215, False: 24.5k]
  ------------------
  629|    215|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    215|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    215|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  630|  24.7k|    ptr[bindex] = rescale[temp];
  631|  24.7k|    if (aindex >= 0)
  ------------------
  |  Branch (631:9): [True: 4.82k, False: 19.9k]
  ------------------
  632|  4.82k|      ptr[aindex] = (1 << cinfo->data_precision) - 1;
  633|  24.7k|    ptr += ps;
  634|  24.7k|  }
  635|  15.7k|  return 1;
  636|  15.7k|}
rdppm-12.c:get_word_rgb_cmyk_row:
  642|  3.14k|{
  643|  3.14k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  644|  3.14k|  register _JSAMPROW ptr;
  645|  3.14k|  register unsigned char *bufferptr;
  646|  3.14k|  register _JSAMPLE *rescale = source->rescale;
  647|  3.14k|  JDIMENSION col;
  648|  3.14k|  unsigned int maxval = source->maxval;
  649|       |
  650|  3.14k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  3.14k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (650:7): [True: 108, False: 3.04k]
  ------------------
  651|    108|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    108|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    108|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  652|  3.14k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  3.14k|#define _buffer  buffer12
  ------------------
  653|  3.14k|  bufferptr = source->iobuffer;
  654|  3.14k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (654:7): [True: 786, False: 2.36k]
  ------------------
  655|  2.70k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (655:36): [True: 1.91k, False: 786]
  ------------------
  656|  1.91k|      register unsigned int r, g, b;
  657|  1.91k|      r  = (*bufferptr++) << 8;
  658|  1.91k|      r |= (*bufferptr++);
  659|  1.91k|      if (r > maxval)
  ------------------
  |  Branch (659:11): [True: 16, False: 1.89k]
  ------------------
  660|     16|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     16|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     16|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  661|  1.91k|      g  = (*bufferptr++) << 8;
  662|  1.91k|      g |= (*bufferptr++);
  663|  1.91k|      if (g > maxval)
  ------------------
  |  Branch (663:11): [True: 18, False: 1.89k]
  ------------------
  664|     18|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     18|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     18|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  665|  1.91k|      b  = (*bufferptr++) << 8;
  666|  1.91k|      b |= (*bufferptr++);
  667|  1.91k|      if (b > maxval)
  ------------------
  |  Branch (667:11): [True: 22, False: 1.89k]
  ------------------
  668|     22|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     22|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     22|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  669|  1.91k|      rgb_to_cmyk(maxval, (_JSAMPLE)r, (_JSAMPLE)g, (_JSAMPLE)b, ptr, ptr + 1,
  670|  1.91k|                  ptr + 2, ptr + 3);
  671|  1.91k|      ptr += 4;
  672|  1.91k|    }
  673|  2.36k|  } else {
  674|  5.40k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (674:36): [True: 3.03k, False: 2.36k]
  ------------------
  675|  3.03k|      register unsigned int r, g, b;
  676|  3.03k|      r  = (*bufferptr++) << 8;
  677|  3.03k|      r |= (*bufferptr++);
  678|  3.03k|      if (r > maxval)
  ------------------
  |  Branch (678:11): [True: 28, False: 3.00k]
  ------------------
  679|     28|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     28|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     28|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  680|  3.03k|      g  = (*bufferptr++) << 8;
  681|  3.03k|      g |= (*bufferptr++);
  682|  3.03k|      if (g > maxval)
  ------------------
  |  Branch (682:11): [True: 24, False: 3.01k]
  ------------------
  683|     24|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     24|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     24|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  684|  3.03k|      b  = (*bufferptr++) << 8;
  685|  3.03k|      b |= (*bufferptr++);
  686|  3.03k|      if (b > maxval)
  ------------------
  |  Branch (686:11): [True: 21, False: 3.01k]
  ------------------
  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.03k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, rescale[r], rescale[g],
  689|  3.03k|                  rescale[b], ptr, ptr + 1, ptr + 2, ptr + 3);
  690|  3.03k|      ptr += 4;
  691|  3.03k|    }
  692|  2.36k|  }
  693|  3.14k|  return 1;
  694|  3.14k|}
rdppm-12.c:get_rgb_row:
  397|  3.79M|{
  398|  3.79M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  399|  3.79M|  register _JSAMPROW ptr;
  400|  3.79M|  register unsigned char *bufferptr;
  401|  3.79M|  register _JSAMPLE *rescale = source->rescale;
  402|  3.79M|  JDIMENSION col;
  403|  3.79M|  unsigned int maxval = source->maxval;
  404|  3.79M|  register int rindex = rgb_red[cinfo->in_color_space];
  405|  3.79M|  register int gindex = rgb_green[cinfo->in_color_space];
  406|  3.79M|  register int bindex = rgb_blue[cinfo->in_color_space];
  407|  3.79M|  register int aindex = alpha_index[cinfo->in_color_space];
  408|  3.79M|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  409|       |
  410|  3.79M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  3.79M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (410:7): [True: 470, False: 3.79M]
  ------------------
  411|    470|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    470|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    470|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  412|  3.79M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  3.79M|#define _buffer  buffer12
  ------------------
  413|  3.79M|  bufferptr = source->iobuffer;
  414|  3.79M|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (414:7): [True: 0, False: 3.79M]
  ------------------
  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.79M|  } else {
  420|  3.79M|    if (aindex >= 0)
  ------------------
  |  Branch (420:9): [True: 758k, False: 3.03M]
  ------------------
  421|   758k|      RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  223|   758k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  5.35M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 4.59M, False: 758k]
  |  |  ------------------
  |  |  225|  4.59M|    ptr[rindex] = read_op; \
  |  |  226|  4.59M|    ptr[gindex] = read_op; \
  |  |  227|  4.59M|    ptr[bindex] = read_op; \
  |  |  228|  4.59M|    alpha_set_op \
  |  |  229|  4.59M|    ptr += ps; \
  |  |  230|  4.59M|  } \
  |  |  231|   758k|}
  ------------------
  422|  3.79M|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  423|  3.03M|    else
  424|  3.03M|      RGB_READ_LOOP(rescale[*bufferptr++], {})
  ------------------
  |  |  223|  3.03M|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  21.4M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 18.3M, False: 3.03M]
  |  |  ------------------
  |  |  225|  18.3M|    ptr[rindex] = read_op; \
  |  |  226|  18.3M|    ptr[gindex] = read_op; \
  |  |  227|  18.3M|    ptr[bindex] = read_op; \
  |  |  228|  18.3M|    alpha_set_op \
  |  |  229|  18.3M|    ptr += ps; \
  |  |  230|  18.3M|  } \
  |  |  231|  3.03M|}
  ------------------
  425|  3.79M|  }
  426|  3.79M|  return 1;
  427|  3.79M|}
rdppm-12.c:get_rgb_cmyk_row:
  434|   758k|{
  435|   758k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  436|   758k|  register _JSAMPROW ptr;
  437|   758k|  register unsigned char *bufferptr;
  438|   758k|  register _JSAMPLE *rescale = source->rescale;
  439|   758k|  JDIMENSION col;
  440|   758k|  unsigned int maxval = source->maxval;
  441|       |
  442|   758k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|   758k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (442:7): [True: 94, False: 758k]
  ------------------
  443|     94|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     94|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     94|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  444|   758k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|   758k|#define _buffer  buffer12
  ------------------
  445|   758k|  bufferptr = source->iobuffer;
  446|   758k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (446:7): [True: 0, False: 758k]
  ------------------
  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|   758k|  } else {
  455|  5.35M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (455:36): [True: 4.59M, False: 758k]
  ------------------
  456|  4.59M|      _JSAMPLE r = rescale[*bufferptr++];
  ------------------
  |  |  108|  4.59M|#define _JSAMPLE  J12SAMPLE
  ------------------
  457|  4.59M|      _JSAMPLE g = rescale[*bufferptr++];
  ------------------
  |  |  108|  4.59M|#define _JSAMPLE  J12SAMPLE
  ------------------
  458|  4.59M|      _JSAMPLE b = rescale[*bufferptr++];
  ------------------
  |  |  108|  4.59M|#define _JSAMPLE  J12SAMPLE
  ------------------
  459|  4.59M|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  460|  4.59M|                  ptr + 2, ptr + 3);
  461|  4.59M|      ptr += 4;
  462|  4.59M|    }
  463|   758k|  }
  464|   758k|  return 1;
  465|   758k|}
rdppm-12.c:finish_input_ppm:
  913|  15.3k|{
  914|       |  /* no work */
  915|  15.3k|}

spng_decode_scanline:
 3302|   844k|{
 3303|   844k|    if(ctx == NULL || out == NULL) return 1;
  ------------------
  |  Branch (3303:8): [True: 0, False: 844k]
  |  Branch (3303:23): [True: 0, False: 844k]
  ------------------
 3304|       |
 3305|   844k|    if(ctx->state >= SPNG_STATE_EOI) return SPNG_EOI;
  ------------------
  |  Branch (3305:8): [True: 0, False: 844k]
  ------------------
 3306|       |
 3307|   844k|    struct decode_flags f = ctx->decode_flags;
 3308|       |
 3309|   844k|    struct spng_row_info *ri = &ctx->row_info;
 3310|   844k|    const struct spng_subimage *sub = ctx->subimage;
 3311|       |
 3312|   844k|    const struct spng_ihdr *ihdr = &ctx->ihdr;
 3313|       |#if 0 /* libjpeg-turbo: Eliminate unused gamma correction code, which
 3314|       |         introduces an unwanted libm dependency */
 3315|       |    const uint16_t *gamma_lut = ctx->gamma_lut;
 3316|       |#endif
 3317|   844k|    unsigned char *trns_px = ctx->trns_px;
 3318|   844k|    const struct spng_sbit *sb = &ctx->decode_sb;
 3319|   844k|    const struct spng_plte_entry *plte = ctx->decode_plte.rgba;
 3320|   844k|    struct spng__iter iter = spng__iter_init(ihdr->bit_depth, ctx->scanline);
 3321|       |
 3322|   844k|    const unsigned char *scanline;
 3323|       |
 3324|   844k|    const int pass = ri->pass;
 3325|   844k|    const int fmt = ctx->fmt;
 3326|   844k|    const size_t scanline_width = sub[pass].scanline_width;
 3327|   844k|    const uint32_t width = sub[pass].width;
 3328|   844k|    uint32_t k;
 3329|   844k|    uint8_t r_8, g_8, b_8, a_8, gray_8;
 3330|   844k|    uint16_t r_16, g_16, b_16, a_16, gray_16;
 3331|   844k|    r_8=0; g_8=0; b_8=0; a_8=0; gray_8=0;
 3332|   844k|    r_16=0; g_16=0; b_16=0; a_16=0; gray_16=0;
 3333|   844k|    size_t pixel_size = 4; /* SPNG_FMT_RGBA8 */
 3334|   844k|    size_t pixel_offset = 0;
 3335|   844k|    unsigned char *pixel;
 3336|   844k|    unsigned processing_depth = ihdr->bit_depth;
 3337|       |
 3338|   844k|    if(f.indexed) processing_depth = 8;
  ------------------
  |  Branch (3338:8): [True: 9.83k, False: 834k]
  ------------------
 3339|       |
 3340|   844k|    if(fmt == SPNG_FMT_RGBA16) pixel_size = 8;
  ------------------
  |  Branch (3340:8): [True: 0, False: 844k]
  ------------------
 3341|   844k|    else if(fmt == SPNG_FMT_RGB8) pixel_size = 3;
  ------------------
  |  Branch (3341:13): [True: 0, False: 844k]
  ------------------
 3342|       |
 3343|   844k|    if(len < sub[pass].out_width) return SPNG_EBUFSIZ;
  ------------------
  |  Branch (3343:8): [True: 0, False: 844k]
  ------------------
 3344|       |
 3345|   844k|    int ret = read_scanline(ctx);
 3346|       |
 3347|   844k|    if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3347:8): [True: 3.78k, False: 840k]
  ------------------
 3348|       |
 3349|   840k|    scanline = ctx->scanline;
 3350|       |
 3351|   840k|    for(k=0; k < width; k++)
  ------------------
  |  Branch (3351:14): [True: 840k, False: 0]
  ------------------
 3352|   840k|    {
 3353|   840k|        pixel = (unsigned char*)out + pixel_offset;
 3354|   840k|        pixel_offset += pixel_size;
 3355|       |
 3356|   840k|        if(f.same_layout)
  ------------------
  |  Branch (3356:12): [True: 840k, False: 0]
  ------------------
 3357|   840k|        {
 3358|   840k|            if(f.zerocopy) break;
  ------------------
  |  Branch (3358:16): [True: 0, False: 840k]
  ------------------
 3359|       |
 3360|   840k|            memcpy(out, scanline, scanline_width - 1);
 3361|   840k|            break;
 3362|   840k|        }
 3363|       |
 3364|      0|        if(f.unpack)
  ------------------
  |  Branch (3364:12): [True: 0, False: 0]
  ------------------
 3365|      0|        {
 3366|      0|            unpack_scanline(out, scanline, width, ihdr->bit_depth, fmt);
 3367|      0|            break;
 3368|      0|        }
 3369|       |
 3370|      0|        if(ihdr->color_type == SPNG_COLOR_TYPE_TRUECOLOR)
  ------------------
  |  Branch (3370:12): [True: 0, False: 0]
  ------------------
 3371|      0|        {
 3372|      0|            if(ihdr->bit_depth == 16)
  ------------------
  |  Branch (3372:16): [True: 0, False: 0]
  ------------------
 3373|      0|            {
 3374|      0|                memcpy(&r_16, scanline + (k * 6), 2);
 3375|      0|                memcpy(&g_16, scanline + (k * 6) + 2, 2);
 3376|      0|                memcpy(&b_16, scanline + (k * 6) + 4, 2);
 3377|       |
 3378|      0|                a_16 = 65535;
 3379|      0|            }
 3380|      0|            else /* == 8 */
 3381|      0|            {
 3382|      0|                if(fmt == SPNG_FMT_RGBA8)
  ------------------
  |  Branch (3382:20): [True: 0, False: 0]
  ------------------
 3383|      0|                {
 3384|      0|                    rgb8_row_to_rgba8(scanline, out, width);
 3385|      0|                    break;
 3386|      0|                }
 3387|       |
 3388|      0|                r_8 = scanline[k * 3];
 3389|      0|                g_8 = scanline[k * 3 + 1];
 3390|      0|                b_8 = scanline[k * 3 + 2];
 3391|       |
 3392|      0|                a_8 = 255;
 3393|      0|            }
 3394|      0|        }
 3395|      0|        else if(ihdr->color_type == SPNG_COLOR_TYPE_INDEXED)
  ------------------
  |  Branch (3395:17): [True: 0, False: 0]
  ------------------
 3396|      0|        {
 3397|      0|            uint8_t entry = 0;
 3398|       |
 3399|      0|            if(ihdr->bit_depth == 8)
  ------------------
  |  Branch (3399:16): [True: 0, False: 0]
  ------------------
 3400|      0|            {
 3401|      0|                if(fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGB8))
  ------------------
  |  Branch (3401:20): [True: 0, False: 0]
  ------------------
 3402|      0|                {
 3403|      0|                    expand_row(out, scanline, &ctx->decode_plte, width, fmt);
 3404|      0|                    break;
 3405|      0|                }
 3406|       |
 3407|      0|                entry = scanline[k];
 3408|      0|            }
 3409|      0|            else /* < 8 */
 3410|      0|            {
 3411|      0|                entry = get_sample(&iter);
 3412|      0|            }
 3413|       |
 3414|      0|            if(fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGB8))
  ------------------
  |  Branch (3414:16): [True: 0, False: 0]
  ------------------
 3415|      0|            {
 3416|      0|                pixel[0] = plte[entry].red;
 3417|      0|                pixel[1] = plte[entry].green;
 3418|      0|                pixel[2] = plte[entry].blue;
 3419|      0|                if(fmt == SPNG_FMT_RGBA8) pixel[3] = plte[entry].alpha;
  ------------------
  |  Branch (3419:20): [True: 0, False: 0]
  ------------------
 3420|       |
 3421|      0|                continue;
 3422|      0|            }
 3423|      0|            else /* RGBA16 */
 3424|      0|            {
 3425|      0|                r_16 = plte[entry].red;
 3426|      0|                g_16 = plte[entry].green;
 3427|      0|                b_16 = plte[entry].blue;
 3428|      0|                a_16 = plte[entry].alpha;
 3429|       |
 3430|      0|                r_16 = (r_16 << 8) | r_16;
 3431|      0|                g_16 = (g_16 << 8) | g_16;
 3432|      0|                b_16 = (b_16 << 8) | b_16;
 3433|      0|                a_16 = (a_16 << 8) | a_16;
 3434|       |
 3435|      0|                memcpy(pixel, &r_16, 2);
 3436|      0|                memcpy(pixel + 2, &g_16, 2);
 3437|      0|                memcpy(pixel + 4, &b_16, 2);
 3438|      0|                memcpy(pixel + 6, &a_16, 2);
 3439|       |
 3440|      0|                continue;
 3441|      0|            }
 3442|      0|        }
 3443|      0|        else if(ihdr->color_type == SPNG_COLOR_TYPE_TRUECOLOR_ALPHA)
  ------------------
  |  Branch (3443:17): [True: 0, False: 0]
  ------------------
 3444|      0|        {
 3445|      0|            if(ihdr->bit_depth == 16)
  ------------------
  |  Branch (3445:16): [True: 0, False: 0]
  ------------------
 3446|      0|            {
 3447|      0|                memcpy(&r_16, scanline + (k * 8), 2);
 3448|      0|                memcpy(&g_16, scanline + (k * 8) + 2, 2);
 3449|      0|                memcpy(&b_16, scanline + (k * 8) + 4, 2);
 3450|      0|                memcpy(&a_16, scanline + (k * 8) + 6, 2);
 3451|      0|            }
 3452|      0|            else /* == 8 */
 3453|      0|            {
 3454|      0|                r_8 = scanline[k * 4];
 3455|      0|                g_8 = scanline[k * 4 + 1];
 3456|      0|                b_8 = scanline[k * 4 + 2];
 3457|      0|                a_8 = scanline[k * 4 + 3];
 3458|      0|            }
 3459|      0|        }
 3460|      0|        else if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE)
  ------------------
  |  Branch (3460:17): [True: 0, False: 0]
  ------------------
 3461|      0|        {
 3462|      0|            if(ihdr->bit_depth == 16)
  ------------------
  |  Branch (3462:16): [True: 0, False: 0]
  ------------------
 3463|      0|            {
 3464|      0|                memcpy(&gray_16, scanline + k * 2, 2);
 3465|       |
 3466|      0|                if(f.apply_trns && ctx->trns.gray == gray_16) a_16 = 0;
  ------------------
  |  Branch (3466:20): [True: 0, False: 0]
  |  Branch (3466:36): [True: 0, False: 0]
  ------------------
 3467|      0|                else a_16 = 65535;
 3468|       |
 3469|      0|                r_16 = gray_16;
 3470|      0|                g_16 = gray_16;
 3471|      0|                b_16 = gray_16;
 3472|      0|            }
 3473|      0|            else /* <= 8 */
 3474|      0|            {
 3475|      0|                gray_8 = get_sample(&iter);
 3476|       |
 3477|      0|                if(f.apply_trns && ctx->trns.gray == gray_8) a_8 = 0;
  ------------------
  |  Branch (3477:20): [True: 0, False: 0]
  |  Branch (3477:36): [True: 0, False: 0]
  ------------------
 3478|      0|                else a_8 = 255;
 3479|       |
 3480|      0|                r_8 = gray_8; g_8 = gray_8; b_8 = gray_8;
 3481|      0|            }
 3482|      0|        }
 3483|      0|        else if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE_ALPHA)
  ------------------
  |  Branch (3483:17): [True: 0, False: 0]
  ------------------
 3484|      0|        {
 3485|      0|            if(ihdr->bit_depth == 16)
  ------------------
  |  Branch (3485:16): [True: 0, False: 0]
  ------------------
 3486|      0|            {
 3487|      0|                memcpy(&gray_16, scanline + (k * 4), 2);
 3488|      0|                memcpy(&a_16, scanline + (k * 4) + 2, 2);
 3489|       |
 3490|      0|                r_16 = gray_16;
 3491|      0|                g_16 = gray_16;
 3492|      0|                b_16 = gray_16;
 3493|      0|            }
 3494|      0|            else /* == 8 */
 3495|      0|            {
 3496|      0|                gray_8 = scanline[k * 2];
 3497|      0|                a_8 = scanline[k * 2 + 1];
 3498|       |
 3499|      0|                r_8 = gray_8;
 3500|      0|                g_8 = gray_8;
 3501|      0|                b_8 = gray_8;
 3502|      0|            }
 3503|      0|        }
 3504|       |
 3505|       |
 3506|      0|        if(fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGB8))
  ------------------
  |  Branch (3506:12): [True: 0, False: 0]
  ------------------
 3507|      0|        {
 3508|      0|            if(ihdr->bit_depth == 16)
  ------------------
  |  Branch (3508:16): [True: 0, False: 0]
  ------------------
 3509|      0|            {
 3510|      0|                r_8 = r_16 >> 8;
 3511|      0|                g_8 = g_16 >> 8;
 3512|      0|                b_8 = b_16 >> 8;
 3513|      0|                a_8 = a_16 >> 8;
 3514|      0|            }
 3515|       |
 3516|      0|            pixel[0] = r_8;
 3517|      0|            pixel[1] = g_8;
 3518|      0|            pixel[2] = b_8;
 3519|       |
 3520|      0|            if(fmt == SPNG_FMT_RGBA8) pixel[3] = a_8;
  ------------------
  |  Branch (3520:16): [True: 0, False: 0]
  ------------------
 3521|      0|        }
 3522|      0|        else if(fmt == SPNG_FMT_RGBA16)
  ------------------
  |  Branch (3522:17): [True: 0, False: 0]
  ------------------
 3523|      0|        {
 3524|      0|            if(ihdr->bit_depth != 16)
  ------------------
  |  Branch (3524:16): [True: 0, False: 0]
  ------------------
 3525|      0|            {
 3526|      0|                r_16 = r_8;
 3527|      0|                g_16 = g_8;
 3528|      0|                b_16 = b_8;
 3529|      0|                a_16 = a_8;
 3530|      0|            }
 3531|       |
 3532|      0|            memcpy(pixel, &r_16, 2);
 3533|      0|            memcpy(pixel + 2, &g_16, 2);
 3534|      0|            memcpy(pixel + 4, &b_16, 2);
 3535|      0|            memcpy(pixel + 6, &a_16, 2);
 3536|      0|        }
 3537|      0|    }/* for(k=0; k < width; k++) */
 3538|       |
 3539|   840k|    if(f.apply_trns) trns_row(out, scanline, trns_px, ctx->bytes_per_pixel, &ctx->ihdr, width, fmt);
  ------------------
  |  Branch (3539:8): [True: 0, False: 840k]
  ------------------
 3540|       |
 3541|   840k|    if(f.do_scaling) scale_row(out, width, fmt, processing_depth, sb);
  ------------------
  |  Branch (3541:8): [True: 0, False: 840k]
  ------------------
 3542|       |
 3543|       |#if 0 /* libjpeg-turbo: Eliminate unused gamma correction code, which
 3544|       |         introduces an unwanted libm dependency */
 3545|       |    if(f.apply_gamma) gamma_correct_row(out, width, fmt, gamma_lut);
 3546|       |#endif
 3547|       |
 3548|       |    /* The previous scanline is always defiltered */
 3549|   840k|    void *t = ctx->prev_scanline;
 3550|   840k|    ctx->prev_scanline = ctx->scanline;
 3551|   840k|    ctx->scanline = t;
 3552|       |
 3553|   840k|    ret = update_row_info(ctx);
 3554|       |
 3555|   840k|    if(ret == SPNG_EOI)
  ------------------
  |  Branch (3555:8): [True: 2.36k, False: 838k]
  ------------------
 3556|  2.36k|    {
 3557|  2.36k|        if(ctx->cur_chunk_bytes_left) /* zlib stream ended before an IDAT chunk boundary */
  ------------------
  |  Branch (3557:12): [True: 84, False: 2.28k]
  ------------------
 3558|     84|        {/* Discard the rest of the chunk */
 3559|     84|            int error = discard_chunk_bytes(ctx, ctx->cur_chunk_bytes_left);
 3560|     84|            if(error) return decode_err(ctx, error);
  ------------------
  |  Branch (3560:16): [True: 77, False: 7]
  ------------------
 3561|     84|        }
 3562|       |
 3563|  2.28k|        ctx->last_idat = ctx->current_chunk;
 3564|  2.28k|    }
 3565|       |
 3566|   840k|    return ret;
 3567|   840k|}
spng_decode_row:
 3570|   844k|{
 3571|   844k|    if(ctx == NULL || out == NULL) return 1;
  ------------------
  |  Branch (3571:8): [True: 0, False: 844k]
  |  Branch (3571:23): [True: 0, False: 844k]
  ------------------
 3572|   844k|    if(ctx->state >= SPNG_STATE_EOI) return SPNG_EOI;
  ------------------
  |  Branch (3572:8): [True: 0, False: 844k]
  ------------------
 3573|   844k|    if(len < ctx->image_width) return SPNG_EBUFSIZ;
  ------------------
  |  Branch (3573:8): [True: 0, False: 844k]
  ------------------
 3574|       |
 3575|   844k|    const struct spng_ihdr *ihdr = &ctx->ihdr;
 3576|   844k|    int ret, pass = ctx->row_info.pass;
 3577|   844k|    unsigned char *outptr = out;
 3578|       |
 3579|   844k|    if(!ihdr->interlace_method || pass == 6) return spng_decode_scanline(ctx, out, len);
  ------------------
  |  Branch (3579:8): [True: 243k, False: 600k]
  |  Branch (3579:35): [True: 132, False: 600k]
  ------------------
 3580|       |
 3581|   600k|    ret = spng_decode_scanline(ctx, ctx->row, ctx->image_width);
 3582|   600k|    if(ret && ret != SPNG_EOI) return ret;
  ------------------
  |  Branch (3582:8): [True: 971, False: 599k]
  |  Branch (3582:15): [True: 971, False: 0]
  ------------------
 3583|       |
 3584|   599k|    uint32_t k;
 3585|   599k|    unsigned pixel_size = 4; /* RGBA8 */
 3586|   599k|    if(ctx->fmt == SPNG_FMT_RGBA16) pixel_size = 8;
  ------------------
  |  Branch (3586:8): [True: 0, False: 599k]
  ------------------
 3587|   599k|    else if(ctx->fmt == SPNG_FMT_RGB8) pixel_size = 3;
  ------------------
  |  Branch (3587:13): [True: 0, False: 599k]
  ------------------
 3588|   599k|    else if(ctx->fmt == SPNG_FMT_G8) pixel_size = 1;
  ------------------
  |  Branch (3588:13): [True: 0, False: 599k]
  ------------------
 3589|   599k|    else if(ctx->fmt == SPNG_FMT_GA8) pixel_size = 2;
  ------------------
  |  Branch (3589:13): [True: 0, False: 599k]
  ------------------
 3590|   599k|    else if(ctx->fmt & (SPNG_FMT_PNG | SPNG_FMT_RAW))
  ------------------
  |  Branch (3590:13): [True: 599k, False: 0]
  ------------------
 3591|   599k|    {
 3592|   599k|        if(ihdr->bit_depth < 8)
  ------------------
  |  Branch (3592:12): [True: 0, False: 599k]
  ------------------
 3593|      0|        {
 3594|      0|            struct spng__iter iter = spng__iter_init(ihdr->bit_depth, ctx->row);
 3595|      0|            const uint8_t samples_per_byte = 8 / ihdr->bit_depth;
 3596|      0|            uint8_t sample;
 3597|       |
 3598|      0|            for(k=0; k < ctx->subimage[pass].width; k++)
  ------------------
  |  Branch (3598:22): [True: 0, False: 0]
  ------------------
 3599|      0|            {
 3600|      0|                sample = get_sample(&iter);
 3601|       |
 3602|      0|                size_t ioffset = adam7_x_start[pass] + k * adam7_x_delta[pass];
 3603|       |
 3604|      0|                sample = sample << (iter.initial_shift - ioffset * ihdr->bit_depth % 8);
 3605|       |
 3606|      0|                ioffset /= samples_per_byte;
 3607|       |
 3608|      0|                outptr[ioffset] |= sample;
 3609|      0|            }
 3610|       |
 3611|      0|            return 0;
 3612|      0|        }
 3613|   599k|        else pixel_size = ctx->bytes_per_pixel;
 3614|   599k|    }
 3615|       |
 3616|  28.9M|    for(k=0; k < ctx->subimage[pass].width; k++)
  ------------------
  |  Branch (3616:14): [True: 28.3M, False: 599k]
  ------------------
 3617|  28.3M|    {
 3618|  28.3M|        size_t ioffset = (adam7_x_start[pass] + (size_t) k * adam7_x_delta[pass]) * pixel_size;
 3619|       |
 3620|  28.3M|        memcpy(outptr + ioffset, ctx->row + k * pixel_size, pixel_size);
 3621|  28.3M|    }
 3622|       |
 3623|   599k|    return 0;
 3624|   599k|}
spng_decode_chunks:
 3627|  31.9k|{
 3628|  31.9k|    if(ctx == NULL) return 1;
  ------------------
  |  Branch (3628:8): [True: 0, False: 31.9k]
  ------------------
 3629|  31.9k|    if(ctx->encode_only) return SPNG_ECTXTYPE;
  ------------------
  |  Branch (3629:8): [True: 0, False: 31.9k]
  ------------------
 3630|  31.9k|    if(ctx->state < SPNG_STATE_INPUT) return SPNG_ENOSRC;
  ------------------
  |  Branch (3630:8): [True: 16.1k, False: 15.8k]
  ------------------
 3631|  15.8k|    if(ctx->state == SPNG_STATE_IEND) return 0;
  ------------------
  |  Branch (3631:8): [True: 0, False: 15.8k]
  ------------------
 3632|       |
 3633|  15.8k|    return read_chunks(ctx, 0);
 3634|  15.8k|}
spng_decode_image:
 3637|  18.2k|{
 3638|  18.2k|    if(ctx == NULL) return 1;
  ------------------
  |  Branch (3638:8): [True: 0, False: 18.2k]
  ------------------
 3639|  18.2k|    if(ctx->encode_only) return SPNG_ECTXTYPE;
  ------------------
  |  Branch (3639:8): [True: 0, False: 18.2k]
  ------------------
 3640|  18.2k|    if(ctx->state >= SPNG_STATE_EOI) return SPNG_EOI;
  ------------------
  |  Branch (3640:8): [True: 0, False: 18.2k]
  ------------------
 3641|       |
 3642|  18.2k|    const struct spng_ihdr *ihdr = &ctx->ihdr;
 3643|       |
 3644|  18.2k|    int ret = read_chunks(ctx, 0);
 3645|  18.2k|    if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3645:8): [True: 8.65k, False: 9.62k]
  ------------------
 3646|       |
 3647|  9.62k|    ret = check_decode_fmt(ihdr, fmt);
 3648|  9.62k|    if(ret) return ret;
  ------------------
  |  Branch (3648:8): [True: 0, False: 9.62k]
  ------------------
 3649|       |
 3650|  9.62k|    ret = calculate_image_width(ihdr, fmt, &ctx->image_width);
 3651|  9.62k|    if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3651:8): [True: 0, False: 9.62k]
  ------------------
 3652|       |
 3653|  9.62k|    if(ctx->image_width > SIZE_MAX / ihdr->height) ctx->image_size = 0; /* overflow */
  ------------------
  |  Branch (3653:8): [True: 0, False: 9.62k]
  ------------------
 3654|  9.62k|    else ctx->image_size = ctx->image_width * ihdr->height;
 3655|       |
 3656|  9.62k|    if( !(flags & SPNG_DECODE_PROGRESSIVE) )
  ------------------
  |  Branch (3656:9): [True: 0, False: 9.62k]
  ------------------
 3657|      0|    {
 3658|      0|        if(out == NULL) return 1;
  ------------------
  |  Branch (3658:12): [True: 0, False: 0]
  ------------------
 3659|      0|        if(!ctx->image_size) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (3659:12): [True: 0, False: 0]
  ------------------
 3660|      0|        if(len < ctx->image_size) return SPNG_EBUFSIZ;
  ------------------
  |  Branch (3660:12): [True: 0, False: 0]
  ------------------
 3661|      0|    }
 3662|       |
 3663|  9.62k|    uint32_t bytes_read = 0;
 3664|       |
 3665|  9.62k|    ret = read_idat_bytes(ctx, &bytes_read);
 3666|  9.62k|    if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3666:8): [True: 293, False: 9.33k]
  ------------------
 3667|       |
 3668|  9.33k|    if(bytes_read > 1)
  ------------------
  |  Branch (3668:8): [True: 8.55k, False: 782]
  ------------------
 3669|  8.55k|    {
 3670|  8.55k|        int valid = read_u16(ctx->data) % 31 ? 0 : 1;
  ------------------
  |  Branch (3670:21): [True: 63, False: 8.49k]
  ------------------
 3671|       |
 3672|  8.55k|        unsigned flg = ctx->data[1];
 3673|  8.55k|        unsigned flevel = flg >> 6;
 3674|  8.55k|        int compression_level = Z_DEFAULT_COMPRESSION;
  ------------------
  |  |  197|  8.55k|#define Z_DEFAULT_COMPRESSION  (-1)
  ------------------
 3675|       |
 3676|  8.55k|        if(flevel == 0) compression_level = 0; /* fastest */
  ------------------
  |  Branch (3676:12): [True: 200, False: 8.35k]
  ------------------
 3677|  8.35k|        else if(flevel == 1) compression_level = 1; /* fast */
  ------------------
  |  Branch (3677:17): [True: 26, False: 8.32k]
  ------------------
 3678|  8.32k|        else if(flevel == 2) compression_level = 6; /* default */
  ------------------
  |  Branch (3678:17): [True: 4.00k, False: 4.32k]
  ------------------
 3679|  4.32k|        else if(flevel == 3) compression_level = 9; /* slowest, max compression */
  ------------------
  |  Branch (3679:17): [True: 4.32k, False: 0]
  ------------------
 3680|       |
 3681|  8.55k|        if(valid) ctx->image_options.compression_level = compression_level;
  ------------------
  |  Branch (3681:12): [True: 8.49k, False: 63]
  ------------------
 3682|  8.55k|    }
 3683|       |
 3684|  9.33k|    ret = spng__inflate_init(ctx, ctx->image_options.window_bits);
 3685|  9.33k|    if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3685:8): [True: 0, False: 9.33k]
  ------------------
 3686|       |
 3687|  9.33k|    ctx->zstream.avail_in = bytes_read;
 3688|  9.33k|    ctx->zstream.next_in = ctx->data;
 3689|       |
 3690|  9.33k|    size_t scanline_buf_size = ctx->subimage[ctx->widest_pass].scanline_width;
 3691|       |
 3692|  9.33k|    scanline_buf_size += 32;
 3693|       |
 3694|  9.33k|    if(scanline_buf_size < 32) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (3694:8): [True: 0, False: 9.33k]
  ------------------
 3695|       |
 3696|  9.33k|    ctx->scanline_buf = spng__malloc(ctx, scanline_buf_size);
 3697|  9.33k|    ctx->prev_scanline_buf = spng__malloc(ctx, scanline_buf_size);
 3698|       |
 3699|  9.33k|    ctx->scanline = ctx->scanline_buf;
 3700|  9.33k|    ctx->prev_scanline = ctx->prev_scanline_buf;
 3701|       |
 3702|  9.33k|    struct decode_flags f = {0};
 3703|       |
 3704|  9.33k|    ctx->fmt = fmt;
 3705|       |
 3706|  9.33k|    if(ihdr->color_type == SPNG_COLOR_TYPE_INDEXED) f.indexed = 1;
  ------------------
  |  Branch (3706:8): [True: 334, False: 9.00k]
  ------------------
 3707|       |
 3708|  9.33k|    unsigned processing_depth = ihdr->bit_depth;
 3709|       |
 3710|  9.33k|    if(f.indexed) processing_depth = 8;
  ------------------
  |  Branch (3710:8): [True: 334, False: 9.00k]
  ------------------
 3711|       |
 3712|  9.33k|    if(ihdr->interlace_method)
  ------------------
  |  Branch (3712:8): [True: 2.92k, False: 6.41k]
  ------------------
 3713|  2.92k|    {
 3714|  2.92k|        f.interlaced = 1;
 3715|  2.92k|        ctx->row_buf = spng__malloc(ctx, ctx->image_width);
 3716|  2.92k|        ctx->row = ctx->row_buf;
 3717|       |
 3718|  2.92k|        if(ctx->row == NULL) return decode_err(ctx, SPNG_EMEM);
  ------------------
  |  Branch (3718:12): [True: 0, False: 2.92k]
  ------------------
 3719|  2.92k|    }
 3720|       |
 3721|  9.33k|    if(ctx->scanline == NULL || ctx->prev_scanline == NULL)
  ------------------
  |  Branch (3721:8): [True: 0, False: 9.33k]
  |  Branch (3721:33): [True: 0, False: 9.33k]
  ------------------
 3722|      0|    {
 3723|      0|        return decode_err(ctx, SPNG_EMEM);
 3724|      0|    }
 3725|       |
 3726|  9.33k|    f.do_scaling = 1;
 3727|  9.33k|    if(f.indexed) f.do_scaling = 0;
  ------------------
  |  Branch (3727:8): [True: 334, False: 9.00k]
  ------------------
 3728|       |
 3729|  9.33k|    unsigned depth_target = 8; /* FMT_RGBA8, G8 */
 3730|  9.33k|    if(fmt == SPNG_FMT_RGBA16) depth_target = 16;
  ------------------
  |  Branch (3730:8): [True: 0, False: 9.33k]
  ------------------
 3731|       |
 3732|  9.33k|    if(flags & SPNG_DECODE_TRNS && ctx->stored.trns) f.apply_trns = 1;
  ------------------
  |  Branch (3732:8): [True: 0, False: 9.33k]
  |  Branch (3732:36): [True: 0, False: 0]
  ------------------
 3733|  9.33k|    else flags &= ~SPNG_DECODE_TRNS;
 3734|       |
 3735|  9.33k|    if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE_ALPHA ||
  ------------------
  |  Branch (3735:8): [True: 1.45k, False: 7.88k]
  ------------------
 3736|  7.88k|       ihdr->color_type == SPNG_COLOR_TYPE_TRUECOLOR_ALPHA) flags &= ~SPNG_DECODE_TRNS;
  ------------------
  |  Branch (3736:8): [True: 1.31k, False: 6.56k]
  ------------------
 3737|       |
 3738|  9.33k|    if(flags & SPNG_DECODE_GAMMA && ctx->stored.gama) f.apply_gamma = 1;
  ------------------
  |  Branch (3738:8): [True: 0, False: 9.33k]
  |  Branch (3738:37): [True: 0, False: 0]
  ------------------
 3739|  9.33k|    else flags &= ~SPNG_DECODE_GAMMA;
 3740|       |
 3741|  9.33k|    if(flags & SPNG_DECODE_USE_SBIT && ctx->stored.sbit) f.use_sbit = 1;
  ------------------
  |  Branch (3741:8): [True: 0, False: 9.33k]
  |  Branch (3741:40): [True: 0, False: 0]
  ------------------
 3742|  9.33k|    else flags &= ~SPNG_DECODE_USE_SBIT;
 3743|       |
 3744|  9.33k|    if(fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGBA16))
  ------------------
  |  Branch (3744:8): [True: 0, False: 9.33k]
  ------------------
 3745|      0|    {
 3746|      0|        if(ihdr->color_type == SPNG_COLOR_TYPE_TRUECOLOR_ALPHA &&
  ------------------
  |  Branch (3746:12): [True: 0, False: 0]
  ------------------
 3747|      0|           ihdr->bit_depth == depth_target) f.same_layout = 1;
  ------------------
  |  Branch (3747:12): [True: 0, False: 0]
  ------------------
 3748|      0|    }
 3749|  9.33k|    else if(fmt == SPNG_FMT_RGB8)
  ------------------
  |  Branch (3749:13): [True: 0, False: 9.33k]
  ------------------
 3750|      0|    {
 3751|      0|        if(ihdr->color_type == SPNG_COLOR_TYPE_TRUECOLOR &&
  ------------------
  |  Branch (3751:12): [True: 0, False: 0]
  ------------------
 3752|      0|           ihdr->bit_depth == depth_target) f.same_layout = 1;
  ------------------
  |  Branch (3752:12): [True: 0, False: 0]
  ------------------
 3753|       |
 3754|      0|        f.apply_trns = 0; /* not applicable */
 3755|      0|    }
 3756|  9.33k|    else if(fmt & (SPNG_FMT_PNG | SPNG_FMT_RAW))
  ------------------
  |  Branch (3756:13): [True: 9.33k, False: 0]
  ------------------
 3757|  9.33k|    {
 3758|  9.33k|        f.same_layout = 1;
 3759|  9.33k|        f.do_scaling = 0;
 3760|  9.33k|        f.apply_gamma = 0; /* for now */
 3761|  9.33k|        f.apply_trns = 0;
 3762|  9.33k|    }
 3763|      0|    else if(fmt == SPNG_FMT_G8 && ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE && ihdr->bit_depth <= 8)
  ------------------
  |  Branch (3763:13): [True: 0, False: 0]
  |  Branch (3763:35): [True: 0, False: 0]
  |  Branch (3763:84): [True: 0, False: 0]
  ------------------
 3764|      0|    {
 3765|      0|        if(ihdr->bit_depth == depth_target) f.same_layout = 1;
  ------------------
  |  Branch (3765:12): [True: 0, False: 0]
  ------------------
 3766|      0|        else if(ihdr->bit_depth < 8) f.unpack = 1;
  ------------------
  |  Branch (3766:17): [True: 0, False: 0]
  ------------------
 3767|       |
 3768|      0|        f.apply_trns = 0;
 3769|      0|    }
 3770|      0|    else if(fmt == SPNG_FMT_GA8 && ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE && ihdr->bit_depth <= 8)
  ------------------
  |  Branch (3770:13): [True: 0, False: 0]
  |  Branch (3770:36): [True: 0, False: 0]
  |  Branch (3770:85): [True: 0, False: 0]
  ------------------
 3771|      0|    {
 3772|      0|        if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE_ALPHA &&
  ------------------
  |  Branch (3772:12): [True: 0, False: 0]
  ------------------
 3773|      0|           ihdr->bit_depth == depth_target) f.same_layout = 1;
  ------------------
  |  Branch (3773:12): [True: 0, False: 0]
  ------------------
 3774|      0|        else if(ihdr->bit_depth <= 8) f.unpack = 1;
  ------------------
  |  Branch (3774:17): [True: 0, False: 0]
  ------------------
 3775|      0|    }
 3776|      0|    else if(fmt == SPNG_FMT_GA16 && ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE && ihdr->bit_depth == 16)
  ------------------
  |  Branch (3776:13): [True: 0, False: 0]
  |  Branch (3776:37): [True: 0, False: 0]
  |  Branch (3776:86): [True: 0, False: 0]
  ------------------
 3777|      0|    {
 3778|      0|        if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE_ALPHA &&
  ------------------
  |  Branch (3778:12): [True: 0, False: 0]
  ------------------
 3779|      0|           ihdr->bit_depth == depth_target) f.same_layout = 1;
  ------------------
  |  Branch (3779:12): [True: 0, False: 0]
  ------------------
 3780|      0|        else if(ihdr->bit_depth == 16) f.unpack = 1;
  ------------------
  |  Branch (3780:17): [True: 0, False: 0]
  ------------------
 3781|      0|    }
 3782|       |
 3783|       |    /*if(f.same_layout && !flags && !f.interlaced) f.zerocopy = 1;*/
 3784|       |
 3785|       |#if 0 /* libjpeg-turbo: Eliminate unused gamma correction code, which
 3786|       |         introduces an unwanted libm dependency */
 3787|       |    uint16_t *gamma_lut = NULL;
 3788|       |
 3789|       |    if(f.apply_gamma)
 3790|       |    {
 3791|       |        float file_gamma = (float)ctx->gama / 100000.0f;
 3792|       |        float max;
 3793|       |
 3794|       |        unsigned lut_entries;
 3795|       |
 3796|       |        if(fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGB8))
 3797|       |        {
 3798|       |            lut_entries = 256;
 3799|       |            max = 255.0f;
 3800|       |
 3801|       |            gamma_lut = ctx->gamma_lut8;
 3802|       |            ctx->gamma_lut = ctx->gamma_lut8;
 3803|       |        }
 3804|       |        else /* SPNG_FMT_RGBA16 */
 3805|       |        {
 3806|       |            lut_entries = 65536;
 3807|       |            max = 65535.0f;
 3808|       |
 3809|       |            ctx->gamma_lut16 = spng__malloc(ctx, lut_entries * sizeof(uint16_t));
 3810|       |            if(ctx->gamma_lut16 == NULL) return decode_err(ctx, SPNG_EMEM);
 3811|       |
 3812|       |            gamma_lut = ctx->gamma_lut16;
 3813|       |            ctx->gamma_lut = ctx->gamma_lut16;
 3814|       |        }
 3815|       |
 3816|       |        float screen_gamma = 2.2f;
 3817|       |        float exponent = file_gamma * screen_gamma;
 3818|       |
 3819|       |        if(FP_ZERO == fpclassify(exponent)) return decode_err(ctx, SPNG_EGAMA);
 3820|       |
 3821|       |        exponent = 1.0f / exponent;
 3822|       |
 3823|       |        unsigned i;
 3824|       |        for(i=0; i < lut_entries; i++)
 3825|       |        {
 3826|       |            float c = pow((float)i / max, exponent) * max;
 3827|       |            float c = 0.0f;
 3828|       |            if(c > max) c = max;
 3829|       |
 3830|       |            gamma_lut[i] = (uint16_t)c;
 3831|       |        }
 3832|       |    }
 3833|       |#endif
 3834|       |
 3835|  9.33k|    struct spng_sbit *sb = &ctx->decode_sb;
 3836|       |
 3837|  9.33k|    sb->red_bits = processing_depth;
 3838|  9.33k|    sb->green_bits = processing_depth;
 3839|  9.33k|    sb->blue_bits = processing_depth;
 3840|  9.33k|    sb->alpha_bits = processing_depth;
 3841|  9.33k|    sb->grayscale_bits = processing_depth;
 3842|       |
 3843|  9.33k|    if(f.use_sbit)
  ------------------
  |  Branch (3843:8): [True: 0, False: 9.33k]
  ------------------
 3844|      0|    {
 3845|      0|        if(ihdr->color_type == 0)
  ------------------
  |  Branch (3845:12): [True: 0, False: 0]
  ------------------
 3846|      0|        {
 3847|      0|            sb->grayscale_bits = ctx->sbit.grayscale_bits;
 3848|      0|            sb->alpha_bits = ihdr->bit_depth;
 3849|      0|        }
 3850|      0|        else if(ihdr->color_type == 2 || ihdr->color_type == 3)
  ------------------
  |  Branch (3850:17): [True: 0, False: 0]
  |  Branch (3850:42): [True: 0, False: 0]
  ------------------
 3851|      0|        {
 3852|      0|            sb->red_bits = ctx->sbit.red_bits;
 3853|      0|            sb->green_bits = ctx->sbit.green_bits;
 3854|      0|            sb->blue_bits = ctx->sbit.blue_bits;
 3855|      0|            sb->alpha_bits = ihdr->bit_depth;
 3856|      0|        }
 3857|      0|        else if(ihdr->color_type == 4)
  ------------------
  |  Branch (3857:17): [True: 0, False: 0]
  ------------------
 3858|      0|        {
 3859|      0|            sb->grayscale_bits = ctx->sbit.grayscale_bits;
 3860|      0|            sb->alpha_bits = ctx->sbit.alpha_bits;
 3861|      0|        }
 3862|      0|        else /* == 6 */
 3863|      0|        {
 3864|      0|            sb->red_bits = ctx->sbit.red_bits;
 3865|      0|            sb->green_bits = ctx->sbit.green_bits;
 3866|      0|            sb->blue_bits = ctx->sbit.blue_bits;
 3867|      0|            sb->alpha_bits = ctx->sbit.alpha_bits;
 3868|      0|        }
 3869|      0|    }
 3870|       |
 3871|  9.33k|    if(ihdr->bit_depth == 16 && fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGB8))
  ------------------
  |  Branch (3871:8): [True: 3.47k, False: 5.85k]
  |  Branch (3871:33): [True: 0, False: 3.47k]
  ------------------
 3872|      0|    {/* samples are scaled down by 8 bits in the decode loop */
 3873|      0|        sb->red_bits -= 8;
 3874|      0|        sb->green_bits -= 8;
 3875|      0|        sb->blue_bits -= 8;
 3876|      0|        sb->alpha_bits -= 8;
 3877|      0|        sb->grayscale_bits -= 8;
 3878|       |
 3879|      0|        processing_depth = 8;
 3880|      0|    }
 3881|       |
 3882|       |    /* Prevent infinite loops in sample_to_target() */
 3883|  9.33k|    if(!depth_target || depth_target > 16 ||
  ------------------
  |  Branch (3883:8): [True: 0, False: 9.33k]
  |  Branch (3883:25): [True: 0, False: 9.33k]
  ------------------
 3884|  9.33k|       !processing_depth || processing_depth > 16 ||
  ------------------
  |  Branch (3884:8): [True: 0, False: 9.33k]
  |  Branch (3884:29): [True: 0, False: 9.33k]
  ------------------
 3885|  9.33k|       !sb->grayscale_bits || sb->grayscale_bits > processing_depth ||
  ------------------
  |  Branch (3885:8): [True: 0, False: 9.33k]
  |  Branch (3885:31): [True: 0, False: 9.33k]
  ------------------
 3886|  9.33k|       !sb->alpha_bits || sb->alpha_bits > processing_depth ||
  ------------------
  |  Branch (3886:8): [True: 0, False: 9.33k]
  |  Branch (3886:27): [True: 0, False: 9.33k]
  ------------------
 3887|  9.33k|       !sb->red_bits || sb->red_bits > processing_depth ||
  ------------------
  |  Branch (3887:8): [True: 0, False: 9.33k]
  |  Branch (3887:25): [True: 0, False: 9.33k]
  ------------------
 3888|  9.33k|       !sb->green_bits || sb->green_bits > processing_depth ||
  ------------------
  |  Branch (3888:8): [True: 0, False: 9.33k]
  |  Branch (3888:27): [True: 0, False: 9.33k]
  ------------------
 3889|  9.33k|       !sb->blue_bits || sb->blue_bits > processing_depth)
  ------------------
  |  Branch (3889:8): [True: 0, False: 9.33k]
  |  Branch (3889:26): [True: 0, False: 9.33k]
  ------------------
 3890|      0|    {
 3891|      0|        return decode_err(ctx, SPNG_ESBIT);
 3892|      0|    }
 3893|       |
 3894|  9.33k|    if(sb->red_bits == sb->green_bits &&
  ------------------
  |  Branch (3894:8): [True: 9.33k, False: 0]
  ------------------
 3895|  9.33k|       sb->green_bits == sb->blue_bits &&
  ------------------
  |  Branch (3895:8): [True: 9.33k, False: 0]
  ------------------
 3896|  9.33k|       sb->blue_bits == sb->alpha_bits &&
  ------------------
  |  Branch (3896:8): [True: 9.33k, False: 0]
  ------------------
 3897|  9.33k|       sb->alpha_bits == processing_depth &&
  ------------------
  |  Branch (3897:8): [True: 9.33k, False: 0]
  ------------------
 3898|  9.33k|       processing_depth == depth_target) f.do_scaling = 0;
  ------------------
  |  Branch (3898:8): [True: 5.85k, False: 3.47k]
  ------------------
 3899|       |
 3900|  9.33k|    struct spng_plte_entry *plte = ctx->decode_plte.rgba;
 3901|       |
 3902|       |    /* Pre-process palette entries */
 3903|  9.33k|    if(f.indexed)
  ------------------
  |  Branch (3903:8): [True: 334, False: 9.00k]
  ------------------
 3904|    334|    {
 3905|    334|        uint8_t red, green, blue, alpha;
 3906|       |
 3907|    334|        uint32_t i;
 3908|  85.8k|        for(i=0; i < 256; i++)
  ------------------
  |  Branch (3908:18): [True: 85.5k, False: 334]
  ------------------
 3909|  85.5k|        {
 3910|  85.5k|            if(f.apply_trns && i < ctx->trns.n_type3_entries)
  ------------------
  |  Branch (3910:16): [True: 0, False: 85.5k]
  |  Branch (3910:32): [True: 0, False: 0]
  ------------------
 3911|      0|                ctx->plte.entries[i].alpha = ctx->trns.type3_alpha[i];
 3912|  85.5k|            else
 3913|  85.5k|                ctx->plte.entries[i].alpha = 255;
 3914|       |
 3915|  85.5k|            red   = sample_to_target(ctx->plte.entries[i].red, 8, sb->red_bits, 8);
 3916|  85.5k|            green = sample_to_target(ctx->plte.entries[i].green, 8, sb->green_bits, 8);
 3917|  85.5k|            blue  = sample_to_target(ctx->plte.entries[i].blue, 8, sb->blue_bits, 8);
 3918|  85.5k|            alpha = sample_to_target(ctx->plte.entries[i].alpha, 8, sb->alpha_bits, 8);
 3919|       |
 3920|       |#if defined(SPNG_ARM)
 3921|       |            if(fmt == SPNG_FMT_RGB8 && ihdr->bit_depth == 8)
 3922|       |            {/* Working with 3 bytes at a time is more of an ARM thing */
 3923|       |                ctx->decode_plte.rgb[i * 3 + 0] = red;
 3924|       |                ctx->decode_plte.rgb[i * 3 + 1] = green;
 3925|       |                ctx->decode_plte.rgb[i * 3 + 2] = blue;
 3926|       |                continue;
 3927|       |            }
 3928|       |#endif
 3929|  85.5k|            plte[i].red = red;
 3930|  85.5k|            plte[i].green = green;
 3931|  85.5k|            plte[i].blue = blue;
 3932|  85.5k|            plte[i].alpha = alpha;
 3933|  85.5k|        }
 3934|       |
 3935|    334|        f.apply_trns = 0;
 3936|    334|    }
 3937|       |
 3938|  9.33k|    unsigned char *trns_px = ctx->trns_px;
 3939|       |
 3940|  9.33k|    if(f.apply_trns)
  ------------------
  |  Branch (3940:8): [True: 0, False: 9.33k]
  ------------------
 3941|      0|    {
 3942|      0|        uint16_t mask = ~0;
 3943|      0|        if(ctx->ihdr.bit_depth < 16) mask = (1 << ctx->ihdr.bit_depth) - 1;
  ------------------
  |  Branch (3943:12): [True: 0, False: 0]
  ------------------
 3944|       |
 3945|      0|        if(fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGBA16))
  ------------------
  |  Branch (3945:12): [True: 0, False: 0]
  ------------------
 3946|      0|        {
 3947|      0|            if(ihdr->color_type == SPNG_COLOR_TYPE_TRUECOLOR)
  ------------------
  |  Branch (3947:16): [True: 0, False: 0]
  ------------------
 3948|      0|            {
 3949|      0|                if(ihdr->bit_depth == 16)
  ------------------
  |  Branch (3949:20): [True: 0, False: 0]
  ------------------
 3950|      0|                {
 3951|      0|                    memcpy(trns_px, &ctx->trns.red, 2);
 3952|      0|                    memcpy(trns_px + 2, &ctx->trns.green, 2);
 3953|      0|                    memcpy(trns_px + 4, &ctx->trns.blue, 2);
 3954|      0|                }
 3955|      0|                else
 3956|      0|                {
 3957|      0|                    trns_px[0] = ctx->trns.red & mask;
 3958|      0|                    trns_px[1] = ctx->trns.green & mask;
 3959|      0|                    trns_px[2] = ctx->trns.blue & mask;
 3960|      0|                }
 3961|      0|            }
 3962|      0|        }
 3963|      0|        else if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE) // fmt == SPNG_FMT_GA8 &&
  ------------------
  |  Branch (3963:17): [True: 0, False: 0]
  ------------------
 3964|      0|        {
 3965|      0|            if(ihdr->bit_depth == 16)
  ------------------
  |  Branch (3965:16): [True: 0, False: 0]
  ------------------
 3966|      0|            {
 3967|      0|                memcpy(trns_px, &ctx->trns.gray, 2);
 3968|      0|            }
 3969|      0|            else
 3970|      0|            {
 3971|      0|                trns_px[0] = ctx->trns.gray & mask;
 3972|      0|            }
 3973|      0|        }
 3974|      0|    }
 3975|       |
 3976|  9.33k|    ctx->decode_flags = f;
 3977|       |
 3978|  9.33k|    ctx->state = SPNG_STATE_DECODE_INIT;
 3979|       |
 3980|  9.33k|    struct spng_row_info *ri = &ctx->row_info;
 3981|  9.33k|    struct spng_subimage *sub = ctx->subimage;
 3982|       |
 3983|  9.33k|    while(!sub[ri->pass].width || !sub[ri->pass].height) ri->pass++;
  ------------------
  |  Branch (3983:11): [True: 0, False: 9.33k]
  |  Branch (3983:35): [True: 0, False: 9.33k]
  ------------------
 3984|       |
 3985|  9.33k|    if(f.interlaced) ri->row_num = adam7_y_start[ri->pass];
  ------------------
  |  Branch (3985:8): [True: 2.92k, False: 6.41k]
  ------------------
 3986|       |
 3987|  9.33k|    unsigned pixel_size = 4; /* SPNG_FMT_RGBA8 */
 3988|       |
 3989|  9.33k|    if(fmt == SPNG_FMT_RGBA16) pixel_size = 8;
  ------------------
  |  Branch (3989:8): [True: 0, False: 9.33k]
  ------------------
 3990|  9.33k|    else if(fmt == SPNG_FMT_RGB8) pixel_size = 3;
  ------------------
  |  Branch (3990:13): [True: 0, False: 9.33k]
  ------------------
 3991|  9.33k|    else if(fmt == SPNG_FMT_G8) pixel_size = 1;
  ------------------
  |  Branch (3991:13): [True: 0, False: 9.33k]
  ------------------
 3992|  9.33k|    else if(fmt == SPNG_FMT_GA8) pixel_size = 2;
  ------------------
  |  Branch (3992:13): [True: 0, False: 9.33k]
  ------------------
 3993|       |
 3994|  9.33k|    int i;
 3995|  36.2k|    for(i=ri->pass; i <= ctx->last_pass; i++)
  ------------------
  |  Branch (3995:21): [True: 26.8k, False: 9.33k]
  ------------------
 3996|  26.8k|    {
 3997|  26.8k|        if(!sub[i].scanline_width) continue;
  ------------------
  |  Branch (3997:12): [True: 300, False: 26.5k]
  ------------------
 3998|       |
 3999|  26.5k|        if(fmt & (SPNG_FMT_PNG | SPNG_FMT_RAW)) sub[i].out_width = sub[i].scanline_width - 1;
  ------------------
  |  Branch (3999:12): [True: 26.5k, False: 0]
  ------------------
 4000|      0|        else sub[i].out_width = (size_t)sub[i].width * pixel_size;
 4001|       |
 4002|  26.5k|        if(sub[i].out_width > UINT32_MAX) return decode_err(ctx, SPNG_EOVERFLOW);
  ------------------
  |  Branch (4002:12): [True: 0, False: 26.5k]
  ------------------
 4003|  26.5k|    }
 4004|       |
 4005|       |    /* Read the first filter byte, offsetting all reads by 1 byte.
 4006|       |    The scanlines will be aligned with the start of the array with
 4007|       |    the next scanline's filter byte at the end,
 4008|       |    the last scanline will end up being 1 byte "shorter". */
 4009|  9.33k|    ret = read_scanline_bytes(ctx, &ri->filter, 1);
 4010|  9.33k|    if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (4010:8): [True: 1.62k, False: 7.71k]
  ------------------
 4011|       |
 4012|  7.71k|    if(ri->filter > 4) return decode_err(ctx, SPNG_EFILTER);
  ------------------
  |  Branch (4012:8): [True: 44, False: 7.66k]
  ------------------
 4013|       |
 4014|  7.66k|    if(flags & SPNG_DECODE_PROGRESSIVE)
  ------------------
  |  Branch (4014:8): [True: 7.66k, False: 0]
  ------------------
 4015|  7.66k|    {
 4016|  7.66k|        return 0;
 4017|  7.66k|    }
 4018|       |
 4019|      0|    do
 4020|      0|    {
 4021|      0|        size_t ioffset = ri->row_num * ctx->image_width;
 4022|       |
 4023|      0|        ret = spng_decode_row(ctx, (unsigned char*)out + ioffset, ctx->image_width);
 4024|      0|    }while(!ret);
  ------------------
  |  Branch (4024:12): [True: 0, False: 0]
  ------------------
 4025|       |
 4026|      0|    if(ret != SPNG_EOI) return decode_err(ctx, ret);
  ------------------
  |  Branch (4026:8): [True: 0, False: 0]
  ------------------
 4027|       |
 4028|      0|    return 0;
 4029|      0|}
spng_ctx_new:
 4901|  31.9k|{
 4902|  31.9k|    struct spng_alloc alloc =
 4903|  31.9k|    {
 4904|  31.9k|        .malloc_fn = malloc,
 4905|  31.9k|        .realloc_fn = realloc,
 4906|  31.9k|        .calloc_fn = calloc,
 4907|  31.9k|        .free_fn = free
 4908|  31.9k|    };
 4909|       |
 4910|  31.9k|    return spng_ctx_new2(&alloc, flags);
 4911|  31.9k|}
spng_ctx_new2:
 4914|  31.9k|{
 4915|  31.9k|    if(alloc == NULL) return NULL;
  ------------------
  |  Branch (4915:8): [True: 0, False: 31.9k]
  ------------------
 4916|  31.9k|    if(flags != (flags & SPNG__CTX_FLAGS_ALL)) return NULL;
  ------------------
  |  Branch (4916:8): [True: 0, False: 31.9k]
  ------------------
 4917|       |
 4918|  31.9k|    if(alloc->malloc_fn == NULL) return NULL;
  ------------------
  |  Branch (4918:8): [True: 0, False: 31.9k]
  ------------------
 4919|  31.9k|    if(alloc->realloc_fn == NULL) return NULL;
  ------------------
  |  Branch (4919:8): [True: 0, False: 31.9k]
  ------------------
 4920|  31.9k|    if(alloc->calloc_fn == NULL) return NULL;
  ------------------
  |  Branch (4920:8): [True: 0, False: 31.9k]
  ------------------
 4921|  31.9k|    if(alloc->free_fn == NULL) return NULL;
  ------------------
  |  Branch (4921:8): [True: 0, False: 31.9k]
  ------------------
 4922|       |
 4923|  31.9k|    spng_ctx *ctx = alloc->calloc_fn(1, sizeof(spng_ctx));
 4924|  31.9k|    if(ctx == NULL) return NULL;
  ------------------
  |  Branch (4924:8): [True: 0, False: 31.9k]
  ------------------
 4925|       |
 4926|  31.9k|    ctx->alloc = *alloc;
 4927|       |
 4928|  31.9k|    ctx->max_width = spng_u32max;
 4929|  31.9k|    ctx->max_height = spng_u32max;
 4930|       |
 4931|  31.9k|    ctx->max_chunk_size = spng_u32max;
 4932|  31.9k|    ctx->chunk_cache_limit = SIZE_MAX;
 4933|  31.9k|    ctx->chunk_count_limit = SPNG_MAX_CHUNK_COUNT;
  ------------------
  |  |   32|  31.9k|#define SPNG_MAX_CHUNK_COUNT (1000)
  ------------------
 4934|       |
 4935|  31.9k|    ctx->state = SPNG_STATE_INIT;
 4936|       |
 4937|  31.9k|    ctx->crc_action_critical = SPNG_CRC_ERROR;
 4938|  31.9k|    ctx->crc_action_ancillary = SPNG_CRC_DISCARD;
 4939|       |
 4940|  31.9k|    const struct spng__zlib_options image_defaults =
 4941|  31.9k|    {
 4942|  31.9k|        .compression_level = Z_DEFAULT_COMPRESSION,
  ------------------
  |  |  197|  31.9k|#define Z_DEFAULT_COMPRESSION  (-1)
  ------------------
 4943|  31.9k|        .window_bits = 15,
 4944|  31.9k|        .mem_level = 8,
 4945|  31.9k|        .strategy = Z_FILTERED,
  ------------------
  |  |  200|  31.9k|#define Z_FILTERED            1
  ------------------
 4946|  31.9k|        .data_type = 0 /* Z_BINARY */
 4947|  31.9k|    };
 4948|       |
 4949|  31.9k|    const struct spng__zlib_options text_defaults =
 4950|  31.9k|    {
 4951|  31.9k|        .compression_level = Z_DEFAULT_COMPRESSION,
  ------------------
  |  |  197|  31.9k|#define Z_DEFAULT_COMPRESSION  (-1)
  ------------------
 4952|  31.9k|        .window_bits = 15,
 4953|  31.9k|        .mem_level = 8,
 4954|  31.9k|        .strategy = Z_DEFAULT_STRATEGY,
  ------------------
  |  |  204|  31.9k|#define Z_DEFAULT_STRATEGY    0
  ------------------
 4955|  31.9k|        .data_type = 1 /* Z_TEXT */
 4956|  31.9k|    };
 4957|       |
 4958|  31.9k|    ctx->image_options = image_defaults;
 4959|  31.9k|    ctx->text_options = text_defaults;
 4960|       |
 4961|  31.9k|    ctx->optimize_option = ~0;
 4962|  31.9k|    ctx->encode_flags.filter_choice = SPNG_FILTER_CHOICE_ALL;
 4963|       |
 4964|  31.9k|    ctx->flags = flags;
 4965|       |
 4966|  31.9k|    if(flags & SPNG_CTX_ENCODER) ctx->encode_only = 1;
  ------------------
  |  Branch (4966:8): [True: 0, False: 31.9k]
  ------------------
 4967|       |
 4968|  31.9k|    return ctx;
 4969|  31.9k|}
spng_ctx_free:
 4972|  31.9k|{
 4973|  31.9k|    if(ctx == NULL) return;
  ------------------
  |  Branch (4973:8): [True: 0, False: 31.9k]
  ------------------
 4974|       |
 4975|  31.9k|    if(ctx->streaming && ctx->stream_buf != NULL) spng__free(ctx, ctx->stream_buf);
  ------------------
  |  Branch (4975:8): [True: 31.9k, False: 0]
  |  Branch (4975:26): [True: 31.9k, False: 0]
  ------------------
 4976|       |
 4977|  31.9k|    if(!ctx->user.exif) spng__free(ctx, ctx->exif.data);
  ------------------
  |  Branch (4977:8): [True: 31.9k, False: 0]
  ------------------
 4978|       |
 4979|  31.9k|    if(!ctx->user.iccp) spng__free(ctx, ctx->iccp.profile);
  ------------------
  |  Branch (4979:8): [True: 31.9k, False: 0]
  ------------------
 4980|       |
 4981|  31.9k|    uint32_t i;
 4982|       |
 4983|  31.9k|    if(ctx->splt_list != NULL && !ctx->user.splt)
  ------------------
  |  Branch (4983:8): [True: 2.25k, False: 29.7k]
  |  Branch (4983:34): [True: 2.25k, False: 0]
  ------------------
 4984|  2.25k|    {
 4985|  3.18k|        for(i=0; i < ctx->n_splt; i++)
  ------------------
  |  Branch (4985:18): [True: 931, False: 2.25k]
  ------------------
 4986|    931|        {
 4987|    931|            spng__free(ctx, ctx->splt_list[i].entries);
 4988|    931|        }
 4989|  2.25k|        spng__free(ctx, ctx->splt_list);
 4990|  2.25k|    }
 4991|       |
 4992|  31.9k|    if(ctx->text_list != NULL)
  ------------------
  |  Branch (4992:8): [True: 7.30k, False: 24.6k]
  ------------------
 4993|  7.30k|    {
 4994|  97.7k|        for(i=0; i< ctx->n_text; i++)
  ------------------
  |  Branch (4994:18): [True: 90.4k, False: 7.30k]
  ------------------
 4995|  90.4k|        {
 4996|  90.4k|            if(ctx->user.text) break;
  ------------------
  |  Branch (4996:16): [True: 0, False: 90.4k]
  ------------------
 4997|       |
 4998|  90.4k|            spng__free(ctx, ctx->text_list[i].keyword);
 4999|  90.4k|            if(ctx->text_list[i].compression_flag) spng__free(ctx, ctx->text_list[i].text);
  ------------------
  |  Branch (4999:16): [True: 83.4k, False: 6.96k]
  ------------------
 5000|  90.4k|        }
 5001|  7.30k|        spng__free(ctx, ctx->text_list);
 5002|  7.30k|    }
 5003|       |
 5004|  31.9k|    if(ctx->chunk_list != NULL && !ctx->user.unknown)
  ------------------
  |  Branch (5004:8): [True: 0, False: 31.9k]
  |  Branch (5004:35): [True: 0, False: 0]
  ------------------
 5005|      0|    {
 5006|      0|        for(i=0; i< ctx->n_chunks; i++)
  ------------------
  |  Branch (5006:18): [True: 0, False: 0]
  ------------------
 5007|      0|        {
 5008|      0|            spng__free(ctx, ctx->chunk_list[i].data);
 5009|      0|        }
 5010|      0|        spng__free(ctx, ctx->chunk_list);
 5011|      0|    }
 5012|       |
 5013|  31.9k|    if(ctx->deflate) deflateEnd(&ctx->zstream);
  ------------------
  |  |   53|  31.9k|#  define deflate               z_deflate
  ------------------
                  if(ctx->deflate) deflateEnd(&ctx->zstream);
  ------------------
  |  |   57|      0|#  define deflateEnd            z_deflateEnd
  ------------------
  |  Branch (5013:8): [True: 0, False: 31.9k]
  ------------------
 5014|  31.9k|    else inflateEnd(&ctx->zstream);
  ------------------
  |  |  121|  31.9k|#  define inflateEnd            z_inflateEnd
  ------------------
 5015|       |
 5016|  31.9k|    if(!ctx->user_owns_out_png) spng__free(ctx, ctx->out_png);
  ------------------
  |  Branch (5016:8): [True: 31.9k, False: 0]
  ------------------
 5017|       |
 5018|       |#if 0 /* libjpeg-turbo: Eliminate unused gamma correction code, which
 5019|       |         introduces an unwanted libm dependency */
 5020|       |    spng__free(ctx, ctx->gamma_lut16);
 5021|       |#endif
 5022|       |
 5023|  31.9k|    spng__free(ctx, ctx->row_buf);
 5024|  31.9k|    spng__free(ctx, ctx->scanline_buf);
 5025|  31.9k|    spng__free(ctx, ctx->prev_scanline_buf);
 5026|  31.9k|    spng__free(ctx, ctx->filtered_scanline_buf);
 5027|       |
 5028|  31.9k|    spng_free_fn *free_fn = ctx->alloc.free_fn;
 5029|       |
 5030|  31.9k|    memset(ctx, 0, sizeof(spng_ctx));
 5031|       |
 5032|  31.9k|    free_fn(ctx);
 5033|  31.9k|}
spng_set_png_stream:
 5094|  31.9k|{
 5095|  31.9k|    if(ctx == NULL || rw_func == NULL) return 1;
  ------------------
  |  Branch (5095:8): [True: 0, False: 31.9k]
  |  Branch (5095:23): [True: 0, False: 31.9k]
  ------------------
 5096|  31.9k|    if(!ctx->state) return SPNG_EBADSTATE;
  ------------------
  |  Branch (5096:8): [True: 0, False: 31.9k]
  ------------------
 5097|       |
 5098|       |    /* SPNG_STATE_OUTPUT shares the same value */
 5099|  31.9k|    if(ctx->state >= SPNG_STATE_INPUT) return SPNG_EBUF_SET;
  ------------------
  |  Branch (5099:8): [True: 0, False: 31.9k]
  ------------------
 5100|       |
 5101|  31.9k|    if(ctx->encode_only)
  ------------------
  |  Branch (5101:8): [True: 0, False: 31.9k]
  ------------------
 5102|      0|    {
 5103|      0|        if(ctx->out_png != NULL) return SPNG_EBUF_SET;
  ------------------
  |  Branch (5103:12): [True: 0, False: 0]
  ------------------
 5104|       |
 5105|      0|        ctx->write_fn = rw_func;
 5106|      0|        ctx->write_ptr = ctx->stream_buf;
 5107|       |
 5108|      0|        ctx->state = SPNG_STATE_OUTPUT;
 5109|      0|    }
 5110|  31.9k|    else
 5111|  31.9k|    {
 5112|  31.9k|        ctx->stream_buf = spng__malloc(ctx, SPNG_READ_SIZE);
  ------------------
  |  |   30|  31.9k|#define SPNG_READ_SIZE (8192)
  ------------------
 5113|  31.9k|        if(ctx->stream_buf == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (5113:12): [True: 0, False: 31.9k]
  ------------------
 5114|       |
 5115|  31.9k|        ctx->read_fn = rw_func;
 5116|  31.9k|        ctx->data = ctx->stream_buf;
 5117|  31.9k|        ctx->data_size = SPNG_READ_SIZE;
  ------------------
  |  |   30|  31.9k|#define SPNG_READ_SIZE (8192)
  ------------------
 5118|       |
 5119|  31.9k|        ctx->state = SPNG_STATE_INPUT;
 5120|  31.9k|    }
 5121|       |
 5122|  31.9k|    ctx->stream_user_ptr = user;
 5123|       |
 5124|  31.9k|    ctx->streaming = 1;
 5125|       |
 5126|  31.9k|    return 0;
 5127|  31.9k|}
spng_set_png_file:
 5130|  31.9k|{
 5131|  31.9k|    if(file == NULL) return 1;
  ------------------
  |  Branch (5131:8): [True: 0, False: 31.9k]
  ------------------
 5132|       |
 5133|  31.9k|    if(ctx->encode_only) return spng_set_png_stream(ctx, file_write_fn, file);
  ------------------
  |  Branch (5133:8): [True: 0, False: 31.9k]
  ------------------
 5134|       |
 5135|  31.9k|    return spng_set_png_stream(ctx, file_read_fn, file);
 5136|  31.9k|}
spng_get_ihdr:
 5399|  31.9k|{
 5400|  31.9k|    if(ctx == NULL) return 1;
  ------------------
  |  Branch (5400:8): [True: 0, False: 31.9k]
  ------------------
 5401|  31.9k|    int ret = read_chunks(ctx, 1);
 5402|  31.9k|    if(ret) return ret;
  ------------------
  |  Branch (5402:8): [True: 1.35k, False: 30.6k]
  ------------------
 5403|  30.6k|    if(ihdr == NULL) return 1;
  ------------------
  |  Branch (5403:8): [True: 0, False: 30.6k]
  ------------------
 5404|       |
 5405|  30.6k|    *ihdr = ctx->ihdr;
 5406|       |
 5407|  30.6k|    return 0;
 5408|  30.6k|}
spng_get_plte:
 5411|    714|{
 5412|  1.56k|    SPNG_GET_CHUNK_BOILERPLATE(plte);
  ------------------
  |  |  119|    714|    if(ctx == NULL) return 1; \
  |  |  ------------------
  |  |  |  Branch (119:8): [True: 0, False: 714]
  |  |  ------------------
  |  |  120|    714|    int ret = read_chunks(ctx, 0); \
  |  |  121|    714|    if(ret) return ret; \
  |  |  ------------------
  |  |  |  Branch (121:8): [True: 287, False: 427]
  |  |  ------------------
  |  |  122|    714|    if(!ctx->stored.chunk) return SPNG_ECHUNKAVAIL; \
  |  |  ------------------
  |  |  |  Branch (122:8): [True: 0, False: 427]
  |  |  ------------------
  |  |  123|    427|    if(chunk == NULL) return 1
  |  |  ------------------
  |  |  |  Branch (123:8): [True: 0, False: 427]
  |  |  ------------------
  ------------------
 5413|       |
 5414|    427|    *plte = ctx->plte;
 5415|       |
 5416|    427|    return 0;
 5417|  1.56k|}
spng_get_iccp:
 5474|  7.66k|{
 5475|  15.3k|    SPNG_GET_CHUNK_BOILERPLATE(iccp);
  ------------------
  |  |  119|  7.66k|    if(ctx == NULL) return 1; \
  |  |  ------------------
  |  |  |  Branch (119:8): [True: 0, False: 7.66k]
  |  |  ------------------
  |  |  120|  7.66k|    int ret = read_chunks(ctx, 0); \
  |  |  121|  7.66k|    if(ret) return ret; \
  |  |  ------------------
  |  |  |  Branch (121:8): [True: 0, False: 7.66k]
  |  |  ------------------
  |  |  122|  7.66k|    if(!ctx->stored.chunk) return SPNG_ECHUNKAVAIL; \
  |  |  ------------------
  |  |  |  Branch (122:8): [True: 7.66k, False: 7]
  |  |  ------------------
  |  |  123|  7.66k|    if(chunk == NULL) return 1
  |  |  ------------------
  |  |  |  Branch (123:8): [True: 0, False: 7]
  |  |  ------------------
  ------------------
 5476|       |
 5477|      7|    *iccp = ctx->iccp;
 5478|       |
 5479|      7|    return 0;
 5480|  15.3k|}
spng_strerror:
 6067|  16.1k|{
 6068|  16.1k|    switch(err)
 6069|  16.1k|    {
 6070|  10.8k|        case SPNG_IO_EOF: return "end of stream";
  ------------------
  |  Branch (6070:9): [True: 10.8k, False: 5.23k]
  ------------------
 6071|      0|        case SPNG_IO_ERROR: return "stream error";
  ------------------
  |  Branch (6071:9): [True: 0, False: 16.1k]
  ------------------
 6072|      0|        case SPNG_OK: return "success";
  ------------------
  |  Branch (6072:9): [True: 0, False: 16.1k]
  ------------------
 6073|      0|        case SPNG_EINVAL: return "invalid argument";
  ------------------
  |  Branch (6073:9): [True: 0, False: 16.1k]
  ------------------
 6074|      0|        case SPNG_EMEM: return "out of memory";
  ------------------
  |  Branch (6074:9): [True: 0, False: 16.1k]
  ------------------
 6075|     35|        case SPNG_EOVERFLOW: return "arithmetic overflow";
  ------------------
  |  Branch (6075:9): [True: 35, False: 16.0k]
  ------------------
 6076|    252|        case SPNG_ESIGNATURE: return "invalid signature";
  ------------------
  |  Branch (6076:9): [True: 252, False: 15.8k]
  ------------------
 6077|    217|        case SPNG_EWIDTH: return "invalid image width";
  ------------------
  |  Branch (6077:9): [True: 217, False: 15.9k]
  ------------------
 6078|    217|        case SPNG_EHEIGHT: return "invalid image height";
  ------------------
  |  Branch (6078:9): [True: 217, False: 15.9k]
  ------------------
 6079|      0|        case SPNG_EUSER_WIDTH: return "image width exceeds user limit";
  ------------------
  |  Branch (6079:9): [True: 0, False: 16.1k]
  ------------------
 6080|      0|        case SPNG_EUSER_HEIGHT: return "image height exceeds user limit";
  ------------------
  |  Branch (6080:9): [True: 0, False: 16.1k]
  ------------------
 6081|    217|        case SPNG_EBIT_DEPTH: return "invalid bit depth";
  ------------------
  |  Branch (6081:9): [True: 217, False: 15.9k]
  ------------------
 6082|     21|        case SPNG_ECOLOR_TYPE: return "invalid color type";
  ------------------
  |  Branch (6082:9): [True: 21, False: 16.0k]
  ------------------
 6083|     14|        case SPNG_ECOMPRESSION_METHOD: return "invalid compression method";
  ------------------
  |  Branch (6083:9): [True: 14, False: 16.1k]
  ------------------
 6084|     42|        case SPNG_EFILTER_METHOD: return "invalid filter method";
  ------------------
  |  Branch (6084:9): [True: 42, False: 16.0k]
  ------------------
 6085|      7|        case SPNG_EINTERLACE_METHOD: return "invalid interlace method";
  ------------------
  |  Branch (6085:9): [True: 7, False: 16.1k]
  ------------------
 6086|    273|        case SPNG_EIHDR_SIZE: return "invalid IHDR chunk size";
  ------------------
  |  Branch (6086:9): [True: 273, False: 15.8k]
  ------------------
 6087|     56|        case SPNG_ENOIHDR: return "missing IHDR chunk";
  ------------------
  |  Branch (6087:9): [True: 56, False: 16.0k]
  ------------------
 6088|     20|        case SPNG_ECHUNK_POS: return "invalid chunk position";
  ------------------
  |  Branch (6088:9): [True: 20, False: 16.0k]
  ------------------
 6089|     44|        case SPNG_ECHUNK_SIZE: return "invalid chunk length";
  ------------------
  |  Branch (6089:9): [True: 44, False: 16.0k]
  ------------------
 6090|    628|        case SPNG_ECHUNK_CRC: return "invalid chunk checksum";
  ------------------
  |  Branch (6090:9): [True: 628, False: 15.4k]
  ------------------
 6091|      0|        case SPNG_ECHUNK_TYPE: return "invalid chunk type";
  ------------------
  |  Branch (6091:9): [True: 0, False: 16.1k]
  ------------------
 6092|    604|        case SPNG_ECHUNK_UNKNOWN_CRITICAL: return "unknown critical chunk";
  ------------------
  |  Branch (6092:9): [True: 604, False: 15.5k]
  ------------------
 6093|      0|        case SPNG_EDUP_PLTE: return "duplicate PLTE chunk";
  ------------------
  |  Branch (6093:9): [True: 0, False: 16.1k]
  ------------------
 6094|      0|        case SPNG_EDUP_CHRM: return "duplicate cHRM chunk";
  ------------------
  |  Branch (6094:9): [True: 0, False: 16.1k]
  ------------------
 6095|      0|        case SPNG_EDUP_GAMA: return "duplicate gAMA chunk";
  ------------------
  |  Branch (6095:9): [True: 0, False: 16.1k]
  ------------------
 6096|      0|        case SPNG_EDUP_ICCP: return "duplicate iCCP chunk";
  ------------------
  |  Branch (6096:9): [True: 0, False: 16.1k]
  ------------------
 6097|      0|        case SPNG_EDUP_SBIT: return "duplicate sBIT chunk";
  ------------------
  |  Branch (6097:9): [True: 0, False: 16.1k]
  ------------------
 6098|      0|        case SPNG_EDUP_SRGB: return "duplicate sRGB chunk";
  ------------------
  |  Branch (6098:9): [True: 0, False: 16.1k]
  ------------------
 6099|      0|        case SPNG_EDUP_BKGD: return "duplicate bKGD chunk";
  ------------------
  |  Branch (6099:9): [True: 0, False: 16.1k]
  ------------------
 6100|      0|        case SPNG_EDUP_HIST: return "duplicate hIST chunk";
  ------------------
  |  Branch (6100:9): [True: 0, False: 16.1k]
  ------------------
 6101|      0|        case SPNG_EDUP_TRNS: return "duplicate tRNS chunk";
  ------------------
  |  Branch (6101:9): [True: 0, False: 16.1k]
  ------------------
 6102|      0|        case SPNG_EDUP_PHYS: return "duplicate pHYs chunk";
  ------------------
  |  Branch (6102:9): [True: 0, False: 16.1k]
  ------------------
 6103|      0|        case SPNG_EDUP_TIME: return "duplicate tIME chunk";
  ------------------
  |  Branch (6103:9): [True: 0, False: 16.1k]
  ------------------
 6104|      0|        case SPNG_EDUP_OFFS: return "duplicate oFFs chunk";
  ------------------
  |  Branch (6104:9): [True: 0, False: 16.1k]
  ------------------
 6105|      0|        case SPNG_EDUP_EXIF: return "duplicate eXIf chunk";
  ------------------
  |  Branch (6105:9): [True: 0, False: 16.1k]
  ------------------
 6106|      0|        case SPNG_ECHRM: return "invalid cHRM chunk";
  ------------------
  |  Branch (6106:9): [True: 0, False: 16.1k]
  ------------------
 6107|      0|        case SPNG_EPLTE_IDX: return "invalid palette (PLTE) index";
  ------------------
  |  Branch (6107:9): [True: 0, False: 16.1k]
  ------------------
 6108|      0|        case SPNG_ETRNS_COLOR_TYPE: return "tRNS chunk with incompatible color type";
  ------------------
  |  Branch (6108:9): [True: 0, False: 16.1k]
  ------------------
 6109|      0|        case SPNG_ETRNS_NO_PLTE: return "missing palette (PLTE) for tRNS chunk";
  ------------------
  |  Branch (6109:9): [True: 0, False: 16.1k]
  ------------------
 6110|      0|        case SPNG_EGAMA: return "invalid gAMA chunk";
  ------------------
  |  Branch (6110:9): [True: 0, False: 16.1k]
  ------------------
 6111|      0|        case SPNG_EICCP_NAME: return "invalid iCCP profile name";
  ------------------
  |  Branch (6111:9): [True: 0, False: 16.1k]
  ------------------
 6112|      0|        case SPNG_EICCP_COMPRESSION_METHOD: return "invalid iCCP compression method";
  ------------------
  |  Branch (6112:9): [True: 0, False: 16.1k]
  ------------------
 6113|      0|        case SPNG_ESBIT: return "invalid sBIT chunk";
  ------------------
  |  Branch (6113:9): [True: 0, False: 16.1k]
  ------------------
 6114|      0|        case SPNG_ESRGB: return "invalid sRGB chunk";
  ------------------
  |  Branch (6114:9): [True: 0, False: 16.1k]
  ------------------
 6115|      0|        case SPNG_ETEXT: return "invalid tEXt chunk";
  ------------------
  |  Branch (6115:9): [True: 0, False: 16.1k]
  ------------------
 6116|      0|        case SPNG_ETEXT_KEYWORD: return "invalid tEXt keyword";
  ------------------
  |  Branch (6116:9): [True: 0, False: 16.1k]
  ------------------
 6117|      0|        case SPNG_EZTXT: return "invalid zTXt chunk";
  ------------------
  |  Branch (6117:9): [True: 0, False: 16.1k]
  ------------------
 6118|      0|        case SPNG_EZTXT_COMPRESSION_METHOD: return "invalid zTXt compression method";
  ------------------
  |  Branch (6118:9): [True: 0, False: 16.1k]
  ------------------
 6119|      0|        case SPNG_EITXT: return "invalid iTXt chunk";
  ------------------
  |  Branch (6119:9): [True: 0, False: 16.1k]
  ------------------
 6120|      0|        case SPNG_EITXT_COMPRESSION_FLAG: return "invalid iTXt compression flag";
  ------------------
  |  Branch (6120:9): [True: 0, False: 16.1k]
  ------------------
 6121|      0|        case SPNG_EITXT_COMPRESSION_METHOD: return "invalid iTXt compression method";
  ------------------
  |  Branch (6121:9): [True: 0, False: 16.1k]
  ------------------
 6122|      0|        case SPNG_EITXT_LANG_TAG: return "invalid iTXt language tag";
  ------------------
  |  Branch (6122:9): [True: 0, False: 16.1k]
  ------------------
 6123|      0|        case SPNG_EITXT_TRANSLATED_KEY: return "invalid iTXt translated key";
  ------------------
  |  Branch (6123:9): [True: 0, False: 16.1k]
  ------------------
 6124|      0|        case SPNG_EBKGD_NO_PLTE: return "missing palette for bKGD chunk";
  ------------------
  |  Branch (6124:9): [True: 0, False: 16.1k]
  ------------------
 6125|      0|        case SPNG_EBKGD_PLTE_IDX: return "invalid palette index for bKGD chunk";
  ------------------
  |  Branch (6125:9): [True: 0, False: 16.1k]
  ------------------
 6126|      0|        case SPNG_EHIST_NO_PLTE: return "missing palette for hIST chunk";
  ------------------
  |  Branch (6126:9): [True: 0, False: 16.1k]
  ------------------
 6127|      0|        case SPNG_EPHYS: return "invalid pHYs chunk";
  ------------------
  |  Branch (6127:9): [True: 0, False: 16.1k]
  ------------------
 6128|      0|        case SPNG_ESPLT_NAME: return "invalid suggested palette name";
  ------------------
  |  Branch (6128:9): [True: 0, False: 16.1k]
  ------------------
 6129|      0|        case SPNG_ESPLT_DUP_NAME: return "duplicate suggested palette (sPLT) name";
  ------------------
  |  Branch (6129:9): [True: 0, False: 16.1k]
  ------------------
 6130|      0|        case SPNG_ESPLT_DEPTH: return "invalid suggested palette (sPLT) sample depth";
  ------------------
  |  Branch (6130:9): [True: 0, False: 16.1k]
  ------------------
 6131|      0|        case SPNG_ETIME: return "invalid tIME chunk";
  ------------------
  |  Branch (6131:9): [True: 0, False: 16.1k]
  ------------------
 6132|      0|        case SPNG_EOFFS: return "invalid oFFs chunk";
  ------------------
  |  Branch (6132:9): [True: 0, False: 16.1k]
  ------------------
 6133|      0|        case SPNG_EEXIF: return "invalid eXIf chunk";
  ------------------
  |  Branch (6133:9): [True: 0, False: 16.1k]
  ------------------
 6134|    133|        case SPNG_EIDAT_TOO_SHORT: return "IDAT stream too short";
  ------------------
  |  Branch (6134:9): [True: 133, False: 15.9k]
  ------------------
 6135|  1.61k|        case SPNG_EIDAT_STREAM: return "IDAT stream error";
  ------------------
  |  Branch (6135:9): [True: 1.61k, False: 14.4k]
  ------------------
 6136|      0|        case SPNG_EZLIB: return "zlib error";
  ------------------
  |  Branch (6136:9): [True: 0, False: 16.1k]
  ------------------
 6137|    613|        case SPNG_EFILTER: return "invalid scanline filter";
  ------------------
  |  Branch (6137:9): [True: 613, False: 15.5k]
  ------------------
 6138|      0|        case SPNG_EBUFSIZ: return "invalid buffer size";
  ------------------
  |  Branch (6138:9): [True: 0, False: 16.1k]
  ------------------
 6139|      0|        case SPNG_EIO: return "i/o error";
  ------------------
  |  Branch (6139:9): [True: 0, False: 16.1k]
  ------------------
 6140|      0|        case SPNG_EOF: return "end of file";
  ------------------
  |  Branch (6140:9): [True: 0, False: 16.1k]
  ------------------
 6141|      0|        case SPNG_EBUF_SET: return "buffer already set";
  ------------------
  |  Branch (6141:9): [True: 0, False: 16.1k]
  ------------------
 6142|      0|        case SPNG_EBADSTATE: return "non-recoverable state";
  ------------------
  |  Branch (6142:9): [True: 0, False: 16.1k]
  ------------------
 6143|      0|        case SPNG_EFMT: return "invalid format";
  ------------------
  |  Branch (6143:9): [True: 0, False: 16.1k]
  ------------------
 6144|      0|        case SPNG_EFLAGS: return "invalid flags";
  ------------------
  |  Branch (6144:9): [True: 0, False: 16.1k]
  ------------------
 6145|      0|        case SPNG_ECHUNKAVAIL: return "chunk not available";
  ------------------
  |  Branch (6145:9): [True: 0, False: 16.1k]
  ------------------
 6146|      0|        case SPNG_ENCODE_ONLY: return "encode only context";
  ------------------
  |  Branch (6146:9): [True: 0, False: 16.1k]
  ------------------
 6147|      0|        case SPNG_EOI: return "reached end-of-image state";
  ------------------
  |  Branch (6147:9): [True: 0, False: 16.1k]
  ------------------
 6148|      7|        case SPNG_ENOPLTE: return "missing PLTE for indexed image";
  ------------------
  |  Branch (6148:9): [True: 7, False: 16.1k]
  ------------------
 6149|     13|        case SPNG_ECHUNK_LIMITS: return "reached chunk/cache limits";
  ------------------
  |  Branch (6149:9): [True: 13, False: 16.1k]
  ------------------
 6150|      0|        case SPNG_EZLIB_INIT: return "zlib init error";
  ------------------
  |  Branch (6150:9): [True: 0, False: 16.1k]
  ------------------
 6151|    201|        case SPNG_ECHUNK_STDLEN: return "chunk exceeds maximum standard length";
  ------------------
  |  Branch (6151:9): [True: 201, False: 15.9k]
  ------------------
 6152|      0|        case SPNG_EINTERNAL: return "internal error";
  ------------------
  |  Branch (6152:9): [True: 0, False: 16.1k]
  ------------------
 6153|      0|        case SPNG_ECTXTYPE: return "invalid operation for context type";
  ------------------
  |  Branch (6153:9): [True: 0, False: 16.1k]
  ------------------
 6154|      0|        case SPNG_ENOSRC: return "source PNG not set";
  ------------------
  |  Branch (6154:9): [True: 0, False: 16.1k]
  ------------------
 6155|      0|        case SPNG_ENODST: return "PNG output not set";
  ------------------
  |  Branch (6155:9): [True: 0, False: 16.1k]
  ------------------
 6156|      0|        case SPNG_EOPSTATE: return "invalid operation for state";
  ------------------
  |  Branch (6156:9): [True: 0, False: 16.1k]
  ------------------
 6157|      0|        case SPNG_ENOTFINAL: return "PNG not finalized";
  ------------------
  |  Branch (6157:9): [True: 0, False: 16.1k]
  ------------------
 6158|      0|        default: return "unknown error";
  ------------------
  |  Branch (6158:9): [True: 0, False: 16.1k]
  ------------------
 6159|  16.1k|    }
 6160|  16.1k|}
spng.c:spng__iter_init:
  494|   844k|{
  495|   844k|    struct spng__iter iter =
  496|   844k|    {
  497|   844k|        .mask = (uint32_t)(1 << bit_depth) - 1,
  498|   844k|        .shift_amount = 8 - bit_depth,
  499|   844k|        .initial_shift = 8 - bit_depth,
  500|   844k|        .bit_depth = bit_depth,
  501|   844k|        .samples = samples
  502|   844k|    };
  503|       |
  504|   844k|    return iter;
  505|   844k|}
spng.c:read_scanline:
 3229|   844k|{
 3230|   844k|    int ret, pass = ctx->row_info.pass;
 3231|   844k|    struct spng_row_info *ri = &ctx->row_info;
 3232|   844k|    const struct spng_subimage *sub = ctx->subimage;
 3233|   844k|    size_t scanline_width = sub[pass].scanline_width;
 3234|   844k|    uint32_t scanline_idx = ri->scanline_idx;
 3235|       |
 3236|   844k|    uint8_t next_filter = 0;
 3237|       |
 3238|   844k|    if(scanline_idx == (sub[pass].height - 1) && ri->pass == ctx->last_pass)
  ------------------
  |  Branch (3238:8): [True: 12.4k, False: 831k]
  |  Branch (3238:50): [True: 2.59k, False: 9.83k]
  ------------------
 3239|  2.59k|    {
 3240|  2.59k|        ret = read_scanline_bytes(ctx, ctx->scanline, scanline_width - 1);
 3241|  2.59k|    }
 3242|   841k|    else
 3243|   841k|    {
 3244|   841k|        ret = read_scanline_bytes(ctx, ctx->scanline, scanline_width);
 3245|   841k|        if(ret) return ret;
  ------------------
  |  Branch (3245:12): [True: 2.98k, False: 838k]
  ------------------
 3246|       |
 3247|   838k|        next_filter = ctx->scanline[scanline_width - 1];
 3248|   838k|        if(next_filter > 4) ret = SPNG_EFILTER;
  ------------------
  |  Branch (3248:12): [True: 569, False: 838k]
  ------------------
 3249|   838k|    }
 3250|       |
 3251|   841k|    if(ret) return ret;
  ------------------
  |  Branch (3251:8): [True: 799, False: 840k]
  ------------------
 3252|       |
 3253|   840k|    if(!scanline_idx && ri->filter > 1)
  ------------------
  |  Branch (3253:8): [True: 16.8k, False: 823k]
  |  Branch (3253:25): [True: 3.82k, False: 13.0k]
  ------------------
 3254|  3.82k|    {
 3255|       |        /* prev_scanline is all zeros for the first scanline */
 3256|  3.82k|        memset(ctx->prev_scanline, 0, scanline_width);
 3257|  3.82k|    }
 3258|       |
 3259|   840k|    if(ctx->ihdr.bit_depth == 16 && ctx->fmt != SPNG_FMT_RAW) u16_row_to_host(ctx->scanline, scanline_width - 1);
  ------------------
  |  Branch (3259:8): [True: 444k, False: 395k]
  |  Branch (3259:37): [True: 444k, False: 0]
  ------------------
 3260|       |
 3261|   840k|    ret = defilter_scanline(ctx->prev_scanline, ctx->scanline, scanline_width, ctx->bytes_per_pixel, ri->filter);
 3262|   840k|    if(ret) return ret;
  ------------------
  |  Branch (3262:8): [True: 0, False: 840k]
  ------------------
 3263|       |
 3264|   840k|    ri->filter = next_filter;
 3265|       |
 3266|   840k|    return 0;
 3267|   840k|}
spng.c:u16_row_to_host:
  524|   444k|{
  525|   444k|    uint16_t *px = row;
  526|   444k|    size_t i, n = size / 2;
  527|       |
  528|  49.2M|    for(i=0; i < n; i++)
  ------------------
  |  Branch (528:14): [True: 48.7M, False: 444k]
  ------------------
  529|  48.7M|    {
  530|  48.7M|        px[i] = read_u16(&px[i]);
  531|  48.7M|    }
  532|   444k|}
spng.c:defilter_scanline:
 1463|   840k|{
 1464|   840k|    if(prev_scanline == NULL || scanline == NULL || !scanline_width) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1464:8): [True: 0, False: 840k]
  |  Branch (1464:33): [True: 0, False: 840k]
  |  Branch (1464:53): [True: 0, False: 840k]
  ------------------
 1465|       |
 1466|   840k|    size_t i;
 1467|   840k|    scanline_width--;
 1468|       |
 1469|   840k|    if(filter == 0) return 0;
  ------------------
  |  Branch (1469:8): [True: 477k, False: 362k]
  ------------------
 1470|       |
 1471|   362k|#ifndef SPNG_DISABLE_OPT
 1472|   362k|    if(filter == SPNG_FILTER_UP) goto no_opt;
  ------------------
  |  Branch (1472:8): [True: 98.1k, False: 264k]
  ------------------
 1473|       |
 1474|   264k|    if(bytes_per_pixel == 4)
  ------------------
  |  Branch (1474:8): [True: 64.6k, False: 199k]
  ------------------
 1475|  64.6k|    {
 1476|  64.6k|        if(filter == SPNG_FILTER_SUB)
  ------------------
  |  Branch (1476:12): [True: 42.7k, False: 21.9k]
  ------------------
 1477|  42.7k|            defilter_sub4(scanline_width, scanline);
 1478|  21.9k|        else if(filter == SPNG_FILTER_AVERAGE)
  ------------------
  |  Branch (1478:17): [True: 2.44k, False: 19.5k]
  ------------------
 1479|  2.44k|            defilter_avg4(scanline_width, scanline, prev_scanline);
 1480|  19.5k|        else if(filter == SPNG_FILTER_PAETH)
  ------------------
  |  Branch (1480:17): [True: 19.5k, False: 0]
  ------------------
 1481|  19.5k|            defilter_paeth4(scanline_width, scanline, prev_scanline);
 1482|      0|        else return SPNG_EFILTER;
 1483|       |
 1484|  64.6k|        return 0;
 1485|  64.6k|    }
 1486|   199k|    else if(bytes_per_pixel == 3)
  ------------------
  |  Branch (1486:13): [True: 99.5k, False: 100k]
  ------------------
 1487|  99.5k|    {
 1488|  99.5k|        if(filter == SPNG_FILTER_SUB)
  ------------------
  |  Branch (1488:12): [True: 4.92k, False: 94.6k]
  ------------------
 1489|  4.92k|            defilter_sub3(scanline_width, scanline);
 1490|  94.6k|        else if(filter == SPNG_FILTER_AVERAGE)
  ------------------
  |  Branch (1490:17): [True: 828, False: 93.7k]
  ------------------
 1491|    828|            defilter_avg3(scanline_width, scanline, prev_scanline);
 1492|  93.7k|        else if(filter == SPNG_FILTER_PAETH)
  ------------------
  |  Branch (1492:17): [True: 93.7k, False: 0]
  ------------------
 1493|  93.7k|            defilter_paeth3(scanline_width, scanline, prev_scanline);
 1494|      0|        else return SPNG_EFILTER;
 1495|       |
 1496|  99.5k|        return 0;
 1497|  99.5k|    }
 1498|   198k|no_opt:
 1499|   198k|#endif
 1500|       |
 1501|   198k|    if(filter == SPNG_FILTER_UP)
  ------------------
  |  Branch (1501:8): [True: 98.1k, False: 100k]
  ------------------
 1502|  98.1k|    {
 1503|  98.1k|        defilter_up(scanline_width, scanline, prev_scanline);
 1504|  98.1k|        return 0;
 1505|  98.1k|    }
 1506|       |
 1507|  29.3M|    for(i=0; i < scanline_width; i++)
  ------------------
  |  Branch (1507:14): [True: 29.2M, False: 100k]
  ------------------
 1508|  29.2M|    {
 1509|  29.2M|        uint8_t x, a, b, c;
 1510|       |
 1511|  29.2M|        if(i >= bytes_per_pixel)
  ------------------
  |  Branch (1511:12): [True: 28.7M, False: 497k]
  ------------------
 1512|  28.7M|        {
 1513|  28.7M|            a = scanline[i - bytes_per_pixel];
 1514|  28.7M|            b = prev_scanline[i];
 1515|  28.7M|            c = prev_scanline[i - bytes_per_pixel];
 1516|  28.7M|        }
 1517|   497k|        else /* First pixel in row */
 1518|   497k|        {
 1519|   497k|            a = 0;
 1520|   497k|            b = prev_scanline[i];
 1521|   497k|            c = 0;
 1522|   497k|        }
 1523|       |
 1524|  29.2M|        x = scanline[i];
 1525|       |
 1526|  29.2M|        switch(filter)
  ------------------
  |  Branch (1526:16): [True: 29.2M, False: 0]
  ------------------
 1527|  29.2M|        {
 1528|  12.3M|            case SPNG_FILTER_SUB:
  ------------------
  |  Branch (1528:13): [True: 12.3M, False: 16.9M]
  ------------------
 1529|  12.3M|            {
 1530|  12.3M|                x = x + a;
 1531|  12.3M|                break;
 1532|      0|            }
 1533|  8.40M|            case SPNG_FILTER_AVERAGE:
  ------------------
  |  Branch (1533:13): [True: 8.40M, False: 20.8M]
  ------------------
 1534|  8.40M|            {
 1535|  8.40M|                uint16_t avg = (a + b) / 2;
 1536|  8.40M|                x = x + avg;
 1537|  8.40M|                break;
 1538|      0|            }
 1539|  8.54M|            case SPNG_FILTER_PAETH:
  ------------------
  |  Branch (1539:13): [True: 8.54M, False: 20.7M]
  ------------------
 1540|  8.54M|            {
 1541|  8.54M|                x = x + paeth(a,b,c);
 1542|  8.54M|                break;
 1543|      0|            }
 1544|  29.2M|        }
 1545|       |
 1546|  29.2M|        scanline[i] = x;
 1547|  29.2M|    }
 1548|       |
 1549|   100k|    return 0;
 1550|   100k|}
spng.c:defilter_sub4:
 6300|  42.7k|{
 6301|       |    /* The Sub filter predicts each pixel as the previous pixel, a.
 6302|       |     * There is no pixel to the left of the first pixel.  It's encoded directly.
 6303|       |     * That works with our main loop if we just say that left pixel was zero.
 6304|       |     */
 6305|  42.7k|    size_t rb = rowbytes+4;
 6306|       |
 6307|  42.7k|    __m128i a, d = _mm_setzero_si128();
 6308|       |
 6309|   518k|    while(rb > 4)
  ------------------
  |  Branch (6309:11): [True: 476k, False: 42.7k]
  ------------------
 6310|   476k|    {
 6311|   476k|        a = d; d = load4(row);
 6312|   476k|        d = _mm_add_epi8(d, a);
 6313|   476k|        store4(row, d);
 6314|       |
 6315|   476k|        row += 4;
 6316|   476k|        rb  -= 4;
 6317|   476k|    }
 6318|  42.7k|}
spng.c:load4:
 6246|  18.0M|{
 6247|  18.0M|    int tmp;
 6248|  18.0M|    memcpy(&tmp, p, sizeof(tmp));
 6249|  18.0M|    return _mm_cvtsi32_si128(tmp);
 6250|  18.0M|}
spng.c:store4:
 6253|  1.08M|{
 6254|  1.08M|    int tmp = _mm_cvtsi128_si32(v);
 6255|  1.08M|    memcpy(p, &tmp, sizeof(int));
 6256|  1.08M|}
spng.c:defilter_avg4:
 6372|  2.44k|{
 6373|       |    /* The Avg filter predicts each pixel as the (truncated) average of a and b.
 6374|       |     * There's no pixel to the left of the first pixel.  Luckily, it's
 6375|       |     * predicted to be half of the pixel above it.  So again, this works
 6376|       |     * perfectly with our loop if we make sure a starts at zero.
 6377|       |     */
 6378|  2.44k|    size_t rb = rowbytes+4;
 6379|       |
 6380|  2.44k|    const __m128i zero = _mm_setzero_si128();
 6381|  2.44k|    __m128i    b;
 6382|  2.44k|    __m128i a, d = zero;
 6383|       |
 6384|  74.0k|    while(rb > 4)
  ------------------
  |  Branch (6384:11): [True: 71.6k, False: 2.44k]
  ------------------
 6385|  71.6k|    {
 6386|  71.6k|        __m128i avg;
 6387|  71.6k|               b = load4(prev);
 6388|  71.6k|        a = d; d = load4(row );
 6389|       |
 6390|       |        /* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
 6391|  71.6k|        avg = _mm_avg_epu8(a,b);
 6392|       |        /* ...but we can fix it up by subtracting off 1 if it rounded up. */
 6393|  71.6k|        avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a, b),
 6394|  71.6k|                                            _mm_set1_epi8(1)));
 6395|       |
 6396|  71.6k|        d = _mm_add_epi8(d, avg);
 6397|  71.6k|        store4(row, d);
 6398|       |
 6399|  71.6k|        prev += 4;
 6400|  71.6k|        row  += 4;
 6401|  71.6k|        rb   -= 4;
 6402|  71.6k|    }
 6403|  2.44k|}
spng.c:defilter_paeth4:
 6531|  19.5k|{
 6532|       |    /* Paeth tries to predict pixel d using the pixel to the left of it, a,
 6533|       |     * and two pixels from the previous row, b and c:
 6534|       |     *   prev: c b
 6535|       |     *   row:  a d
 6536|       |     * The Paeth function predicts d to be whichever of a, b, or c is nearest to
 6537|       |     * p=a+b-c.
 6538|       |     *
 6539|       |     * The first pixel has no left context, and so uses an Up filter, p = b.
 6540|       |     * This works naturally with our main loop's p = a+b-c if we force a and c
 6541|       |     * to zero.
 6542|       |     * Here we zero b and d, which become c and a respectively at the start of
 6543|       |     * the loop.
 6544|       |     */
 6545|  19.5k|    size_t rb = rowbytes+4;
 6546|       |
 6547|  19.5k|    const __m128i zero = _mm_setzero_si128();
 6548|  19.5k|    __m128i pa, pb, pc, smallest, nearest;
 6549|  19.5k|    __m128i c, b = zero,
 6550|  19.5k|            a, d = zero;
 6551|       |
 6552|   556k|    while(rb > 4)
  ------------------
  |  Branch (6552:11): [True: 537k, False: 19.5k]
  ------------------
 6553|   537k|    {
 6554|       |        /* It's easiest to do this math (particularly, deal with pc) with 16-bit
 6555|       |         * intermediates.
 6556|       |         */
 6557|   537k|        c = b; b = _mm_unpacklo_epi8(load4(prev), zero);
 6558|   537k|        a = d; d = _mm_unpacklo_epi8(load4(row ), zero);
 6559|       |
 6560|       |        /* (p-a) == (a+b-c - a) == (b-c) */
 6561|   537k|        pa = _mm_sub_epi16(b, c);
 6562|       |
 6563|       |        /* (p-b) == (a+b-c - b) == (a-c) */
 6564|   537k|        pb = _mm_sub_epi16(a, c);
 6565|       |
 6566|       |        /* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
 6567|   537k|        pc = _mm_add_epi16(pa, pb);
 6568|       |
 6569|   537k|        pa = abs_i16(pa);  /* |p-a| */
 6570|   537k|        pb = abs_i16(pb);  /* |p-b| */
 6571|   537k|        pc = abs_i16(pc);  /* |p-c| */
 6572|       |
 6573|   537k|        smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
 6574|       |
 6575|       |        /* Paeth breaks ties favoring a over b over c. */
 6576|   537k|        nearest  = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
 6577|   537k|                            if_then_else(_mm_cmpeq_epi16(smallest, pb), b, c));
 6578|       |
 6579|       |        /* Note `_epi8`: we need addition to wrap modulo 255. */
 6580|   537k|        d = _mm_add_epi8(d, nearest);
 6581|   537k|        store4(row, _mm_packus_epi16(d, d));
 6582|       |
 6583|   537k|        prev += 4;
 6584|   537k|        row  += 4;
 6585|   537k|        rb   -= 4;
 6586|   537k|    }
 6587|  19.5k|}
spng.c:abs_i16:
 6410|  25.3M|{
 6411|       |#if defined(__SSSE3__) || defined(__AVX__)
 6412|       |    return _mm_abs_epi16(x);
 6413|       |#else
 6414|       |    /* Read this all as, return x<0 ? -x : x.
 6415|       |     * To negate two's complement, you flip all the bits then add 1.
 6416|       |     */
 6417|  25.3M|    __m128i is_negative = _mm_cmplt_epi16(x, _mm_setzero_si128());
 6418|       |
 6419|       |    /* Flip negative lanes. */
 6420|  25.3M|    x = _mm_xor_si128(x, is_negative);
 6421|       |
 6422|       |    /* +1 to negative lanes, else +0. */
 6423|  25.3M|    x = _mm_sub_epi16(x, is_negative);
 6424|  25.3M|    return x;
 6425|  25.3M|#endif
 6426|  25.3M|}
spng.c:if_then_else:
 6430|  16.9M|{
 6431|       |#if defined(__SSE4_1__) || defined(__AVX__)
 6432|       |    return _mm_blendv_epi8(e, t, c);
 6433|       |#else
 6434|  16.9M|    return _mm_or_si128(_mm_and_si128(c, t), _mm_andnot_si128(c, e));
 6435|  16.9M|#endif
 6436|  16.9M|}
spng.c:defilter_sub3:
 6272|  4.92k|{
 6273|       |    /* The Sub filter predicts each pixel as the previous pixel, a.
 6274|       |     * There is no pixel to the left of the first pixel.  It's encoded directly.
 6275|       |     * That works with our main loop if we just say that left pixel was zero.
 6276|       |     */
 6277|  4.92k|    size_t rb = rowbytes;
 6278|       |
 6279|  4.92k|    __m128i a, d = _mm_setzero_si128();
 6280|       |
 6281|   574k|    while(rb >= 4)
  ------------------
  |  Branch (6281:11): [True: 569k, False: 4.92k]
  ------------------
 6282|   569k|    {
 6283|   569k|        a = d; d = load4(row);
 6284|   569k|        d = _mm_add_epi8(d, a);
 6285|   569k|        store3(row, d);
 6286|       |
 6287|   569k|        row += 3;
 6288|   569k|        rb  -= 3;
 6289|   569k|    }
 6290|       |
 6291|  4.92k|    if(rb > 0)
  ------------------
  |  Branch (6291:8): [True: 4.92k, False: 0]
  ------------------
 6292|  4.92k|    {
 6293|  4.92k|        a = d; d = load3(row);
 6294|  4.92k|        d = _mm_add_epi8(d, a);
 6295|  4.92k|        store3(row, d);
 6296|  4.92k|    }
 6297|  4.92k|}
spng.c:store3:
 6266|  8.54M|{
 6267|  8.54M|    int tmp = _mm_cvtsi128_si32(v);
 6268|  8.54M|    memcpy(p, &tmp, 3);
 6269|  8.54M|}
spng.c:load3:
 6259|   194k|{
 6260|   194k|    uint32_t tmp = 0;
 6261|   194k|    memcpy(&tmp, p, 3);
 6262|   194k|    return _mm_cvtsi32_si128(tmp);
 6263|   194k|}
spng.c:defilter_avg3:
 6321|    828|{
 6322|       |    /* The Avg filter predicts each pixel as the (truncated) average of a and b.
 6323|       |     * There's no pixel to the left of the first pixel.  Luckily, it's
 6324|       |     * predicted to be half of the pixel above it.  So again, this works
 6325|       |     * perfectly with our loop if we make sure a starts at zero.
 6326|       |     */
 6327|       |
 6328|    828|    size_t rb = rowbytes;
 6329|       |
 6330|    828|    const __m128i zero = _mm_setzero_si128();
 6331|       |
 6332|    828|    __m128i b;
 6333|    828|    __m128i a, d = zero;
 6334|       |
 6335|  46.5k|    while(rb >= 4)
  ------------------
  |  Branch (6335:11): [True: 45.7k, False: 828]
  ------------------
 6336|  45.7k|    {
 6337|  45.7k|        __m128i avg;
 6338|  45.7k|               b = load4(prev);
 6339|  45.7k|        a = d; d = load4(row );
 6340|       |
 6341|       |        /* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
 6342|  45.7k|        avg = _mm_avg_epu8(a,b);
 6343|       |        /* ...but we can fix it up by subtracting off 1 if it rounded up. */
 6344|  45.7k|        avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a, b),
 6345|  45.7k|                                            _mm_set1_epi8(1)));
 6346|  45.7k|        d = _mm_add_epi8(d, avg);
 6347|  45.7k|        store3(row, d);
 6348|       |
 6349|  45.7k|        prev += 3;
 6350|  45.7k|        row  += 3;
 6351|  45.7k|        rb   -= 3;
 6352|  45.7k|    }
 6353|       |
 6354|    828|    if(rb > 0)
  ------------------
  |  Branch (6354:8): [True: 828, False: 0]
  ------------------
 6355|    828|    {
 6356|    828|        __m128i avg;
 6357|    828|               b = load3(prev);
 6358|    828|        a = d; d = load3(row );
 6359|       |
 6360|       |        /* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
 6361|    828|        avg = _mm_avg_epu8(a, b);
 6362|       |        /* ...but we can fix it up by subtracting off 1 if it rounded up. */
 6363|    828|        avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a, b),
 6364|    828|                                            _mm_set1_epi8(1)));
 6365|       |
 6366|    828|        d = _mm_add_epi8(d, avg);
 6367|    828|        store3(row, d);
 6368|    828|    }
 6369|    828|}
spng.c:defilter_paeth3:
 6439|  93.7k|{
 6440|       |    /* Paeth tries to predict pixel d using the pixel to the left of it, a,
 6441|       |     * and two pixels from the previous row, b and c:
 6442|       |     *   prev: c b
 6443|       |     *   row:  a d
 6444|       |     * The Paeth function predicts d to be whichever of a, b, or c is nearest to
 6445|       |     * p=a+b-c.
 6446|       |     *
 6447|       |     * The first pixel has no left context, and so uses an Up filter, p = b.
 6448|       |     * This works naturally with our main loop's p = a+b-c if we force a and c
 6449|       |     * to zero.
 6450|       |     * Here we zero b and d, which become c and a respectively at the start of
 6451|       |     * the loop.
 6452|       |     */
 6453|  93.7k|    size_t rb = rowbytes;
 6454|  93.7k|    const __m128i zero = _mm_setzero_si128();
 6455|  93.7k|    __m128i c, b = zero,
 6456|  93.7k|            a, d = zero;
 6457|       |
 6458|  7.92M|    while(rb >= 4)
  ------------------
  |  Branch (6458:11): [True: 7.83M, False: 93.7k]
  ------------------
 6459|  7.83M|    {
 6460|       |        /* It's easiest to do this math (particularly, deal with pc) with 16-bit
 6461|       |         * intermediates.
 6462|       |         */
 6463|  7.83M|        __m128i pa,pb,pc,smallest,nearest;
 6464|  7.83M|        c = b; b = _mm_unpacklo_epi8(load4(prev), zero);
 6465|  7.83M|        a = d; d = _mm_unpacklo_epi8(load4(row ), zero);
 6466|       |
 6467|       |        /* (p-a) == (a+b-c - a) == (b-c) */
 6468|       |
 6469|  7.83M|        pa = _mm_sub_epi16(b, c);
 6470|       |
 6471|       |        /* (p-b) == (a+b-c - b) == (a-c) */
 6472|  7.83M|        pb = _mm_sub_epi16(a, c);
 6473|       |
 6474|       |        /* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
 6475|  7.83M|        pc = _mm_add_epi16(pa, pb);
 6476|       |
 6477|  7.83M|        pa = abs_i16(pa);  /* |p-a| */
 6478|  7.83M|        pb = abs_i16(pb);  /* |p-b| */
 6479|  7.83M|        pc = abs_i16(pc);  /* |p-c| */
 6480|       |
 6481|  7.83M|        smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
 6482|       |
 6483|       |        /* Paeth breaks ties favoring a over b over c. */
 6484|  7.83M|        nearest  = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
 6485|  7.83M|                            if_then_else(_mm_cmpeq_epi16(smallest, pb), b, c));
 6486|       |
 6487|       |        /* Note `_epi8`: we need addition to wrap modulo 255. */
 6488|  7.83M|        d = _mm_add_epi8(d, nearest);
 6489|  7.83M|        store3(row, _mm_packus_epi16(d, d));
 6490|       |
 6491|  7.83M|        prev += 3;
 6492|  7.83M|        row  += 3;
 6493|  7.83M|        rb   -= 3;
 6494|  7.83M|    }
 6495|       |
 6496|  93.7k|    if(rb > 0)
  ------------------
  |  Branch (6496:8): [True: 93.7k, False: 0]
  ------------------
 6497|  93.7k|    {
 6498|       |        /* It's easiest to do this math (particularly, deal with pc) with 16-bit
 6499|       |         * intermediates.
 6500|       |         */
 6501|  93.7k|        __m128i pa, pb, pc, smallest, nearest;
 6502|  93.7k|        c = b; b = _mm_unpacklo_epi8(load3(prev), zero);
 6503|  93.7k|        a = d; d = _mm_unpacklo_epi8(load3(row ), zero);
 6504|       |
 6505|       |        /* (p-a) == (a+b-c - a) == (b-c) */
 6506|  93.7k|        pa = _mm_sub_epi16(b, c);
 6507|       |
 6508|       |        /* (p-b) == (a+b-c - b) == (a-c) */
 6509|  93.7k|        pb = _mm_sub_epi16(a, c);
 6510|       |
 6511|       |        /* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
 6512|  93.7k|        pc = _mm_add_epi16(pa, pb);
 6513|       |
 6514|  93.7k|        pa = abs_i16(pa);  /* |p-a| */
 6515|  93.7k|        pb = abs_i16(pb);  /* |p-b| */
 6516|  93.7k|        pc = abs_i16(pc);  /* |p-c| */
 6517|       |
 6518|  93.7k|        smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
 6519|       |
 6520|       |        /* Paeth breaks ties favoring a over b over c. */
 6521|  93.7k|        nearest  = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
 6522|  93.7k|                            if_then_else(_mm_cmpeq_epi16(smallest, pb), b, c));
 6523|       |
 6524|       |        /* Note `_epi8`: we need addition to wrap modulo 255. */
 6525|  93.7k|        d = _mm_add_epi8(d, nearest);
 6526|  93.7k|        store3(row, _mm_packus_epi16(d, d));
 6527|  93.7k|    }
 6528|  93.7k|}
spng.c:defilter_up:
 1449|  98.1k|{
 1450|  98.1k|    size_t i;
 1451|  24.7M|    for(i=0; i < bytes; i++)
  ------------------
  |  Branch (1451:14): [True: 24.6M, False: 98.1k]
  ------------------
 1452|  24.6M|    {
 1453|  24.6M|        row[i] += prev[i];
 1454|  24.6M|    }
 1455|  98.1k|}
spng.c:paeth:
 1435|  8.54M|{
 1436|  8.54M|    int16_t p = a + b - c;
 1437|  8.54M|    int16_t pa = abs(p - a);
 1438|  8.54M|    int16_t pb = abs(p - b);
 1439|  8.54M|    int16_t pc = abs(p - c);
 1440|       |
 1441|  8.54M|    if(pa <= pb && pa <= pc) return a;
  ------------------
  |  Branch (1441:8): [True: 6.59M, False: 1.94M]
  |  Branch (1441:20): [True: 6.51M, False: 80.3k]
  ------------------
 1442|  2.02M|    else if(pb <= pc) return b;
  ------------------
  |  Branch (1442:13): [True: 1.92M, False: 103k]
  ------------------
 1443|       |
 1444|   103k|    return c;
 1445|  8.54M|}
spng.c:decode_err:
  764|  38.2k|{
  765|  38.2k|    ctx->state = SPNG_STATE_INVALID;
  766|       |
  767|  38.2k|    return err;
  768|  38.2k|}
spng.c:update_row_info:
 3270|   840k|{
 3271|   840k|    int interlacing = ctx->ihdr.interlace_method;
 3272|   840k|    struct spng_row_info *ri = &ctx->row_info;
 3273|   840k|    const struct spng_subimage *sub = ctx->subimage;
 3274|       |
 3275|   840k|    if(ri->scanline_idx == (sub[ri->pass].height - 1)) /* Last scanline */
  ------------------
  |  Branch (3275:8): [True: 12.0k, False: 828k]
  ------------------
 3276|  12.0k|    {
 3277|  12.0k|        if(ri->pass == ctx->last_pass)
  ------------------
  |  Branch (3277:12): [True: 2.36k, False: 9.70k]
  ------------------
 3278|  2.36k|        {
 3279|  2.36k|            ctx->state = SPNG_STATE_EOI;
 3280|       |
 3281|  2.36k|            return SPNG_EOI;
 3282|  2.36k|        }
 3283|       |
 3284|  9.70k|        ri->scanline_idx = 0;
 3285|  9.70k|        ri->pass++;
 3286|       |
 3287|       |        /* Skip empty passes */
 3288|  9.85k|        while( (!sub[ri->pass].width || !sub[ri->pass].height) && (ri->pass < ctx->last_pass)) ri->pass++;
  ------------------
  |  Branch (3288:17): [True: 108, False: 9.74k]
  |  Branch (3288:41): [True: 42, False: 9.70k]
  |  Branch (3288:67): [True: 150, False: 0]
  ------------------
 3289|  9.70k|    }
 3290|   828k|    else
 3291|   828k|    {
 3292|   828k|        ri->row_num++;
 3293|   828k|        ri->scanline_idx++;
 3294|   828k|    }
 3295|       |
 3296|   838k|    if(interlacing) ri->row_num = adam7_y_start[ri->pass] + ri->scanline_idx * adam7_y_delta[ri->pass];
  ------------------
  |  Branch (3296:8): [True: 599k, False: 238k]
  ------------------
 3297|       |
 3298|   838k|    return 0;
 3299|   840k|}
spng.c:discard_chunk_bytes:
 1160|   766k|{
 1161|   766k|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1161:8): [True: 0, False: 766k]
  ------------------
 1162|   766k|    if(!bytes) return 0;
  ------------------
  |  Branch (1162:8): [True: 687k, False: 79.4k]
  ------------------
 1163|       |
 1164|  79.4k|    int ret;
 1165|       |
 1166|  79.4k|    if(ctx->streaming) /* Do small, consecutive reads */
  ------------------
  |  Branch (1166:8): [True: 79.4k, False: 0]
  ------------------
 1167|  79.4k|    {
 1168|   159k|        while(bytes)
  ------------------
  |  Branch (1168:15): [True: 84.4k, False: 75.5k]
  ------------------
 1169|  84.4k|        {
 1170|  84.4k|            uint32_t len = SPNG_READ_SIZE;
  ------------------
  |  |   30|  84.4k|#define SPNG_READ_SIZE (8192)
  ------------------
 1171|       |
 1172|  84.4k|            if(len > bytes) len = bytes;
  ------------------
  |  Branch (1172:16): [True: 76.3k, False: 8.10k]
  ------------------
 1173|       |
 1174|  84.4k|            ret = read_chunk_bytes(ctx, len);
 1175|  84.4k|            if(ret) return ret;
  ------------------
  |  Branch (1175:16): [True: 3.97k, False: 80.4k]
  ------------------
 1176|       |
 1177|  80.4k|            bytes -= len;
 1178|  80.4k|        }
 1179|  79.4k|    }
 1180|      0|    else
 1181|      0|    {
 1182|      0|        ret = read_chunk_bytes(ctx, bytes);
 1183|      0|        if(ret) return ret;
  ------------------
  |  Branch (1183:12): [True: 0, False: 0]
  ------------------
 1184|      0|    }
 1185|       |
 1186|  75.5k|    return 0;
 1187|  79.4k|}
spng.c:read_chunk_bytes:
 1106|   483k|{
 1107|   483k|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1107:8): [True: 0, False: 483k]
  ------------------
 1108|   483k|    if(!ctx->cur_chunk_bytes_left || !bytes) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1108:8): [True: 15.9k, False: 467k]
  |  Branch (1108:38): [True: 0, False: 467k]
  ------------------
 1109|   467k|    if(bytes > ctx->cur_chunk_bytes_left) return SPNG_EINTERNAL; /* XXX: more specific error? */
  ------------------
  |  Branch (1109:8): [True: 0, False: 467k]
  ------------------
 1110|       |
 1111|   467k|    int ret;
 1112|       |
 1113|   467k|    ret = read_data(ctx, bytes);
 1114|   467k|    if(ret) return ret;
  ------------------
  |  Branch (1114:8): [True: 6.79k, False: 460k]
  ------------------
 1115|       |
 1116|   460k|    if(!ctx->skip_crc) ctx->cur_actual_crc = crc32(ctx->cur_actual_crc, ctx->data, bytes);
  ------------------
  |  |   46|   460k|#  define crc32                 z_crc32
  ------------------
  |  Branch (1116:8): [True: 460k, False: 0]
  ------------------
 1117|       |
 1118|   460k|    ctx->cur_chunk_bytes_left -= bytes;
 1119|       |
 1120|   460k|    return ret;
 1121|   467k|}
spng.c:read_data:
  778|  2.14M|{
  779|  2.14M|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (779:8): [True: 0, False: 2.14M]
  ------------------
  780|  2.14M|    if(!bytes) return 0;
  ------------------
  |  Branch (780:8): [True: 0, False: 2.14M]
  ------------------
  781|       |
  782|  2.14M|    if(ctx->streaming && (bytes > SPNG_READ_SIZE)) return SPNG_EINTERNAL;
  ------------------
  |  |   30|  2.14M|#define SPNG_READ_SIZE (8192)
  ------------------
  |  Branch (782:8): [True: 2.14M, False: 0]
  |  Branch (782:26): [True: 0, False: 2.14M]
  ------------------
  783|       |
  784|  2.14M|    int ret = ctx->read_fn(ctx, ctx->stream_user_ptr, ctx->stream_buf, bytes);
  785|       |
  786|  2.14M|    if(ret)
  ------------------
  |  Branch (786:8): [True: 33.9k, False: 2.11M]
  ------------------
  787|  33.9k|    {
  788|  33.9k|        if(ret > 0 || ret < SPNG_IO_ERROR) ret = SPNG_IO_ERROR;
  ------------------
  |  Branch (788:12): [True: 0, False: 33.9k]
  |  Branch (788:23): [True: 0, False: 33.9k]
  ------------------
  789|       |
  790|  33.9k|        return ret;
  791|  33.9k|    }
  792|       |
  793|  2.11M|    ctx->bytes_read += bytes;
  794|  2.11M|    if(ctx->bytes_read < bytes) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (794:8): [True: 0, False: 2.11M]
  ------------------
  795|       |
  796|  2.11M|    return 0;
  797|  2.11M|}
spng.c:read_chunks:
 3117|  74.5k|{
 3118|  74.5k|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (3118:8): [True: 0, False: 74.5k]
  ------------------
 3119|  74.5k|    if(!ctx->state) return SPNG_EBADSTATE;
  ------------------
  |  Branch (3119:8): [True: 0, False: 74.5k]
  ------------------
 3120|  74.5k|    if(ctx->data == NULL)
  ------------------
  |  Branch (3120:8): [True: 0, False: 74.5k]
  ------------------
 3121|      0|    {
 3122|      0|        if(ctx->encode_only) return 0;
  ------------------
  |  Branch (3122:12): [True: 0, False: 0]
  ------------------
 3123|      0|        else return SPNG_EINTERNAL;
 3124|      0|    }
 3125|       |
 3126|  74.5k|    int ret = 0;
 3127|       |
 3128|  74.5k|    if(ctx->state == SPNG_STATE_INPUT)
  ------------------
  |  Branch (3128:8): [True: 31.9k, False: 42.5k]
  ------------------
 3129|  31.9k|    {
 3130|  31.9k|        ret = read_ihdr(ctx);
 3131|       |
 3132|  31.9k|        if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3132:12): [True: 1.35k, False: 30.6k]
  ------------------
 3133|       |
 3134|  30.6k|        ctx->state = SPNG_STATE_IHDR;
 3135|  30.6k|    }
 3136|       |
 3137|  73.1k|    if(only_ihdr) return 0;
  ------------------
  |  Branch (3137:8): [True: 30.6k, False: 42.5k]
  ------------------
 3138|       |
 3139|  42.5k|    if(ctx->state == SPNG_STATE_EOI)
  ------------------
  |  Branch (3139:8): [True: 2.28k, False: 40.2k]
  ------------------
 3140|  2.28k|    {
 3141|  2.28k|        ctx->state = SPNG_STATE_AFTER_IDAT;
 3142|  2.28k|        ctx->prev_was_idat = 1;
 3143|  2.28k|    }
 3144|       |
 3145|   669k|    while(ctx->state < SPNG_STATE_FIRST_IDAT || ctx->state == SPNG_STATE_AFTER_IDAT)
  ------------------
  |  Branch (3145:11): [True: 629k, False: 40.0k]
  |  Branch (3145:49): [True: 19.8k, False: 20.1k]
  ------------------
 3146|   649k|    {
 3147|   649k|        ret = read_non_idat_chunks(ctx);
 3148|       |
 3149|   649k|        if(!ret)
  ------------------
  |  Branch (3149:12): [True: 10.5k, False: 639k]
  ------------------
 3150|  10.5k|        {
 3151|  10.5k|            if(ctx->state < SPNG_STATE_FIRST_IDAT) ctx->state = SPNG_STATE_FIRST_IDAT;
  ------------------
  |  Branch (3151:16): [True: 10.4k, False: 51]
  ------------------
 3152|     51|            else if(ctx->state == SPNG_STATE_AFTER_IDAT) ctx->state = SPNG_STATE_IEND;
  ------------------
  |  Branch (3152:21): [True: 51, False: 0]
  ------------------
 3153|  10.5k|        }
 3154|   639k|        else
 3155|   639k|        {
 3156|   639k|            switch(ret)
 3157|   639k|            {
 3158|  24.2k|                case SPNG_ECHUNK_POS:
  ------------------
  |  Branch (3158:17): [True: 24.2k, False: 614k]
  ------------------
 3159|   334k|                case SPNG_ECHUNK_SIZE: /* size != expected size, SPNG_ECHUNK_STDLEN = invalid size */
  ------------------
  |  Branch (3159:17): [True: 310k, False: 328k]
  ------------------
 3160|   334k|                case SPNG_EDUP_PLTE:
  ------------------
  |  Branch (3160:17): [True: 0, False: 639k]
  ------------------
 3161|   335k|                case SPNG_EDUP_CHRM:
  ------------------
  |  Branch (3161:17): [True: 903, False: 638k]
  ------------------
 3162|   336k|                case SPNG_EDUP_GAMA:
  ------------------
  |  Branch (3162:17): [True: 721, False: 638k]
  ------------------
 3163|   350k|                case SPNG_EDUP_ICCP:
  ------------------
  |  Branch (3163:17): [True: 14.2k, False: 624k]
  ------------------
 3164|   351k|                case SPNG_EDUP_SBIT:
  ------------------
  |  Branch (3164:17): [True: 1.33k, False: 637k]
  ------------------
 3165|   352k|                case SPNG_EDUP_SRGB:
  ------------------
  |  Branch (3165:17): [True: 861, False: 638k]
  ------------------
 3166|   360k|                case SPNG_EDUP_BKGD:
  ------------------
  |  Branch (3166:17): [True: 7.60k, False: 631k]
  ------------------
 3167|   360k|                case SPNG_EDUP_HIST:
  ------------------
  |  Branch (3167:17): [True: 308, False: 638k]
  ------------------
 3168|   366k|                case SPNG_EDUP_TRNS:
  ------------------
  |  Branch (3168:17): [True: 6.02k, False: 633k]
  ------------------
 3169|   368k|                case SPNG_EDUP_PHYS:
  ------------------
  |  Branch (3169:17): [True: 1.98k, False: 637k]
  ------------------
 3170|   372k|                case SPNG_EDUP_TIME:
  ------------------
  |  Branch (3170:17): [True: 3.85k, False: 635k]
  ------------------
 3171|   372k|                case SPNG_EDUP_OFFS:
  ------------------
  |  Branch (3171:17): [True: 469, False: 638k]
  ------------------
 3172|   377k|                case SPNG_EDUP_EXIF:
  ------------------
  |  Branch (3172:17): [True: 4.94k, False: 634k]
  ------------------
 3173|   379k|                case SPNG_ECHRM:
  ------------------
  |  Branch (3173:17): [True: 1.38k, False: 637k]
  ------------------
 3174|   380k|                case SPNG_ETRNS_COLOR_TYPE:
  ------------------
  |  Branch (3174:17): [True: 875, False: 638k]
  ------------------
 3175|   380k|                case SPNG_ETRNS_NO_PLTE:
  ------------------
  |  Branch (3175:17): [True: 0, False: 639k]
  ------------------
 3176|   380k|                case SPNG_EGAMA:
  ------------------
  |  Branch (3176:17): [True: 525, False: 638k]
  ------------------
 3177|   380k|                case SPNG_EICCP_NAME:
  ------------------
  |  Branch (3177:17): [True: 105, False: 638k]
  ------------------
 3178|   380k|                case SPNG_EICCP_COMPRESSION_METHOD:
  ------------------
  |  Branch (3178:17): [True: 112, False: 638k]
  ------------------
 3179|   385k|                case SPNG_ESBIT:
  ------------------
  |  Branch (3179:17): [True: 4.94k, False: 634k]
  ------------------
 3180|   386k|                case SPNG_ESRGB:
  ------------------
  |  Branch (3180:17): [True: 567, False: 638k]
  ------------------
 3181|   386k|                case SPNG_ETEXT:
  ------------------
  |  Branch (3181:17): [True: 0, False: 639k]
  ------------------
 3182|   438k|                case SPNG_ETEXT_KEYWORD:
  ------------------
  |  Branch (3182:17): [True: 52.5k, False: 586k]
  ------------------
 3183|   452k|                case SPNG_EZTXT:
  ------------------
  |  Branch (3183:17): [True: 13.5k, False: 625k]
  ------------------
 3184|   456k|                case SPNG_EZTXT_COMPRESSION_METHOD:
  ------------------
  |  Branch (3184:17): [True: 4.48k, False: 634k]
  ------------------
 3185|   459k|                case SPNG_EITXT:
  ------------------
  |  Branch (3185:17): [True: 2.92k, False: 636k]
  ------------------
 3186|   461k|                case SPNG_EITXT_COMPRESSION_FLAG:
  ------------------
  |  Branch (3186:17): [True: 2.12k, False: 636k]
  ------------------
 3187|   463k|                case SPNG_EITXT_COMPRESSION_METHOD:
  ------------------
  |  Branch (3187:17): [True: 1.35k, False: 637k]
  ------------------
 3188|   463k|                case SPNG_EITXT_LANG_TAG:
  ------------------
  |  Branch (3188:17): [True: 259, False: 638k]
  ------------------
 3189|   463k|                case SPNG_EITXT_TRANSLATED_KEY:
  ------------------
  |  Branch (3189:17): [True: 0, False: 639k]
  ------------------
 3190|   469k|                case SPNG_EBKGD_NO_PLTE:
  ------------------
  |  Branch (3190:17): [True: 6.44k, False: 632k]
  ------------------
 3191|   471k|                case SPNG_EBKGD_PLTE_IDX:
  ------------------
  |  Branch (3191:17): [True: 1.60k, False: 637k]
  ------------------
 3192|   475k|                case SPNG_EHIST_NO_PLTE:
  ------------------
  |  Branch (3192:17): [True: 3.54k, False: 635k]
  ------------------
 3193|   477k|                case SPNG_EPHYS:
  ------------------
  |  Branch (3193:17): [True: 2.61k, False: 636k]
  ------------------
 3194|   551k|                case SPNG_ESPLT_NAME:
  ------------------
  |  Branch (3194:17): [True: 73.7k, False: 565k]
  ------------------
 3195|   552k|                case SPNG_ESPLT_DUP_NAME:
  ------------------
  |  Branch (3195:17): [True: 1.37k, False: 637k]
  ------------------
 3196|   555k|                case SPNG_ESPLT_DEPTH:
  ------------------
  |  Branch (3196:17): [True: 2.30k, False: 636k]
  ------------------
 3197|   560k|                case SPNG_ETIME:
  ------------------
  |  Branch (3197:17): [True: 5.52k, False: 633k]
  ------------------
 3198|   561k|                case SPNG_EOFFS:
  ------------------
  |  Branch (3198:17): [True: 812, False: 638k]
  ------------------
 3199|   562k|                case SPNG_EEXIF:
  ------------------
  |  Branch (3199:17): [True: 777, False: 638k]
  ------------------
 3200|   619k|                case SPNG_EZLIB:
  ------------------
  |  Branch (3200:17): [True: 57.3k, False: 581k]
  ------------------
 3201|   619k|                {
 3202|   619k|                    if(!ctx->strict && !is_critical_chunk(&ctx->current_chunk))
  ------------------
  |  Branch (3202:24): [True: 619k, False: 0]
  |  Branch (3202:40): [True: 619k, False: 273]
  ------------------
 3203|   619k|                    {
 3204|   619k|                        ret = discard_chunk_bytes(ctx, ctx->cur_chunk_bytes_left);
 3205|   619k|                        if(ret) return decode_err(ctx, ret);
  ------------------
  |  Branch (3205:28): [True: 2.61k, False: 616k]
  ------------------
 3206|       |
 3207|   616k|                        if(ctx->undo) ctx->undo(ctx);
  ------------------
  |  Branch (3207:28): [True: 232k, False: 384k]
  ------------------
 3208|       |
 3209|   616k|                        ctx->stored = ctx->prev_stored;
 3210|       |
 3211|   616k|                        ctx->discard = 0;
 3212|   616k|                        ctx->undo = NULL;
 3213|       |
 3214|   616k|                        continue;
 3215|   619k|                    }
 3216|    273|                    else return decode_err(ctx, ret);
 3217|       |
 3218|      0|                    break;
 3219|   619k|                }
 3220|  19.5k|                default: return decode_err(ctx, ret);
  ------------------
  |  Branch (3220:17): [True: 19.5k, False: 619k]
  ------------------
 3221|   639k|            }
 3222|   639k|        }
 3223|   649k|    }
 3224|       |
 3225|  20.1k|    return ret;
 3226|  42.5k|}
spng.c:read_ihdr:
 2278|  31.9k|{
 2279|  31.9k|    int ret;
 2280|  31.9k|    struct spng_chunk *chunk = &ctx->current_chunk;
 2281|  31.9k|    const unsigned char *data;
 2282|       |
 2283|  31.9k|    chunk->offset = 8;
 2284|  31.9k|    chunk->length = 13;
 2285|  31.9k|    size_t sizeof_sig_ihdr = 29;
 2286|       |
 2287|  31.9k|    ret = read_data(ctx, sizeof_sig_ihdr);
 2288|  31.9k|    if(ret) return ret;
  ------------------
  |  Branch (2288:8): [True: 7, False: 31.9k]
  ------------------
 2289|       |
 2290|  31.9k|    data = ctx->data;
 2291|       |
 2292|  31.9k|    if(memcmp(data, spng_signature, sizeof(spng_signature))) return SPNG_ESIGNATURE;
  ------------------
  |  Branch (2292:8): [True: 252, False: 31.7k]
  ------------------
 2293|       |
 2294|  31.7k|    chunk->length = read_u32(data + 8);
 2295|  31.7k|    memcpy(&chunk->type, data + 12, 4);
 2296|       |
 2297|  31.7k|    if(chunk->length != 13) return SPNG_EIHDR_SIZE;
  ------------------
  |  Branch (2297:8): [True: 273, False: 31.4k]
  ------------------
 2298|  31.4k|    if(memcmp(chunk->type, type_ihdr, 4)) return SPNG_ENOIHDR;
  ------------------
  |  Branch (2298:8): [True: 56, False: 31.3k]
  ------------------
 2299|       |
 2300|  31.3k|    ctx->cur_actual_crc = crc32(0, NULL, 0);
  ------------------
  |  |   46|  31.3k|#  define crc32                 z_crc32
  ------------------
 2301|  31.3k|    ctx->cur_actual_crc = crc32(ctx->cur_actual_crc, data + 12, 17);
  ------------------
  |  |   46|  31.3k|#  define crc32                 z_crc32
  ------------------
 2302|       |
 2303|  31.3k|    ctx->ihdr.width = read_u32(data + 16);
 2304|  31.3k|    ctx->ihdr.height = read_u32(data + 20);
 2305|  31.3k|    ctx->ihdr.bit_depth = data[24];
 2306|  31.3k|    ctx->ihdr.color_type = data[25];
 2307|  31.3k|    ctx->ihdr.compression_method = data[26];
 2308|  31.3k|    ctx->ihdr.filter_method = data[27];
 2309|  31.3k|    ctx->ihdr.interlace_method = data[28];
 2310|       |
 2311|  31.3k|    ret = check_ihdr(&ctx->ihdr, ctx->max_width, ctx->max_height);
 2312|  31.3k|    if(ret) return ret;
  ------------------
  |  Branch (2312:8): [True: 735, False: 30.6k]
  ------------------
 2313|       |
 2314|  30.6k|    ctx->file.ihdr = 1;
 2315|  30.6k|    ctx->stored.ihdr = 1;
 2316|       |
 2317|  30.6k|    if(ctx->ihdr.bit_depth < 8) ctx->bytes_per_pixel = 1;
  ------------------
  |  Branch (2317:8): [True: 9.28k, False: 21.3k]
  ------------------
 2318|  21.3k|    else ctx->bytes_per_pixel = num_channels(&ctx->ihdr) * (ctx->ihdr.bit_depth / 8);
 2319|       |
 2320|  30.6k|    ret = calculate_subimages(ctx);
 2321|  30.6k|    if(ret) return ret;
  ------------------
  |  Branch (2321:8): [True: 35, False: 30.6k]
  ------------------
 2322|       |
 2323|  30.6k|    return 0;
 2324|  30.6k|}
spng.c:read_u32:
  454|  1.73M|{
  455|  1.73M|    const unsigned char *data = src;
  456|       |
  457|  1.73M|    return (data[0] & 0xFFUL) << 24 | (data[1] & 0xFFUL) << 16 |
  458|  1.73M|           (data[2] & 0xFFUL) << 8  | (data[3] & 0xFFUL);
  459|  1.73M|}
spng.c:read_non_idat_chunks:
 2371|   649k|{
 2372|   649k|    int ret;
 2373|   649k|    struct spng_chunk chunk;
 2374|   649k|    const unsigned char *data;
 2375|       |
 2376|   649k|    ctx->discard = 0;
 2377|   649k|    ctx->undo = NULL;
 2378|   649k|    ctx->prev_stored = ctx->stored;
 2379|       |
 2380|   801k|    while( !(ret = read_header(ctx)))
  ------------------
  |  Branch (2380:12): [True: 788k, False: 13.0k]
  ------------------
 2381|   788k|    {
 2382|   788k|        if(ctx->discard)
  ------------------
  |  Branch (2382:12): [True: 305k, False: 482k]
  ------------------
 2383|   305k|        {
 2384|   305k|            if(ctx->undo) ctx->undo(ctx);
  ------------------
  |  Branch (2384:16): [True: 9.10k, False: 296k]
  ------------------
 2385|       |
 2386|   305k|            ctx->stored = ctx->prev_stored;
 2387|   305k|        }
 2388|       |
 2389|   788k|        ctx->discard = 0;
 2390|   788k|        ctx->undo = NULL;
 2391|       |
 2392|   788k|        ctx->prev_stored = ctx->stored;
 2393|   788k|        chunk = ctx->current_chunk;
 2394|       |
 2395|   788k|        if(!memcmp(chunk.type, type_idat, 4))
  ------------------
  |  Branch (2395:12): [True: 11.0k, False: 777k]
  ------------------
 2396|  11.0k|        {
 2397|  11.0k|            if(ctx->state < SPNG_STATE_FIRST_IDAT)
  ------------------
  |  Branch (2397:16): [True: 10.4k, False: 546]
  ------------------
 2398|  10.4k|            {
 2399|  10.4k|                if(ctx->ihdr.color_type == 3 && !ctx->stored.plte) return SPNG_ENOPLTE;
  ------------------
  |  Branch (2399:20): [True: 441, False: 10.0k]
  |  Branch (2399:49): [True: 14, False: 427]
  ------------------
 2400|       |
 2401|  10.4k|                ctx->first_idat = chunk;
 2402|  10.4k|                return 0;
 2403|  10.4k|            }
 2404|       |
 2405|    546|            if(ctx->prev_was_idat)
  ------------------
  |  Branch (2405:16): [True: 539, False: 7]
  ------------------
 2406|    539|            {
 2407|       |                /* Ignore extra IDAT's */
 2408|    539|                ret = discard_chunk_bytes(ctx, chunk.length);
 2409|    539|                if(ret) return ret;
  ------------------
  |  Branch (2409:20): [True: 287, False: 252]
  ------------------
 2410|       |
 2411|    252|                continue;
 2412|    539|            }
 2413|      7|            else return SPNG_ECHUNK_POS; /* IDAT chunk not at the end of the IDAT sequence */
 2414|    546|        }
 2415|       |
 2416|   777k|        ctx->prev_was_idat = 0;
 2417|       |
 2418|   777k|        if(is_small_chunk(chunk.type))
  ------------------
  |  Branch (2418:12): [True: 107k, False: 669k]
  ------------------
 2419|   107k|        {
 2420|       |            /* None of the known chunks can be zero length */
 2421|   107k|            if(!chunk.length) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2421:16): [True: 665, False: 106k]
  ------------------
 2422|       |
 2423|       |            /* The largest of these chunks is PLTE with 256 entries */
 2424|   106k|            ret = read_chunk_bytes(ctx, chunk.length > 768 ? 768 : chunk.length);
  ------------------
  |  Branch (2424:41): [True: 1.93k, False: 104k]
  ------------------
 2425|   106k|            if(ret) return ret;
  ------------------
  |  Branch (2425:16): [True: 462, False: 106k]
  ------------------
 2426|   106k|        }
 2427|       |
 2428|   776k|        data = ctx->data;
 2429|       |
 2430|   776k|        if(is_critical_chunk(&chunk))
  ------------------
  |  Branch (2430:12): [True: 4.41k, False: 771k]
  ------------------
 2431|  4.41k|        {
 2432|  4.41k|            if(!memcmp(chunk.type, type_plte, 4))
  ------------------
  |  Branch (2432:16): [True: 2.53k, False: 1.88k]
  ------------------
 2433|  2.53k|            {
 2434|  2.53k|                if(ctx->file.trns || ctx->file.hist || ctx->file.bkgd) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2434:20): [True: 7, False: 2.52k]
  |  Branch (2434:38): [True: 7, False: 2.52k]
  |  Branch (2434:56): [True: 7, False: 2.51k]
  ------------------
 2435|  2.51k|                if(chunk.length % 3 != 0) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2435:20): [True: 7, False: 2.50k]
  ------------------
 2436|       |
 2437|  2.50k|                ctx->plte.n_entries = chunk.length / 3;
 2438|       |
 2439|  2.50k|                if(check_plte(&ctx->plte, &ctx->ihdr)) return SPNG_ECHUNK_SIZE; /* XXX: EPLTE? */
  ------------------
  |  Branch (2439:20): [True: 105, False: 2.40k]
  ------------------
 2440|       |
 2441|  2.40k|                size_t i;
 2442|  79.6k|                for(i=0; i < ctx->plte.n_entries; i++)
  ------------------
  |  Branch (2442:26): [True: 77.2k, False: 2.40k]
  ------------------
 2443|  77.2k|                {
 2444|  77.2k|                    ctx->plte.entries[i].red   = data[i * 3];
 2445|  77.2k|                    ctx->plte.entries[i].green = data[i * 3 + 1];
 2446|  77.2k|                    ctx->plte.entries[i].blue  = data[i * 3 + 2];
 2447|  77.2k|                }
 2448|       |
 2449|  2.40k|                ctx->file.plte = 1;
 2450|  2.40k|                ctx->stored.plte = 1;
 2451|  2.40k|            }
 2452|  1.88k|            else if(!memcmp(chunk.type, type_iend, 4))
  ------------------
  |  Branch (2452:21): [True: 446, False: 1.43k]
  ------------------
 2453|    446|            {
 2454|    446|                if(ctx->state == SPNG_STATE_AFTER_IDAT)
  ------------------
  |  Branch (2454:20): [True: 418, False: 28]
  ------------------
 2455|    418|                {
 2456|    418|                    if(chunk.length) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2456:24): [True: 98, False: 320]
  ------------------
 2457|       |
 2458|    320|                    ret = read_and_check_crc(ctx);
 2459|    320|                    if(ret == -SPNG_CRC_DISCARD) ret = 0;
  ------------------
  |  Branch (2459:24): [True: 7, False: 313]
  ------------------
 2460|       |
 2461|    320|                    return ret;
 2462|    418|                }
 2463|     28|                else return SPNG_ECHUNK_POS;
 2464|    446|            }
 2465|  1.43k|            else if(!memcmp(chunk.type, type_ihdr, 4)) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2465:21): [True: 7, False: 1.42k]
  ------------------
 2466|  1.42k|            else return SPNG_ECHUNK_UNKNOWN_CRITICAL;
 2467|  4.41k|        }
 2468|   771k|        else if(!memcmp(chunk.type, type_chrm, 4)) /* Ancillary chunks */
  ------------------
  |  Branch (2468:17): [True: 3.59k, False: 768k]
  ------------------
 2469|  3.59k|        {
 2470|  3.59k|            if(ctx->file.plte) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2470:16): [True: 469, False: 3.12k]
  ------------------
 2471|  3.12k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2471:16): [True: 77, False: 3.05k]
  ------------------
 2472|  3.05k|            if(ctx->file.chrm) return SPNG_EDUP_CHRM;
  ------------------
  |  Branch (2472:16): [True: 903, False: 2.14k]
  ------------------
 2473|       |
 2474|  2.14k|            if(chunk.length != 32) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2474:16): [True: 378, False: 1.77k]
  ------------------
 2475|       |
 2476|  1.77k|            ctx->chrm_int.white_point_x = read_u32(data);
 2477|  1.77k|            ctx->chrm_int.white_point_y = read_u32(data + 4);
 2478|  1.77k|            ctx->chrm_int.red_x = read_u32(data + 8);
 2479|  1.77k|            ctx->chrm_int.red_y = read_u32(data + 12);
 2480|  1.77k|            ctx->chrm_int.green_x = read_u32(data + 16);
 2481|  1.77k|            ctx->chrm_int.green_y = read_u32(data + 20);
 2482|  1.77k|            ctx->chrm_int.blue_x = read_u32(data + 24);
 2483|  1.77k|            ctx->chrm_int.blue_y = read_u32(data + 28);
 2484|       |
 2485|  1.77k|            if(check_chrm_int(&ctx->chrm_int)) return SPNG_ECHRM;
  ------------------
  |  Branch (2485:16): [True: 1.38k, False: 385]
  ------------------
 2486|       |
 2487|    385|            ctx->file.chrm = 1;
 2488|    385|            ctx->stored.chrm = 1;
 2489|    385|        }
 2490|   768k|        else if(!memcmp(chunk.type, type_gama, 4))
  ------------------
  |  Branch (2490:17): [True: 11.5k, False: 756k]
  ------------------
 2491|  11.5k|        {
 2492|  11.5k|            if(ctx->file.plte) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2492:16): [True: 5.04k, False: 6.54k]
  ------------------
 2493|  6.54k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2493:16): [True: 525, False: 6.02k]
  ------------------
 2494|  6.02k|            if(ctx->file.gama) return SPNG_EDUP_GAMA;
  ------------------
  |  Branch (2494:16): [True: 721, False: 5.29k]
  ------------------
 2495|       |
 2496|  5.29k|            if(chunk.length != 4) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2496:16): [True: 4.15k, False: 1.14k]
  ------------------
 2497|       |
 2498|  1.14k|            ctx->gama = read_u32(data);
 2499|       |
 2500|  1.14k|            if(!ctx->gama) return SPNG_EGAMA;
  ------------------
  |  Branch (2500:16): [True: 77, False: 1.07k]
  ------------------
 2501|  1.07k|            if(ctx->gama > spng_u32max) return SPNG_EGAMA;
  ------------------
  |  Branch (2501:16): [True: 448, False: 623]
  ------------------
 2502|       |
 2503|    623|            ctx->file.gama = 1;
 2504|    623|            ctx->stored.gama = 1;
 2505|    623|        }
 2506|   756k|        else if(!memcmp(chunk.type, type_sbit, 4))
  ------------------
  |  Branch (2506:17): [True: 10.5k, False: 745k]
  ------------------
 2507|  10.5k|        {
 2508|  10.5k|            if(ctx->file.plte) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2508:16): [True: 917, False: 9.68k]
  ------------------
 2509|  9.68k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2509:16): [True: 217, False: 9.46k]
  ------------------
 2510|  9.46k|            if(ctx->file.sbit) return SPNG_EDUP_SBIT;
  ------------------
  |  Branch (2510:16): [True: 1.33k, False: 8.12k]
  ------------------
 2511|       |
 2512|  8.12k|            if(ctx->ihdr.color_type == 0)
  ------------------
  |  Branch (2512:16): [True: 3.10k, False: 5.02k]
  ------------------
 2513|  3.10k|            {
 2514|  3.10k|                if(chunk.length != 1) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2514:20): [True: 1.56k, False: 1.54k]
  ------------------
 2515|       |
 2516|  1.54k|                ctx->sbit.grayscale_bits = data[0];
 2517|  1.54k|            }
 2518|  5.02k|            else if(ctx->ihdr.color_type == 2 || ctx->ihdr.color_type == 3)
  ------------------
  |  Branch (2518:21): [True: 679, False: 4.34k]
  |  Branch (2518:50): [True: 987, False: 3.36k]
  ------------------
 2519|  1.66k|            {
 2520|  1.66k|                if(chunk.length != 3) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2520:20): [True: 742, False: 924]
  ------------------
 2521|       |
 2522|    924|                ctx->sbit.red_bits = data[0];
 2523|    924|                ctx->sbit.green_bits = data[1];
 2524|    924|                ctx->sbit.blue_bits = data[2];
 2525|    924|            }
 2526|  3.36k|            else if(ctx->ihdr.color_type == 4)
  ------------------
  |  Branch (2526:21): [True: 721, False: 2.63k]
  ------------------
 2527|    721|            {
 2528|    721|                if(chunk.length != 2) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2528:20): [True: 140, False: 581]
  ------------------
 2529|       |
 2530|    581|                ctx->sbit.grayscale_bits = data[0];
 2531|    581|                ctx->sbit.alpha_bits = data[1];
 2532|    581|            }
 2533|  2.63k|            else if(ctx->ihdr.color_type == 6)
  ------------------
  |  Branch (2533:21): [True: 2.63k, False: 0]
  ------------------
 2534|  2.63k|            {
 2535|  2.63k|                if(chunk.length != 4) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2535:20): [True: 602, False: 2.03k]
  ------------------
 2536|       |
 2537|  2.03k|                ctx->sbit.red_bits = data[0];
 2538|  2.03k|                ctx->sbit.green_bits = data[1];
 2539|  2.03k|                ctx->sbit.blue_bits = data[2];
 2540|  2.03k|                ctx->sbit.alpha_bits = data[3];
 2541|  2.03k|            }
 2542|       |
 2543|  5.08k|            if(check_sbit(&ctx->sbit, &ctx->ihdr)) return SPNG_ESBIT;
  ------------------
  |  Branch (2543:16): [True: 4.94k, False: 140]
  ------------------
 2544|       |
 2545|    140|            ctx->file.sbit = 1;
 2546|    140|            ctx->stored.sbit = 1;
 2547|    140|        }
 2548|   745k|        else if(!memcmp(chunk.type, type_srgb, 4))
  ------------------
  |  Branch (2548:17): [True: 2.60k, False: 743k]
  ------------------
 2549|  2.60k|        {
 2550|  2.60k|            if(ctx->file.plte) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2550:16): [True: 210, False: 2.39k]
  ------------------
 2551|  2.39k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2551:16): [True: 210, False: 2.18k]
  ------------------
 2552|  2.18k|            if(ctx->file.srgb) return SPNG_EDUP_SRGB;
  ------------------
  |  Branch (2552:16): [True: 861, False: 1.32k]
  ------------------
 2553|       |
 2554|  1.32k|            if(chunk.length != 1) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2554:16): [True: 616, False: 707]
  ------------------
 2555|       |
 2556|    707|            ctx->srgb_rendering_intent = data[0];
 2557|       |
 2558|    707|            if(ctx->srgb_rendering_intent > 3) return SPNG_ESRGB;
  ------------------
  |  Branch (2558:16): [True: 567, False: 140]
  ------------------
 2559|       |
 2560|    140|            ctx->file.srgb = 1;
 2561|    140|            ctx->stored.srgb = 1;
 2562|    140|        }
 2563|   743k|        else if(!memcmp(chunk.type, type_bkgd, 4))
  ------------------
  |  Branch (2563:17): [True: 28.2k, False: 715k]
  ------------------
 2564|  28.2k|        {
 2565|  28.2k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2565:16): [True: 2.28k, False: 25.9k]
  ------------------
 2566|  25.9k|            if(ctx->file.bkgd) return SPNG_EDUP_BKGD;
  ------------------
  |  Branch (2566:16): [True: 7.60k, False: 18.3k]
  ------------------
 2567|       |
 2568|  18.3k|            if(ctx->ihdr.color_type == 0 || ctx->ihdr.color_type == 4)
  ------------------
  |  Branch (2568:16): [True: 1.98k, False: 16.4k]
  |  Branch (2568:45): [True: 497, False: 15.9k]
  ------------------
 2569|  2.47k|            {
 2570|  2.47k|                if(chunk.length != 2) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2570:20): [True: 1.86k, False: 616]
  ------------------
 2571|       |
 2572|    616|                ctx->bkgd.gray = read_u16(data);
 2573|    616|            }
 2574|  15.9k|            else if(ctx->ihdr.color_type == 2 || ctx->ihdr.color_type == 6)
  ------------------
  |  Branch (2574:21): [True: 1.00k, False: 14.9k]
  |  Branch (2574:50): [True: 1.27k, False: 13.6k]
  ------------------
 2575|  2.27k|            {
 2576|  2.27k|                if(chunk.length != 6) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2576:20): [True: 2.03k, False: 245]
  ------------------
 2577|       |
 2578|    245|                ctx->bkgd.red = read_u16(data);
 2579|    245|                ctx->bkgd.green = read_u16(data + 2);
 2580|    245|                ctx->bkgd.blue = read_u16(data + 4);
 2581|    245|            }
 2582|  13.6k|            else if(ctx->ihdr.color_type == 3)
  ------------------
  |  Branch (2582:21): [True: 13.6k, False: 0]
  ------------------
 2583|  13.6k|            {
 2584|  13.6k|                if(chunk.length != 1) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2584:20): [True: 5.50k, False: 8.12k]
  ------------------
 2585|  8.12k|                if(!ctx->file.plte) return SPNG_EBKGD_NO_PLTE;
  ------------------
  |  Branch (2585:20): [True: 6.44k, False: 1.68k]
  ------------------
 2586|       |
 2587|  1.68k|                ctx->bkgd.plte_index = data[0];
 2588|  1.68k|                if(ctx->bkgd.plte_index >= ctx->plte.n_entries) return SPNG_EBKGD_PLTE_IDX;
  ------------------
  |  Branch (2588:20): [True: 1.60k, False: 77]
  ------------------
 2589|  1.68k|            }
 2590|       |
 2591|    938|            ctx->file.bkgd = 1;
 2592|    938|            ctx->stored.bkgd = 1;
 2593|    938|        }
 2594|   715k|        else if(!memcmp(chunk.type, type_trns, 4))
  ------------------
  |  Branch (2594:17): [True: 21.9k, False: 693k]
  ------------------
 2595|  21.9k|        {
 2596|  21.9k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2596:16): [True: 336, False: 21.6k]
  ------------------
 2597|  21.6k|            if(ctx->file.trns) return SPNG_EDUP_TRNS;
  ------------------
  |  Branch (2597:16): [True: 6.02k, False: 15.5k]
  ------------------
 2598|  15.5k|            if(!chunk.length) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2598:16): [True: 0, False: 15.5k]
  ------------------
 2599|       |
 2600|  15.5k|            if(ctx->ihdr.color_type == 0)
  ------------------
  |  Branch (2600:16): [True: 490, False: 15.1k]
  ------------------
 2601|    490|            {
 2602|    490|                if(chunk.length != 2) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2602:20): [True: 399, False: 91]
  ------------------
 2603|       |
 2604|     91|                ctx->trns.gray = read_u16(data);
 2605|     91|            }
 2606|  15.1k|            else if(ctx->ihdr.color_type == 2)
  ------------------
  |  Branch (2606:21): [True: 13.1k, False: 1.96k]
  ------------------
 2607|  13.1k|            {
 2608|  13.1k|                if(chunk.length != 6) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2608:20): [True: 13.1k, False: 35]
  ------------------
 2609|       |
 2610|     35|                ctx->trns.red = read_u16(data);
 2611|     35|                ctx->trns.green = read_u16(data + 2);
 2612|     35|                ctx->trns.blue = read_u16(data + 4);
 2613|     35|            }
 2614|  1.96k|            else if(ctx->ihdr.color_type == 3)
  ------------------
  |  Branch (2614:21): [True: 1.08k, False: 875]
  ------------------
 2615|  1.08k|            {
 2616|  1.08k|                if(chunk.length > ctx->plte.n_entries) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2616:20): [True: 854, False: 231]
  ------------------
 2617|    231|                if(!ctx->file.plte) return SPNG_ETRNS_NO_PLTE;
  ------------------
  |  Branch (2617:20): [True: 0, False: 231]
  ------------------
 2618|       |
 2619|    231|                memcpy(ctx->trns.type3_alpha, data, chunk.length);
 2620|    231|                ctx->trns.n_type3_entries = chunk.length;
 2621|    231|            }
 2622|       |
 2623|  1.23k|            if(ctx->ihdr.color_type == 4 || ctx->ihdr.color_type == 6)  return SPNG_ETRNS_COLOR_TYPE;
  ------------------
  |  Branch (2623:16): [True: 217, False: 1.01k]
  |  Branch (2623:45): [True: 658, False: 357]
  ------------------
 2624|       |
 2625|    357|            ctx->file.trns = 1;
 2626|    357|            ctx->stored.trns = 1;
 2627|    357|        }
 2628|   693k|        else if(!memcmp(chunk.type, type_hist, 4))
  ------------------
  |  Branch (2628:17): [True: 6.74k, False: 686k]
  ------------------
 2629|  6.74k|        {
 2630|  6.74k|            if(!ctx->file.plte) return SPNG_EHIST_NO_PLTE;
  ------------------
  |  Branch (2630:16): [True: 3.54k, False: 3.19k]
  ------------------
 2631|  3.19k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2631:16): [True: 112, False: 3.08k]
  ------------------
 2632|  3.08k|            if(ctx->file.hist) return SPNG_EDUP_HIST;
  ------------------
  |  Branch (2632:16): [True: 308, False: 2.77k]
  ------------------
 2633|       |
 2634|  2.77k|            if( (chunk.length / 2) != (ctx->plte.n_entries) ) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2634:17): [True: 2.70k, False: 70]
  ------------------
 2635|       |
 2636|     70|            size_t k;
 2637|    476|            for(k=0; k < (chunk.length / 2); k++)
  ------------------
  |  Branch (2637:22): [True: 406, False: 70]
  ------------------
 2638|    406|            {
 2639|    406|                ctx->hist.frequency[k] = read_u16(data + k*2);
 2640|    406|            }
 2641|       |
 2642|     70|            ctx->file.hist = 1;
 2643|     70|            ctx->stored.hist = 1;
 2644|     70|        }
 2645|   686k|        else if(!memcmp(chunk.type, type_phys, 4))
  ------------------
  |  Branch (2645:17): [True: 6.16k, False: 680k]
  ------------------
 2646|  6.16k|        {
 2647|  6.16k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2647:16): [True: 1.05k, False: 5.11k]
  ------------------
 2648|  5.11k|            if(ctx->file.phys) return SPNG_EDUP_PHYS;
  ------------------
  |  Branch (2648:16): [True: 1.98k, False: 3.13k]
  ------------------
 2649|       |
 2650|  3.13k|            if(chunk.length != 9) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2650:16): [True: 294, False: 2.84k]
  ------------------
 2651|       |
 2652|  2.84k|            ctx->phys.ppu_x = read_u32(data);
 2653|  2.84k|            ctx->phys.ppu_y = read_u32(data + 4);
 2654|  2.84k|            ctx->phys.unit_specifier = data[8];
 2655|       |
 2656|  2.84k|            if(check_phys(&ctx->phys)) return SPNG_EPHYS;
  ------------------
  |  Branch (2656:16): [True: 2.61k, False: 224]
  ------------------
 2657|       |
 2658|    224|            ctx->file.phys = 1;
 2659|    224|            ctx->stored.phys = 1;
 2660|    224|        }
 2661|   680k|        else if(!memcmp(chunk.type, type_time, 4))
  ------------------
  |  Branch (2661:17): [True: 10.0k, False: 670k]
  ------------------
 2662|  10.0k|        {
 2663|  10.0k|            if(ctx->file.time) return SPNG_EDUP_TIME;
  ------------------
  |  Branch (2663:16): [True: 3.85k, False: 6.16k]
  ------------------
 2664|       |
 2665|  6.16k|            if(chunk.length != 7) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2665:16): [True: 315, False: 5.84k]
  ------------------
 2666|       |
 2667|  5.84k|            struct spng_time time;
 2668|       |
 2669|  5.84k|            time.year = read_u16(data);
 2670|  5.84k|            time.month = data[2];
 2671|  5.84k|            time.day = data[3];
 2672|  5.84k|            time.hour = data[4];
 2673|  5.84k|            time.minute = data[5];
 2674|  5.84k|            time.second = data[6];
 2675|       |
 2676|  5.84k|            if(check_time(&time)) return SPNG_ETIME;
  ------------------
  |  Branch (2676:16): [True: 5.52k, False: 322]
  ------------------
 2677|       |
 2678|    322|            ctx->file.time = 1;
 2679|       |
 2680|    322|            if(!ctx->user.time) ctx->time = time;
  ------------------
  |  Branch (2680:16): [True: 322, False: 0]
  ------------------
 2681|       |
 2682|    322|            ctx->stored.time = 1;
 2683|    322|        }
 2684|   670k|        else if(!memcmp(chunk.type, type_offs, 4))
  ------------------
  |  Branch (2684:17): [True: 2.21k, False: 667k]
  ------------------
 2685|  2.21k|        {
 2686|  2.21k|            if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2686:16): [True: 546, False: 1.67k]
  ------------------
 2687|  1.67k|            if(ctx->file.offs) return SPNG_EDUP_OFFS;
  ------------------
  |  Branch (2687:16): [True: 469, False: 1.20k]
  ------------------
 2688|       |
 2689|  1.20k|            if(chunk.length != 9) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2689:16): [True: 301, False: 903]
  ------------------
 2690|       |
 2691|    903|            ctx->offs.x = read_s32(data);
 2692|    903|            ctx->offs.y = read_s32(data + 4);
 2693|    903|            ctx->offs.unit_specifier = data[8];
 2694|       |
 2695|    903|            if(check_offs(&ctx->offs)) return SPNG_EOFFS;
  ------------------
  |  Branch (2695:16): [True: 812, False: 91]
  ------------------
 2696|       |
 2697|     91|            ctx->file.offs = 1;
 2698|     91|            ctx->stored.offs = 1;
 2699|     91|        }
 2700|   667k|        else /* Arbitrary-length chunk */
 2701|   667k|        {
 2702|       |
 2703|   667k|            if(!memcmp(chunk.type, type_exif, 4))
  ------------------
  |  Branch (2703:16): [True: 6.12k, False: 661k]
  ------------------
 2704|  6.12k|            {
 2705|  6.12k|                if(ctx->file.exif) return SPNG_EDUP_EXIF;
  ------------------
  |  Branch (2705:20): [True: 4.94k, False: 1.17k]
  ------------------
 2706|  1.17k|                if(!chunk.length) return SPNG_EEXIF;
  ------------------
  |  Branch (2706:20): [True: 343, False: 833]
  ------------------
 2707|       |
 2708|    833|                ctx->file.exif = 1;
 2709|       |
 2710|    833|                if(ctx->user.exif) goto discard;
  ------------------
  |  Branch (2710:20): [True: 0, False: 833]
  ------------------
 2711|       |
 2712|    833|                if(increase_cache_usage(ctx, chunk.length, 1)) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (2712:20): [True: 0, False: 833]
  ------------------
 2713|       |
 2714|    833|                struct spng_exif exif;
 2715|       |
 2716|    833|                exif.length = chunk.length;
 2717|       |
 2718|    833|                exif.data = spng__malloc(ctx, chunk.length);
 2719|    833|                if(exif.data == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (2719:20): [True: 0, False: 833]
  ------------------
 2720|       |
 2721|    833|                ret = read_chunk_bytes2(ctx, exif.data, chunk.length);
 2722|    833|                if(ret)
  ------------------
  |  Branch (2722:20): [True: 385, False: 448]
  ------------------
 2723|    385|                {
 2724|    385|                    spng__free(ctx, exif.data);
 2725|    385|                    return ret;
 2726|    385|                }
 2727|       |
 2728|    448|                if(check_exif(&exif))
  ------------------
  |  Branch (2728:20): [True: 434, False: 14]
  ------------------
 2729|    434|                {
 2730|    434|                    spng__free(ctx, exif.data);
 2731|    434|                    return SPNG_EEXIF;
 2732|    434|                }
 2733|       |
 2734|     14|                ctx->exif = exif;
 2735|       |
 2736|     14|                ctx->stored.exif = 1;
 2737|     14|            }
 2738|   661k|            else if(!memcmp(chunk.type, type_iccp, 4))
  ------------------
  |  Branch (2738:21): [True: 21.3k, False: 640k]
  ------------------
 2739|  21.3k|            {/* TODO: add test file with color profile */
 2740|  21.3k|                if(ctx->file.plte) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2740:20): [True: 868, False: 20.4k]
  ------------------
 2741|  20.4k|                if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2741:20): [True: 2.22k, False: 18.2k]
  ------------------
 2742|  18.2k|                if(ctx->file.iccp) return SPNG_EDUP_ICCP;
  ------------------
  |  Branch (2742:20): [True: 14.2k, False: 4.04k]
  ------------------
 2743|  4.04k|                if(!chunk.length) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2743:20): [True: 644, False: 3.40k]
  ------------------
 2744|       |
 2745|  3.40k|                ctx->file.iccp = 1;
 2746|       |
 2747|  3.40k|                uint32_t peek_bytes =  81 > chunk.length ? chunk.length : 81;
  ------------------
  |  Branch (2747:40): [True: 616, False: 2.78k]
  ------------------
 2748|       |
 2749|  3.40k|                ret = read_chunk_bytes(ctx, peek_bytes);
 2750|  3.40k|                if(ret) return ret;
  ------------------
  |  Branch (2750:20): [True: 259, False: 3.14k]
  ------------------
 2751|       |
 2752|  3.14k|                unsigned char *keyword_nul = memchr(ctx->data, '\0', peek_bytes);
 2753|  3.14k|                if(keyword_nul == NULL) return SPNG_EICCP_NAME;
  ------------------
  |  Branch (2753:20): [True: 14, False: 3.12k]
  ------------------
 2754|       |
 2755|  3.12k|                uint32_t keyword_len = keyword_nul - ctx->data;
 2756|       |
 2757|  3.12k|                if(keyword_len > 79) return SPNG_EICCP_NAME;
  ------------------
  |  Branch (2757:20): [True: 7, False: 3.12k]
  ------------------
 2758|       |
 2759|  3.12k|                memcpy(ctx->iccp.profile_name, ctx->data, keyword_len);
 2760|       |
 2761|  3.12k|                if(check_png_keyword(ctx->iccp.profile_name)) return SPNG_EICCP_NAME;
  ------------------
  |  Branch (2761:20): [True: 84, False: 3.03k]
  ------------------
 2762|       |
 2763|  3.03k|                if(chunk.length < (keyword_len + 2)) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2763:20): [True: 35, False: 3.00k]
  ------------------
 2764|       |
 2765|  3.00k|                if(ctx->data[keyword_len + 1] != 0) return SPNG_EICCP_COMPRESSION_METHOD;
  ------------------
  |  Branch (2765:20): [True: 112, False: 2.89k]
  ------------------
 2766|       |
 2767|  2.89k|                ret = spng__inflate_stream(ctx, &ctx->iccp.profile, &ctx->iccp.profile_len, 0, ctx->data + keyword_len + 2, peek_bytes - (keyword_len + 2));
 2768|       |
 2769|  2.89k|                if(ret) return ret;
  ------------------
  |  Branch (2769:20): [True: 2.84k, False: 49]
  ------------------
 2770|       |
 2771|     49|                ctx->stored.iccp = 1;
 2772|     49|            }
 2773|   640k|             else if(!memcmp(chunk.type, type_text, 4) ||
  ------------------
  |  Branch (2773:22): [True: 126k, False: 513k]
  ------------------
 2774|   513k|                     !memcmp(chunk.type, type_ztxt, 4) ||
  ------------------
  |  Branch (2774:22): [True: 227k, False: 286k]
  ------------------
 2775|   286k|                     !memcmp(chunk.type, type_itxt, 4))
  ------------------
  |  Branch (2775:22): [True: 103k, False: 182k]
  ------------------
 2776|   458k|            {
 2777|   458k|                if(!chunk.length) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2777:20): [True: 230k, False: 228k]
  ------------------
 2778|       |
 2779|   228k|                ctx->file.text = 1;
 2780|       |
 2781|   228k|                if(ctx->user.text) goto discard;
  ------------------
  |  Branch (2781:20): [True: 0, False: 228k]
  ------------------
 2782|       |
 2783|   228k|                if(increase_cache_usage(ctx, sizeof(struct spng_text2), 1)) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (2783:20): [True: 7, False: 228k]
  ------------------
 2784|       |
 2785|   228k|                ctx->n_text++;
 2786|   228k|                if(ctx->n_text < 1) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (2786:20): [True: 0, False: 228k]
  ------------------
 2787|   228k|                if(sizeof(struct spng_text2) > SIZE_MAX / ctx->n_text) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (2787:20): [True: 0, False: 228k]
  ------------------
 2788|       |
 2789|   228k|                void *buf = spng__realloc(ctx, ctx->text_list, ctx->n_text * sizeof(struct spng_text2));
 2790|   228k|                if(buf == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (2790:20): [True: 0, False: 228k]
  ------------------
 2791|   228k|                ctx->text_list = buf;
 2792|       |
 2793|   228k|                struct spng_text2 *text = &ctx->text_list[ctx->n_text - 1];
 2794|   228k|                memset(text, 0, sizeof(struct spng_text2));
 2795|       |
 2796|   228k|                ctx->undo = text_undo;
 2797|       |
 2798|   228k|                uint32_t text_offset = 0, language_tag_offset = 0, translated_keyword_offset = 0;
 2799|   228k|                uint32_t peek_bytes = 256; /* enough for 3 80-byte keywords and some text bytes */
 2800|   228k|                uint32_t keyword_len;
 2801|       |
 2802|   228k|                if(peek_bytes > chunk.length) peek_bytes = chunk.length;
  ------------------
  |  Branch (2802:20): [True: 218k, False: 9.56k]
  ------------------
 2803|       |
 2804|   228k|                ret = read_chunk_bytes(ctx, peek_bytes);
 2805|   228k|                if(ret) return ret;
  ------------------
  |  Branch (2805:20): [True: 516, False: 227k]
  ------------------
 2806|       |
 2807|   227k|                data = ctx->data;
 2808|       |
 2809|   227k|                const unsigned char *zlib_stream = NULL;
 2810|   227k|                const unsigned char *peek_end = data + peek_bytes;
 2811|   227k|                const unsigned char *keyword_nul = memchr(data, 0, chunk.length > 80 ? 80 : chunk.length);
  ------------------
  |  Branch (2811:68): [True: 10.9k, False: 216k]
  ------------------
 2812|       |
 2813|   227k|                if(keyword_nul == NULL) return SPNG_ETEXT_KEYWORD;
  ------------------
  |  Branch (2813:20): [True: 15.9k, False: 211k]
  ------------------
 2814|       |
 2815|   211k|                keyword_len = keyword_nul - data;
 2816|       |
 2817|   211k|                if(!memcmp(chunk.type, type_text, 4))
  ------------------
  |  Branch (2817:20): [True: 35.3k, False: 176k]
  ------------------
 2818|  35.3k|                {
 2819|  35.3k|                    text->type = SPNG_TEXT;
 2820|       |
 2821|  35.3k|                    text->text_length = chunk.length - keyword_len - 1;
 2822|       |
 2823|  35.3k|                    text_offset = keyword_len;
 2824|       |
 2825|       |                    /* increment past nul if there is a text field */
 2826|  35.3k|                    if(text->text_length) text_offset++;
  ------------------
  |  Branch (2826:24): [True: 22.7k, False: 12.6k]
  ------------------
 2827|  35.3k|                }
 2828|   176k|                else if(!memcmp(chunk.type, type_ztxt, 4))
  ------------------
  |  Branch (2828:25): [True: 157k, False: 18.6k]
  ------------------
 2829|   157k|                {
 2830|   157k|                    text->type = SPNG_ZTXT;
 2831|       |
 2832|   157k|                    if((peek_bytes - keyword_len) <= 2) return SPNG_EZTXT;
  ------------------
  |  Branch (2832:24): [True: 13.5k, False: 144k]
  ------------------
 2833|       |
 2834|   144k|                    if(keyword_nul[1]) return SPNG_EZTXT_COMPRESSION_METHOD;
  ------------------
  |  Branch (2834:24): [True: 4.48k, False: 139k]
  ------------------
 2835|       |
 2836|   139k|                    text->compression_flag = 1;
 2837|       |
 2838|   139k|                    text_offset = keyword_len + 2;
 2839|   139k|                }
 2840|  18.6k|                else if(!memcmp(chunk.type, type_itxt, 4))
  ------------------
  |  Branch (2840:25): [True: 18.6k, False: 0]
  ------------------
 2841|  18.6k|                {
 2842|  18.6k|                    text->type = SPNG_ITXT;
 2843|       |
 2844|       |                    /* at least two 1-byte fields, two >=0 length strings, and one byte of (compressed) text */
 2845|  18.6k|                    if((peek_bytes - keyword_len) < 5) return SPNG_EITXT;
  ------------------
  |  Branch (2845:24): [True: 1.03k, False: 17.6k]
  ------------------
 2846|       |
 2847|  17.6k|                    text->compression_flag = keyword_nul[1];
 2848|       |
 2849|  17.6k|                    if(text->compression_flag > 1) return SPNG_EITXT_COMPRESSION_FLAG;
  ------------------
  |  Branch (2849:24): [True: 2.12k, False: 15.4k]
  ------------------
 2850|       |
 2851|  15.4k|                    if(keyword_nul[2]) return SPNG_EITXT_COMPRESSION_METHOD;
  ------------------
  |  Branch (2851:24): [True: 1.35k, False: 14.1k]
  ------------------
 2852|       |
 2853|  14.1k|                    language_tag_offset = keyword_len + 3;
 2854|       |
 2855|  14.1k|                    const unsigned char *term;
 2856|  14.1k|                    term = memchr(data + language_tag_offset, 0, peek_bytes - language_tag_offset);
 2857|  14.1k|                    if(term == NULL) return SPNG_EITXT_LANG_TAG;
  ------------------
  |  Branch (2857:24): [True: 259, False: 13.8k]
  ------------------
 2858|       |
 2859|  13.8k|                    if((peek_end - term) < 2) return SPNG_EITXT;
  ------------------
  |  Branch (2859:24): [True: 1.30k, False: 12.5k]
  ------------------
 2860|       |
 2861|  12.5k|                    translated_keyword_offset = term - data + 1;
 2862|       |
 2863|  12.5k|                    zlib_stream = memchr(data + translated_keyword_offset, 0, peek_bytes - translated_keyword_offset);
 2864|  12.5k|                    if(zlib_stream == NULL) return SPNG_EITXT;
  ------------------
  |  Branch (2864:24): [True: 581, False: 11.9k]
  ------------------
 2865|  11.9k|                    if(zlib_stream == peek_end) return SPNG_EITXT;
  ------------------
  |  Branch (2865:24): [True: 0, False: 11.9k]
  ------------------
 2866|       |
 2867|  11.9k|                    text_offset = zlib_stream - data + 1;
 2868|  11.9k|                    text->text_length = chunk.length - text_offset;
 2869|  11.9k|                }
 2870|      0|                else return SPNG_EINTERNAL;
 2871|       |
 2872|       |
 2873|   186k|                if(text->compression_flag)
  ------------------
  |  Branch (2873:20): [True: 141k, False: 45.0k]
  ------------------
 2874|   141k|                {
 2875|       |                    /* cache usage = peek_bytes + decompressed text size + nul */
 2876|   141k|                    if(increase_cache_usage(ctx, peek_bytes, 0)) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (2876:24): [True: 0, False: 141k]
  ------------------
 2877|       |
 2878|   141k|                    text->keyword = spng__calloc(ctx, 1, peek_bytes);
 2879|   141k|                    if(text->keyword == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (2879:24): [True: 0, False: 141k]
  ------------------
 2880|       |
 2881|   141k|                    memcpy(text->keyword, data, peek_bytes);
 2882|       |
 2883|   141k|                    zlib_stream = ctx->data + text_offset;
 2884|       |
 2885|   141k|                    ret = spng__inflate_stream(ctx, &text->text, &text->text_length, 1, zlib_stream, peek_bytes - text_offset);
 2886|       |
 2887|   141k|                    if(ret) return ret;
  ------------------
  |  Branch (2887:24): [True: 55.5k, False: 86.3k]
  ------------------
 2888|       |
 2889|  86.3k|                    text->text[text->text_length - 1] = '\0';
 2890|  86.3k|                    text->cache_usage = text->text_length + peek_bytes;
 2891|  86.3k|                }
 2892|  45.0k|                else
 2893|  45.0k|                {
 2894|  45.0k|                    if(increase_cache_usage(ctx, chunk.length + 1, 0)) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (2894:24): [True: 0, False: 45.0k]
  ------------------
 2895|       |
 2896|  45.0k|                    text->keyword = spng__malloc(ctx, chunk.length + 1);
 2897|  45.0k|                    if(text->keyword == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (2897:24): [True: 0, False: 45.0k]
  ------------------
 2898|       |
 2899|  45.0k|                    memcpy(text->keyword, data, peek_bytes);
 2900|       |
 2901|  45.0k|                    if(chunk.length > peek_bytes)
  ------------------
  |  Branch (2901:24): [True: 819, False: 44.2k]
  ------------------
 2902|    819|                    {
 2903|    819|                        ret = read_chunk_bytes2(ctx, text->keyword + peek_bytes, chunk.length - peek_bytes);
 2904|    819|                        if(ret) return ret;
  ------------------
  |  Branch (2904:28): [True: 434, False: 385]
  ------------------
 2905|    819|                    }
 2906|       |
 2907|  44.6k|                    text->text = text->keyword + text_offset;
 2908|       |
 2909|  44.6k|                    text->text_length = chunk.length - text_offset;
 2910|       |
 2911|  44.6k|                    text->text[text->text_length] = '\0';
 2912|  44.6k|                    text->cache_usage = chunk.length + 1;
 2913|  44.6k|                }
 2914|       |
 2915|   130k|                if(check_png_keyword(text->keyword)) return SPNG_ETEXT_KEYWORD;
  ------------------
  |  Branch (2915:20): [True: 36.5k, False: 94.3k]
  ------------------
 2916|       |
 2917|  94.3k|                text->text_length = strlen(text->text);
 2918|       |
 2919|  94.3k|                if(text->type != SPNG_ITXT)
  ------------------
  |  Branch (2919:20): [True: 87.3k, False: 7.00k]
  ------------------
 2920|  87.3k|                {
 2921|  87.3k|                    language_tag_offset = keyword_len;
 2922|  87.3k|                    translated_keyword_offset = keyword_len;
 2923|       |
 2924|  87.3k|                    if(ctx->strict && check_png_text(text->text, text->text_length))
  ------------------
  |  Branch (2924:24): [True: 0, False: 87.3k]
  |  Branch (2924:39): [True: 0, False: 0]
  ------------------
 2925|      0|                    {
 2926|      0|                        if(text->type == SPNG_ZTXT) return SPNG_EZTXT;
  ------------------
  |  Branch (2926:28): [True: 0, False: 0]
  ------------------
 2927|      0|                        else return SPNG_ETEXT;
 2928|      0|                    }
 2929|  87.3k|                }
 2930|       |
 2931|  94.3k|                text->language_tag = text->keyword + language_tag_offset;
 2932|  94.3k|                text->translated_keyword = text->keyword + translated_keyword_offset;
 2933|       |
 2934|  94.3k|                ctx->stored.text = 1;
 2935|  94.3k|            }
 2936|   182k|            else if(!memcmp(chunk.type, type_splt, 4))
  ------------------
  |  Branch (2936:21): [True: 134k, False: 48.0k]
  ------------------
 2937|   134k|            {
 2938|   134k|                if(ctx->state == SPNG_STATE_AFTER_IDAT) return SPNG_ECHUNK_POS;
  ------------------
  |  Branch (2938:20): [True: 9.10k, False: 124k]
  ------------------
 2939|   124k|                if(ctx->user.splt) goto discard; /* XXX: could check profile names for uniqueness */
  ------------------
  |  Branch (2939:20): [True: 0, False: 124k]
  ------------------
 2940|   124k|                if(!chunk.length) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2940:20): [True: 20.0k, False: 104k]
  ------------------
 2941|       |
 2942|   104k|                ctx->file.splt = 1;
 2943|       |
 2944|       |                /* chunk.length + sizeof(struct spng_splt) + splt->n_entries * sizeof(struct spng_splt_entry) */
 2945|   104k|                if(increase_cache_usage(ctx, chunk.length + sizeof(struct spng_splt), 1)) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (2945:20): [True: 7, False: 104k]
  ------------------
 2946|       |
 2947|   104k|                ctx->n_splt++;
 2948|   104k|                if(ctx->n_splt < 1) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (2948:20): [True: 0, False: 104k]
  ------------------
 2949|   104k|                if(sizeof(struct spng_splt) > SIZE_MAX / ctx->n_splt) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (2949:20): [True: 0, False: 104k]
  ------------------
 2950|       |
 2951|   104k|                void *buf = spng__realloc(ctx, ctx->splt_list, ctx->n_splt * sizeof(struct spng_splt));
 2952|   104k|                if(buf == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (2952:20): [True: 0, False: 104k]
  ------------------
 2953|   104k|                ctx->splt_list = buf;
 2954|       |
 2955|   104k|                struct spng_splt *splt = &ctx->splt_list[ctx->n_splt - 1];
 2956|       |
 2957|   104k|                memset(splt, 0, sizeof(struct spng_splt));
 2958|       |
 2959|   104k|                ctx->undo = splt_undo;
 2960|       |
 2961|   104k|                void *t = spng__malloc(ctx, chunk.length);
 2962|   104k|                if(t == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (2962:20): [True: 0, False: 104k]
  ------------------
 2963|       |
 2964|   104k|                splt->entries = t; /* simplifies error handling */
 2965|   104k|                data = t;
 2966|       |
 2967|   104k|                ret = read_chunk_bytes2(ctx, t, chunk.length);
 2968|   104k|                if(ret) return ret;
  ------------------
  |  Branch (2968:20): [True: 266, False: 104k]
  ------------------
 2969|       |
 2970|   104k|                uint32_t keyword_len = chunk.length < 80 ? chunk.length : 80;
  ------------------
  |  Branch (2970:40): [True: 96.7k, False: 7.90k]
  ------------------
 2971|       |
 2972|   104k|                const unsigned char *keyword_nul = memchr(data, 0, keyword_len);
 2973|   104k|                if(keyword_nul == NULL) return SPNG_ESPLT_NAME;
  ------------------
  |  Branch (2973:20): [True: 15.3k, False: 89.3k]
  ------------------
 2974|       |
 2975|  89.3k|                keyword_len = keyword_nul - data;
 2976|       |
 2977|  89.3k|                memcpy(splt->name, data, keyword_len);
 2978|       |
 2979|  89.3k|                if(check_png_keyword(splt->name)) return SPNG_ESPLT_NAME;
  ------------------
  |  Branch (2979:20): [True: 58.3k, False: 30.9k]
  ------------------
 2980|       |
 2981|  30.9k|                uint32_t j;
 2982|  34.1k|                for(j=0; j < (ctx->n_splt - 1); j++)
  ------------------
  |  Branch (2982:26): [True: 4.57k, False: 29.5k]
  ------------------
 2983|  4.57k|                {
 2984|  4.57k|                    if(!strcmp(ctx->splt_list[j].name, splt->name)) return SPNG_ESPLT_DUP_NAME;
  ------------------
  |  Branch (2984:24): [True: 1.37k, False: 3.20k]
  ------------------
 2985|  4.57k|                }
 2986|       |
 2987|  29.5k|                if( (chunk.length - keyword_len) <= 2) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2987:21): [True: 22.1k, False: 7.37k]
  ------------------
 2988|       |
 2989|  7.37k|                splt->sample_depth = data[keyword_len + 1];
 2990|       |
 2991|  7.37k|                uint32_t entries_len = chunk.length - keyword_len - 2;
 2992|  7.37k|                if(!entries_len) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2992:20): [True: 0, False: 7.37k]
  ------------------
 2993|       |
 2994|  7.37k|                if(splt->sample_depth == 16)
  ------------------
  |  Branch (2994:20): [True: 1.11k, False: 6.25k]
  ------------------
 2995|  1.11k|                {
 2996|  1.11k|                    if(entries_len % 10 != 0) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2996:24): [True: 504, False: 609]
  ------------------
 2997|    609|                    splt->n_entries = entries_len / 10;
 2998|    609|                }
 2999|  6.25k|                else if(splt->sample_depth == 8)
  ------------------
  |  Branch (2999:25): [True: 3.95k, False: 2.30k]
  ------------------
 3000|  3.95k|                {
 3001|  3.95k|                    if(entries_len % 6 != 0) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (3001:24): [True: 280, False: 3.67k]
  ------------------
 3002|  3.67k|                    splt->n_entries = entries_len / 6;
 3003|  3.67k|                }
 3004|  2.30k|                else return SPNG_ESPLT_DEPTH;
 3005|       |
 3006|  4.28k|                if(!splt->n_entries) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (3006:20): [True: 0, False: 4.28k]
  ------------------
 3007|       |
 3008|  4.28k|                size_t list_size = splt->n_entries;
 3009|       |
 3010|  4.28k|                if(list_size > SIZE_MAX / sizeof(struct spng_splt_entry)) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (3010:20): [True: 0, False: 4.28k]
  ------------------
 3011|       |
 3012|  4.28k|                list_size *= sizeof(struct spng_splt_entry);
 3013|       |
 3014|  4.28k|                if(increase_cache_usage(ctx, list_size, 0)) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (3014:20): [True: 0, False: 4.28k]
  ------------------
 3015|       |
 3016|  4.28k|                splt->entries = spng__malloc(ctx, list_size);
 3017|  4.28k|                if(splt->entries == NULL)
  ------------------
  |  Branch (3017:20): [True: 0, False: 4.28k]
  ------------------
 3018|      0|                {
 3019|      0|                    spng__free(ctx, t);
 3020|      0|                    return SPNG_EMEM;
 3021|      0|                }
 3022|       |
 3023|  4.28k|                data = (unsigned char*)t + keyword_len + 2;
 3024|       |
 3025|  4.28k|                uint32_t k;
 3026|  4.28k|                if(splt->sample_depth == 16)
  ------------------
  |  Branch (3026:20): [True: 609, False: 3.67k]
  ------------------
 3027|    609|                {
 3028|  2.03k|                    for(k=0; k < splt->n_entries; k++)
  ------------------
  |  Branch (3028:30): [True: 1.42k, False: 609]
  ------------------
 3029|  1.42k|                    {
 3030|  1.42k|                        splt->entries[k].red =   read_u16(data + k * 10);
 3031|  1.42k|                        splt->entries[k].green = read_u16(data + k * 10 + 2);
 3032|  1.42k|                        splt->entries[k].blue =  read_u16(data + k * 10 + 4);
 3033|  1.42k|                        splt->entries[k].alpha = read_u16(data + k * 10 + 6);
 3034|  1.42k|                        splt->entries[k].frequency = read_u16(data + k * 10 + 8);
 3035|  1.42k|                    }
 3036|    609|                }
 3037|  3.67k|                else if(splt->sample_depth == 8)
  ------------------
  |  Branch (3037:25): [True: 3.67k, False: 0]
  ------------------
 3038|  3.67k|                {
 3039|  29.3k|                    for(k=0; k < splt->n_entries; k++)
  ------------------
  |  Branch (3039:30): [True: 25.6k, False: 3.67k]
  ------------------
 3040|  25.6k|                    {
 3041|  25.6k|                        splt->entries[k].red =   data[k * 6];
 3042|  25.6k|                        splt->entries[k].green = data[k * 6 + 1];
 3043|  25.6k|                        splt->entries[k].blue =  data[k * 6 + 2];
 3044|  25.6k|                        splt->entries[k].alpha = data[k * 6 + 3];
 3045|  25.6k|                        splt->entries[k].frequency = read_u16(data + k * 6 + 4);
 3046|  25.6k|                    }
 3047|  3.67k|                }
 3048|       |
 3049|  4.28k|                spng__free(ctx, t);
 3050|  4.28k|                decrease_cache_usage(ctx, chunk.length);
 3051|       |
 3052|  4.28k|                ctx->stored.splt = 1;
 3053|  4.28k|            }
 3054|  48.0k|            else /* Unknown chunk */
 3055|  48.0k|            {
 3056|  48.0k|                ctx->file.unknown = 1;
 3057|       |
 3058|  48.0k|                if(!ctx->keep_unknown) goto discard;
  ------------------
  |  Branch (3058:20): [True: 48.0k, False: 0]
  ------------------
 3059|      0|                if(ctx->user.unknown) goto discard;
  ------------------
  |  Branch (3059:20): [True: 0, False: 0]
  ------------------
 3060|       |
 3061|      0|                if(increase_cache_usage(ctx, chunk.length + sizeof(struct spng_unknown_chunk), 1)) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (3061:20): [True: 0, False: 0]
  ------------------
 3062|       |
 3063|      0|                ctx->n_chunks++;
 3064|      0|                if(ctx->n_chunks < 1) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (3064:20): [True: 0, False: 0]
  ------------------
 3065|      0|                if(sizeof(struct spng_unknown_chunk) > SIZE_MAX / ctx->n_chunks) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (3065:20): [True: 0, False: 0]
  ------------------
 3066|       |
 3067|      0|                void *buf = spng__realloc(ctx, ctx->chunk_list, ctx->n_chunks * sizeof(struct spng_unknown_chunk));
 3068|      0|                if(buf == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (3068:20): [True: 0, False: 0]
  ------------------
 3069|      0|                ctx->chunk_list = buf;
 3070|       |
 3071|      0|                struct spng_unknown_chunk *chunkp = &ctx->chunk_list[ctx->n_chunks - 1];
 3072|       |
 3073|      0|                memset(chunkp, 0, sizeof(struct spng_unknown_chunk));
 3074|       |
 3075|      0|                ctx->undo = chunk_undo;
 3076|       |
 3077|      0|                memcpy(chunkp->type, chunk.type, 4);
 3078|       |
 3079|      0|                if(ctx->state < SPNG_STATE_FIRST_IDAT)
  ------------------
  |  Branch (3079:20): [True: 0, False: 0]
  ------------------
 3080|      0|                {
 3081|      0|                    if(ctx->file.plte) chunkp->location = SPNG_AFTER_PLTE;
  ------------------
  |  Branch (3081:24): [True: 0, False: 0]
  ------------------
 3082|      0|                    else chunkp->location = SPNG_AFTER_IHDR;
 3083|      0|                }
 3084|      0|                else if(ctx->state >= SPNG_STATE_AFTER_IDAT) chunkp->location = SPNG_AFTER_IDAT;
  ------------------
  |  Branch (3084:25): [True: 0, False: 0]
  ------------------
 3085|       |
 3086|      0|                if(chunk.length > 0)
  ------------------
  |  Branch (3086:20): [True: 0, False: 0]
  ------------------
 3087|      0|                {
 3088|      0|                    void *t = spng__malloc(ctx, chunk.length);
 3089|      0|                    if(t == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (3089:24): [True: 0, False: 0]
  ------------------
 3090|       |
 3091|      0|                    ret = read_chunk_bytes2(ctx, t, chunk.length);
 3092|      0|                    if(ret)
  ------------------
  |  Branch (3092:24): [True: 0, False: 0]
  ------------------
 3093|      0|                    {
 3094|      0|                        spng__free(ctx, t);
 3095|      0|                        return ret;
 3096|      0|                    }
 3097|       |
 3098|      0|                    chunkp->length = chunk.length;
 3099|      0|                    chunkp->data = t;
 3100|      0|                }
 3101|       |
 3102|      0|                ctx->stored.unknown = 1;
 3103|      0|            }
 3104|       |
 3105|   146k|discard:
 3106|   146k|            ret = discard_chunk_bytes(ctx, ctx->cur_chunk_bytes_left);
 3107|   146k|            if(ret) return ret;
  ------------------
  |  Branch (3107:16): [True: 1.00k, False: 145k]
  ------------------
 3108|   146k|        }
 3109|       |
 3110|   776k|    }
 3111|       |
 3112|  13.0k|    return ret;
 3113|   649k|}
spng.c:read_header:
 1060|   823k|{
 1061|   823k|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1061:8): [True: 0, False: 823k]
  ------------------
 1062|       |
 1063|   823k|    int ret;
 1064|   823k|    struct spng_chunk chunk = { 0 };
 1065|       |
 1066|   823k|    ret = read_and_check_crc(ctx);
 1067|   823k|    if(ret)
  ------------------
  |  Branch (1067:8): [True: 321k, False: 501k]
  ------------------
 1068|   321k|    {
 1069|   321k|        if(ret == -SPNG_CRC_DISCARD)
  ------------------
  |  Branch (1069:12): [True: 320k, False: 1.04k]
  ------------------
 1070|   320k|        {
 1071|   320k|            ctx->discard = 1;
 1072|   320k|        }
 1073|  1.04k|        else return ret;
 1074|   321k|    }
 1075|       |
 1076|   822k|    ret = read_data(ctx, 8);
 1077|   822k|    if(ret) return ret;
  ------------------
  |  Branch (1077:8): [True: 14.4k, False: 807k]
  ------------------
 1078|       |
 1079|   807k|    chunk.offset = ctx->bytes_read - 8;
 1080|       |
 1081|   807k|    chunk.length = read_u32(ctx->data);
 1082|       |
 1083|   807k|    memcpy(&chunk.type, ctx->data + 4, 4);
 1084|       |
 1085|   807k|    if(chunk.length > spng_u32max) return SPNG_ECHUNK_STDLEN;
  ------------------
  |  Branch (1085:8): [True: 503, False: 807k]
  ------------------
 1086|       |
 1087|   807k|    ctx->cur_chunk_bytes_left = chunk.length;
 1088|       |
 1089|   807k|    if(is_critical_chunk(&chunk) && ctx->crc_action_critical == SPNG_CRC_USE) ctx->skip_crc = 1;
  ------------------
  |  Branch (1089:8): [True: 34.5k, False: 772k]
  |  Branch (1089:37): [True: 0, False: 34.5k]
  ------------------
 1090|   807k|    else if(ctx->crc_action_ancillary == SPNG_CRC_USE) ctx->skip_crc = 1;
  ------------------
  |  Branch (1090:13): [True: 0, False: 807k]
  ------------------
 1091|   807k|    else ctx->skip_crc = 0;
 1092|       |
 1093|   807k|    if(!ctx->skip_crc)
  ------------------
  |  Branch (1093:8): [True: 807k, False: 0]
  ------------------
 1094|   807k|    {
 1095|   807k|        ctx->cur_actual_crc = crc32(0, NULL, 0);
  ------------------
  |  |   46|   807k|#  define crc32                 z_crc32
  ------------------
 1096|   807k|        ctx->cur_actual_crc = crc32(ctx->cur_actual_crc, chunk.type, 4);
  ------------------
  |  |   46|   807k|#  define crc32                 z_crc32
  ------------------
 1097|   807k|    }
 1098|       |
 1099|   807k|    ctx->current_chunk = chunk;
 1100|       |
 1101|   807k|    return 0;
 1102|   807k|}
spng.c:is_small_chunk:
 2262|   777k|{
 2263|   777k|    if(!memcmp(type, type_plte, 4)) return 1;
  ------------------
  |  Branch (2263:8): [True: 2.59k, False: 774k]
  ------------------
 2264|   774k|    else if(!memcmp(type, type_chrm, 4)) return 1;
  ------------------
  |  Branch (2264:13): [True: 3.64k, False: 770k]
  ------------------
 2265|   770k|    else if(!memcmp(type, type_gama, 4)) return 1;
  ------------------
  |  Branch (2265:13): [True: 11.7k, False: 759k]
  ------------------
 2266|   759k|    else if(!memcmp(type, type_sbit, 4)) return 1;
  ------------------
  |  Branch (2266:13): [True: 10.6k, False: 748k]
  ------------------
 2267|   748k|    else if(!memcmp(type, type_srgb, 4)) return 1;
  ------------------
  |  Branch (2267:13): [True: 2.61k, False: 746k]
  ------------------
 2268|   746k|    else if(!memcmp(type, type_bkgd, 4)) return 1;
  ------------------
  |  Branch (2268:13): [True: 28.3k, False: 717k]
  ------------------
 2269|   717k|    else if(!memcmp(type, type_trns, 4)) return 1;
  ------------------
  |  Branch (2269:13): [True: 22.5k, False: 695k]
  ------------------
 2270|   695k|    else if(!memcmp(type, type_hist, 4)) return 1;
  ------------------
  |  Branch (2270:13): [True: 6.76k, False: 688k]
  ------------------
 2271|   688k|    else if(!memcmp(type, type_phys, 4)) return 1;
  ------------------
  |  Branch (2271:13): [True: 6.19k, False: 682k]
  ------------------
 2272|   682k|    else if(!memcmp(type, type_time, 4)) return 1;
  ------------------
  |  Branch (2272:13): [True: 10.0k, False: 672k]
  ------------------
 2273|   672k|    else if(!memcmp(type, type_offs, 4)) return 1;
  ------------------
  |  Branch (2273:13): [True: 2.26k, False: 669k]
  ------------------
 2274|   669k|    else return 0;
 2275|   777k|}
spng.c:read_and_check_crc:
 1029|   823k|{
 1030|   823k|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1030:8): [True: 0, False: 823k]
  ------------------
 1031|       |
 1032|   823k|    int ret;
 1033|   823k|    ret = read_data(ctx, 4);
 1034|   823k|    if(ret) return ret;
  ------------------
  |  Branch (1034:8): [True: 12.7k, False: 810k]
  ------------------
 1035|       |
 1036|   810k|    ctx->current_chunk.crc = read_u32(ctx->data);
 1037|       |
 1038|   810k|    if(ctx->skip_crc) return 0;
  ------------------
  |  Branch (1038:8): [True: 0, False: 810k]
  ------------------
 1039|       |
 1040|   810k|    if(ctx->cur_actual_crc != ctx->current_chunk.crc)
  ------------------
  |  Branch (1040:8): [True: 309k, False: 501k]
  ------------------
 1041|   309k|    {
 1042|   309k|        if(is_critical_chunk(&ctx->current_chunk))
  ------------------
  |  Branch (1042:12): [True: 1.30k, False: 307k]
  ------------------
 1043|  1.30k|        {
 1044|  1.30k|            if(ctx->crc_action_critical == SPNG_CRC_USE) return 0;
  ------------------
  |  Branch (1044:16): [True: 0, False: 1.30k]
  ------------------
 1045|  1.30k|        }
 1046|   307k|        else
 1047|   307k|        {
 1048|   307k|            if(ctx->crc_action_ancillary == SPNG_CRC_USE) return 0;
  ------------------
  |  Branch (1048:16): [True: 0, False: 307k]
  ------------------
 1049|   307k|            if(ctx->crc_action_ancillary == SPNG_CRC_DISCARD) return -SPNG_CRC_DISCARD;
  ------------------
  |  Branch (1049:16): [True: 307k, False: 0]
  ------------------
 1050|   307k|        }
 1051|       |
 1052|  1.30k|        return SPNG_ECHUNK_CRC;
 1053|   309k|    }
 1054|       |
 1055|   501k|    return 0;
 1056|   810k|}
spng.c:read_s32:
  462|  1.80k|{
  463|  1.80k|    int32_t ret = (int32_t)read_u32(src);
  464|       |
  465|  1.80k|    return ret;
  466|  1.80k|}
spng.c:increase_cache_usage:
  723|   611k|{
  724|   611k|    if(ctx == NULL || !bytes) return SPNG_EINTERNAL;
  ------------------
  |  Branch (724:8): [True: 0, False: 611k]
  |  Branch (724:23): [True: 0, False: 611k]
  ------------------
  725|       |
  726|   611k|    if(new_chunk)
  ------------------
  |  Branch (726:8): [True: 333k, False: 277k]
  ------------------
  727|   333k|    {
  728|   333k|        ctx->chunk_count_total++;
  729|   333k|        if(ctx->chunk_count_total < 1) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (729:12): [True: 0, False: 333k]
  ------------------
  730|       |
  731|   333k|        if(ctx->chunk_count_total > ctx->chunk_count_limit) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (731:12): [True: 14, False: 333k]
  ------------------
  732|   333k|    }
  733|       |
  734|   611k|    size_t new_usage = ctx->chunk_cache_usage + bytes;
  735|       |
  736|   611k|    if(new_usage < ctx->chunk_cache_usage) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (736:8): [True: 0, False: 611k]
  ------------------
  737|       |
  738|   611k|    if(new_usage > ctx->chunk_cache_limit) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (738:8): [True: 0, False: 611k]
  ------------------
  739|       |
  740|   611k|    ctx->chunk_cache_usage = new_usage;
  741|       |
  742|   611k|    return 0;
  743|   611k|}
spng.c:read_chunk_bytes2:
 1125|   106k|{
 1126|   106k|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1126:8): [True: 0, False: 106k]
  ------------------
 1127|   106k|    if(!ctx->cur_chunk_bytes_left || !bytes) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1127:8): [True: 0, False: 106k]
  |  Branch (1127:38): [True: 0, False: 106k]
  ------------------
 1128|   106k|    if(bytes > ctx->cur_chunk_bytes_left) return SPNG_EINTERNAL; /* XXX: more specific error? */
  ------------------
  |  Branch (1128:8): [True: 0, False: 106k]
  ------------------
 1129|       |
 1130|   106k|    int ret;
 1131|   106k|    uint32_t len = bytes;
 1132|       |
 1133|   106k|    if(ctx->streaming && len > SPNG_READ_SIZE) len = SPNG_READ_SIZE;
  ------------------
  |  |   30|   106k|#define SPNG_READ_SIZE (8192)
  ------------------
                  if(ctx->streaming && len > SPNG_READ_SIZE) len = SPNG_READ_SIZE;
  ------------------
  |  |   30|  1.23k|#define SPNG_READ_SIZE (8192)
  ------------------
  |  Branch (1133:8): [True: 106k, False: 0]
  |  Branch (1133:26): [True: 1.23k, False: 105k]
  ------------------
 1134|       |
 1135|   219k|    while(bytes)
  ------------------
  |  Branch (1135:11): [True: 113k, False: 105k]
  ------------------
 1136|   113k|    {
 1137|   113k|        if(len > bytes) len = bytes;
  ------------------
  |  Branch (1137:12): [True: 434, False: 113k]
  ------------------
 1138|       |
 1139|   113k|        ret = ctx->read_fn(ctx, ctx->stream_user_ptr, out, len);
 1140|   113k|        if(ret) return ret;
  ------------------
  |  Branch (1140:12): [True: 1.08k, False: 112k]
  ------------------
 1141|       |
 1142|   112k|        if(!ctx->streaming) memcpy(out, ctx->data, len);
  ------------------
  |  Branch (1142:12): [True: 0, False: 112k]
  ------------------
 1143|       |
 1144|   112k|        ctx->bytes_read += len;
 1145|   112k|        if(ctx->bytes_read < len) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (1145:12): [True: 0, False: 112k]
  ------------------
 1146|       |
 1147|   112k|        if(!ctx->skip_crc) ctx->cur_actual_crc = crc32(ctx->cur_actual_crc, out, len);
  ------------------
  |  |   46|   112k|#  define crc32                 z_crc32
  ------------------
  |  Branch (1147:12): [True: 112k, False: 0]
  ------------------
 1148|       |
 1149|   112k|        ctx->cur_chunk_bytes_left -= len;
 1150|       |
 1151|   112k|        out = (char*)out + len;
 1152|   112k|        bytes -= len;
 1153|   112k|        len = SPNG_READ_SIZE;
  ------------------
  |  |   30|   112k|#define SPNG_READ_SIZE (8192)
  ------------------
 1154|   112k|    }
 1155|       |
 1156|   105k|    return 0;
 1157|   106k|}
spng.c:spng__inflate_stream:
 1254|   144k|{
 1255|   144k|    int ret = spng__inflate_init(ctx, 15);
 1256|   144k|    if(ret) return ret;
  ------------------
  |  Branch (1256:8): [True: 0, False: 144k]
  ------------------
 1257|       |
 1258|   144k|    size_t max = ctx->chunk_cache_limit - ctx->chunk_cache_usage;
 1259|       |
 1260|   144k|    if(ctx->max_chunk_size < max) max = ctx->max_chunk_size;
  ------------------
  |  Branch (1260:8): [True: 144k, False: 0]
  ------------------
 1261|       |
 1262|   144k|    if(extra > max) return SPNG_ECHUNK_LIMITS;
  ------------------
  |  Branch (1262:8): [True: 0, False: 144k]
  ------------------
 1263|   144k|    max -= extra;
 1264|       |
 1265|   144k|    uint32_t read_size;
 1266|   144k|    size_t size = 8 * 1024;
 1267|   144k|    void *t, *buf = spng__malloc(ctx, size);
 1268|       |
 1269|   144k|    if(buf == NULL) return SPNG_EMEM;
  ------------------
  |  Branch (1269:8): [True: 0, False: 144k]
  ------------------
 1270|       |
 1271|   144k|    z_stream *stream = &ctx->zstream;
 1272|       |
 1273|   144k|    if(start_buf != NULL && start_len)
  ------------------
  |  Branch (1273:8): [True: 144k, False: 0]
  |  Branch (1273:29): [True: 143k, False: 1.30k]
  ------------------
 1274|   143k|    {
 1275|   143k|        stream->avail_in = (uInt)start_len;
 1276|   143k|        stream->next_in = start_buf;
 1277|   143k|    }
 1278|  1.30k|    else
 1279|  1.30k|    {
 1280|  1.30k|        stream->avail_in = 0;
 1281|  1.30k|        stream->next_in = NULL;
 1282|  1.30k|    }
 1283|       |
 1284|   144k|    stream->avail_out = (uInt)size;
 1285|   144k|    stream->next_out = buf;
 1286|       |
 1287|   197k|    while(ret != Z_STREAM_END)
  ------------------
  |  |  182|   197k|#define Z_STREAM_END    1
  ------------------
  |  Branch (1287:11): [True: 197k, False: 0]
  ------------------
 1288|   197k|    {
 1289|   197k|        ret = inflate(stream, Z_NO_FLUSH);
  ------------------
  |  |  114|   197k|#  define inflate               z_inflate
  ------------------
                      ret = inflate(stream, Z_NO_FLUSH);
  ------------------
  |  |  172|   197k|#define Z_NO_FLUSH      0
  ------------------
 1290|       |
 1291|   197k|        if(ret == Z_STREAM_END) break;
  ------------------
  |  |  182|   197k|#define Z_STREAM_END    1
  ------------------
  |  Branch (1291:12): [True: 87.2k, False: 109k]
  ------------------
 1292|       |
 1293|   109k|        if(ret != Z_OK && ret != Z_BUF_ERROR)
  ------------------
  |  |  181|   219k|#define Z_OK            0
  ------------------
                      if(ret != Z_OK && ret != Z_BUF_ERROR)
  ------------------
  |  |  188|  41.7k|#define Z_BUF_ERROR    (-5)
  ------------------
  |  Branch (1293:12): [True: 41.7k, False: 68.1k]
  |  Branch (1293:27): [True: 40.4k, False: 1.31k]
  ------------------
 1294|  40.4k|        {
 1295|  40.4k|            ret = SPNG_EZLIB;
 1296|  40.4k|            goto err;
 1297|  40.4k|        }
 1298|       |
 1299|  69.4k|        if(!stream->avail_out) /* Resize buffer */
  ------------------
  |  Branch (1299:12): [True: 37.6k, False: 31.7k]
  ------------------
 1300|  37.6k|        {
 1301|       |            /* overflow or reached chunk/cache limit */
 1302|  37.6k|            if( (2 > SIZE_MAX / size) || (size > max / 2) )
  ------------------
  |  Branch (1302:17): [True: 0, False: 37.6k]
  |  Branch (1302:42): [True: 0, False: 37.6k]
  ------------------
 1303|      0|            {
 1304|      0|                ret = SPNG_ECHUNK_LIMITS;
 1305|      0|                goto err;
 1306|      0|            }
 1307|       |
 1308|  37.6k|            size *= 2;
 1309|       |
 1310|  37.6k|            t = spng__realloc(ctx, buf, size);
 1311|  37.6k|            if(t == NULL) goto mem;
  ------------------
  |  Branch (1311:16): [True: 0, False: 37.6k]
  ------------------
 1312|       |
 1313|  37.6k|            buf = t;
 1314|       |
 1315|  37.6k|            stream->avail_out = (uInt)size / 2;
 1316|  37.6k|            stream->next_out = (unsigned char*)buf + size / 2;
 1317|  37.6k|        }
 1318|  31.7k|        else if(!stream->avail_in) /* Read more chunk bytes */
  ------------------
  |  Branch (1318:17): [True: 31.7k, False: 0]
  ------------------
 1319|  31.7k|        {
 1320|  31.7k|            read_size = ctx->cur_chunk_bytes_left;
 1321|  31.7k|            if(ctx->streaming && read_size > SPNG_READ_SIZE) read_size = SPNG_READ_SIZE;
  ------------------
  |  |   30|  31.7k|#define SPNG_READ_SIZE (8192)
  ------------------
                          if(ctx->streaming && read_size > SPNG_READ_SIZE) read_size = SPNG_READ_SIZE;
  ------------------
  |  |   30|  9.12k|#define SPNG_READ_SIZE (8192)
  ------------------
  |  Branch (1321:16): [True: 31.7k, False: 0]
  |  Branch (1321:34): [True: 9.12k, False: 22.6k]
  ------------------
 1322|       |
 1323|  31.7k|            ret = read_chunk_bytes(ctx, read_size);
 1324|       |
 1325|  31.7k|            if(ret)
  ------------------
  |  Branch (1325:16): [True: 17.0k, False: 14.6k]
  ------------------
 1326|  17.0k|            {
 1327|  17.0k|                if(!read_size) ret = SPNG_EZLIB;
  ------------------
  |  Branch (1327:20): [True: 15.9k, False: 1.11k]
  ------------------
 1328|       |
 1329|  17.0k|                goto err;
 1330|  17.0k|            }
 1331|       |
 1332|  14.6k|            stream->avail_in = read_size;
 1333|  14.6k|            stream->next_in = ctx->data;
 1334|  14.6k|        }
 1335|  69.4k|    }
 1336|       |
 1337|  87.2k|    size = stream->total_out;
 1338|       |
 1339|  87.2k|    if(!size)
  ------------------
  |  Branch (1339:8): [True: 861, False: 86.3k]
  ------------------
 1340|    861|    {
 1341|    861|        ret = SPNG_EZLIB;
 1342|    861|        goto err;
 1343|    861|    }
 1344|       |
 1345|  86.3k|    size += extra;
 1346|  86.3k|    if(size < extra) goto mem;
  ------------------
  |  Branch (1346:8): [True: 0, False: 86.3k]
  ------------------
 1347|       |
 1348|  86.3k|    t = spng__realloc(ctx, buf, size);
 1349|  86.3k|    if(t == NULL) goto mem;
  ------------------
  |  Branch (1349:8): [True: 0, False: 86.3k]
  ------------------
 1350|       |
 1351|  86.3k|    buf = t;
 1352|       |
 1353|  86.3k|    (void)increase_cache_usage(ctx, size, 0);
 1354|       |
 1355|  86.3k|    *out = buf;
 1356|  86.3k|    *len = size;
 1357|       |
 1358|  86.3k|    return 0;
 1359|       |
 1360|      0|mem:
 1361|      0|    ret = SPNG_EMEM;
 1362|  58.4k|err:
 1363|  58.4k|    spng__free(ctx, buf);
 1364|  58.4k|    return ret;
 1365|      0|}
spng.c:spng__realloc:
  416|   457k|{
  417|   457k|    return ctx->alloc.realloc_fn(ptr, size);
  418|   457k|}
spng.c:text_undo:
 2341|   137k|{
 2342|   137k|    struct spng_text2 *text = &ctx->text_list[ctx->n_text - 1];
 2343|       |
 2344|   137k|    spng__free(ctx, text->keyword);
 2345|   137k|    if(text->compression_flag) spng__free(ctx, text->text);
  ------------------
  |  Branch (2345:8): [True: 60.8k, False: 76.8k]
  ------------------
 2346|       |
 2347|   137k|    decrease_cache_usage(ctx, text->cache_usage);
 2348|   137k|    decrease_cache_usage(ctx, sizeof(struct spng_text2));
 2349|       |
 2350|   137k|    text->keyword = NULL;
 2351|   137k|    text->text = NULL;
 2352|       |
 2353|   137k|    ctx->n_text--;
 2354|   137k|}
spng.c:splt_undo:
 2327|   103k|{
 2328|   103k|    struct spng_splt *splt = &ctx->splt_list[ctx->n_splt - 1];
 2329|       |
 2330|   103k|    spng__free(ctx, splt->entries);
 2331|       |
 2332|   103k|    decrease_cache_usage(ctx, sizeof(struct spng_splt));
 2333|   103k|    decrease_cache_usage(ctx, splt->n_entries * sizeof(struct spng_splt_entry));
 2334|       |
 2335|   103k|    splt->entries = NULL;
 2336|       |
 2337|   103k|    ctx->n_splt--;
 2338|   103k|}
spng.c:decrease_cache_usage:
  746|   487k|{
  747|   487k|    if(ctx == NULL || !usage) return SPNG_EINTERNAL;
  ------------------
  |  Branch (747:8): [True: 0, False: 487k]
  |  Branch (747:23): [True: 196k, False: 291k]
  ------------------
  748|   291k|    if(usage > ctx->chunk_cache_usage) return SPNG_EINTERNAL;
  ------------------
  |  Branch (748:8): [True: 0, False: 291k]
  ------------------
  749|       |
  750|   291k|    ctx->chunk_cache_usage -= usage;
  751|       |
  752|   291k|    return 0;
  753|   291k|}
spng.c:is_critical_chunk:
  756|  2.66M|{
  757|  2.66M|    if(chunk == NULL) return 0;
  ------------------
  |  Branch (757:8): [True: 0, False: 2.66M]
  ------------------
  758|  2.66M|    if((chunk->type[0] & (1 << 5)) == 0) return 1;
  ------------------
  |  Branch (758:8): [True: 49.8k, False: 2.61M]
  ------------------
  759|       |
  760|  2.61M|    return 0;
  761|  2.66M|}
spng.c:check_decode_fmt:
  639|  9.62k|{
  640|  9.62k|    switch(fmt)
  641|  9.62k|    {
  642|      0|        case SPNG_FMT_RGBA8:
  ------------------
  |  Branch (642:9): [True: 0, False: 9.62k]
  ------------------
  643|      0|        case SPNG_FMT_RGBA16:
  ------------------
  |  Branch (643:9): [True: 0, False: 9.62k]
  ------------------
  644|      0|        case SPNG_FMT_RGB8:
  ------------------
  |  Branch (644:9): [True: 0, False: 9.62k]
  ------------------
  645|  9.62k|        case SPNG_FMT_PNG:
  ------------------
  |  Branch (645:9): [True: 9.62k, False: 0]
  ------------------
  646|  9.62k|        case SPNG_FMT_RAW:
  ------------------
  |  Branch (646:9): [True: 0, False: 9.62k]
  ------------------
  647|  9.62k|            return 0;
  648|      0|        case SPNG_FMT_G8:
  ------------------
  |  Branch (648:9): [True: 0, False: 9.62k]
  ------------------
  649|      0|        case SPNG_FMT_GA8:
  ------------------
  |  Branch (649:9): [True: 0, False: 9.62k]
  ------------------
  650|      0|            if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE && ihdr->bit_depth <= 8) return 0;
  ------------------
  |  Branch (650:16): [True: 0, False: 0]
  |  Branch (650:65): [True: 0, False: 0]
  ------------------
  651|      0|            else return SPNG_EFMT;
  652|      0|        case SPNG_FMT_GA16:
  ------------------
  |  Branch (652:9): [True: 0, False: 9.62k]
  ------------------
  653|      0|            if(ihdr->color_type == SPNG_COLOR_TYPE_GRAYSCALE && ihdr->bit_depth == 16) return 0;
  ------------------
  |  Branch (653:16): [True: 0, False: 0]
  |  Branch (653:65): [True: 0, False: 0]
  ------------------
  654|      0|            else return SPNG_EFMT;
  655|      0|        default: return SPNG_EFMT;
  ------------------
  |  Branch (655:9): [True: 0, False: 9.62k]
  ------------------
  656|  9.62k|    }
  657|  9.62k|}
spng.c:calculate_image_width:
  660|  9.62k|{
  661|  9.62k|    if(ihdr == NULL || len == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (661:8): [True: 0, False: 9.62k]
  |  Branch (661:24): [True: 0, False: 9.62k]
  ------------------
  662|       |
  663|  9.62k|    size_t res = ihdr->width;
  664|  9.62k|    unsigned bytes_per_pixel;
  665|       |
  666|  9.62k|    switch(fmt)
  667|  9.62k|    {
  668|      0|        case SPNG_FMT_RGBA8:
  ------------------
  |  Branch (668:9): [True: 0, False: 9.62k]
  ------------------
  669|      0|        case SPNG_FMT_GA16:
  ------------------
  |  Branch (669:9): [True: 0, False: 9.62k]
  ------------------
  670|      0|            bytes_per_pixel = 4;
  671|      0|            break;
  672|      0|        case SPNG_FMT_RGBA16:
  ------------------
  |  Branch (672:9): [True: 0, False: 9.62k]
  ------------------
  673|      0|            bytes_per_pixel = 8;
  674|      0|            break;
  675|      0|        case SPNG_FMT_RGB8:
  ------------------
  |  Branch (675:9): [True: 0, False: 9.62k]
  ------------------
  676|      0|            bytes_per_pixel = 3;
  677|      0|            break;
  678|  9.62k|        case SPNG_FMT_PNG:
  ------------------
  |  Branch (678:9): [True: 9.62k, False: 0]
  ------------------
  679|  9.62k|        case SPNG_FMT_RAW:
  ------------------
  |  Branch (679:9): [True: 0, False: 9.62k]
  ------------------
  680|  9.62k|        {
  681|  9.62k|            int ret = calculate_scanline_width(ihdr, ihdr->width, &res);
  682|  9.62k|            if(ret) return ret;
  ------------------
  |  Branch (682:16): [True: 0, False: 9.62k]
  ------------------
  683|       |
  684|  9.62k|            res -= 1; /* exclude filter byte */
  685|  9.62k|            bytes_per_pixel = 1;
  686|  9.62k|            break;
  687|  9.62k|        }
  688|      0|        case SPNG_FMT_G8:
  ------------------
  |  Branch (688:9): [True: 0, False: 9.62k]
  ------------------
  689|      0|            bytes_per_pixel = 1;
  690|      0|            break;
  691|      0|        case SPNG_FMT_GA8:
  ------------------
  |  Branch (691:9): [True: 0, False: 9.62k]
  ------------------
  692|      0|            bytes_per_pixel = 2;
  693|      0|            break;
  694|      0|        default: return SPNG_EINTERNAL;
  ------------------
  |  Branch (694:9): [True: 0, False: 9.62k]
  ------------------
  695|  9.62k|    }
  696|       |
  697|  9.62k|    if(res > SIZE_MAX / bytes_per_pixel) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (697:8): [True: 0, False: 9.62k]
  ------------------
  698|  9.62k|    res = res * bytes_per_pixel;
  699|       |
  700|  9.62k|    *len = res;
  701|       |
  702|  9.62k|    return 0;
  703|  9.62k|}
spng.c:calculate_scanline_width:
  571|  80.0k|{
  572|  80.0k|    if(ihdr == NULL || !width) return SPNG_EINTERNAL;
  ------------------
  |  Branch (572:8): [True: 0, False: 80.0k]
  |  Branch (572:24): [True: 0, False: 80.0k]
  ------------------
  573|       |
  574|  80.0k|    size_t res = num_channels(ihdr) * ihdr->bit_depth;
  575|       |
  576|  80.0k|    if(res > SIZE_MAX / width) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (576:8): [True: 0, False: 80.0k]
  ------------------
  577|  80.0k|    res = res * width;
  578|       |
  579|  80.0k|    res += 15; /* Filter byte + 7 for rounding */
  580|       |
  581|  80.0k|    if(res < 15) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (581:8): [True: 0, False: 80.0k]
  ------------------
  582|       |
  583|  80.0k|    res /= 8;
  584|       |
  585|  80.0k|    if(res > UINT32_MAX) return SPNG_EOVERFLOW;
  ------------------
  |  Branch (585:8): [True: 35, False: 80.0k]
  ------------------
  586|       |
  587|  80.0k|    *scanline_width = res;
  588|       |
  589|  80.0k|    return 0;
  590|  80.0k|}
spng.c:read_idat_bytes:
 1369|  31.8k|{
 1370|  31.8k|    if(ctx == NULL || bytes_read == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1370:8): [True: 0, False: 31.8k]
  |  Branch (1370:23): [True: 0, False: 31.8k]
  ------------------
 1371|  31.8k|    if(memcmp(ctx->current_chunk.type, type_idat, 4)) return SPNG_EIDAT_TOO_SHORT;
  ------------------
  |  Branch (1371:8): [True: 0, False: 31.8k]
  ------------------
 1372|       |
 1373|  31.8k|    int ret;
 1374|  31.8k|    uint32_t len;
 1375|       |
 1376|  50.7k|    while(!ctx->cur_chunk_bytes_left)
  ------------------
  |  Branch (1376:11): [True: 21.9k, False: 28.8k]
  ------------------
 1377|  21.9k|    {
 1378|  21.9k|        ret = read_header(ctx);
 1379|  21.9k|        if(ret) return ret;
  ------------------
  |  Branch (1379:12): [True: 2.91k, False: 19.0k]
  ------------------
 1380|       |
 1381|  19.0k|        if(memcmp(ctx->current_chunk.type, type_idat, 4)) return SPNG_EIDAT_TOO_SHORT;
  ------------------
  |  Branch (1381:12): [True: 114, False: 18.9k]
  ------------------
 1382|  19.0k|    }
 1383|       |
 1384|  28.8k|    if(ctx->streaming)
  ------------------
  |  Branch (1384:8): [True: 28.8k, False: 0]
  ------------------
 1385|  28.8k|    {/* TODO: estimate bytes to read for progressive reads */
 1386|  28.8k|        len = SPNG_READ_SIZE;
  ------------------
  |  |   30|  28.8k|#define SPNG_READ_SIZE (8192)
  ------------------
 1387|  28.8k|        if(len > ctx->cur_chunk_bytes_left) len = ctx->cur_chunk_bytes_left;
  ------------------
  |  Branch (1387:12): [True: 27.9k, False: 841]
  ------------------
 1388|  28.8k|    }
 1389|      0|    else len = ctx->current_chunk.length;
 1390|       |
 1391|  28.8k|    ret = read_chunk_bytes(ctx, len);
 1392|       |
 1393|  28.8k|    *bytes_read = len;
 1394|       |
 1395|  28.8k|    return ret;
 1396|  31.8k|}
spng.c:read_u16:
  447|  48.8M|{
  448|  48.8M|    const unsigned char *data = src;
  449|       |
  450|  48.8M|    return (data[0] & 0xFFU) << 8 | (data[1] & 0xFFU);
  451|  48.8M|}
spng.c:spng__inflate_init:
 1190|   154k|{
 1191|   154k|    if(ctx->zstream.state) inflateEnd(&ctx->zstream);
  ------------------
  |  |  121|   137k|#  define inflateEnd            z_inflateEnd
  ------------------
  |  Branch (1191:8): [True: 137k, False: 16.3k]
  ------------------
 1192|       |
 1193|   154k|    ctx->inflate = 1;
  ------------------
  |  |  114|   154k|#  define inflate               z_inflate
  ------------------
 1194|       |
 1195|   154k|    ctx->zstream.zalloc = spng__zalloc;
 1196|   154k|    ctx->zstream.zfree = spng__zfree;
 1197|   154k|    ctx->zstream.opaque = ctx;
 1198|       |
 1199|   154k|    if(inflateInit2(&ctx->zstream, window_bits) != Z_OK) return SPNG_EZLIB_INIT;
  ------------------
  |  |  125|   154k|#  define inflateInit2          z_inflateInit2
  |  |  ------------------
  |  |  |  | 1926|   154k|          inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
  |  |  |  |  ------------------
  |  |  |  |  |  |  126|   154k|#  define inflateInit2_         z_inflateInit2_
  |  |  |  |  ------------------
  |  |  |  |                         inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|   154k|#define ZLIB_VERSION "1.3.2"
  |  |  |  |  ------------------
  |  |  |  | 1927|   154k|                        (int)sizeof(z_stream))
  |  |  ------------------
  ------------------
                  if(inflateInit2(&ctx->zstream, window_bits) != Z_OK) return SPNG_EZLIB_INIT;
  ------------------
  |  |  181|   154k|#define Z_OK            0
  ------------------
  |  Branch (1199:8): [True: 0, False: 154k]
  ------------------
 1200|       |
 1201|   154k|#if ZLIB_VERNUM >= 0x1290 && !defined(SPNG_USE_MINIZ)
 1202|       |
 1203|   154k|    int validate = 1;
 1204|       |
 1205|   154k|    if(ctx->flags & SPNG_CTX_IGNORE_ADLER32) validate = 0;
  ------------------
  |  Branch (1205:8): [True: 0, False: 154k]
  ------------------
 1206|       |
 1207|   154k|    if(is_critical_chunk(&ctx->current_chunk))
  ------------------
  |  Branch (1207:8): [True: 9.33k, False: 144k]
  ------------------
 1208|  9.33k|    {
 1209|  9.33k|        if(ctx->crc_action_critical == SPNG_CRC_USE) validate = 0;
  ------------------
  |  Branch (1209:12): [True: 0, False: 9.33k]
  ------------------
 1210|  9.33k|    }
 1211|   144k|    else /* ancillary */
 1212|   144k|    {
 1213|   144k|        if(ctx->crc_action_ancillary == SPNG_CRC_USE) validate = 0;
  ------------------
  |  Branch (1213:12): [True: 0, False: 144k]
  ------------------
 1214|   144k|    }
 1215|       |
 1216|   154k|    if(inflateValidate(&ctx->zstream, validate)) return SPNG_EZLIB_INIT;
  ------------------
  |  |  137|   154k|#  define inflateValidate       z_inflateValidate
  ------------------
  |  Branch (1216:8): [True: 0, False: 154k]
  ------------------
 1217|       |
 1218|       |#else /* This requires zlib >= 1.2.11 */
 1219|       |#if 0 /* libjpeg-turbo: Silence warning */
 1220|       |    #pragma message ("inflateValidate() not available, SPNG_CTX_IGNORE_ADLER32 will be ignored")
 1221|       |#endif
 1222|       |#endif
 1223|       |
 1224|   154k|    return 0;
 1225|   154k|}
spng.c:spng__zalloc:
  430|   179k|{
  431|   179k|    spng_ctx *ctx = opaque;
  432|       |
  433|   179k|    if(size > SIZE_MAX / items) return NULL;
  ------------------
  |  Branch (433:8): [True: 0, False: 179k]
  ------------------
  434|       |
  435|   179k|    size_t len = (size_t)items * size;
  436|       |
  437|   179k|    return spng__malloc(ctx, len);
  438|   179k|}
spng.c:spng__zfree:
  441|   179k|{
  442|   179k|    spng_ctx *ctx = opqaue;
  443|   179k|    spng__free(ctx, ptr);
  444|   179k|}
spng.c:spng__malloc:
  406|   532k|{
  407|   532k|    return ctx->alloc.malloc_fn(size);
  408|   532k|}
spng.c:sample_to_target:
 1722|   342k|{
 1723|   342k|    if(bit_depth == sbits)
  ------------------
  |  Branch (1723:8): [True: 342k, False: 0]
  ------------------
 1724|   342k|    {
 1725|   342k|        if(target == sbits) return sample; /* No scaling */
  ------------------
  |  Branch (1725:12): [True: 342k, False: 0]
  ------------------
 1726|   342k|    }/* bit_depth > sbits */
 1727|      0|    else sample = sample >> (bit_depth - sbits); /* Shift significant bits to bottom */
 1728|       |
 1729|       |    /* Downscale */
 1730|      0|    if(target < sbits) return sample >> (sbits - target);
  ------------------
  |  Branch (1730:8): [True: 0, False: 0]
  ------------------
 1731|       |
 1732|       |    /* Upscale using left bit replication */
 1733|      0|    int8_t shift_amount = target - sbits;
 1734|      0|    uint16_t sample_bits = sample;
 1735|      0|    sample = 0;
 1736|       |
 1737|      0|    while(shift_amount >= 0)
  ------------------
  |  Branch (1737:11): [True: 0, False: 0]
  ------------------
 1738|      0|    {
 1739|      0|        sample = sample | (sample_bits << shift_amount);
 1740|      0|        shift_amount -= sbits;
 1741|      0|    }
 1742|       |
 1743|      0|    int8_t partial = shift_amount + (int8_t)sbits;
 1744|       |
 1745|      0|    if(partial != 0) sample = sample | (sample_bits >> abs(shift_amount));
  ------------------
  |  Branch (1745:8): [True: 0, False: 0]
  ------------------
 1746|       |
 1747|      0|    return sample;
 1748|      0|}
spng.c:read_scanline_bytes:
 1399|   853k|{
 1400|   853k|    if(ctx == NULL || dest == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (1400:8): [True: 0, False: 853k]
  |  Branch (1400:23): [True: 0, False: 853k]
  ------------------
 1401|       |
 1402|   853k|    int ret = Z_OK;
  ------------------
  |  |  181|   853k|#define Z_OK            0
  ------------------
 1403|   853k|    uint32_t bytes_read;
 1404|       |
 1405|   853k|    z_stream *zstream = &ctx->zstream;
 1406|       |
 1407|   853k|    zstream->avail_out = (uInt)len;
 1408|   853k|    zstream->next_out = dest;
 1409|       |
 1410|  1.74M|    while(zstream->avail_out != 0)
  ------------------
  |  Branch (1410:11): [True: 894k, False: 848k]
  ------------------
 1411|   894k|    {
 1412|   894k|        ret = inflate(zstream, Z_NO_FLUSH);
  ------------------
  |  |  114|   894k|#  define inflate               z_inflate
  ------------------
                      ret = inflate(zstream, Z_NO_FLUSH);
  ------------------
  |  |  172|   894k|#define Z_NO_FLUSH      0
  ------------------
 1413|       |
 1414|   894k|        if(ret == Z_OK) continue;
  ------------------
  |  |  181|   894k|#define Z_OK            0
  ------------------
  |  Branch (1414:12): [True: 869k, False: 25.1k]
  ------------------
 1415|       |
 1416|  25.1k|        if(ret == Z_STREAM_END) /* Reached an end-marker */
  ------------------
  |  |  182|  25.1k|#define Z_STREAM_END    1
  ------------------
  |  Branch (1416:12): [True: 1.28k, False: 23.8k]
  ------------------
 1417|  1.28k|        {
 1418|  1.28k|            if(zstream->avail_out != 0) return SPNG_EIDAT_TOO_SHORT;
  ------------------
  |  Branch (1418:16): [True: 19, False: 1.26k]
  ------------------
 1419|  1.28k|        }
 1420|  23.8k|        else if(ret == Z_BUF_ERROR) /* Read more IDAT bytes */
  ------------------
  |  |  188|  23.8k|#define Z_BUF_ERROR    (-5)
  ------------------
  |  Branch (1420:17): [True: 22.2k, False: 1.61k]
  ------------------
 1421|  22.2k|        {
 1422|  22.2k|            ret = read_idat_bytes(ctx, &bytes_read);
 1423|  22.2k|            if(ret) return ret;
  ------------------
  |  Branch (1423:16): [True: 3.19k, False: 19.0k]
  ------------------
 1424|       |
 1425|  19.0k|            zstream->avail_in = bytes_read;
 1426|  19.0k|            zstream->next_in = ctx->data;
 1427|  19.0k|        }
 1428|  1.61k|        else return SPNG_EIDAT_STREAM;
 1429|  25.1k|    }
 1430|       |
 1431|   848k|    return 0;
 1432|   853k|}
spng.c:calculate_subimages:
  593|  30.6k|{
  594|  30.6k|    if(ctx == NULL) return SPNG_EINTERNAL;
  ------------------
  |  Branch (594:8): [True: 0, False: 30.6k]
  ------------------
  595|       |
  596|  30.6k|    struct spng_ihdr *ihdr = &ctx->ihdr;
  597|  30.6k|    struct spng_subimage *sub = ctx->subimage;
  598|       |
  599|  30.6k|    if(ihdr->interlace_method == 1)
  ------------------
  |  Branch (599:8): [True: 6.89k, False: 23.7k]
  ------------------
  600|  6.89k|    {
  601|  6.89k|        sub[0].width = (ihdr->width + 7) >> 3;
  602|  6.89k|        sub[0].height = (ihdr->height + 7) >> 3;
  603|  6.89k|        sub[1].width = (ihdr->width + 3) >> 3;
  604|  6.89k|        sub[1].height = (ihdr->height + 7) >> 3;
  605|  6.89k|        sub[2].width = (ihdr->width + 3) >> 2;
  606|  6.89k|        sub[2].height = (ihdr->height + 3) >> 3;
  607|  6.89k|        sub[3].width = (ihdr->width + 1) >> 2;
  608|  6.89k|        sub[3].height = (ihdr->height + 3) >> 2;
  609|  6.89k|        sub[4].width = (ihdr->width + 1) >> 1;
  610|  6.89k|        sub[4].height = (ihdr->height + 1) >> 2;
  611|  6.89k|        sub[5].width = ihdr->width >> 1;
  612|  6.89k|        sub[5].height = (ihdr->height + 1) >> 1;
  613|  6.89k|        sub[6].width = ihdr->width;
  614|  6.89k|        sub[6].height = ihdr->height >> 1;
  615|  6.89k|    }
  616|  23.7k|    else
  617|  23.7k|    {
  618|  23.7k|        sub[0].width = ihdr->width;
  619|  23.7k|        sub[0].height = ihdr->height;
  620|  23.7k|    }
  621|       |
  622|  30.6k|    int i;
  623|   245k|    for(i=0; i < 7; i++)
  ------------------
  |  Branch (623:14): [True: 214k, False: 30.6k]
  ------------------
  624|   214k|    {
  625|   214k|        if(sub[i].width == 0 || sub[i].height == 0) continue;
  ------------------
  |  Branch (625:12): [True: 143k, False: 70.6k]
  |  Branch (625:33): [True: 231, False: 70.4k]
  ------------------
  626|       |
  627|  70.4k|        int ret = calculate_scanline_width(ihdr, sub[i].width, &sub[i].scanline_width);
  628|  70.4k|        if(ret) return ret;
  ------------------
  |  Branch (628:12): [True: 35, False: 70.4k]
  ------------------
  629|       |
  630|  70.4k|        if(sub[ctx->widest_pass].scanline_width < sub[i].scanline_width) ctx->widest_pass = i;
  ------------------
  |  Branch (630:12): [True: 18.7k, False: 51.6k]
  ------------------
  631|       |
  632|  70.4k|        ctx->last_pass = i;
  633|  70.4k|    }
  634|       |
  635|  30.6k|    return 0;
  636|  30.6k|}
spng.c:num_channels:
  556|   101k|{
  557|   101k|    switch(ihdr->color_type)
  558|   101k|    {
  559|  39.2k|        case SPNG_COLOR_TYPE_TRUECOLOR: return 3;
  ------------------
  |  Branch (559:9): [True: 39.2k, False: 62.2k]
  ------------------
  560|  8.91k|        case SPNG_COLOR_TYPE_GRAYSCALE_ALPHA: return 2;
  ------------------
  |  Branch (560:9): [True: 8.91k, False: 92.5k]
  ------------------
  561|  13.6k|        case SPNG_COLOR_TYPE_TRUECOLOR_ALPHA: return 4;
  ------------------
  |  Branch (561:9): [True: 13.6k, False: 87.8k]
  ------------------
  562|  31.1k|        case SPNG_COLOR_TYPE_GRAYSCALE:
  ------------------
  |  Branch (562:9): [True: 31.1k, False: 70.3k]
  ------------------
  563|  39.6k|        case SPNG_COLOR_TYPE_INDEXED:
  ------------------
  |  Branch (563:9): [True: 8.58k, False: 92.8k]
  ------------------
  564|  39.6k|            return 1;
  565|      0|        default: return 0;
  ------------------
  |  Branch (565:9): [True: 0, False: 101k]
  ------------------
  566|   101k|    }
  567|   101k|}
spng.c:spng__free:
  421|   985k|{
  422|   985k|    ctx->alloc.free_fn(ptr);
  423|   985k|}
spng.c:file_read_fn:
 5050|  2.25M|{
 5051|  2.25M|    FILE *file = user;
 5052|  2.25M|    (void)ctx;
 5053|       |
 5054|  2.25M|    if(fread(data, n, 1, file) != 1)
  ------------------
  |  Branch (5054:8): [True: 35.0k, False: 2.22M]
  ------------------
 5055|  35.0k|    {
 5056|  35.0k|        if(feof(file)) return SPNG_IO_EOF;
  ------------------
  |  Branch (5056:12): [True: 35.0k, False: 0]
  ------------------
 5057|      0|        else return SPNG_IO_ERROR;
 5058|  35.0k|    }
 5059|       |
 5060|  2.22M|    return 0;
 5061|  2.25M|}
spng.c:check_ihdr:
 2043|  31.3k|{
 2044|  31.3k|    if(ihdr->width > spng_u32max || !ihdr->width) return SPNG_EWIDTH;
  ------------------
  |  Branch (2044:8): [True: 210, False: 31.1k]
  |  Branch (2044:37): [True: 7, False: 31.1k]
  ------------------
 2045|  31.1k|    if(ihdr->height > spng_u32max || !ihdr->height) return SPNG_EHEIGHT;
  ------------------
  |  Branch (2045:8): [True: 210, False: 30.9k]
  |  Branch (2045:38): [True: 7, False: 30.9k]
  ------------------
 2046|       |
 2047|  30.9k|    if(ihdr->width > max_width) return SPNG_EUSER_WIDTH;
  ------------------
  |  Branch (2047:8): [True: 0, False: 30.9k]
  ------------------
 2048|  30.9k|    if(ihdr->height > max_height) return SPNG_EUSER_HEIGHT;
  ------------------
  |  Branch (2048:8): [True: 0, False: 30.9k]
  ------------------
 2049|       |
 2050|  30.9k|    switch(ihdr->color_type)
 2051|  30.9k|    {
 2052|  12.5k|        case SPNG_COLOR_TYPE_GRAYSCALE:
  ------------------
  |  Branch (2052:9): [True: 12.5k, False: 18.3k]
  ------------------
 2053|  12.5k|        {
 2054|  12.5k|            if( !(ihdr->bit_depth == 1 || ihdr->bit_depth == 2 ||
  ------------------
  |  Branch (2054:19): [True: 2.72k, False: 9.84k]
  |  Branch (2054:43): [True: 1.36k, False: 8.48k]
  ------------------
 2055|  8.48k|                  ihdr->bit_depth == 4 || ihdr->bit_depth == 8 ||
  ------------------
  |  Branch (2055:19): [True: 1.74k, False: 6.74k]
  |  Branch (2055:43): [True: 5.51k, False: 1.22k]
  ------------------
 2056|  1.22k|                  ihdr->bit_depth == 16) )
  ------------------
  |  Branch (2056:19): [True: 1.13k, False: 91]
  ------------------
 2057|     91|                  return SPNG_EBIT_DEPTH;
 2058|       |
 2059|  12.4k|            break;
 2060|  12.5k|        }
 2061|  12.4k|        case SPNG_COLOR_TYPE_TRUECOLOR:
  ------------------
  |  Branch (2061:9): [True: 8.98k, False: 21.9k]
  ------------------
 2062|  10.9k|        case SPNG_COLOR_TYPE_GRAYSCALE_ALPHA:
  ------------------
  |  Branch (2062:9): [True: 2.01k, False: 28.9k]
  ------------------
 2063|  14.0k|        case SPNG_COLOR_TYPE_TRUECOLOR_ALPHA:
  ------------------
  |  Branch (2063:9): [True: 3.06k, False: 27.8k]
  ------------------
 2064|  14.0k|        {
 2065|  14.0k|            if( !(ihdr->bit_depth == 8 || ihdr->bit_depth == 16) )
  ------------------
  |  Branch (2065:19): [True: 8.54k, False: 5.52k]
  |  Branch (2065:43): [True: 5.46k, False: 63]
  ------------------
 2066|     63|                return SPNG_EBIT_DEPTH;
 2067|       |
 2068|  14.0k|            break;
 2069|  14.0k|        }
 2070|  14.0k|        case SPNG_COLOR_TYPE_INDEXED:
  ------------------
  |  Branch (2070:9): [True: 4.30k, False: 26.6k]
  ------------------
 2071|  4.30k|        {
 2072|  4.30k|            if( !(ihdr->bit_depth == 1 || ihdr->bit_depth == 2 ||
  ------------------
  |  Branch (2072:19): [True: 1.16k, False: 3.14k]
  |  Branch (2072:43): [True: 581, False: 2.56k]
  ------------------
 2073|  2.56k|                  ihdr->bit_depth == 4 || ihdr->bit_depth == 8) )
  ------------------
  |  Branch (2073:19): [True: 1.75k, False: 805]
  |  Branch (2073:43): [True: 742, False: 63]
  ------------------
 2074|     63|                return SPNG_EBIT_DEPTH;
 2075|       |
 2076|  4.24k|            break;
 2077|  4.30k|        }
 2078|  4.24k|        default: return SPNG_ECOLOR_TYPE;
  ------------------
  |  Branch (2078:9): [True: 21, False: 30.9k]
  ------------------
 2079|  30.9k|    }
 2080|       |
 2081|  30.7k|    if(ihdr->compression_method) return SPNG_ECOMPRESSION_METHOD;
  ------------------
  |  Branch (2081:8): [True: 14, False: 30.7k]
  ------------------
 2082|  30.7k|    if(ihdr->filter_method) return SPNG_EFILTER_METHOD;
  ------------------
  |  Branch (2082:8): [True: 42, False: 30.6k]
  ------------------
 2083|       |
 2084|  30.6k|    if(ihdr->interlace_method > 1) return SPNG_EINTERLACE_METHOD;
  ------------------
  |  Branch (2084:8): [True: 7, False: 30.6k]
  ------------------
 2085|       |
 2086|  30.6k|    return 0;
 2087|  30.6k|}
spng.c:check_plte:
 2090|  2.50k|{
 2091|  2.50k|    if(plte == NULL || ihdr == NULL) return 1;
  ------------------
  |  Branch (2091:8): [True: 0, False: 2.50k]
  |  Branch (2091:24): [True: 0, False: 2.50k]
  ------------------
 2092|       |
 2093|  2.50k|    if(plte->n_entries == 0) return 1;
  ------------------
  |  Branch (2093:8): [True: 0, False: 2.50k]
  ------------------
 2094|  2.50k|    if(plte->n_entries > 256) return 1;
  ------------------
  |  Branch (2094:8): [True: 91, False: 2.41k]
  ------------------
 2095|       |
 2096|  2.41k|    if(ihdr->color_type == SPNG_COLOR_TYPE_INDEXED)
  ------------------
  |  Branch (2096:8): [True: 1.36k, False: 1.05k]
  ------------------
 2097|  1.36k|    {
 2098|  1.36k|        if(plte->n_entries > (1U << ihdr->bit_depth)) return 1;
  ------------------
  |  Branch (2098:12): [True: 14, False: 1.35k]
  ------------------
 2099|  1.36k|    }
 2100|       |
 2101|  2.40k|    return 0;
 2102|  2.41k|}
spng.c:check_chrm_int:
 2152|  1.77k|{
 2153|  1.77k|    if(chrm_int == NULL) return 1;
  ------------------
  |  Branch (2153:8): [True: 0, False: 1.77k]
  ------------------
 2154|       |
 2155|  1.77k|    if(chrm_int->white_point_x > spng_u32max ||
  ------------------
  |  Branch (2155:8): [True: 119, False: 1.65k]
  ------------------
 2156|  1.65k|       chrm_int->white_point_y > spng_u32max ||
  ------------------
  |  Branch (2156:8): [True: 119, False: 1.53k]
  ------------------
 2157|  1.53k|       chrm_int->red_x > spng_u32max ||
  ------------------
  |  Branch (2157:8): [True: 140, False: 1.39k]
  ------------------
 2158|  1.39k|       chrm_int->red_y > spng_u32max ||
  ------------------
  |  Branch (2158:8): [True: 126, False: 1.26k]
  ------------------
 2159|  1.26k|       chrm_int->green_x  > spng_u32max ||
  ------------------
  |  Branch (2159:8): [True: 252, False: 1.01k]
  ------------------
 2160|  1.01k|       chrm_int->green_y  > spng_u32max ||
  ------------------
  |  Branch (2160:8): [True: 252, False: 763]
  ------------------
 2161|    763|       chrm_int->blue_x > spng_u32max ||
  ------------------
  |  Branch (2161:8): [True: 126, False: 637]
  ------------------
 2162|  1.38k|       chrm_int->blue_y > spng_u32max) return SPNG_ECHRM;
  ------------------
  |  Branch (2162:8): [True: 252, False: 385]
  ------------------
 2163|       |
 2164|    385|    return 0;
 2165|  1.77k|}
spng.c:check_png_keyword:
 2219|   223k|{
 2220|   223k|    if(str == NULL) return 1;
  ------------------
  |  Branch (2220:8): [True: 0, False: 223k]
  ------------------
 2221|   223k|    size_t len = strlen(str);
 2222|   223k|    const char *end = str + len;
 2223|       |
 2224|   223k|    if(!len) return 1;
  ------------------
  |  Branch (2224:8): [True: 76.8k, False: 146k]
  ------------------
 2225|   146k|    if(len > 79) return 1;
  ------------------
  |  Branch (2225:8): [True: 0, False: 146k]
  ------------------
 2226|   146k|    if(str[0] == ' ') return 1; /* Leading space */
  ------------------
  |  Branch (2226:8): [True: 91, False: 146k]
  ------------------
 2227|   146k|    if(end[-1] == ' ') return 1; /* Trailing space */
  ------------------
  |  Branch (2227:8): [True: 210, False: 146k]
  ------------------
 2228|   146k|    if(strstr(str, "  ") != NULL) return 1; /* Consecutive spaces */
  ------------------
  |  Branch (2228:8): [True: 2.52k, False: 143k]
  ------------------
 2229|       |
 2230|   143k|    uint8_t c;
 2231|   469k|    while(str != end)
  ------------------
  |  Branch (2231:11): [True: 341k, False: 128k]
  ------------------
 2232|   341k|    {
 2233|   341k|        memcpy(&c, str, 1);
 2234|       |
 2235|   341k|        if( (c >= 32 && c <= 126) || (c >= 161) ) str++;
  ------------------
  |  Branch (2235:14): [True: 327k, False: 13.3k]
  |  Branch (2235:25): [True: 249k, False: 77.7k]
  |  Branch (2235:38): [True: 75.8k, False: 15.3k]
  ------------------
 2236|  15.3k|        else return 1; /* Invalid character */
 2237|   341k|    }
 2238|       |
 2239|   128k|    return 0;
 2240|   143k|}
spng.c:check_sbit:
 2105|  5.08k|{
 2106|  5.08k|    if(sbit == NULL || ihdr == NULL) return 1;
  ------------------
  |  Branch (2106:8): [True: 0, False: 5.08k]
  |  Branch (2106:24): [True: 0, False: 5.08k]
  ------------------
 2107|       |
 2108|  5.08k|    if(ihdr->color_type == 0)
  ------------------
  |  Branch (2108:8): [True: 1.54k, False: 3.54k]
  ------------------
 2109|  1.54k|    {
 2110|  1.54k|        if(sbit->grayscale_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2110:12): [True: 763, False: 777]
  ------------------
 2111|    777|        if(sbit->grayscale_bits > ihdr->bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2111:12): [True: 756, False: 21]
  ------------------
 2112|    777|    }
 2113|  3.54k|    else if(ihdr->color_type == 2 || ihdr->color_type == 3)
  ------------------
  |  Branch (2113:13): [True: 273, False: 3.26k]
  |  Branch (2113:38): [True: 651, False: 2.61k]
  ------------------
 2114|    924|    {
 2115|    924|        if(sbit->red_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2115:12): [True: 329, False: 595]
  ------------------
 2116|    595|        if(sbit->green_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2116:12): [True: 84, False: 511]
  ------------------
 2117|    511|        if(sbit->blue_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2117:12): [True: 42, False: 469]
  ------------------
 2118|       |
 2119|    469|        uint8_t bit_depth;
 2120|    469|        if(ihdr->color_type == 3) bit_depth = 8;
  ------------------
  |  Branch (2120:12): [True: 322, False: 147]
  ------------------
 2121|    147|        else bit_depth = ihdr->bit_depth;
 2122|       |
 2123|    469|        if(sbit->red_bits > bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2123:12): [True: 119, False: 350]
  ------------------
 2124|    350|        if(sbit->green_bits > bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2124:12): [True: 238, False: 112]
  ------------------
 2125|    112|        if(sbit->blue_bits > bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2125:12): [True: 91, False: 21]
  ------------------
 2126|    112|    }
 2127|  2.61k|    else if(ihdr->color_type == 4)
  ------------------
  |  Branch (2127:13): [True: 581, False: 2.03k]
  ------------------
 2128|    581|    {
 2129|    581|        if(sbit->grayscale_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2129:12): [True: 210, False: 371]
  ------------------
 2130|    371|        if(sbit->alpha_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2130:12): [True: 98, False: 273]
  ------------------
 2131|       |
 2132|    273|        if(sbit->grayscale_bits > ihdr->bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2132:12): [True: 168, False: 105]
  ------------------
 2133|    105|        if(sbit->alpha_bits > ihdr->bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2133:12): [True: 91, False: 14]
  ------------------
 2134|    105|    }
 2135|  2.03k|    else if(ihdr->color_type == 6)
  ------------------
  |  Branch (2135:13): [True: 2.03k, False: 0]
  ------------------
 2136|  2.03k|    {
 2137|  2.03k|        if(sbit->red_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2137:12): [True: 504, False: 1.53k]
  ------------------
 2138|  1.53k|        if(sbit->green_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2138:12): [True: 77, False: 1.45k]
  ------------------
 2139|  1.45k|        if(sbit->blue_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2139:12): [True: 77, False: 1.37k]
  ------------------
 2140|  1.37k|        if(sbit->alpha_bits == 0) return SPNG_ESBIT;
  ------------------
  |  Branch (2140:12): [True: 77, False: 1.30k]
  ------------------
 2141|       |
 2142|  1.30k|        if(sbit->red_bits > ihdr->bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2142:12): [True: 791, False: 511]
  ------------------
 2143|    511|        if(sbit->green_bits > ihdr->bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2143:12): [True: 112, False: 399]
  ------------------
 2144|    399|        if(sbit->blue_bits > ihdr->bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2144:12): [True: 238, False: 161]
  ------------------
 2145|    161|        if(sbit->alpha_bits > ihdr->bit_depth) return SPNG_ESBIT;
  ------------------
  |  Branch (2145:12): [True: 77, False: 84]
  ------------------
 2146|    161|    }
 2147|       |
 2148|    140|    return 0;
 2149|  5.08k|}
spng.c:spng__calloc:
  411|   141k|{
  412|   141k|    return ctx->alloc.calloc_fn(nmemb, size);
  413|   141k|}
spng.c:check_phys:
 2168|  2.84k|{
 2169|  2.84k|    if(phys == NULL) return 1;
  ------------------
  |  Branch (2169:8): [True: 0, False: 2.84k]
  ------------------
 2170|       |
 2171|  2.84k|    if(phys->unit_specifier > 1) return SPNG_EPHYS;
  ------------------
  |  Branch (2171:8): [True: 2.33k, False: 511]
  ------------------
 2172|       |
 2173|    511|    if(phys->ppu_x > spng_u32max) return SPNG_EPHYS;
  ------------------
  |  Branch (2173:8): [True: 133, False: 378]
  ------------------
 2174|    378|    if(phys->ppu_y > spng_u32max) return SPNG_EPHYS;
  ------------------
  |  Branch (2174:8): [True: 154, False: 224]
  ------------------
 2175|       |
 2176|    224|    return 0;
 2177|    378|}
spng.c:check_time:
 2180|  5.84k|{
 2181|  5.84k|    if(time == NULL) return 1;
  ------------------
  |  Branch (2181:8): [True: 0, False: 5.84k]
  ------------------
 2182|       |
 2183|  5.84k|    if(time->month == 0 || time->month > 12) return 1;
  ------------------
  |  Branch (2183:8): [True: 4.84k, False: 1.00k]
  |  Branch (2183:28): [True: 175, False: 826]
  ------------------
 2184|    826|    if(time->day == 0 || time->day > 31) return 1;
  ------------------
  |  Branch (2184:8): [True: 126, False: 700]
  |  Branch (2184:26): [True: 147, False: 553]
  ------------------
 2185|    553|    if(time->hour > 23) return 1;
  ------------------
  |  Branch (2185:8): [True: 91, False: 462]
  ------------------
 2186|    462|    if(time->minute > 59) return 1;
  ------------------
  |  Branch (2186:8): [True: 42, False: 420]
  ------------------
 2187|    420|    if(time->second > 60) return 1;
  ------------------
  |  Branch (2187:8): [True: 98, False: 322]
  ------------------
 2188|       |
 2189|    322|    return 0;
 2190|    420|}
spng.c:check_offs:
 2193|    903|{
 2194|    903|    if(offs == NULL) return 1;
  ------------------
  |  Branch (2194:8): [True: 0, False: 903]
  ------------------
 2195|       |
 2196|    903|    if(offs->unit_specifier > 1) return 1;
  ------------------
  |  Branch (2196:8): [True: 812, False: 91]
  ------------------
 2197|       |
 2198|     91|    return 0;
 2199|    903|}
spng.c:check_exif:
 2202|    448|{
 2203|    448|    if(exif == NULL) return 1;
  ------------------
  |  Branch (2203:8): [True: 0, False: 448]
  ------------------
 2204|    448|    if(exif->data == NULL) return 1;
  ------------------
  |  Branch (2204:8): [True: 0, False: 448]
  ------------------
 2205|       |
 2206|    448|    if(exif->length < 4) return SPNG_ECHUNK_SIZE;
  ------------------
  |  Branch (2206:8): [True: 28, False: 420]
  ------------------
 2207|    420|    if(exif->length > spng_u32max) return SPNG_ECHUNK_STDLEN;
  ------------------
  |  Branch (2207:8): [True: 0, False: 420]
  ------------------
 2208|       |
 2209|    420|    const uint8_t exif_le[4] = { 73, 73, 42, 0 };
 2210|    420|    const uint8_t exif_be[4] = { 77, 77, 0, 42 };
 2211|       |
 2212|    420|    if(memcmp(exif->data, exif_le, 4) && memcmp(exif->data, exif_be, 4)) return 1;
  ------------------
  |  Branch (2212:8): [True: 413, False: 7]
  |  Branch (2212:42): [True: 406, False: 7]
  ------------------
 2213|       |
 2214|     14|    return 0;
 2215|    420|}

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

z_crc32_z:
  626|  2.25M|uLong ZEXPORT crc32_z(uLong crc, const unsigned char FAR *buf, z_size_t len) {
  627|       |    /* Return initial CRC, if requested. */
  628|  2.25M|    if (buf == Z_NULL) return 0;
  ------------------
  |  |  216|  2.25M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (628:9): [True: 838k, False: 1.41M]
  ------------------
  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|  1.41M|    crc = (~crc) & 0xffffffff;
  636|       |
  637|  1.41M|#ifdef W
  638|       |
  639|       |    /* If provided enough bytes, do a braided CRC calculation. */
  640|  1.41M|    if (len >= N * W + W - 1) {
  ------------------
  |  |   64|  1.41M|#  define N 5
  ------------------
                  if (len >= N * W + W - 1) {
  ------------------
  |  |   90|  1.41M|#      define W 8
  ------------------
                  if (len >= N * W + W - 1) {
  ------------------
  |  |   90|  1.41M|#      define W 8
  ------------------
  |  Branch (640:9): [True: 78.8k, False: 1.33M]
  ------------------
  641|  78.8k|        z_size_t blks;
  642|  78.8k|        z_word_t const *words;
  643|  78.8k|        unsigned endian;
  644|  78.8k|        int k;
  645|       |
  646|       |        /* Compute the CRC up to a z_word_t boundary. */
  647|  78.8k|        while (len && ((z_size_t)buf & (W - 1)) != 0) {
  ------------------
  |  |   90|  78.8k|#      define W 8
  ------------------
  |  Branch (647:16): [True: 78.8k, False: 0]
  |  Branch (647:23): [True: 0, False: 78.8k]
  ------------------
  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|  78.8k|        blks = len / (N * W);
  ------------------
  |  |   64|  78.8k|#  define N 5
  ------------------
                      blks = len / (N * W);
  ------------------
  |  |   90|  78.8k|#      define W 8
  ------------------
  654|  78.8k|        len -= blks * N * W;
  ------------------
  |  |   64|  78.8k|#  define N 5
  ------------------
                      len -= blks * N * W;
  ------------------
  |  |   90|  78.8k|#      define W 8
  ------------------
  655|  78.8k|        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|  78.8k|        endian = 1;
  662|  78.8k|        if (*(unsigned char *)&endian) {
  ------------------
  |  Branch (662:13): [True: 78.8k, False: 0]
  ------------------
  663|       |            /* Little endian. */
  664|       |
  665|  78.8k|            z_crc_t crc0;
  666|  78.8k|            z_word_t word0;
  667|  78.8k|#if N > 1
  668|  78.8k|            z_crc_t crc1;
  669|  78.8k|            z_word_t word1;
  670|  78.8k|#if N > 2
  671|  78.8k|            z_crc_t crc2;
  672|  78.8k|            z_word_t word2;
  673|  78.8k|#if N > 3
  674|  78.8k|            z_crc_t crc3;
  675|  78.8k|            z_word_t word3;
  676|  78.8k|#if N > 4
  677|  78.8k|            z_crc_t crc4;
  678|  78.8k|            z_word_t word4;
  679|       |#if N > 5
  680|       |            z_crc_t crc5;
  681|       |            z_word_t word5;
  682|       |#endif
  683|  78.8k|#endif
  684|  78.8k|#endif
  685|  78.8k|#endif
  686|  78.8k|#endif
  687|       |
  688|       |            /* Initialize the CRC for each braid. */
  689|  78.8k|            crc0 = crc;
  690|  78.8k|#if N > 1
  691|  78.8k|            crc1 = 0;
  692|  78.8k|#if N > 2
  693|  78.8k|            crc2 = 0;
  694|  78.8k|#if N > 3
  695|  78.8k|            crc3 = 0;
  696|  78.8k|#if N > 4
  697|  78.8k|            crc4 = 0;
  698|       |#if N > 5
  699|       |            crc5 = 0;
  700|       |#endif
  701|  78.8k|#endif
  702|  78.8k|#endif
  703|  78.8k|#endif
  704|  78.8k|#endif
  705|       |
  706|       |            /*
  707|       |              Process the first blks-1 blocks, computing the CRCs on each braid
  708|       |              independently.
  709|       |             */
  710|  4.64M|            while (--blks) {
  ------------------
  |  Branch (710:20): [True: 4.56M, False: 78.8k]
  ------------------
  711|       |                /* Load the word for each braid into registers. */
  712|  4.56M|                word0 = crc0 ^ words[0];
  713|  4.56M|#if N > 1
  714|  4.56M|                word1 = crc1 ^ words[1];
  715|  4.56M|#if N > 2
  716|  4.56M|                word2 = crc2 ^ words[2];
  717|  4.56M|#if N > 3
  718|  4.56M|                word3 = crc3 ^ words[3];
  719|  4.56M|#if N > 4
  720|  4.56M|                word4 = crc4 ^ words[4];
  721|       |#if N > 5
  722|       |                word5 = crc5 ^ words[5];
  723|       |#endif
  724|  4.56M|#endif
  725|  4.56M|#endif
  726|  4.56M|#endif
  727|  4.56M|#endif
  728|  4.56M|                words += N;
  ------------------
  |  |   64|  4.56M|#  define N 5
  ------------------
  729|       |
  730|       |                /* Compute and update the CRC for each word. The loop should
  731|       |                   get unrolled. */
  732|  4.56M|                crc0 = crc_braid_table[0][word0 & 0xff];
  733|  4.56M|#if N > 1
  734|  4.56M|                crc1 = crc_braid_table[0][word1 & 0xff];
  735|  4.56M|#if N > 2
  736|  4.56M|                crc2 = crc_braid_table[0][word2 & 0xff];
  737|  4.56M|#if N > 3
  738|  4.56M|                crc3 = crc_braid_table[0][word3 & 0xff];
  739|  4.56M|#if N > 4
  740|  4.56M|                crc4 = crc_braid_table[0][word4 & 0xff];
  741|       |#if N > 5
  742|       |                crc5 = crc_braid_table[0][word5 & 0xff];
  743|       |#endif
  744|  4.56M|#endif
  745|  4.56M|#endif
  746|  4.56M|#endif
  747|  4.56M|#endif
  748|  36.5M|                for (k = 1; k < W; k++) {
  ------------------
  |  |   90|  36.5M|#      define W 8
  ------------------
  |  Branch (748:29): [True: 31.9M, False: 4.56M]
  ------------------
  749|  31.9M|                    crc0 ^= crc_braid_table[k][(word0 >> (k << 3)) & 0xff];
  750|  31.9M|#if N > 1
  751|  31.9M|                    crc1 ^= crc_braid_table[k][(word1 >> (k << 3)) & 0xff];
  752|  31.9M|#if N > 2
  753|  31.9M|                    crc2 ^= crc_braid_table[k][(word2 >> (k << 3)) & 0xff];
  754|  31.9M|#if N > 3
  755|  31.9M|                    crc3 ^= crc_braid_table[k][(word3 >> (k << 3)) & 0xff];
  756|  31.9M|#if N > 4
  757|  31.9M|                    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|  31.9M|#endif
  762|  31.9M|#endif
  763|  31.9M|#endif
  764|  31.9M|#endif
  765|  31.9M|                }
  766|  4.56M|            }
  767|       |
  768|       |            /*
  769|       |              Process the last block, combining the CRCs of the N braids at the
  770|       |              same time.
  771|       |             */
  772|  78.8k|            crc = crc_word(crc0 ^ words[0]);
  773|  78.8k|#if N > 1
  774|  78.8k|            crc = crc_word(crc1 ^ words[1] ^ crc);
  775|  78.8k|#if N > 2
  776|  78.8k|            crc = crc_word(crc2 ^ words[2] ^ crc);
  777|  78.8k|#if N > 3
  778|  78.8k|            crc = crc_word(crc3 ^ words[3] ^ crc);
  779|  78.8k|#if N > 4
  780|  78.8k|            crc = crc_word(crc4 ^ words[4] ^ crc);
  781|       |#if N > 5
  782|       |            crc = crc_word(crc5 ^ words[5] ^ crc);
  783|       |#endif
  784|  78.8k|#endif
  785|  78.8k|#endif
  786|  78.8k|#endif
  787|  78.8k|#endif
  788|  78.8k|            words += N;
  ------------------
  |  |   64|  78.8k|#  define N 5
  ------------------
  789|  78.8k|        }
  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|  78.8k|        buf = (unsigned char const *)words;
  918|  78.8k|    }
  919|       |
  920|  1.41M|#endif /* W */
  921|       |
  922|       |    /* Complete the computation of the CRC on any remaining bytes. */
  923|  2.02M|    while (len >= 8) {
  ------------------
  |  Branch (923:12): [True: 614k, False: 1.41M]
  ------------------
  924|   614k|        len -= 8;
  925|   614k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  926|   614k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  927|   614k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  928|   614k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  929|   614k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  930|   614k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  931|   614k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  932|   614k|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  933|   614k|    }
  934|  6.44M|    while (len) {
  ------------------
  |  Branch (934:12): [True: 5.03M, False: 1.41M]
  ------------------
  935|  5.03M|        len--;
  936|  5.03M|        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
  937|  5.03M|    }
  938|       |
  939|       |    /* Return the CRC, post-conditioned. */
  940|  1.41M|    return crc ^ 0xffffffff;
  941|  2.25M|}
z_crc32:
  946|  2.25M|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|  2.25M|    return crc32_z(crc, buf, len);
  ------------------
  |  |   52|  2.25M|#  define crc32_z               z_crc32_z
  ------------------
  951|  2.25M|}
crc32.c:crc_word:
  608|   394k|local z_crc_t crc_word(z_word_t data) {
  609|   394k|    int k;
  610|  3.55M|    for (k = 0; k < W; k++)
  ------------------
  |  |   90|  3.55M|#      define W 8
  ------------------
  |  Branch (610:17): [True: 3.15M, False: 394k]
  ------------------
  611|  3.15M|        data = (data >> 8) ^ crc_table[data & 0xff];
  612|   394k|    return (z_crc_t)data;
  613|   394k|}

z_inflate_fast:
   50|   516k|void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
   51|   516k|    struct inflate_state FAR *state;
   52|   516k|    z_const unsigned char FAR *in;      /* local strm->next_in */
   53|   516k|    z_const unsigned char FAR *last;    /* have enough input while in < last */
   54|   516k|    unsigned char FAR *out;     /* local strm->next_out */
   55|   516k|    unsigned char FAR *beg;     /* inflate()'s initial strm->next_out */
   56|   516k|    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|   516k|    unsigned wsize;             /* window size or zero if not using window */
   61|   516k|    unsigned whave;             /* valid bytes in the window */
   62|   516k|    unsigned wnext;             /* window write index */
   63|   516k|    unsigned char FAR *window;  /* allocated sliding window, if wsize != 0 */
   64|   516k|    unsigned long hold;         /* local strm->hold */
   65|   516k|    unsigned bits;              /* local strm->bits */
   66|   516k|    code const FAR *lcode;      /* local strm->lencode */
   67|   516k|    code const FAR *dcode;      /* local strm->distcode */
   68|   516k|    unsigned lmask;             /* mask for first level of length codes */
   69|   516k|    unsigned dmask;             /* mask for first level of distance codes */
   70|   516k|    code const *here;           /* retrieved table entry */
   71|   516k|    unsigned op;                /* code bits, operation, extra bits, or */
   72|       |                                /*  window position, window bytes to copy */
   73|   516k|    unsigned len;               /* match length, unused bytes */
   74|   516k|    unsigned dist;              /* match distance */
   75|   516k|    unsigned char FAR *from;    /* where to copy match from */
   76|       |
   77|       |    /* copy state to local variables */
   78|   516k|    state = (struct inflate_state FAR *)strm->state;
   79|   516k|    in = strm->next_in;
   80|   516k|    last = in + (strm->avail_in - 5);
   81|   516k|    out = strm->next_out;
   82|   516k|    beg = out - (start - strm->avail_out);
   83|   516k|    end = out + (strm->avail_out - 257);
   84|       |#ifdef INFLATE_STRICT
   85|       |    dmax = state->dmax;
   86|       |#endif
   87|   516k|    wsize = state->wsize;
   88|   516k|    whave = state->whave;
   89|   516k|    wnext = state->wnext;
   90|   516k|    window = state->window;
   91|   516k|    hold = state->hold;
   92|   516k|    bits = state->bits;
   93|   516k|    lcode = state->lencode;
   94|   516k|    dcode = state->distcode;
   95|   516k|    lmask = (1U << state->lenbits) - 1;
   96|   516k|    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|  68.5M|    do {
  101|  68.5M|        if (bits < 15) {
  ------------------
  |  Branch (101:13): [True: 22.0M, False: 46.4M]
  ------------------
  102|  22.0M|            hold += (unsigned long)(*in++) << bits;
  103|  22.0M|            bits += 8;
  104|  22.0M|            hold += (unsigned long)(*in++) << bits;
  105|  22.0M|            bits += 8;
  106|  22.0M|        }
  107|  68.5M|        here = lcode + (hold & lmask);
  108|  73.3M|      dolen:
  109|  73.3M|        op = (unsigned)(here->bits);
  110|  73.3M|        hold >>= op;
  111|  73.3M|        bits -= op;
  112|  73.3M|        op = (unsigned)(here->op);
  113|  73.3M|        if (op == 0) {                          /* literal */
  ------------------
  |  Branch (113:13): [True: 21.1M, False: 52.1M]
  ------------------
  114|  21.1M|            Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ?
  115|  21.1M|                    "inflate:         literal '%c'\n" :
  116|  21.1M|                    "inflate:         literal 0x%02x\n", here->val));
  117|  21.1M|            *out++ = (unsigned char)(here->val);
  118|  21.1M|        }
  119|  52.1M|        else if (op & 16) {                     /* length base */
  ------------------
  |  Branch (119:18): [True: 47.1M, False: 4.91M]
  ------------------
  120|  47.1M|            len = (unsigned)(here->val);
  121|  47.1M|            op &= 15;                           /* number of extra bits */
  122|  47.1M|            if (op) {
  ------------------
  |  Branch (122:17): [True: 17.1M, False: 30.0M]
  ------------------
  123|  17.1M|                if (bits < op) {
  ------------------
  |  Branch (123:21): [True: 3.54k, False: 17.1M]
  ------------------
  124|  3.54k|                    hold += (unsigned long)(*in++) << bits;
  125|  3.54k|                    bits += 8;
  126|  3.54k|                }
  127|  17.1M|                len += (unsigned)hold & ((1U << op) - 1);
  128|  17.1M|                hold >>= op;
  129|  17.1M|                bits -= op;
  130|  17.1M|            }
  131|  47.1M|            Tracevv((stderr, "inflate:         length %u\n", len));
  132|  47.1M|            if (bits < 15) {
  ------------------
  |  Branch (132:17): [True: 14.3M, False: 32.8M]
  ------------------
  133|  14.3M|                hold += (unsigned long)(*in++) << bits;
  134|  14.3M|                bits += 8;
  135|  14.3M|                hold += (unsigned long)(*in++) << bits;
  136|  14.3M|                bits += 8;
  137|  14.3M|            }
  138|  47.1M|            here = dcode + (hold & dmask);
  139|  54.5M|          dodist:
  140|  54.5M|            op = (unsigned)(here->bits);
  141|  54.5M|            hold >>= op;
  142|  54.5M|            bits -= op;
  143|  54.5M|            op = (unsigned)(here->op);
  144|  54.5M|            if (op & 16) {                      /* distance base */
  ------------------
  |  Branch (144:17): [True: 47.1M, False: 7.39M]
  ------------------
  145|  47.1M|                dist = (unsigned)(here->val);
  146|  47.1M|                op &= 15;                       /* number of extra bits */
  147|  47.1M|                if (bits < op) {
  ------------------
  |  Branch (147:21): [True: 22.4k, False: 47.1M]
  ------------------
  148|  22.4k|                    hold += (unsigned long)(*in++) << bits;
  149|  22.4k|                    bits += 8;
  150|  22.4k|                    if (bits < op) {
  ------------------
  |  Branch (150:25): [True: 518, False: 21.9k]
  ------------------
  151|    518|                        hold += (unsigned long)(*in++) << bits;
  152|    518|                        bits += 8;
  153|    518|                    }
  154|  22.4k|                }
  155|  47.1M|                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|  47.1M|                hold >>= op;
  165|  47.1M|                bits -= op;
  166|  47.1M|                Tracevv((stderr, "inflate:         distance %u\n", dist));
  167|  47.1M|                op = (unsigned)(out - beg);     /* max distance in output */
  168|  47.1M|                if (dist > op) {                /* see if copy from window */
  ------------------
  |  Branch (168:21): [True: 197k, False: 47.0M]
  ------------------
  169|   197k|                    op = dist - op;             /* distance back in window */
  170|   197k|                    if (op > whave) {
  ------------------
  |  Branch (170:25): [True: 997, False: 196k]
  ------------------
  171|    997|                        if (state->sane) {
  ------------------
  |  Branch (171:29): [True: 997, False: 0]
  ------------------
  172|    997|                            strm->msg = (z_const char *)
  173|    997|                                "invalid distance too far back";
  174|    997|                            state->mode = BAD;
  175|    997|                            break;
  176|    997|                        }
  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|    997|                    }
  197|   196k|                    from = window;
  198|   196k|                    if (wnext == 0) {           /* very common case */
  ------------------
  |  Branch (198:25): [True: 63.9k, False: 132k]
  ------------------
  199|  63.9k|                        from += wsize - op;
  200|  63.9k|                        if (op < len) {         /* some from window */
  ------------------
  |  Branch (200:29): [True: 5.60k, False: 58.3k]
  ------------------
  201|  5.60k|                            len -= op;
  202|   299k|                            do {
  203|   299k|                                *out++ = *from++;
  204|   299k|                            } while (--op);
  ------------------
  |  Branch (204:38): [True: 294k, False: 5.60k]
  ------------------
  205|  5.60k|                            from = out - dist;  /* rest from output */
  206|  5.60k|                        }
  207|  63.9k|                    }
  208|   132k|                    else if (wnext < op) {      /* wrap around window */
  ------------------
  |  Branch (208:30): [True: 30.8k, False: 101k]
  ------------------
  209|  30.8k|                        from += wsize + wnext - op;
  210|  30.8k|                        op -= wnext;
  211|  30.8k|                        if (op < len) {         /* some from end of window */
  ------------------
  |  Branch (211:29): [True: 545, False: 30.2k]
  ------------------
  212|    545|                            len -= op;
  213|  54.8k|                            do {
  214|  54.8k|                                *out++ = *from++;
  215|  54.8k|                            } while (--op);
  ------------------
  |  Branch (215:38): [True: 54.3k, False: 545]
  ------------------
  216|    545|                            from = window;
  217|    545|                            if (wnext < len) {  /* some from start of window */
  ------------------
  |  Branch (217:33): [True: 214, False: 331]
  ------------------
  218|    214|                                op = wnext;
  219|    214|                                len -= op;
  220|  12.4k|                                do {
  221|  12.4k|                                    *out++ = *from++;
  222|  12.4k|                                } while (--op);
  ------------------
  |  Branch (222:42): [True: 12.2k, False: 214]
  ------------------
  223|    214|                                from = out - dist;      /* rest from output */
  224|    214|                            }
  225|    545|                        }
  226|  30.8k|                    }
  227|   101k|                    else {                      /* contiguous in window */
  228|   101k|                        from += wnext - op;
  229|   101k|                        if (op < len) {         /* some from window */
  ------------------
  |  Branch (229:29): [True: 10.2k, False: 91.5k]
  ------------------
  230|  10.2k|                            len -= op;
  231|   946k|                            do {
  232|   946k|                                *out++ = *from++;
  233|   946k|                            } while (--op);
  ------------------
  |  Branch (233:38): [True: 935k, False: 10.2k]
  ------------------
  234|  10.2k|                            from = out - dist;  /* rest from output */
  235|  10.2k|                        }
  236|   101k|                    }
  237|  6.02M|                    while (len > 2) {
  ------------------
  |  Branch (237:28): [True: 5.82M, False: 196k]
  ------------------
  238|  5.82M|                        *out++ = *from++;
  239|  5.82M|                        *out++ = *from++;
  240|  5.82M|                        *out++ = *from++;
  241|  5.82M|                        len -= 3;
  242|  5.82M|                    }
  243|   196k|                    if (len) {
  ------------------
  |  Branch (243:25): [True: 120k, False: 75.9k]
  ------------------
  244|   120k|                        *out++ = *from++;
  245|   120k|                        if (len > 1)
  ------------------
  |  Branch (245:29): [True: 78.8k, False: 41.7k]
  ------------------
  246|  78.8k|                            *out++ = *from++;
  247|   120k|                    }
  248|   196k|                }
  249|  47.0M|                else {
  250|  47.0M|                    from = out - dist;          /* copy direct from output */
  251|  2.74G|                    do {                        /* minimum length is three */
  252|  2.74G|                        *out++ = *from++;
  253|  2.74G|                        *out++ = *from++;
  254|  2.74G|                        *out++ = *from++;
  255|  2.74G|                        len -= 3;
  256|  2.74G|                    } while (len > 2);
  ------------------
  |  Branch (256:30): [True: 2.69G, False: 47.0M]
  ------------------
  257|  47.0M|                    if (len) {
  ------------------
  |  Branch (257:25): [True: 17.0M, False: 29.9M]
  ------------------
  258|  17.0M|                        *out++ = *from++;
  259|  17.0M|                        if (len > 1)
  ------------------
  |  Branch (259:29): [True: 16.9M, False: 83.7k]
  ------------------
  260|  16.9M|                            *out++ = *from++;
  261|  17.0M|                    }
  262|  47.0M|                }
  263|  47.1M|            }
  264|  7.39M|            else if ((op & 64) == 0) {          /* 2nd level distance code */
  ------------------
  |  Branch (264:22): [True: 7.39M, False: 287]
  ------------------
  265|  7.39M|                here = dcode + here->val + (hold & ((1U << op) - 1));
  266|  7.39M|                goto dodist;
  267|  7.39M|            }
  268|    287|            else {
  269|    287|                strm->msg = (z_const char *)"invalid distance code";
  270|    287|                state->mode = BAD;
  271|    287|                break;
  272|    287|            }
  273|  54.5M|        }
  274|  4.91M|        else if ((op & 64) == 0) {              /* 2nd level length code */
  ------------------
  |  Branch (274:18): [True: 4.81M, False: 105k]
  ------------------
  275|  4.81M|            here = lcode + here->val + (hold & ((1U << op) - 1));
  276|  4.81M|            goto dolen;
  277|  4.81M|        }
  278|   105k|        else if (op & 32) {                     /* end-of-block */
  ------------------
  |  Branch (278:18): [True: 104k, False: 105]
  ------------------
  279|   104k|            Tracevv((stderr, "inflate:         end of block\n"));
  280|   104k|            state->mode = TYPE;
  281|   104k|            break;
  282|   104k|        }
  283|    105|        else {
  284|    105|            strm->msg = (z_const char *)"invalid literal/length code";
  285|    105|            state->mode = BAD;
  286|    105|            break;
  287|    105|        }
  288|  73.3M|    } while (in < last && out < end);
  ------------------
  |  Branch (288:14): [True: 68.2M, False: 130k]
  |  Branch (288:27): [True: 67.9M, False: 279k]
  ------------------
  289|       |
  290|       |    /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
  291|   516k|    len = bits >> 3;
  292|   516k|    in -= len;
  293|   516k|    bits -= len << 3;
  294|   516k|    hold &= (1U << bits) - 1;
  295|       |
  296|       |    /* update state and return */
  297|   516k|    strm->next_in = in;
  298|   516k|    strm->next_out = out;
  299|   516k|    strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
  ------------------
  |  Branch (299:33): [True: 478k, False: 37.5k]
  ------------------
  300|   516k|    strm->avail_out = (unsigned)(out < end ?
  ------------------
  |  Branch (300:34): [True: 235k, False: 280k]
  ------------------
  301|   280k|                                 257 + (end - out) : 257 - (out - end));
  302|   516k|    state->hold = hold;
  303|   516k|    state->bits = bits;
  304|   516k|    return;
  305|   516k|}

z_inflateResetKeep:
  100|   154k|int ZEXPORT inflateResetKeep(z_streamp strm) {
  101|   154k|    struct inflate_state FAR *state;
  102|       |
  103|   154k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (103:9): [True: 0, False: 154k]
  ------------------
  104|   154k|    state = (struct inflate_state FAR *)strm->state;
  105|   154k|    strm->total_in = strm->total_out = state->total = 0;
  106|   154k|    strm->msg = Z_NULL;
  ------------------
  |  |  216|   154k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  107|   154k|    strm->data_type = 0;
  108|   154k|    if (state->wrap)        /* to support ill-conceived Java test suite */
  ------------------
  |  Branch (108:9): [True: 154k, False: 0]
  ------------------
  109|   154k|        strm->adler = state->wrap & 1;
  110|   154k|    state->mode = HEAD;
  111|   154k|    state->last = 0;
  112|   154k|    state->havedict = 0;
  113|   154k|    state->flags = -1;
  114|   154k|    state->dmax = 32768U;
  115|   154k|    state->head = Z_NULL;
  ------------------
  |  |  216|   154k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  116|   154k|    state->hold = 0;
  117|   154k|    state->bits = 0;
  118|   154k|    state->lencode = state->distcode = state->next = state->codes;
  119|   154k|    state->sane = 1;
  120|   154k|    state->back = -1;
  121|   154k|    Tracev((stderr, "inflate: reset\n"));
  122|   154k|    return Z_OK;
  ------------------
  |  |  181|   154k|#define Z_OK            0
  ------------------
  123|   154k|}
z_inflateReset:
  125|   154k|int ZEXPORT inflateReset(z_streamp strm) {
  126|   154k|    struct inflate_state FAR *state;
  127|       |
  128|   154k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (128:9): [True: 0, False: 154k]
  ------------------
  129|   154k|    state = (struct inflate_state FAR *)strm->state;
  130|   154k|    state->wsize = 0;
  131|   154k|    state->whave = 0;
  132|   154k|    state->wnext = 0;
  133|   154k|    return inflateResetKeep(strm);
  ------------------
  |  |  132|   154k|#  define inflateResetKeep      z_inflateResetKeep
  ------------------
  134|   154k|}
z_inflateReset2:
  136|   154k|int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
  137|   154k|    int wrap;
  138|   154k|    struct inflate_state FAR *state;
  139|       |
  140|       |    /* get the state */
  141|   154k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (141:9): [True: 0, False: 154k]
  ------------------
  142|   154k|    state = (struct inflate_state FAR *)strm->state;
  143|       |
  144|       |    /* extract wrap request from windowBits parameter */
  145|   154k|    if (windowBits < 0) {
  ------------------
  |  Branch (145:9): [True: 0, False: 154k]
  ------------------
  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|   154k|    else {
  152|   154k|        wrap = (windowBits >> 4) + 5;
  153|       |#ifdef GUNZIP
  154|       |        if (windowBits < 48)
  155|       |            windowBits &= 15;
  156|       |#endif
  157|   154k|    }
  158|       |
  159|       |    /* set number of window bits, free window if different */
  160|   154k|    if (windowBits && (windowBits < 8 || windowBits > 15))
  ------------------
  |  Branch (160:9): [True: 154k, False: 0]
  |  Branch (160:24): [True: 0, False: 154k]
  |  Branch (160:42): [True: 0, False: 154k]
  ------------------
  161|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  162|   154k|    if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
  ------------------
  |  |  216|   308k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (162:9): [True: 0, False: 154k]
  |  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|   154k|    state->wrap = wrap;
  169|   154k|    state->wbits = (unsigned)windowBits;
  170|   154k|    return inflateReset(strm);
  ------------------
  |  |  130|   154k|#  define inflateReset          z_inflateReset
  ------------------
  171|   154k|}
z_inflateInit2_:
  174|   154k|                          const char *version, int stream_size) {
  175|   154k|    int ret;
  176|   154k|    struct inflate_state FAR *state;
  177|       |
  178|   154k|    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
  ------------------
  |  |  216|   308k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
                  if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
  ------------------
  |  |   44|   154k|#define ZLIB_VERSION "1.3.2"
  ------------------
  |  Branch (178:9): [True: 0, False: 154k]
  |  Branch (178:30): [True: 0, False: 154k]
  ------------------
  179|   154k|        stream_size != (int)(sizeof(z_stream)))
  ------------------
  |  Branch (179:9): [True: 0, False: 154k]
  ------------------
  180|      0|        return Z_VERSION_ERROR;
  ------------------
  |  |  189|      0|#define Z_VERSION_ERROR (-6)
  ------------------
  181|   154k|    if (strm == Z_NULL) return Z_STREAM_ERROR;
  ------------------
  |  |  216|   154k|#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: 154k]
  ------------------
  182|   154k|    strm->msg = Z_NULL;                 /* in case we return an error */
  ------------------
  |  |  216|   154k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  183|   154k|    if (strm->zalloc == (alloc_func)0) {
  ------------------
  |  Branch (183:9): [True: 0, False: 154k]
  ------------------
  184|       |#ifdef Z_SOLO
  185|       |        return Z_STREAM_ERROR;
  186|       |#else
  187|      0|        strm->zalloc = zcalloc;
  ------------------
  |  |  150|      0|#    define zcalloc               z_zcalloc
  ------------------
  188|      0|        strm->opaque = (voidpf)0;
  189|      0|#endif
  190|      0|    }
  191|   154k|    if (strm->zfree == (free_func)0)
  ------------------
  |  Branch (191:9): [True: 0, False: 154k]
  ------------------
  192|       |#ifdef Z_SOLO
  193|       |        return Z_STREAM_ERROR;
  194|       |#else
  195|      0|        strm->zfree = zcfree;
  ------------------
  |  |  151|      0|#    define zcfree                z_zcfree
  ------------------
  196|   154k|#endif
  197|   154k|    state = (struct inflate_state FAR *)
  198|   154k|            ZALLOC(strm, 1, sizeof(struct inflate_state));
  ------------------
  |  |  253|   154k|           (*((strm)->zalloc))((strm)->opaque, (items), (size))
  ------------------
  199|   154k|    if (state == Z_NULL) return Z_MEM_ERROR;
  ------------------
  |  |  216|   154k|#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: 154k]
  ------------------
  200|   154k|    zmemzero(state, sizeof(struct inflate_state));
  ------------------
  |  |  218|   154k|#    define zmemzero(dest, len) memset(dest, 0, len)
  ------------------
  201|   154k|    Tracev((stderr, "inflate: allocated\n"));
  202|   154k|    strm->state = (struct internal_state FAR *)state;
  203|   154k|    state->strm = strm;
  204|   154k|    state->window = Z_NULL;
  ------------------
  |  |  216|   154k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  205|   154k|    state->mode = HEAD;     /* to pass state test in inflateReset2() */
  206|   154k|    ret = inflateReset2(strm, windowBits);
  ------------------
  |  |  131|   154k|#  define inflateReset2         z_inflateReset2
  ------------------
  207|   154k|    if (ret != Z_OK) {
  ------------------
  |  |  181|   154k|#define Z_OK            0
  ------------------
  |  Branch (207:9): [True: 0, False: 154k]
  ------------------
  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|   154k|    return ret;
  212|   154k|}
z_inflate:
  474|  1.09M|int ZEXPORT inflate(z_streamp strm, int flush) {
  475|  1.09M|    struct inflate_state FAR *state;
  476|  1.09M|    z_const unsigned char FAR *next;    /* next input */
  477|  1.09M|    unsigned char FAR *put;     /* next output */
  478|  1.09M|    unsigned have, left;        /* available input and output */
  479|  1.09M|    unsigned long hold;         /* bit buffer */
  480|  1.09M|    unsigned bits;              /* bits in bit buffer */
  481|  1.09M|    unsigned in, out;           /* save starting available input and output */
  482|  1.09M|    unsigned copy;              /* number of stored or match bytes to copy */
  483|  1.09M|    unsigned char FAR *from;    /* where to copy match bytes from */
  484|  1.09M|    code here;                  /* current decoding table entry */
  485|  1.09M|    code last;                  /* parent table entry */
  486|  1.09M|    unsigned len;               /* length to copy for repeats, bits to drop */
  487|  1.09M|    int ret;                    /* return code */
  488|       |#ifdef GUNZIP
  489|       |    unsigned char hbuf[4];      /* buffer for gzip header crc calculation */
  490|       |#endif
  491|  1.09M|    static const unsigned short order[19] = /* permutation of code lengths */
  492|  1.09M|        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
  493|       |
  494|  1.09M|    if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
  ------------------
  |  |  216|  2.18M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (494:9): [True: 0, False: 1.09M]
  |  Branch (494:36): [True: 0, False: 1.09M]
  ------------------
  495|  1.09M|        (strm->next_in == Z_NULL && strm->avail_in != 0))
  ------------------
  |  |  216|  2.18M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (495:10): [True: 1.30k, False: 1.09M]
  |  Branch (495:37): [True: 0, False: 1.30k]
  ------------------
  496|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  497|       |
  498|  1.09M|    state = (struct inflate_state FAR *)strm->state;
  499|  1.09M|    if (state->mode == TYPE) state->mode = TYPEDO;      /* skip check */
  ------------------
  |  Branch (499:9): [True: 530, False: 1.09M]
  ------------------
  500|  1.09M|    LOAD();
  ------------------
  |  |  329|  1.09M|    do { \
  |  |  330|  1.09M|        put = strm->next_out; \
  |  |  331|  1.09M|        left = strm->avail_out; \
  |  |  332|  1.09M|        next = strm->next_in; \
  |  |  333|  1.09M|        have = strm->avail_in; \
  |  |  334|  1.09M|        hold = state->hold; \
  |  |  335|  1.09M|        bits = state->bits; \
  |  |  336|  1.09M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (336:14): [Folded, False: 1.09M]
  |  |  ------------------
  ------------------
  501|  1.09M|    in = have;
  502|  1.09M|    out = left;
  503|  1.09M|    ret = Z_OK;
  ------------------
  |  |  181|  1.09M|#define Z_OK            0
  ------------------
  504|  1.09M|    for (;;)
  505|  5.32M|        switch (state->mode) {
  506|   155k|        case HEAD:
  ------------------
  |  Branch (506:9): [True: 155k, False: 5.16M]
  ------------------
  507|   155k|            if (state->wrap == 0) {
  ------------------
  |  Branch (507:17): [True: 0, False: 155k]
  ------------------
  508|      0|                state->mode = TYPEDO;
  509|      0|                break;
  510|      0|            }
  511|   155k|            NEEDBITS(16);
  ------------------
  |  |  369|   155k|    do { \
  |  |  370|   460k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 308k, False: 151k]
  |  |  ------------------
  |  |  371|   308k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   308k|    do { \
  |  |  |  |  360|   308k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 3.48k, False: 304k]
  |  |  |  |  ------------------
  |  |  |  |  361|   308k|        have--; \
  |  |  |  |  362|   304k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   304k|        bits += 8; \
  |  |  |  |  364|   304k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 304k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   155k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 151k]
  |  |  ------------------
  ------------------
  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|   151k|            if (
  527|   151k|#endif
  528|   151k|                ((BITS(8) << 8) + (hold >> 8)) % 31) {
  ------------------
  |  |  376|   151k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  |  Branch (528:17): [True: 8.84k, False: 143k]
  ------------------
  529|  8.84k|                strm->msg = (z_const char *)"incorrect header check";
  530|  8.84k|                state->mode = BAD;
  531|  8.84k|                break;
  532|  8.84k|            }
  533|   143k|            if (BITS(4) != Z_DEFLATED) {
  ------------------
  |  |  376|   143k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
                          if (BITS(4) != Z_DEFLATED) {
  ------------------
  |  |  213|   143k|#define Z_DEFLATED   8
  ------------------
  |  Branch (533:17): [True: 832, False: 142k]
  ------------------
  534|    832|                strm->msg = (z_const char *)"unknown compression method";
  535|    832|                state->mode = BAD;
  536|    832|                break;
  537|    832|            }
  538|   142k|            DROPBITS(4);
  ------------------
  |  |  380|   142k|    do { \
  |  |  381|   142k|        hold >>= (n); \
  |  |  382|   142k|        bits -= (unsigned)(n); \
  |  |  383|   142k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 142k]
  |  |  ------------------
  ------------------
  539|   142k|            len = BITS(4) + 8;
  ------------------
  |  |  376|   142k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  540|   142k|            if (state->wbits == 0)
  ------------------
  |  Branch (540:17): [True: 0, False: 142k]
  ------------------
  541|      0|                state->wbits = len;
  542|   142k|            if (len > 15 || len > state->wbits) {
  ------------------
  |  Branch (542:17): [True: 91, False: 142k]
  |  Branch (542:29): [True: 0, False: 142k]
  ------------------
  543|     91|                strm->msg = (z_const char *)"invalid window size";
  544|     91|                state->mode = BAD;
  545|     91|                break;
  546|     91|            }
  547|   142k|            state->dmax = 1U << len;
  548|   142k|            state->flags = 0;               /* indicate zlib header */
  549|   142k|            Tracev((stderr, "inflate:   zlib header ok\n"));
  550|   142k|            strm->adler = state->check = adler32(0L, Z_NULL, 0);
  ------------------
  |  |   34|   142k|#  define adler32               z_adler32
  ------------------
                          strm->adler = state->check = adler32(0L, Z_NULL, 0);
  ------------------
  |  |  216|   142k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  551|   142k|            state->mode = hold & 0x200 ? DICTID : TYPE;
  ------------------
  |  Branch (551:27): [True: 177, False: 142k]
  ------------------
  552|   142k|            INITBITS();
  ------------------
  |  |  351|   142k|    do { \
  |  |  352|   142k|        hold = 0; \
  |  |  353|   142k|        bits = 0; \
  |  |  354|   142k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 142k]
  |  |  ------------------
  ------------------
  553|   142k|            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|    285|        case DICTID:
  ------------------
  |  Branch (694:9): [True: 285, False: 5.32M]
  ------------------
  695|    285|            NEEDBITS(32);
  ------------------
  |  |  369|    285|    do { \
  |  |  370|    900|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 761, False: 139]
  |  |  ------------------
  |  |  371|    761|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|    761|    do { \
  |  |  |  |  360|    761|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 146, False: 615]
  |  |  |  |  ------------------
  |  |  |  |  361|    761|        have--; \
  |  |  |  |  362|    615|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|    615|        bits += 8; \
  |  |  |  |  364|    615|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 615]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|    285|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 139]
  |  |  ------------------
  ------------------
  696|    139|            strm->adler = state->check = ZSWAP32(hold);
  ------------------
  |  |  258|    139|#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
  |  |  259|    139|                    (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
  ------------------
  697|    139|            INITBITS();
  ------------------
  |  |  351|    139|    do { \
  |  |  352|    139|        hold = 0; \
  |  |  353|    139|        bits = 0; \
  |  |  354|    139|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 139]
  |  |  ------------------
  ------------------
  698|    139|            state->mode = DICT;
  699|       |                /* fallthrough */
  700|    139|        case DICT:
  ------------------
  |  Branch (700:9): [True: 0, False: 5.32M]
  ------------------
  701|    139|            if (state->havedict == 0) {
  ------------------
  |  Branch (701:17): [True: 139, False: 0]
  ------------------
  702|    139|                RESTORE();
  ------------------
  |  |  340|    139|    do { \
  |  |  341|    139|        strm->next_out = put; \
  |  |  342|    139|        strm->avail_out = left; \
  |  |  343|    139|        strm->next_in = next; \
  |  |  344|    139|        strm->avail_in = have; \
  |  |  345|    139|        state->hold = hold; \
  |  |  346|    139|        state->bits = bits; \
  |  |  347|    139|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 139]
  |  |  ------------------
  ------------------
  703|    139|                return Z_NEED_DICT;
  ------------------
  |  |  183|    139|#define Z_NEED_DICT     2
  ------------------
  704|    139|            }
  705|      0|            strm->adler = state->check = adler32(0L, Z_NULL, 0);
  ------------------
  |  |   34|      0|#  define adler32               z_adler32
  ------------------
                          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|   250k|        case TYPE:
  ------------------
  |  Branch (708:9): [True: 250k, False: 5.07M]
  ------------------
  709|   250k|            if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  177|   501k|#define Z_BLOCK         5
  ------------------
                          if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|   250k|#define Z_TREES         6
  ------------------
  |  Branch (709:17): [True: 0, False: 250k]
  |  Branch (709:37): [True: 0, False: 250k]
  ------------------
  710|       |                /* fallthrough */
  711|   251k|        case TYPEDO:
  ------------------
  |  Branch (711:9): [True: 1.03k, False: 5.32M]
  ------------------
  712|   251k|            if (state->last) {
  ------------------
  |  Branch (712:17): [True: 100k, False: 151k]
  ------------------
  713|   100k|                BYTEBITS();
  ------------------
  |  |  387|   100k|    do { \
  |  |  388|   100k|        hold >>= bits & 7; \
  |  |  389|   100k|        bits -= bits & 7; \
  |  |  390|   100k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (390:14): [Folded, False: 100k]
  |  |  ------------------
  ------------------
  714|   100k|                state->mode = CHECK;
  715|   100k|                break;
  716|   100k|            }
  717|   151k|            NEEDBITS(3);
  ------------------
  |  |  369|   151k|    do { \
  |  |  370|   294k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 144k, False: 150k]
  |  |  ------------------
  |  |  371|   151k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   144k|    do { \
  |  |  |  |  360|   144k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.06k, False: 143k]
  |  |  |  |  ------------------
  |  |  |  |  361|   144k|        have--; \
  |  |  |  |  362|   143k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   143k|        bits += 8; \
  |  |  |  |  364|   143k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 143k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   151k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 150k]
  |  |  ------------------
  ------------------
  718|   150k|            state->last = BITS(1);
  ------------------
  |  |  376|   150k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  719|   150k|            DROPBITS(1);
  ------------------
  |  |  380|   150k|    do { \
  |  |  381|   150k|        hold >>= (n); \
  |  |  382|   150k|        bits -= (unsigned)(n); \
  |  |  383|   150k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 150k]
  |  |  ------------------
  ------------------
  720|   150k|            switch (BITS(2)) {
  ------------------
  |  |  376|   150k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  721|  7.81k|            case 0:                             /* stored block */
  ------------------
  |  Branch (721:13): [True: 7.81k, False: 142k]
  ------------------
  722|  7.81k|                Tracev((stderr, "inflate:     stored block%s\n",
  723|  7.81k|                        state->last ? " (last)" : ""));
  724|  7.81k|                state->mode = STORED;
  725|  7.81k|                break;
  726|   115k|            case 1:                             /* fixed block */
  ------------------
  |  Branch (726:13): [True: 115k, False: 35.1k]
  ------------------
  727|   115k|                inflate_fixed(state);
  ------------------
  |  |  141|   115k|#  define inflate_fixed         z_inflate_fixed
  ------------------
  728|   115k|                Tracev((stderr, "inflate:     fixed codes block%s\n",
  729|   115k|                        state->last ? " (last)" : ""));
  730|   115k|                state->mode = LEN_;             /* decode codes */
  731|   115k|                if (flush == Z_TREES) {
  ------------------
  |  |  178|   115k|#define Z_TREES         6
  ------------------
  |  Branch (731:21): [True: 0, False: 115k]
  ------------------
  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|   115k|                break;
  736|   115k|            case 2:                             /* dynamic block */
  ------------------
  |  Branch (736:13): [True: 26.8k, False: 123k]
  ------------------
  737|  26.8k|                Tracev((stderr, "inflate:     dynamic codes block%s\n",
  738|  26.8k|                        state->last ? " (last)" : ""));
  739|  26.8k|                state->mode = TABLE;
  740|  26.8k|                break;
  741|    543|            default:
  ------------------
  |  Branch (741:13): [True: 543, False: 149k]
  ------------------
  742|    543|                strm->msg = (z_const char *)"invalid block type";
  743|    543|                state->mode = BAD;
  744|   150k|            }
  745|   150k|            DROPBITS(2);
  ------------------
  |  |  380|   150k|    do { \
  |  |  381|   150k|        hold >>= (n); \
  |  |  382|   150k|        bits -= (unsigned)(n); \
  |  |  383|   150k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 150k]
  |  |  ------------------
  ------------------
  746|   150k|            break;
  747|  7.88k|        case STORED:
  ------------------
  |  Branch (747:9): [True: 7.88k, False: 5.31M]
  ------------------
  748|  7.88k|            BYTEBITS();                         /* go to byte boundary */
  ------------------
  |  |  387|  7.88k|    do { \
  |  |  388|  7.88k|        hold >>= bits & 7; \
  |  |  389|  7.88k|        bits -= bits & 7; \
  |  |  390|  7.88k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (390:14): [Folded, False: 7.88k]
  |  |  ------------------
  ------------------
  749|  7.88k|            NEEDBITS(32);
  ------------------
  |  |  369|  7.88k|    do { \
  |  |  370|  38.6k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 31.0k, False: 7.64k]
  |  |  ------------------
  |  |  371|  31.0k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  31.0k|    do { \
  |  |  |  |  360|  31.0k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 245, False: 30.7k]
  |  |  |  |  ------------------
  |  |  |  |  361|  31.0k|        have--; \
  |  |  |  |  362|  30.7k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  30.7k|        bits += 8; \
  |  |  |  |  364|  30.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 30.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  7.88k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 7.64k]
  |  |  ------------------
  ------------------
  750|  7.64k|            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
  ------------------
  |  Branch (750:17): [True: 6.59k, False: 1.04k]
  ------------------
  751|  6.59k|                strm->msg = (z_const char *)"invalid stored block lengths";
  752|  6.59k|                state->mode = BAD;
  753|  6.59k|                break;
  754|  6.59k|            }
  755|  1.04k|            state->length = (unsigned)hold & 0xffff;
  756|  1.04k|            Tracev((stderr, "inflate:       stored length %u\n",
  757|  1.04k|                    state->length));
  758|  1.04k|            INITBITS();
  ------------------
  |  |  351|  1.04k|    do { \
  |  |  352|  1.04k|        hold = 0; \
  |  |  353|  1.04k|        bits = 0; \
  |  |  354|  1.04k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 1.04k]
  |  |  ------------------
  ------------------
  759|  1.04k|            state->mode = COPY_;
  760|  1.04k|            if (flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|  1.04k|#define Z_TREES         6
  ------------------
  |  Branch (760:17): [True: 0, False: 1.04k]
  ------------------
  761|       |                /* fallthrough */
  762|  1.04k|        case COPY_:
  ------------------
  |  Branch (762:9): [True: 0, False: 5.32M]
  ------------------
  763|  1.04k|            state->mode = COPY;
  764|       |                /* fallthrough */
  765|  22.5k|        case COPY:
  ------------------
  |  Branch (765:9): [True: 21.4k, False: 5.30M]
  ------------------
  766|  22.5k|            copy = state->length;
  767|  22.5k|            if (copy) {
  ------------------
  |  Branch (767:17): [True: 21.8k, False: 691]
  ------------------
  768|  21.8k|                if (copy > have) copy = have;
  ------------------
  |  Branch (768:21): [True: 20.6k, False: 1.18k]
  ------------------
  769|  21.8k|                if (copy > left) copy = left;
  ------------------
  |  Branch (769:21): [True: 20.1k, False: 1.70k]
  ------------------
  770|  21.8k|                if (copy == 0) goto inf_leave;
  ------------------
  |  Branch (770:21): [True: 10.9k, False: 10.8k]
  ------------------
  771|  10.8k|                zmemcpy(put, next, copy);
  ------------------
  |  |  216|  10.8k|#    define zmemcpy memcpy
  ------------------
  772|  10.8k|                have -= copy;
  773|  10.8k|                next += copy;
  774|  10.8k|                left -= copy;
  775|  10.8k|                put += copy;
  776|  10.8k|                state->length -= copy;
  777|  10.8k|                break;
  778|  21.8k|            }
  779|    691|            Tracev((stderr, "inflate:       stored end\n"));
  780|    691|            state->mode = TYPE;
  781|    691|            break;
  782|  28.6k|        case TABLE:
  ------------------
  |  Branch (782:9): [True: 28.6k, False: 5.29M]
  ------------------
  783|  28.6k|            NEEDBITS(14);
  ------------------
  |  |  369|  28.6k|    do { \
  |  |  370|  82.2k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 55.4k, False: 26.7k]
  |  |  ------------------
  |  |  371|  55.4k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  55.4k|    do { \
  |  |  |  |  360|  55.4k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.90k, False: 53.5k]
  |  |  |  |  ------------------
  |  |  |  |  361|  55.4k|        have--; \
  |  |  |  |  362|  53.5k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  53.5k|        bits += 8; \
  |  |  |  |  364|  53.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 53.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  28.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 26.7k]
  |  |  ------------------
  ------------------
  784|  26.7k|            state->nlen = BITS(5) + 257;
  ------------------
  |  |  376|  26.7k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  785|  26.7k|            DROPBITS(5);
  ------------------
  |  |  380|  26.7k|    do { \
  |  |  381|  26.7k|        hold >>= (n); \
  |  |  382|  26.7k|        bits -= (unsigned)(n); \
  |  |  383|  26.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 26.7k]
  |  |  ------------------
  ------------------
  786|  26.7k|            state->ndist = BITS(5) + 1;
  ------------------
  |  |  376|  26.7k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  787|  26.7k|            DROPBITS(5);
  ------------------
  |  |  380|  26.7k|    do { \
  |  |  381|  26.7k|        hold >>= (n); \
  |  |  382|  26.7k|        bits -= (unsigned)(n); \
  |  |  383|  26.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 26.7k]
  |  |  ------------------
  ------------------
  788|  26.7k|            state->ncode = BITS(4) + 4;
  ------------------
  |  |  376|  26.7k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  789|  26.7k|            DROPBITS(4);
  ------------------
  |  |  380|  26.7k|    do { \
  |  |  381|  26.7k|        hold >>= (n); \
  |  |  382|  26.7k|        bits -= (unsigned)(n); \
  |  |  383|  26.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 26.7k]
  |  |  ------------------
  ------------------
  790|  26.7k|#ifndef PKZIP_BUG_WORKAROUND
  791|  26.7k|            if (state->nlen > 286 || state->ndist > 30) {
  ------------------
  |  Branch (791:17): [True: 20, False: 26.7k]
  |  Branch (791:38): [True: 1.24k, False: 25.5k]
  ------------------
  792|  1.26k|                strm->msg = (z_const char *)
  793|  1.26k|                    "too many length or distance symbols";
  794|  1.26k|                state->mode = BAD;
  795|  1.26k|                break;
  796|  1.26k|            }
  797|  25.5k|#endif
  798|  25.5k|            Tracev((stderr, "inflate:       table sizes ok\n"));
  799|  25.5k|            state->have = 0;
  800|  25.5k|            state->mode = LENLENS;
  801|       |                /* fallthrough */
  802|  30.1k|        case LENLENS:
  ------------------
  |  Branch (802:9): [True: 4.60k, False: 5.31M]
  ------------------
  803|   392k|            while (state->have < state->ncode) {
  ------------------
  |  Branch (803:20): [True: 367k, False: 25.4k]
  ------------------
  804|   367k|                NEEDBITS(3);
  ------------------
  |  |  369|   367k|    do { \
  |  |  370|   487k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 124k, False: 362k]
  |  |  ------------------
  |  |  371|   367k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   124k|    do { \
  |  |  |  |  360|   124k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 4.70k, False: 119k]
  |  |  |  |  ------------------
  |  |  |  |  361|   124k|        have--; \
  |  |  |  |  362|   119k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   119k|        bits += 8; \
  |  |  |  |  364|   119k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 119k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   367k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 362k]
  |  |  ------------------
  ------------------
  805|   362k|                state->lens[order[state->have++]] = (unsigned short)BITS(3);
  ------------------
  |  |  376|   362k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  806|   362k|                DROPBITS(3);
  ------------------
  |  |  380|   362k|    do { \
  |  |  381|   362k|        hold >>= (n); \
  |  |  382|   362k|        bits -= (unsigned)(n); \
  |  |  383|   362k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 362k]
  |  |  ------------------
  ------------------
  807|   362k|            }
  808|   146k|            while (state->have < 19)
  ------------------
  |  Branch (808:20): [True: 120k, False: 25.4k]
  ------------------
  809|   120k|                state->lens[order[state->have++]] = 0;
  810|  25.4k|            state->next = state->codes;
  811|  25.4k|            state->lencode = state->distcode = (const code FAR *)(state->next);
  812|  25.4k|            state->lenbits = 7;
  813|  25.4k|            ret = inflate_table(CODES, state->lens, 19, &(state->next),
  ------------------
  |  |  140|  25.4k|#  define inflate_table         z_inflate_table
  ------------------
  814|  25.4k|                                &(state->lenbits), state->work);
  815|  25.4k|            if (ret) {
  ------------------
  |  Branch (815:17): [True: 2.73k, False: 22.6k]
  ------------------
  816|  2.73k|                strm->msg = (z_const char *)"invalid code lengths set";
  817|  2.73k|                state->mode = BAD;
  818|  2.73k|                break;
  819|  2.73k|            }
  820|  22.6k|            Tracev((stderr, "inflate:       code lengths ok\n"));
  821|  22.6k|            state->have = 0;
  822|  22.6k|            state->mode = CODELENS;
  823|       |                /* fallthrough */
  824|  37.8k|        case CODELENS:
  ------------------
  |  Branch (824:9): [True: 15.1k, False: 5.30M]
  ------------------
  825|  1.24M|            while (state->have < state->nlen + state->ndist) {
  ------------------
  |  Branch (825:20): [True: 1.22M, False: 16.6k]
  ------------------
  826|  1.60M|                for (;;) {
  827|  1.60M|                    here = state->lencode[BITS(state->lenbits)];
  ------------------
  |  |  376|  1.60M|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  828|  1.60M|                    if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (828:25): [True: 1.21M, False: 388k]
  ------------------
  829|   388k|                    PULLBYTE();
  ------------------
  |  |  359|   388k|    do { \
  |  |  360|   388k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 11.7k, False: 376k]
  |  |  ------------------
  |  |  361|   388k|        have--; \
  |  |  362|   376k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|   376k|        bits += 8; \
  |  |  364|   376k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 376k]
  |  |  ------------------
  ------------------
  830|   388k|                }
  831|  1.21M|                if (here.val < 16) {
  ------------------
  |  Branch (831:21): [True: 1.04M, False: 171k]
  ------------------
  832|  1.04M|                    DROPBITS(here.bits);
  ------------------
  |  |  380|  1.04M|    do { \
  |  |  381|  1.04M|        hold >>= (n); \
  |  |  382|  1.04M|        bits -= (unsigned)(n); \
  |  |  383|  1.04M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 1.04M]
  |  |  ------------------
  ------------------
  833|  1.04M|                    state->lens[state->have++] = here.val;
  834|  1.04M|                }
  835|   171k|                else {
  836|   171k|                    if (here.val == 16) {
  ------------------
  |  Branch (836:25): [True: 41.0k, False: 130k]
  ------------------
  837|  41.0k|                        NEEDBITS(here.bits + 2);
  ------------------
  |  |  369|  41.0k|    do { \
  |  |  370|  51.8k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 12.1k, False: 39.7k]
  |  |  ------------------
  |  |  371|  41.0k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  12.1k|    do { \
  |  |  |  |  360|  12.1k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.33k, False: 10.7k]
  |  |  |  |  ------------------
  |  |  |  |  361|  12.1k|        have--; \
  |  |  |  |  362|  10.7k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  10.7k|        bits += 8; \
  |  |  |  |  364|  10.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 10.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  41.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 39.7k]
  |  |  ------------------
  ------------------
  838|  39.7k|                        DROPBITS(here.bits);
  ------------------
  |  |  380|  39.7k|    do { \
  |  |  381|  39.7k|        hold >>= (n); \
  |  |  382|  39.7k|        bits -= (unsigned)(n); \
  |  |  383|  39.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 39.7k]
  |  |  ------------------
  ------------------
  839|  39.7k|                        if (state->have == 0) {
  ------------------
  |  Branch (839:29): [True: 84, False: 39.6k]
  ------------------
  840|     84|                            strm->msg = (z_const char *)
  841|     84|                                "invalid bit length repeat";
  842|     84|                            state->mode = BAD;
  843|     84|                            break;
  844|     84|                        }
  845|  39.6k|                        len = state->lens[state->have - 1];
  846|  39.6k|                        copy = 3 + BITS(2);
  ------------------
  |  |  376|  39.6k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  847|  39.6k|                        DROPBITS(2);
  ------------------
  |  |  380|  39.6k|    do { \
  |  |  381|  39.6k|        hold >>= (n); \
  |  |  382|  39.6k|        bits -= (unsigned)(n); \
  |  |  383|  39.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 39.6k]
  |  |  ------------------
  ------------------
  848|  39.6k|                    }
  849|   130k|                    else if (here.val == 17) {
  ------------------
  |  Branch (849:30): [True: 39.5k, False: 90.5k]
  ------------------
  850|  39.5k|                        NEEDBITS(here.bits + 3);
  ------------------
  |  |  369|  39.5k|    do { \
  |  |  370|  55.9k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 17.5k, False: 38.4k]
  |  |  ------------------
  |  |  371|  39.5k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  17.5k|    do { \
  |  |  |  |  360|  17.5k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.03k, False: 16.4k]
  |  |  |  |  ------------------
  |  |  |  |  361|  17.5k|        have--; \
  |  |  |  |  362|  16.4k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  16.4k|        bits += 8; \
  |  |  |  |  364|  16.4k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 16.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  39.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 38.4k]
  |  |  ------------------
  ------------------
  851|  38.4k|                        DROPBITS(here.bits);
  ------------------
  |  |  380|  38.4k|    do { \
  |  |  381|  38.4k|        hold >>= (n); \
  |  |  382|  38.4k|        bits -= (unsigned)(n); \
  |  |  383|  38.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 38.4k]
  |  |  ------------------
  ------------------
  852|  38.4k|                        len = 0;
  853|  38.4k|                        copy = 3 + BITS(3);
  ------------------
  |  |  376|  38.4k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  854|  38.4k|                        DROPBITS(3);
  ------------------
  |  |  380|  38.4k|    do { \
  |  |  381|  38.4k|        hold >>= (n); \
  |  |  382|  38.4k|        bits -= (unsigned)(n); \
  |  |  383|  38.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 38.4k]
  |  |  ------------------
  ------------------
  855|  38.4k|                    }
  856|  90.5k|                    else {
  857|  90.5k|                        NEEDBITS(here.bits + 7);
  ------------------
  |  |  369|  90.5k|    do { \
  |  |  370|   164k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 76.1k, False: 88.7k]
  |  |  ------------------
  |  |  371|  90.5k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  76.1k|    do { \
  |  |  |  |  360|  76.1k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.81k, False: 74.3k]
  |  |  |  |  ------------------
  |  |  |  |  361|  76.1k|        have--; \
  |  |  |  |  362|  74.3k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  74.3k|        bits += 8; \
  |  |  |  |  364|  74.3k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 74.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  90.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 88.7k]
  |  |  ------------------
  ------------------
  858|  88.7k|                        DROPBITS(here.bits);
  ------------------
  |  |  380|  88.7k|    do { \
  |  |  381|  88.7k|        hold >>= (n); \
  |  |  382|  88.7k|        bits -= (unsigned)(n); \
  |  |  383|  88.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 88.7k]
  |  |  ------------------
  ------------------
  859|  88.7k|                        len = 0;
  860|  88.7k|                        copy = 11 + BITS(7);
  ------------------
  |  |  376|  88.7k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  861|  88.7k|                        DROPBITS(7);
  ------------------
  |  |  380|  88.7k|    do { \
  |  |  381|  88.7k|        hold >>= (n); \
  |  |  382|  88.7k|        bits -= (unsigned)(n); \
  |  |  383|  88.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 88.7k]
  |  |  ------------------
  ------------------
  862|  88.7k|                    }
  863|   166k|                    if (state->have + copy > state->nlen + state->ndist) {
  ------------------
  |  Branch (863:25): [True: 5.14k, False: 161k]
  ------------------
  864|  5.14k|                        strm->msg = (z_const char *)
  865|  5.14k|                            "invalid bit length repeat";
  866|  5.14k|                        state->mode = BAD;
  867|  5.14k|                        break;
  868|  5.14k|                    }
  869|  5.57M|                    while (copy--)
  ------------------
  |  Branch (869:28): [True: 5.40M, False: 161k]
  ------------------
  870|  5.40M|                        state->lens[state->have++] = (unsigned short)len;
  871|   161k|                }
  872|  1.21M|            }
  873|       |
  874|       |            /* handle error breaks in while */
  875|  21.8k|            if (state->mode == BAD) break;
  ------------------
  |  Branch (875:17): [True: 5.23k, False: 16.6k]
  ------------------
  876|       |
  877|       |            /* check for end-of-block code (better have one) */
  878|  16.6k|            if (state->lens[256] == 0) {
  ------------------
  |  Branch (878:17): [True: 166, False: 16.4k]
  ------------------
  879|    166|                strm->msg = (z_const char *)
  880|    166|                    "invalid code -- missing end-of-block";
  881|    166|                state->mode = BAD;
  882|    166|                break;
  883|    166|            }
  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|  16.4k|            state->next = state->codes;
  889|  16.4k|            state->lencode = (const code FAR *)(state->next);
  890|  16.4k|            state->lenbits = 9;
  891|  16.4k|            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
  ------------------
  |  |  140|  16.4k|#  define inflate_table         z_inflate_table
  ------------------
  892|  16.4k|                                &(state->lenbits), state->work);
  893|  16.4k|            if (ret) {
  ------------------
  |  Branch (893:17): [True: 1.29k, False: 15.1k]
  ------------------
  894|  1.29k|                strm->msg = (z_const char *)"invalid literal/lengths set";
  895|  1.29k|                state->mode = BAD;
  896|  1.29k|                break;
  897|  1.29k|            }
  898|  15.1k|            state->distcode = (const code FAR *)(state->next);
  899|  15.1k|            state->distbits = 6;
  900|  15.1k|            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
  ------------------
  |  |  140|  15.1k|#  define inflate_table         z_inflate_table
  ------------------
  901|  15.1k|                            &(state->next), &(state->distbits), state->work);
  902|  15.1k|            if (ret) {
  ------------------
  |  Branch (902:17): [True: 477, False: 14.6k]
  ------------------
  903|    477|                strm->msg = (z_const char *)"invalid distances set";
  904|    477|                state->mode = BAD;
  905|    477|                break;
  906|    477|            }
  907|  14.6k|            Tracev((stderr, "inflate:       codes ok\n"));
  908|  14.6k|            state->mode = LEN_;
  909|  14.6k|            if (flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|  14.6k|#define Z_TREES         6
  ------------------
  |  Branch (909:17): [True: 0, False: 14.6k]
  ------------------
  910|       |                /* fallthrough */
  911|   129k|        case LEN_:
  ------------------
  |  Branch (911:9): [True: 115k, False: 5.20M]
  ------------------
  912|   129k|            state->mode = LEN;
  913|       |                /* fallthrough */
  914|  1.83M|        case LEN:
  ------------------
  |  Branch (914:9): [True: 1.70M, False: 3.61M]
  ------------------
  915|  1.83M|            if (have >= 6 && left >= 258) {
  ------------------
  |  Branch (915:17): [True: 1.48M, False: 354k]
  |  Branch (915:30): [True: 516k, False: 965k]
  ------------------
  916|   516k|                RESTORE();
  ------------------
  |  |  340|   516k|    do { \
  |  |  341|   516k|        strm->next_out = put; \
  |  |  342|   516k|        strm->avail_out = left; \
  |  |  343|   516k|        strm->next_in = next; \
  |  |  344|   516k|        strm->avail_in = have; \
  |  |  345|   516k|        state->hold = hold; \
  |  |  346|   516k|        state->bits = bits; \
  |  |  347|   516k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 516k]
  |  |  ------------------
  ------------------
  917|   516k|                inflate_fast(strm, out);
  ------------------
  |  |  139|   516k|#  define inflate_fast          z_inflate_fast
  ------------------
  918|   516k|                LOAD();
  ------------------
  |  |  329|   516k|    do { \
  |  |  330|   516k|        put = strm->next_out; \
  |  |  331|   516k|        left = strm->avail_out; \
  |  |  332|   516k|        next = strm->next_in; \
  |  |  333|   516k|        have = strm->avail_in; \
  |  |  334|   516k|        hold = state->hold; \
  |  |  335|   516k|        bits = state->bits; \
  |  |  336|   516k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (336:14): [Folded, False: 516k]
  |  |  ------------------
  ------------------
  919|   516k|                if (state->mode == TYPE)
  ------------------
  |  Branch (919:21): [True: 104k, False: 411k]
  ------------------
  920|   104k|                    state->back = -1;
  921|   516k|                break;
  922|   516k|            }
  923|  1.31M|            state->back = 0;
  924|  1.74M|            for (;;) {
  925|  1.74M|                here = state->lencode[BITS(state->lenbits)];
  ------------------
  |  |  376|  1.74M|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  926|  1.74M|                if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (926:21): [True: 1.30M, False: 443k]
  ------------------
  927|   443k|                PULLBYTE();
  ------------------
  |  |  359|   443k|    do { \
  |  |  360|   443k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 15.2k, False: 428k]
  |  |  ------------------
  |  |  361|   443k|        have--; \
  |  |  362|   428k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|   428k|        bits += 8; \
  |  |  364|   428k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 428k]
  |  |  ------------------
  ------------------
  928|   443k|            }
  929|  1.30M|            if (here.op && (here.op & 0xf0) == 0) {
  ------------------
  |  Branch (929:17): [True: 970k, False: 334k]
  |  Branch (929:28): [True: 32.8k, False: 937k]
  ------------------
  930|  32.8k|                last = here;
  931|  39.3k|                for (;;) {
  932|  39.3k|                    here = state->lencode[last.val +
  933|  39.3k|                            (BITS(last.bits + last.op) >> last.bits)];
  ------------------
  |  |  376|  39.3k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  934|  39.3k|                    if ((unsigned)(last.bits + here.bits) <= bits) break;
  ------------------
  |  Branch (934:25): [True: 32.5k, False: 6.81k]
  ------------------
  935|  6.81k|                    PULLBYTE();
  ------------------
  |  |  359|  6.81k|    do { \
  |  |  360|  6.81k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 245, False: 6.57k]
  |  |  ------------------
  |  |  361|  6.81k|        have--; \
  |  |  362|  6.57k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|  6.57k|        bits += 8; \
  |  |  364|  6.57k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 6.57k]
  |  |  ------------------
  ------------------
  936|  6.81k|                }
  937|  32.5k|                DROPBITS(last.bits);
  ------------------
  |  |  380|  32.5k|    do { \
  |  |  381|  32.5k|        hold >>= (n); \
  |  |  382|  32.5k|        bits -= (unsigned)(n); \
  |  |  383|  32.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  938|  32.5k|                state->back += last.bits;
  939|  32.5k|            }
  940|  1.30M|            DROPBITS(here.bits);
  ------------------
  |  |  380|  1.30M|    do { \
  |  |  381|  1.30M|        hold >>= (n); \
  |  |  382|  1.30M|        bits -= (unsigned)(n); \
  |  |  383|  1.30M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 1.30M]
  |  |  ------------------
  ------------------
  941|  1.30M|            state->back += here.bits;
  942|  1.30M|            state->length = (unsigned)here.val;
  943|  1.30M|            if ((int)(here.op) == 0) {
  ------------------
  |  Branch (943:17): [True: 342k, False: 961k]
  ------------------
  944|   342k|                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
  945|   342k|                        "inflate:         literal '%c'\n" :
  946|   342k|                        "inflate:         literal 0x%02x\n", here.val));
  947|   342k|                state->mode = LIT;
  948|   342k|                break;
  949|   342k|            }
  950|   961k|            if (here.op & 32) {
  ------------------
  |  Branch (950:17): [True: 3.07k, False: 958k]
  ------------------
  951|  3.07k|                Tracevv((stderr, "inflate:         end of block\n"));
  952|  3.07k|                state->back = -1;
  953|  3.07k|                state->mode = TYPE;
  954|  3.07k|                break;
  955|  3.07k|            }
  956|   958k|            if (here.op & 64) {
  ------------------
  |  Branch (956:17): [True: 98, False: 958k]
  ------------------
  957|     98|                strm->msg = (z_const char *)"invalid literal/length code";
  958|     98|                state->mode = BAD;
  959|     98|                break;
  960|     98|            }
  961|   958k|            state->extra = (unsigned)(here.op) & 15;
  962|   958k|            state->mode = LENEXT;
  963|       |                /* fallthrough */
  964|   962k|        case LENEXT:
  ------------------
  |  Branch (964:9): [True: 3.50k, False: 5.31M]
  ------------------
  965|   962k|            if (state->extra) {
  ------------------
  |  Branch (965:17): [True: 114k, False: 847k]
  ------------------
  966|   114k|                NEEDBITS(state->extra);
  ------------------
  |  |  369|   114k|    do { \
  |  |  370|   162k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 52.0k, False: 110k]
  |  |  ------------------
  |  |  371|   114k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  52.0k|    do { \
  |  |  |  |  360|  52.0k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 3.79k, False: 48.2k]
  |  |  |  |  ------------------
  |  |  |  |  361|  52.0k|        have--; \
  |  |  |  |  362|  48.2k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  48.2k|        bits += 8; \
  |  |  |  |  364|  48.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 48.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   114k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 110k]
  |  |  ------------------
  ------------------
  967|   110k|                state->length += BITS(state->extra);
  ------------------
  |  |  376|   110k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  968|   110k|                DROPBITS(state->extra);
  ------------------
  |  |  380|   110k|    do { \
  |  |  381|   110k|        hold >>= (n); \
  |  |  382|   110k|        bits -= (unsigned)(n); \
  |  |  383|   110k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 110k]
  |  |  ------------------
  ------------------
  969|   110k|                state->back += state->extra;
  970|   110k|            }
  971|   958k|            Tracevv((stderr, "inflate:         length %u\n", state->length));
  972|   958k|            state->was = state->length;
  973|   958k|            state->mode = DIST;
  974|       |                /* fallthrough */
  975|   968k|        case DIST:
  ------------------
  |  Branch (975:9): [True: 9.90k, False: 5.31M]
  ------------------
  976|  1.17M|            for (;;) {
  977|  1.17M|                here = state->distcode[BITS(state->distbits)];
  ------------------
  |  |  376|  1.17M|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  978|  1.17M|                if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (978:21): [True: 946k, False: 230k]
  ------------------
  979|   230k|                PULLBYTE();
  ------------------
  |  |  359|   230k|    do { \
  |  |  360|   230k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 21.2k, False: 209k]
  |  |  ------------------
  |  |  361|   230k|        have--; \
  |  |  362|   209k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|   209k|        bits += 8; \
  |  |  364|   209k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 209k]
  |  |  ------------------
  ------------------
  980|   230k|            }
  981|   946k|            if ((here.op & 0xf0) == 0) {
  ------------------
  |  Branch (981:17): [True: 49.5k, False: 897k]
  ------------------
  982|  49.5k|                last = here;
  983|  73.6k|                for (;;) {
  984|  73.6k|                    here = state->distcode[last.val +
  985|  73.6k|                            (BITS(last.bits + last.op) >> last.bits)];
  ------------------
  |  |  376|  73.6k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  986|  73.6k|                    if ((unsigned)(last.bits + here.bits) <= bits) break;
  ------------------
  |  Branch (986:25): [True: 48.9k, False: 24.6k]
  ------------------
  987|  24.6k|                    PULLBYTE();
  ------------------
  |  |  359|  24.6k|    do { \
  |  |  360|  24.6k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 537, False: 24.0k]
  |  |  ------------------
  |  |  361|  24.6k|        have--; \
  |  |  362|  24.0k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|  24.0k|        bits += 8; \
  |  |  364|  24.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 24.0k]
  |  |  ------------------
  ------------------
  988|  24.6k|                }
  989|  48.9k|                DROPBITS(last.bits);
  ------------------
  |  |  380|  48.9k|    do { \
  |  |  381|  48.9k|        hold >>= (n); \
  |  |  382|  48.9k|        bits -= (unsigned)(n); \
  |  |  383|  48.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 48.9k]
  |  |  ------------------
  ------------------
  990|  48.9k|                state->back += last.bits;
  991|  48.9k|            }
  992|   946k|            DROPBITS(here.bits);
  ------------------
  |  |  380|   946k|    do { \
  |  |  381|   946k|        hold >>= (n); \
  |  |  382|   946k|        bits -= (unsigned)(n); \
  |  |  383|   946k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 946k]
  |  |  ------------------
  ------------------
  993|   946k|            state->back += here.bits;
  994|   946k|            if (here.op & 64) {
  ------------------
  |  Branch (994:17): [True: 144, False: 946k]
  ------------------
  995|    144|                strm->msg = (z_const char *)"invalid distance code";
  996|    144|                state->mode = BAD;
  997|    144|                break;
  998|    144|            }
  999|   946k|            state->offset = (unsigned)here.val;
 1000|   946k|            state->extra = (unsigned)(here.op) & 15;
 1001|   946k|            state->mode = DISTEXT;
 1002|       |                /* fallthrough */
 1003|   951k|        case DISTEXT:
  ------------------
  |  Branch (1003:9): [True: 5.24k, False: 5.31M]
  ------------------
 1004|   951k|            if (state->extra) {
  ------------------
  |  Branch (1004:17): [True: 168k, False: 783k]
  ------------------
 1005|   168k|                NEEDBITS(state->extra);
  ------------------
  |  |  369|   168k|    do { \
  |  |  370|   323k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 161k, False: 162k]
  |  |  ------------------
  |  |  371|   168k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   161k|    do { \
  |  |  |  |  360|   161k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 6.30k, False: 155k]
  |  |  |  |  ------------------
  |  |  |  |  361|   161k|        have--; \
  |  |  |  |  362|   155k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   155k|        bits += 8; \
  |  |  |  |  364|   155k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 155k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   168k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 162k]
  |  |  ------------------
  ------------------
 1006|   162k|                state->offset += BITS(state->extra);
  ------------------
  |  |  376|   162k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
 1007|   162k|                DROPBITS(state->extra);
  ------------------
  |  |  380|   162k|    do { \
  |  |  381|   162k|        hold >>= (n); \
  |  |  382|   162k|        bits -= (unsigned)(n); \
  |  |  383|   162k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 162k]
  |  |  ------------------
  ------------------
 1008|   162k|                state->back += state->extra;
 1009|   162k|            }
 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|   945k|            Tracevv((stderr, "inflate:         distance %u\n", state->offset));
 1018|   945k|            state->mode = MATCH;
 1019|       |                /* fallthrough */
 1020|  3.45M|        case MATCH:
  ------------------
  |  Branch (1020:9): [True: 2.50M, False: 2.81M]
  ------------------
 1021|  3.45M|            if (left == 0) goto inf_leave;
  ------------------
  |  Branch (1021:17): [True: 866k, False: 2.58M]
  ------------------
 1022|  2.58M|            copy = out - left;
 1023|  2.58M|            if (state->offset > copy) {         /* copy from window */
  ------------------
  |  Branch (1023:17): [True: 973k, False: 1.60M]
  ------------------
 1024|   973k|                copy = state->offset - copy;
 1025|   973k|                if (copy > state->whave) {
  ------------------
  |  Branch (1025:21): [True: 710, False: 973k]
  ------------------
 1026|    710|                    if (state->sane) {
  ------------------
  |  Branch (1026:25): [True: 710, False: 0]
  ------------------
 1027|    710|                        strm->msg = (z_const char *)
 1028|    710|                            "invalid distance too far back";
 1029|    710|                        state->mode = BAD;
 1030|    710|                        break;
 1031|    710|                    }
 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|    710|                }
 1046|   973k|                if (copy > state->wnext) {
  ------------------
  |  Branch (1046:21): [True: 51.0k, False: 922k]
  ------------------
 1047|  51.0k|                    copy -= state->wnext;
 1048|  51.0k|                    from = state->window + (state->wsize - copy);
 1049|  51.0k|                }
 1050|   922k|                else
 1051|   922k|                    from = state->window + (state->wnext - copy);
 1052|   973k|                if (copy > state->length) copy = state->length;
  ------------------
  |  Branch (1052:21): [True: 179k, False: 793k]
  ------------------
 1053|   973k|            }
 1054|  1.60M|            else {                              /* copy from output */
 1055|  1.60M|                from = put - state->offset;
 1056|  1.60M|                copy = state->length;
 1057|  1.60M|            }
 1058|  2.58M|            if (copy > left) copy = left;
  ------------------
  |  Branch (1058:17): [True: 858k, False: 1.72M]
  ------------------
 1059|  2.58M|            left -= copy;
 1060|  2.58M|            state->length -= copy;
 1061|   213M|            do {
 1062|   213M|                *put++ = *from++;
 1063|   213M|            } while (--copy);
  ------------------
  |  Branch (1063:22): [True: 210M, False: 2.58M]
  ------------------
 1064|  2.58M|            if (state->length == 0) state->mode = LEN;
  ------------------
  |  Branch (1064:17): [True: 941k, False: 1.64M]
  ------------------
 1065|  2.58M|            break;
 1066|   350k|        case LIT:
  ------------------
  |  Branch (1066:9): [True: 350k, False: 4.97M]
  ------------------
 1067|   350k|            if (left == 0) goto inf_leave;
  ------------------
  |  Branch (1067:17): [True: 7.91k, False: 342k]
  ------------------
 1068|   342k|            *put++ = (unsigned char)(state->length);
 1069|   342k|            left--;
 1070|   342k|            state->mode = LEN;
 1071|   342k|            break;
 1072|   100k|        case CHECK:
  ------------------
  |  Branch (1072:9): [True: 100k, False: 5.22M]
  ------------------
 1073|   100k|            if (state->wrap) {
  ------------------
  |  Branch (1073:17): [True: 100k, False: 0]
  ------------------
 1074|   100k|                NEEDBITS(32);
  ------------------
  |  |  369|   100k|    do { \
  |  |  370|   501k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 401k, False: 100k]
  |  |  ------------------
  |  |  371|   401k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   401k|    do { \
  |  |  |  |  360|   401k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 403, False: 400k]
  |  |  |  |  ------------------
  |  |  |  |  361|   401k|        have--; \
  |  |  |  |  362|   400k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   400k|        bits += 8; \
  |  |  |  |  364|   400k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 400k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   100k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 100k]
  |  |  ------------------
  ------------------
 1075|   100k|                out -= left;
 1076|   100k|                strm->total_out += out;
 1077|   100k|                state->total += out;
 1078|   100k|                if ((state->wrap & 4) && out)
  ------------------
  |  Branch (1078:21): [True: 100k, False: 0]
  |  Branch (1078:42): [True: 98.9k, False: 1.08k]
  ------------------
 1079|  98.9k|                    strm->adler = state->check =
 1080|  98.9k|                        UPDATE_CHECK(state->check, put - out, out);
  ------------------
  |  |  305|  98.9k|#  define UPDATE_CHECK(check, buf, len) adler32(check, buf, len)
  |  |  ------------------
  |  |  |  |   34|  98.9k|#  define adler32               z_adler32
  |  |  ------------------
  ------------------
 1081|   100k|                out = left;
 1082|   100k|                if ((state->wrap & 4) && (
  ------------------
  |  Branch (1082:21): [True: 100k, False: 0]
  |  Branch (1082:42): [True: 11.5k, False: 88.5k]
  ------------------
 1083|       |#ifdef GUNZIP
 1084|       |                     state->flags ? hold :
 1085|       |#endif
 1086|   100k|                     ZSWAP32(hold)) != state->check) {
  ------------------
  |  |  258|   100k|#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
  |  |  259|   100k|                    (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
  ------------------
 1087|  11.5k|                    strm->msg = (z_const char *)"incorrect data check";
 1088|  11.5k|                    state->mode = BAD;
 1089|  11.5k|                    break;
 1090|  11.5k|                }
 1091|  88.5k|                INITBITS();
  ------------------
  |  |  351|  88.5k|    do { \
  |  |  352|  88.5k|        hold = 0; \
  |  |  353|  88.5k|        bits = 0; \
  |  |  354|  88.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 88.5k]
  |  |  ------------------
  ------------------
 1092|  88.5k|                Tracev((stderr, "inflate:   check matches trailer\n"));
 1093|  88.5k|            }
 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|  88.5k|            state->mode = DONE;
 1110|       |                /* fallthrough */
 1111|  88.5k|        case DONE:
  ------------------
  |  Branch (1111:9): [True: 7, False: 5.32M]
  ------------------
 1112|  88.5k|            ret = Z_STREAM_END;
  ------------------
  |  |  182|  88.5k|#define Z_STREAM_END    1
  ------------------
 1113|  88.5k|            goto inf_leave;
 1114|  41.9k|        case BAD:
  ------------------
  |  Branch (1114:9): [True: 41.9k, False: 5.28M]
  ------------------
 1115|  41.9k|            ret = Z_DATA_ERROR;
  ------------------
  |  |  186|  41.9k|#define Z_DATA_ERROR   (-3)
  ------------------
 1116|  41.9k|            goto inf_leave;
 1117|      0|        case MEM:
  ------------------
  |  Branch (1117:9): [True: 0, False: 5.32M]
  ------------------
 1118|      0|            return Z_MEM_ERROR;
  ------------------
  |  |  187|      0|#define Z_MEM_ERROR    (-4)
  ------------------
 1119|      0|        case SYNC:
  ------------------
  |  Branch (1119:9): [True: 0, False: 5.32M]
  ------------------
 1120|       |                /* fallthrough */
 1121|      0|        default:
  ------------------
  |  Branch (1121:9): [True: 0, False: 5.32M]
  ------------------
 1122|      0|            return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
 1123|  5.32M|        }
 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|  1.09M|  inf_leave:
 1132|  1.09M|    RESTORE();
  ------------------
  |  |  340|  1.09M|    do { \
  |  |  341|  1.09M|        strm->next_out = put; \
  |  |  342|  1.09M|        strm->avail_out = left; \
  |  |  343|  1.09M|        strm->next_in = next; \
  |  |  344|  1.09M|        strm->avail_in = have; \
  |  |  345|  1.09M|        state->hold = hold; \
  |  |  346|  1.09M|        state->bits = bits; \
  |  |  347|  1.09M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 1.09M]
  |  |  ------------------
  ------------------
 1133|  1.09M|    if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
  ------------------
  |  Branch (1133:9): [True: 913k, False: 178k]
  |  Branch (1133:26): [True: 33.2k, False: 145k]
  |  Branch (1133:52): [True: 25.1k, False: 8.11k]
  ------------------
 1134|  25.1k|            (state->mode < CHECK || flush != Z_FINISH)))
  ------------------
  |  |  176|    147|#define Z_FINISH        4
  ------------------
  |  Branch (1134:14): [True: 24.9k, False: 147]
  |  Branch (1134:37): [True: 147, False: 0]
  ------------------
 1135|   938k|        if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
  ------------------
  |  Branch (1135:13): [True: 0, False: 938k]
  ------------------
 1136|      0|            state->mode = MEM;
 1137|      0|            return Z_MEM_ERROR;
  ------------------
  |  |  187|      0|#define Z_MEM_ERROR    (-4)
  ------------------
 1138|      0|        }
 1139|  1.09M|    in -= strm->avail_in;
 1140|  1.09M|    out -= strm->avail_out;
 1141|  1.09M|    strm->total_in += in;
 1142|  1.09M|    strm->total_out += out;
 1143|  1.09M|    state->total += out;
 1144|  1.09M|    if ((state->wrap & 4) && out)
  ------------------
  |  Branch (1144:9): [True: 1.09M, False: 0]
  |  Branch (1144:30): [True: 929k, False: 161k]
  ------------------
 1145|   929k|        strm->adler = state->check =
 1146|   929k|            UPDATE_CHECK(state->check, strm->next_out - out, out);
  ------------------
  |  |  305|   929k|#  define UPDATE_CHECK(check, buf, len) adler32(check, buf, len)
  |  |  ------------------
  |  |  |  |   34|   929k|#  define adler32               z_adler32
  |  |  ------------------
  ------------------
 1147|  1.09M|    strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
  ------------------
  |  Branch (1147:43): [True: 1.04M, False: 45.8k]
  ------------------
 1148|  1.09M|                      (state->mode == TYPE ? 128 : 0) +
  ------------------
  |  Branch (1148:24): [True: 551, False: 1.09M]
  ------------------
 1149|  1.09M|                      (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
  ------------------
  |  Branch (1149:24): [True: 0, False: 1.09M]
  |  Branch (1149:47): [True: 0, False: 1.09M]
  ------------------
 1150|  1.09M|    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
  ------------------
  |  |  176|  1.06M|#define Z_FINISH        4
  ------------------
                  if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
  ------------------
  |  |  181|  23.6k|#define Z_OK            0
  ------------------
  |  Branch (1150:11): [True: 567k, False: 523k]
  |  Branch (1150:22): [True: 23.6k, False: 544k]
  |  Branch (1150:35): [True: 0, False: 1.06M]
  |  Branch (1150:57): [True: 23.5k, False: 96]
  ------------------
 1151|  23.5k|        ret = Z_BUF_ERROR;
  ------------------
  |  |  188|  23.5k|#define Z_BUF_ERROR    (-5)
  ------------------
 1152|  1.09M|    return ret;
 1153|  1.09M|}
z_inflateEnd:
 1155|   169k|int ZEXPORT inflateEnd(z_streamp strm) {
 1156|   169k|    struct inflate_state FAR *state;
 1157|   169k|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (1157:9): [True: 15.6k, False: 154k]
  ------------------
 1158|  15.6k|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|  15.6k|#define Z_STREAM_ERROR (-2)
  ------------------
 1159|   154k|    state = (struct inflate_state FAR *)strm->state;
 1160|   154k|    if (state->window != Z_NULL) ZFREE(strm, state->window);
  ------------------
  |  |  216|   154k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
                  if (state->window != Z_NULL) ZFREE(strm, state->window);
  ------------------
  |  |  254|  25.1k|#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  ------------------
  |  Branch (1160:9): [True: 25.1k, False: 129k]
  ------------------
 1161|   154k|    ZFREE(strm, strm->state);
  ------------------
  |  |  254|   154k|#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  ------------------
 1162|   154k|    strm->state = Z_NULL;
  ------------------
  |  |  216|   154k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
 1163|   154k|    Tracev((stderr, "inflate: end\n"));
 1164|   154k|    return Z_OK;
  ------------------
  |  |  181|   154k|#define Z_OK            0
  ------------------
 1165|   169k|}
z_inflateValidate:
 1385|   154k|int ZEXPORT inflateValidate(z_streamp strm, int check) {
 1386|   154k|    struct inflate_state FAR *state;
 1387|       |
 1388|   154k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (1388:9): [True: 0, False: 154k]
  ------------------
 1389|   154k|    state = (struct inflate_state FAR *)strm->state;
 1390|   154k|    if (check && state->wrap)
  ------------------
  |  Branch (1390:9): [True: 154k, False: 0]
  |  Branch (1390:18): [True: 154k, False: 0]
  ------------------
 1391|   154k|        state->wrap |= 4;
 1392|      0|    else
 1393|      0|        state->wrap &= ~4;
 1394|   154k|    return Z_OK;
  ------------------
  |  |  181|   154k|#define Z_OK            0
  ------------------
 1395|   154k|}
inflate.c:inflateStateCheck:
   88|  1.87M|local int inflateStateCheck(z_streamp strm) {
   89|  1.87M|    struct inflate_state FAR *state;
   90|  1.87M|    if (strm == Z_NULL ||
  ------------------
  |  |  216|  3.75M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (90:9): [True: 0, False: 1.87M]
  ------------------
   91|  1.87M|        strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
  ------------------
  |  Branch (91:9): [True: 15.6k, False: 1.86M]
  |  Branch (91:42): [True: 0, False: 1.86M]
  ------------------
   92|  15.6k|        return 1;
   93|  1.86M|    state = (struct inflate_state FAR *)strm->state;
   94|  1.86M|    if (state == Z_NULL || state->strm != strm ||
  ------------------
  |  |  216|  3.72M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (94:9): [True: 0, False: 1.86M]
  |  Branch (94:28): [True: 0, False: 1.86M]
  ------------------
   95|  1.86M|        state->mode < HEAD || state->mode > SYNC)
  ------------------
  |  Branch (95:9): [True: 0, False: 1.86M]
  |  Branch (95:31): [True: 0, False: 1.86M]
  ------------------
   96|      0|        return 1;
   97|  1.86M|    return 0;
   98|  1.86M|}
inflate.c:updatewindow:
  252|   938k|local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
  253|   938k|    struct inflate_state FAR *state;
  254|   938k|    unsigned dist;
  255|       |
  256|   938k|    state = (struct inflate_state FAR *)strm->state;
  257|       |
  258|       |    /* if it hasn't been done already, allocate space for the window */
  259|   938k|    if (state->window == Z_NULL) {
  ------------------
  |  |  216|   938k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (259:9): [True: 25.1k, False: 913k]
  ------------------
  260|  25.1k|        state->window = (unsigned char FAR *)
  261|  25.1k|                        ZALLOC(strm, 1U << state->wbits,
  ------------------
  |  |  253|  25.1k|           (*((strm)->zalloc))((strm)->opaque, (items), (size))
  ------------------
  262|  25.1k|                               sizeof(unsigned char));
  263|  25.1k|        if (state->window == Z_NULL) return 1;
  ------------------
  |  |  216|  25.1k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (263:13): [True: 0, False: 25.1k]
  ------------------
  264|  25.1k|    }
  265|       |
  266|       |    /* if window not in use yet, initialize */
  267|   938k|    if (state->wsize == 0) {
  ------------------
  |  Branch (267:9): [True: 25.1k, False: 913k]
  ------------------
  268|  25.1k|        state->wsize = 1U << state->wbits;
  269|  25.1k|        state->wnext = 0;
  270|  25.1k|        state->whave = 0;
  271|  25.1k|    }
  272|       |
  273|       |    /* copy state->wsize or less output bytes into the circular window */
  274|   938k|    if (copy >= state->wsize) {
  ------------------
  |  Branch (274:9): [True: 21.2k, False: 916k]
  ------------------
  275|  21.2k|        zmemcpy(state->window, end - state->wsize, state->wsize);
  ------------------
  |  |  216|  21.2k|#    define zmemcpy memcpy
  ------------------
  276|  21.2k|        state->wnext = 0;
  277|  21.2k|        state->whave = state->wsize;
  278|  21.2k|    }
  279|   916k|    else {
  280|   916k|        dist = state->wsize - state->wnext;
  281|   916k|        if (dist > copy) dist = copy;
  ------------------
  |  Branch (281:13): [True: 899k, False: 17.0k]
  ------------------
  282|   916k|        zmemcpy(state->window + state->wnext, end - copy, dist);
  ------------------
  |  |  216|   916k|#    define zmemcpy memcpy
  ------------------
  283|   916k|        copy -= dist;
  284|   916k|        if (copy) {
  ------------------
  |  Branch (284:13): [True: 9.32k, False: 907k]
  ------------------
  285|  9.32k|            zmemcpy(state->window, end - copy, copy);
  ------------------
  |  |  216|  9.32k|#    define zmemcpy memcpy
  ------------------
  286|  9.32k|            state->wnext = copy;
  287|  9.32k|            state->whave = state->wsize;
  288|  9.32k|        }
  289|   907k|        else {
  290|   907k|            state->wnext += dist;
  291|   907k|            if (state->wnext == state->wsize) state->wnext = 0;
  ------------------
  |  Branch (291:17): [True: 7.72k, False: 899k]
  ------------------
  292|   907k|            if (state->whave < state->wsize) state->whave += dist;
  ------------------
  |  Branch (292:17): [True: 585k, False: 321k]
  ------------------
  293|   907k|        }
  294|   916k|    }
  295|   938k|    return 0;
  296|   938k|}

z_inflate_table:
   48|  57.0k|                                unsigned FAR *bits, unsigned short FAR *work) {
   49|  57.0k|    unsigned len;               /* a code's length in bits */
   50|  57.0k|    unsigned sym;               /* index of code symbols */
   51|  57.0k|    unsigned min, max;          /* minimum and maximum code lengths */
   52|  57.0k|    unsigned root;              /* number of index bits for root table */
   53|  57.0k|    unsigned curr;              /* number of index bits for current table */
   54|  57.0k|    unsigned drop;              /* code bits to drop for sub-table */
   55|  57.0k|    int left;                   /* number of prefix codes available */
   56|  57.0k|    unsigned used;              /* code entries in table used */
   57|  57.0k|    unsigned huff;              /* Huffman code */
   58|  57.0k|    unsigned incr;              /* for incrementing code, index */
   59|  57.0k|    unsigned fill;              /* index for replicating entries */
   60|  57.0k|    unsigned low;               /* low bits for current root entry */
   61|  57.0k|    unsigned mask;              /* mask for low root bits */
   62|  57.0k|    code here;                  /* table entry for duplication */
   63|  57.0k|    code FAR *next;             /* next available space in table */
   64|  57.0k|    const unsigned short FAR *base = NULL;  /* base value table to use */
   65|  57.0k|    const unsigned short FAR *extra = NULL; /* extra bits table to use */
   66|  57.0k|    unsigned match = 0;         /* use base and extra for symbol >= match */
   67|  57.0k|    unsigned short count[MAXBITS+1];    /* number of codes of each length */
   68|  57.0k|    unsigned short offs[MAXBITS+1];     /* offsets in table for each length */
   69|  57.0k|    static const unsigned short lbase[31] = { /* Length codes 257..285 base */
   70|  57.0k|        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
   71|  57.0k|        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
   72|  57.0k|    static const unsigned short lext[31] = { /* Length codes 257..285 extra */
   73|  57.0k|        16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
   74|  57.0k|        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 75};
   75|  57.0k|    static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
   76|  57.0k|        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
   77|  57.0k|        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
   78|  57.0k|        8193, 12289, 16385, 24577, 0, 0};
   79|  57.0k|    static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
   80|  57.0k|        16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
   81|  57.0k|        23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
   82|  57.0k|        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|   969k|    for (len = 0; len <= MAXBITS; len++)
  ------------------
  |  |   23|   969k|#define MAXBITS 15
  ------------------
  |  Branch (116:19): [True: 912k, False: 57.0k]
  ------------------
  117|   912k|        count[len] = 0;
  118|  5.51M|    for (sym = 0; sym < codes; sym++)
  ------------------
  |  Branch (118:19): [True: 5.45M, False: 57.0k]
  ------------------
  119|  5.45M|        count[lens[sym]]++;
  120|       |
  121|       |    /* bound code lengths, force root to be within code lengths */
  122|  57.0k|    root = *bits;
  123|   609k|    for (max = MAXBITS; max >= 1; max--)
  ------------------
  |  |   23|  57.0k|#define MAXBITS 15
  ------------------
  |  Branch (123:25): [True: 609k, False: 288]
  ------------------
  124|   609k|        if (count[max] != 0) break;
  ------------------
  |  Branch (124:13): [True: 56.7k, False: 552k]
  ------------------
  125|  57.0k|    if (root > max) root = max;
  ------------------
  |  Branch (125:9): [True: 45.4k, False: 11.6k]
  ------------------
  126|  57.0k|    if (max == 0) {                     /* no symbols to code at all */
  ------------------
  |  Branch (126:9): [True: 288, False: 56.7k]
  ------------------
  127|    288|        here.op = (unsigned char)64;    /* invalid code marker */
  128|    288|        here.bits = (unsigned char)1;
  129|    288|        here.val = (unsigned short)0;
  130|    288|        *(*table)++ = here;             /* make a table to force an error */
  131|    288|        *(*table)++ = here;
  132|    288|        *bits = 1;
  133|    288|        return 0;     /* no symbols, but wait for decoding to report error */
  134|    288|    }
  135|  90.6k|    for (min = 1; min < max; min++)
  ------------------
  |  Branch (135:19): [True: 88.4k, False: 2.21k]
  ------------------
  136|  88.4k|        if (count[min] != 0) break;
  ------------------
  |  Branch (136:13): [True: 54.5k, False: 33.9k]
  ------------------
  137|  56.7k|    if (root < min) root = min;
  ------------------
  |  Branch (137:9): [True: 138, False: 56.6k]
  ------------------
  138|       |
  139|       |    /* check for an over-subscribed or incomplete set of lengths */
  140|  56.7k|    left = 1;
  141|   872k|    for (len = 1; len <= MAXBITS; len++) {
  ------------------
  |  |   23|   872k|#define MAXBITS 15
  ------------------
  |  Branch (141:19): [True: 818k, False: 53.7k]
  ------------------
  142|   818k|        left <<= 1;
  143|   818k|        left -= count[len];
  144|   818k|        if (left < 0) return -1;        /* over-subscribed */
  ------------------
  |  Branch (144:13): [True: 3.03k, False: 815k]
  ------------------
  145|   818k|    }
  146|  53.7k|    if (left > 0 && (type == CODES || max != 1))
  ------------------
  |  Branch (146:9): [True: 1.77k, False: 51.9k]
  |  Branch (146:22): [True: 385, False: 1.38k]
  |  Branch (146:39): [True: 1.08k, False: 307]
  ------------------
  147|  1.46k|        return -1;                      /* incomplete set */
  148|       |
  149|       |    /* generate offsets into symbol table for each length for sorting */
  150|  52.2k|    offs[1] = 0;
  151|   783k|    for (len = 1; len < MAXBITS; len++)
  ------------------
  |  |   23|   783k|#define MAXBITS 15
  ------------------
  |  Branch (151:19): [True: 731k, False: 52.2k]
  ------------------
  152|   731k|        offs[len + 1] = offs[len] + count[len];
  153|       |
  154|       |    /* sort symbols by length, by symbol order within each length */
  155|  5.09M|    for (sym = 0; sym < codes; sym++)
  ------------------
  |  Branch (155:19): [True: 5.03M, False: 52.2k]
  ------------------
  156|  5.03M|        if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
  ------------------
  |  Branch (156:13): [True: 854k, False: 4.18M]
  ------------------
  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|  52.2k|    switch (type) {
  ------------------
  |  Branch (190:13): [True: 52.2k, False: 0]
  ------------------
  191|  22.4k|    case CODES:
  ------------------
  |  Branch (191:5): [True: 22.4k, False: 29.8k]
  ------------------
  192|  22.4k|        match = 20;
  193|  22.4k|        break;
  194|  15.1k|    case LENS:
  ------------------
  |  Branch (194:5): [True: 15.1k, False: 37.0k]
  ------------------
  195|  15.1k|        base = lbase;
  196|  15.1k|        extra = lext;
  197|  15.1k|        match = 257;
  198|  15.1k|        break;
  199|  14.6k|    case DISTS:
  ------------------
  |  Branch (199:5): [True: 14.6k, False: 37.5k]
  ------------------
  200|  14.6k|        base = dbase;
  201|  14.6k|        extra = dext;
  202|  52.2k|    }
  203|       |
  204|       |    /* initialize state for loop */
  205|  52.2k|    huff = 0;                   /* starting code */
  206|  52.2k|    sym = 0;                    /* starting code symbol */
  207|  52.2k|    len = min;                  /* starting code length */
  208|  52.2k|    next = *table;              /* current table to fill in */
  209|  52.2k|    curr = root;                /* current table index bits */
  210|  52.2k|    drop = 0;                   /* current bits to drop from code for index */
  211|  52.2k|    low = (unsigned)(-1);       /* trigger new sub-table when len > root */
  212|  52.2k|    used = 1U << root;          /* use root table entries */
  213|  52.2k|    mask = used - 1;            /* mask for comparing low */
  214|       |
  215|       |    /* check available table space */
  216|  52.2k|    if ((type == LENS && used > ENOUGH_LENS) ||
  ------------------
  |  |   49|  15.1k|#define ENOUGH_LENS 852
  ------------------
  |  Branch (216:10): [True: 15.1k, False: 37.0k]
  |  Branch (216:26): [True: 0, False: 15.1k]
  ------------------
  217|  52.2k|        (type == DISTS && used > ENOUGH_DISTS))
  ------------------
  |  |   50|  14.6k|#define ENOUGH_DISTS 592
  ------------------
  |  Branch (217:10): [True: 14.6k, False: 37.5k]
  |  Branch (217:27): [True: 0, False: 14.6k]
  ------------------
  218|      0|        return 1;
  219|       |
  220|       |    /* process all codes and make table entries */
  221|   854k|    for (;;) {
  222|       |        /* create table entry */
  223|   854k|        here.bits = (unsigned char)(len - drop);
  224|   854k|        if (work[sym] + 1U < match) {
  ------------------
  |  Branch (224:13): [True: 575k, False: 279k]
  ------------------
  225|   575k|            here.op = (unsigned char)0;
  226|   575k|            here.val = work[sym];
  227|   575k|        }
  228|   279k|        else if (work[sym] >= match) {
  ------------------
  |  Branch (228:18): [True: 264k, False: 15.1k]
  ------------------
  229|   264k|            here.op = (unsigned char)(extra[work[sym] - match]);
  230|   264k|            here.val = base[work[sym] - match];
  231|   264k|        }
  232|  15.1k|        else {
  233|  15.1k|            here.op = (unsigned char)(32 + 64);         /* end of block */
  234|  15.1k|            here.val = 0;
  235|  15.1k|        }
  236|       |
  237|       |        /* replicate for those indices with low len bits equal to huff */
  238|   854k|        incr = 1U << (len - drop);
  239|   854k|        fill = 1U << curr;
  240|   854k|        min = fill;                 /* save offset to next table */
  241|  3.50M|        do {
  242|  3.50M|            fill -= incr;
  243|  3.50M|            next[(huff >> drop) + fill] = here;
  244|  3.50M|        } while (fill != 0);
  ------------------
  |  Branch (244:18): [True: 2.64M, False: 854k]
  ------------------
  245|       |
  246|       |        /* backwards increment the len-bit code huff */
  247|   854k|        incr = 1U << (len - 1);
  248|  1.65M|        while (huff & incr)
  ------------------
  |  Branch (248:16): [True: 802k, False: 854k]
  ------------------
  249|   802k|            incr >>= 1;
  250|   854k|        if (incr != 0) {
  ------------------
  |  Branch (250:13): [True: 802k, False: 51.9k]
  ------------------
  251|   802k|            huff &= incr - 1;
  252|   802k|            huff += incr;
  253|   802k|        }
  254|  51.9k|        else
  255|  51.9k|            huff = 0;
  256|       |
  257|       |        /* go to next symbol, update count, len */
  258|   854k|        sym++;
  259|   854k|        if (--(count[len]) == 0) {
  ------------------
  |  Branch (259:13): [True: 225k, False: 628k]
  ------------------
  260|   225k|            if (len == max) break;
  ------------------
  |  Branch (260:17): [True: 52.2k, False: 173k]
  ------------------
  261|   173k|            len = lens[work[sym]];
  262|   173k|        }
  263|       |
  264|       |        /* create new sub-table if needed */
  265|   802k|        if (len > root && (huff & mask) != low) {
  ------------------
  |  Branch (265:13): [True: 74.9k, False: 727k]
  |  Branch (265:27): [True: 26.2k, False: 48.7k]
  ------------------
  266|       |            /* if first time, transition to sub-tables */
  267|  26.2k|            if (drop == 0)
  ------------------
  |  Branch (267:17): [True: 6.19k, False: 20.0k]
  ------------------
  268|  6.19k|                drop = root;
  269|       |
  270|       |            /* increment past last table */
  271|  26.2k|            next += min;            /* here min is 1 << curr */
  272|       |
  273|       |            /* determine length of next table */
  274|  26.2k|            curr = len - drop;
  275|  26.2k|            left = (int)(1 << curr);
  276|  31.1k|            while (curr + drop < max) {
  ------------------
  |  Branch (276:20): [True: 23.2k, False: 7.92k]
  ------------------
  277|  23.2k|                left -= count[curr + drop];
  278|  23.2k|                if (left <= 0) break;
  ------------------
  |  Branch (278:21): [True: 18.3k, False: 4.90k]
  ------------------
  279|  4.90k|                curr++;
  280|  4.90k|                left <<= 1;
  281|  4.90k|            }
  282|       |
  283|       |            /* check for enough space */
  284|  26.2k|            used += 1U << curr;
  285|  26.2k|            if ((type == LENS && used > ENOUGH_LENS) ||
  ------------------
  |  |   49|  16.7k|#define ENOUGH_LENS 852
  ------------------
  |  Branch (285:18): [True: 16.7k, False: 9.50k]
  |  Branch (285:34): [True: 0, False: 16.7k]
  ------------------
  286|  26.2k|                (type == DISTS && used > ENOUGH_DISTS))
  ------------------
  |  |   50|  9.50k|#define ENOUGH_DISTS 592
  ------------------
  |  Branch (286:18): [True: 9.50k, False: 16.7k]
  |  Branch (286:35): [True: 0, False: 9.50k]
  ------------------
  287|      0|                return 1;
  288|       |
  289|       |            /* point entry in root table to sub-table */
  290|  26.2k|            low = huff & mask;
  291|  26.2k|            (*table)[low].op = (unsigned char)curr;
  292|  26.2k|            (*table)[low].bits = (unsigned char)root;
  293|  26.2k|            (*table)[low].val = (unsigned short)(next - *table);
  294|  26.2k|        }
  295|   802k|    }
  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|  52.2k|    if (huff != 0) {
  ------------------
  |  Branch (300:9): [True: 307, False: 51.9k]
  ------------------
  301|    307|        here.op = (unsigned char)64;            /* invalid code marker */
  302|    307|        here.bits = (unsigned char)(len - drop);
  303|    307|        here.val = (unsigned short)0;
  304|    307|        next[huff] = here;
  305|    307|    }
  306|       |
  307|       |    /* set return parameters */
  308|  52.2k|    *table += used;
  309|  52.2k|    *bits = root;
  310|  52.2k|    return 0;
  311|  52.2k|}
z_inflate_fixed:
  364|   115k|void inflate_fixed(struct inflate_state FAR *state) {
  365|       |#ifdef BUILDFIXED
  366|       |    z_once(&built, buildtables);
  367|       |#endif /* BUILDFIXED */
  368|   115k|    state->lencode = lenfix;
  369|   115k|    state->lenbits = 9;
  370|   115k|    state->distcode = distfix;
  371|   115k|    state->distbits = 5;
  372|   115k|}

tj3Compress12:
   80|  21.2k|{
   81|  21.2k|  static const char FUNCTION_NAME[] = GET_STRING(tj3Compress, BITS_IN_JSAMPLE);
  ------------------
  |  |   71|  21.2k|#define GET_STRING(name, suffix)  _GET_STRING(name, suffix)
  |  |  ------------------
  |  |  |  |   70|  21.2k|#define _GET_STRING(name, suffix)  #name #suffix
  |  |  ------------------
  ------------------
   82|  21.2k|  int i, retval = 0;
   83|  21.2k|  boolean alloc = TRUE;
  ------------------
  |  |  210|  21.2k|#define TRUE    1
  ------------------
   84|  21.2k|  _JSAMPROW *row_pointer = NULL;
  ------------------
  |  |   46|  21.2k|#define _JSAMPROW  J12SAMPROW
  ------------------
   85|       |
   86|  21.2k|  GET_CINSTANCE(handle)
  ------------------
  |  |  326|  21.2k|  tjinstance *this = (tjinstance *)handle; \
  |  |  327|  21.2k|  j_compress_ptr cinfo = NULL; \
  |  |  328|  21.2k|  \
  |  |  329|  21.2k|  if (!this) { \
  |  |  ------------------
  |  |  |  Branch (329:7): [True: 0, False: 21.2k]
  |  |  ------------------
  |  |  330|      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 */
  |  |  ------------------
  |  |  331|      0|    return -1; \
  |  |  332|      0|  } \
  |  |  333|  21.2k|  cinfo = &this->cinfo; \
  |  |  334|  21.2k|  this->jerr.warning = FALSE; \
  |  |  ------------------
  |  |  |  |  207|  21.2k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  335|  21.2k|  this->isInstanceError = FALSE;
  |  |  ------------------
  |  |  |  |  207|  21.2k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  ------------------
   87|  21.2k|  if ((this->init & COMPRESS) == 0)
  ------------------
  |  Branch (87:7): [True: 0, False: 21.2k]
  ------------------
   88|  21.2k|    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|  21.2k|  if (srcBuf == NULL || width <= 0 || pitch < 0 || height <= 0 ||
  ------------------
  |  Branch (90:7): [True: 0, False: 21.2k]
  |  Branch (90:25): [True: 0, False: 21.2k]
  |  Branch (90:39): [True: 0, False: 21.2k]
  |  Branch (90:52): [True: 0, False: 21.2k]
  ------------------
   91|  21.2k|      pixelFormat < 0 || pixelFormat >= TJ_NUMPF || jpegBuf == NULL ||
  ------------------
  |  |  283|  42.4k|#define TJ_NUMPF  12
  ------------------
  |  Branch (91:7): [True: 0, False: 21.2k]
  |  Branch (91:26): [True: 0, False: 21.2k]
  |  Branch (91:53): [True: 0, False: 21.2k]
  ------------------
   92|  21.2k|      jpegSize == NULL)
  ------------------
  |  Branch (92:7): [True: 0, False: 21.2k]
  ------------------
   93|  21.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|}
  |  |  ------------------
  ------------------
   94|       |
   95|  21.2k|  if (!this->lossless && this->quality == -1)
  ------------------
  |  Branch (95:7): [True: 21.2k, False: 0]
  |  Branch (95:26): [True: 0, False: 21.2k]
  ------------------
   96|  21.2k|    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|  21.2k|  if (!this->lossless && this->subsamp == TJSAMP_UNKNOWN)
  ------------------
  |  Branch (97:7): [True: 21.2k, False: 0]
  |  Branch (97:26): [True: 0, False: 21.2k]
  ------------------
   98|  21.2k|    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|  21.2k|  if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
  ------------------
  |  Branch (100:7): [True: 21.2k, False: 0]
  ------------------
  101|      0|  else if (pitch < width * tjPixelSize[pixelFormat])
  ------------------
  |  Branch (101:12): [True: 0, False: 0]
  ------------------
  102|  21.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|}
  |  |  ------------------
  ------------------
  103|       |
  104|  21.2k|  if ((row_pointer = (_JSAMPROW *)malloc(sizeof(_JSAMPROW) * height)) == NULL)
  ------------------
  |  Branch (104:7): [True: 0, False: 21.2k]
  ------------------
  105|  21.2k|    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|  21.2k|  CATCH_LIBJPEG(this);
  ------------------
  |  |  293|  21.2k|#define CATCH_LIBJPEG(this) { \
  |  |  294|  21.2k|  if (setjmp(this->jerr.setjmp_buffer)) { \
  |  |  295|      3|    /* If we get here, the JPEG code has signaled an error. */ \
  |  |  296|      3|    retval = -1;  goto bailout; \
  |  |  297|      3|  } \
  |  |  298|  21.2k|}
  ------------------
  |  Branch (107:3): [True: 3, False: 21.2k]
  ------------------
  108|       |
  109|  21.2k|  cinfo->image_width = width;
  110|  21.2k|  cinfo->image_height = height;
  111|  21.2k|  cinfo->data_precision = BITS_IN_JSAMPLE;
  ------------------
  |  | 1270|  21.2k|#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|  21.2k|  if (this->lossless && this->precision >= BITS_IN_JSAMPLE - 3 &&
  ------------------
  |  | 1270|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (116:7): [True: 0, False: 21.2k]
  |  Branch (116:25): [True: 0, False: 0]
  ------------------
  117|      0|      this->precision <= BITS_IN_JSAMPLE)
  ------------------
  |  | 1270|      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|  21.2k|  setCompDefaults(this, pixelFormat, FALSE);
  ------------------
  |  |  207|  21.2k|#define FALSE   0               /* values of boolean */
  ------------------
  122|  21.2k|  if (this->noRealloc) alloc = FALSE;
  ------------------
  |  |  207|  3.01k|#define FALSE   0               /* values of boolean */
  ------------------
  |  Branch (122:7): [True: 3.01k, False: 18.2k]
  ------------------
  123|  21.2k|  jpeg_mem_dest_tj(cinfo, jpegBuf, jpegSize, alloc);
  124|       |
  125|  21.2k|  jpeg_start_compress(cinfo, TRUE);
  ------------------
  |  |  210|  21.2k|#define TRUE    1
  ------------------
  126|  21.2k|  if (this->iccBuf != NULL && this->iccSize != 0)
  ------------------
  |  Branch (126:7): [True: 17.7k, False: 3.46k]
  |  Branch (126:31): [True: 17.7k, False: 0]
  ------------------
  127|  17.7k|    jpeg_write_icc_profile(cinfo, this->iccBuf, (unsigned int)this->iccSize);
  128|  26.2M|  for (i = 0; i < height; i++) {
  ------------------
  |  Branch (128:15): [True: 26.1M, False: 21.2k]
  ------------------
  129|  26.1M|    if (this->bottomUp)
  ------------------
  |  Branch (129:9): [True: 3.85M, False: 22.3M]
  ------------------
  130|  3.85M|      row_pointer[i] = (_JSAMPROW)&srcBuf[(height - i - 1) * (size_t)pitch];
  131|  22.3M|    else
  132|  22.3M|      row_pointer[i] = (_JSAMPROW)&srcBuf[i * (size_t)pitch];
  133|  26.1M|  }
  134|  42.4k|  while (cinfo->next_scanline < cinfo->image_height)
  ------------------
  |  Branch (134:10): [True: 21.2k, False: 21.2k]
  ------------------
  135|  21.2k|    _jpeg_write_scanlines(cinfo, &row_pointer[cinfo->next_scanline],
  ------------------
  |  |   55|  21.2k|#define _jpeg_write_scanlines  jpeg12_write_scanlines
  ------------------
  136|  21.2k|                          cinfo->image_height - cinfo->next_scanline);
  137|  21.2k|  jpeg_finish_compress(cinfo);
  138|       |
  139|  21.2k|bailout:
  140|  21.2k|  if (cinfo->global_state > CSTATE_START && alloc)
  ------------------
  |  |   44|  42.4k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (140:7): [True: 3, False: 21.2k]
  |  Branch (140:45): [True: 3, False: 0]
  ------------------
  141|      3|    (*cinfo->dest->term_destination) (cinfo);
  142|  21.2k|  if (cinfo->global_state > CSTATE_START || retval == -1)
  ------------------
  |  |   44|  42.4k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (142:7): [True: 3, False: 21.2k]
  |  Branch (142:45): [True: 0, False: 21.2k]
  ------------------
  143|      3|    jpeg_abort_compress(cinfo);
  144|  21.2k|  free(row_pointer);
  145|  21.2k|  if (this->jerr.warning) retval = -1;
  ------------------
  |  Branch (145:7): [True: 0, False: 21.2k]
  ------------------
  146|  21.2k|  return retval;
  147|  21.2k|}
_tj3LoadImageFromFileHandle12:
  306|  47.9k|{
  307|  47.9k|  static const char FUNCTION_NAME[] =
  308|  47.9k|    GET_STRING(tj3LoadImage, BITS_IN_JSAMPLE);
  ------------------
  |  |   71|  47.9k|#define GET_STRING(name, suffix)  _GET_STRING(name, suffix)
  |  |  ------------------
  |  |  |  |   70|  47.9k|#define _GET_STRING(name, suffix)  #name #suffix
  |  |  ------------------
  ------------------
  309|       |
  310|  47.9k|  int retval = 0, tempc;
  311|  47.9k|  size_t pitch;
  312|  47.9k|  tjhandle handle2 = NULL;
  313|  47.9k|  tjinstance *this2;
  314|  47.9k|  j_compress_ptr cinfo = NULL;
  315|  47.9k|  cjpeg_source_ptr src = NULL;
  316|  47.9k|  _JSAMPLE *dstBuf = NULL;
  ------------------
  |  |   45|  47.9k|#define _JSAMPLE  J12SAMPLE
  ------------------
  317|  47.9k|  boolean invert;
  318|       |
  319|  47.9k|  GET_TJINSTANCE(handle, NULL)
  ------------------
  |  |  350|  47.9k|  tjinstance *this = (tjinstance *)handle; \
  |  |  351|  47.9k|  \
  |  |  352|  47.9k|  if (!this) { \
  |  |  ------------------
  |  |  |  Branch (352:7): [True: 0, False: 47.9k]
  |  |  ------------------
  |  |  353|      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 */
  |  |  ------------------
  |  |  354|      0|    return errorReturn; \
  |  |  355|      0|  } \
  |  |  356|  47.9k|  this->jerr.warning = FALSE; \
  |  |  ------------------
  |  |  |  |  207|  47.9k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  357|  47.9k|  this->isInstanceError = FALSE;
  |  |  ------------------
  |  |  |  |  207|  47.9k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  ------------------
  320|       |
  321|  47.9k|  if (!file || !width || align < 1 || !height || !pixelFormat ||
  ------------------
  |  Branch (321:7): [True: 0, False: 47.9k]
  |  Branch (321:16): [True: 0, False: 47.9k]
  |  Branch (321:26): [True: 0, False: 47.9k]
  |  Branch (321:39): [True: 0, False: 47.9k]
  |  Branch (321:50): [True: 0, False: 47.9k]
  ------------------
  322|  47.9k|      *pixelFormat < TJPF_UNKNOWN || *pixelFormat >= TJ_NUMPF)
  ------------------
  |  |  283|  47.9k|#define TJ_NUMPF  12
  ------------------
  |  Branch (322:7): [True: 0, False: 47.9k]
  |  Branch (322:38): [True: 0, False: 47.9k]
  ------------------
  323|  47.9k|    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|  47.9k|  if ((align & (align - 1)) != 0)
  ------------------
  |  Branch (324:7): [True: 0, False: 47.9k]
  ------------------
  325|  47.9k|    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|  47.9k|  if ((handle2 = tj3Init(TJINIT_COMPRESS)) == NULL) return NULL;
  ------------------
  |  Branch (330:7): [True: 0, False: 47.9k]
  ------------------
  331|  47.9k|  this2 = (tjinstance *)handle2;
  332|  47.9k|  cinfo = &this2->cinfo;
  333|       |
  334|  47.9k|  if ((tempc = getc(file)) < 0 || ungetc(tempc, file) == EOF)
  ------------------
  |  Branch (334:7): [True: 0, False: 47.9k]
  |  Branch (334:35): [True: 0, False: 47.9k]
  ------------------
  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|  47.9k|  else if (tempc == EOF)
  ------------------
  |  Branch (336:12): [True: 0, False: 47.9k]
  ------------------
  337|  47.9k|    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|  47.9k|  CATCH_LIBJPEG2();
  ------------------
  |  |  303|  47.9k|#define CATCH_LIBJPEG2() { \
  |  |  304|  47.9k|  if (setjmp(this2->jerr.setjmp_buffer)) { \
  |  |  305|     35|    memcpy(this->errStr, this2->errStr, JMSG_LENGTH_MAX); \
  |  |  ------------------
  |  |  |  |  792|     35|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  306|     35|    this->jerr.warning = this2->jerr.warning; \
  |  |  307|     35|    this->isInstanceError = this2->isInstanceError; \
  |  |  308|     35|    retval = -1;  goto bailout; \
  |  |  309|     35|  } \
  |  |  310|  47.9k|}
  ------------------
  |  Branch (339:3): [True: 35, False: 47.9k]
  ------------------
  340|       |
  341|  47.9k|  cinfo->data_precision = BITS_IN_JSAMPLE;
  ------------------
  |  | 1270|  47.9k|#define BITS_IN_JSAMPLE  12
  ------------------
  342|  47.9k|  if (*pixelFormat == TJPF_UNKNOWN) cinfo->in_color_space = JCS_UNKNOWN;
  ------------------
  |  Branch (342:7): [True: 0, False: 47.9k]
  ------------------
  343|  47.9k|  else cinfo->in_color_space = pf2cs[*pixelFormat];
  344|  47.9k|  if (tempc == 'B') {
  ------------------
  |  Branch (344:7): [True: 35, False: 47.9k]
  ------------------
  345|     35|    if ((src = jinit_read_bmp(cinfo, FALSE)) == NULL)
  ------------------
  |  |  207|     35|#define FALSE   0               /* values of boolean */
  ------------------
  |  Branch (345:9): [True: 0, False: 35]
  ------------------
  346|     35|      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|     35|    invert = !this->bottomUp;
  348|  47.9k|  } else if (tempc == 0x89) {
  ------------------
  |  Branch (348:14): [True: 31.9k, False: 15.9k]
  ------------------
  349|       |#if BITS_IN_JSAMPLE == 8
  350|       |    if (this->precision >= 2 && this->precision <= BITS_IN_JSAMPLE)
  351|       |#else
  352|  31.9k|    if (this->precision >= BITS_IN_JSAMPLE - 3 &&
  ------------------
  |  | 1270|  31.9k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (352:9): [True: 0, False: 31.9k]
  ------------------
  353|      0|        this->precision <= BITS_IN_JSAMPLE)
  ------------------
  |  | 1270|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (353:9): [True: 0, False: 0]
  ------------------
  354|      0|#endif
  355|      0|      cinfo->data_precision = this->precision;
  356|  31.9k|    if ((src = _jinit_read_png(cinfo)) == NULL)
  ------------------
  |  |   48|  31.9k|#define _jinit_read_png  j12init_read_png
  ------------------
  |  Branch (356:9): [True: 0, False: 31.9k]
  ------------------
  357|  31.9k|      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|  31.9k|    invert = this->bottomUp;
  359|  31.9k|  } else if (tempc == 'P') {
  ------------------
  |  Branch (359:14): [True: 15.3k, False: 567]
  ------------------
  360|       |#if BITS_IN_JSAMPLE == 8
  361|       |    if (this->precision >= 2 && this->precision <= BITS_IN_JSAMPLE)
  362|       |#else
  363|  15.3k|    if (this->precision >= BITS_IN_JSAMPLE - 3 &&
  ------------------
  |  | 1270|  15.3k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (363:9): [True: 0, False: 15.3k]
  ------------------
  364|      0|        this->precision <= BITS_IN_JSAMPLE)
  ------------------
  |  | 1270|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (364:9): [True: 0, False: 0]
  ------------------
  365|      0|#endif
  366|      0|      cinfo->data_precision = this->precision;
  367|  15.3k|    if ((src = _jinit_read_ppm(cinfo)) == NULL)
  ------------------
  |  |   50|  15.3k|#define _jinit_read_ppm  j12init_read_ppm
  ------------------
  |  Branch (367:9): [True: 0, False: 15.3k]
  ------------------
  368|  15.3k|      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|  15.3k|    invert = this->bottomUp;
  370|  15.3k|  } else
  371|  47.3k|    THROW("Unsupported file type");
  ------------------
  |  |  283|    567|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|    567|#define THROWRV(m, rv) { \
  |  |  |  |  280|    567|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|    567|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|    567|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|    567|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|    567|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|    567|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|    567|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|    567|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|    567|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|    567|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|    567|}
  |  |  |  |  ------------------
  |  |  |  |  282|    567|}
  |  |  ------------------
  ------------------
  372|       |
  373|  47.3k|  CATCH_LIBJPEG2();
  ------------------
  |  |  303|  47.3k|#define CATCH_LIBJPEG2() { \
  |  |  304|  47.3k|  if (setjmp(this2->jerr.setjmp_buffer)) { \
  |  |  305|  26.5k|    memcpy(this->errStr, this2->errStr, JMSG_LENGTH_MAX); \
  |  |  ------------------
  |  |  |  |  792|  26.5k|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  306|  26.5k|    this->jerr.warning = this2->jerr.warning; \
  |  |  307|  26.5k|    this->isInstanceError = this2->isInstanceError; \
  |  |  308|  26.5k|    retval = -1;  goto bailout; \
  |  |  309|  26.5k|  } \
  |  |  310|  47.3k|}
  ------------------
  |  Branch (373:3): [True: 26.5k, False: 20.8k]
  ------------------
  374|       |
  375|  20.8k|  cinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
  376|       |
  377|  20.8k|  src->input_file = file;
  378|       |  /* Refuse to load images larger than the specified size. */
  379|  20.8k|  src->max_pixels = this->maxPixels;
  380|  20.8k|  (*src->start_input) (cinfo, src);
  381|  20.8k|  if (tempc == 'B') {
  ------------------
  |  Branch (381:7): [True: 0, False: 20.8k]
  ------------------
  382|      0|    if (cinfo->X_density && cinfo->Y_density) {
  ------------------
  |  Branch (382:9): [True: 0, False: 0]
  |  Branch (382:29): [True: 0, False: 0]
  ------------------
  383|      0|      this->xDensity = cinfo->X_density;
  384|      0|      this->yDensity = cinfo->Y_density;
  385|      0|      this->densityUnits = cinfo->density_unit;
  386|      0|    }
  387|  20.8k|  } else if (tempc == 0x89 && (this->init & COMPRESS) &&
  ------------------
  |  Branch (387:14): [True: 7.66k, False: 13.1k]
  |  Branch (387:31): [True: 7.66k, False: 0]
  ------------------
  388|  7.66k|             (this->saveMarkers == 2 || this->saveMarkers == 4)) {
  ------------------
  |  Branch (388:15): [True: 7.66k, False: 0]
  |  Branch (388:41): [True: 0, False: 0]
  ------------------
  389|  7.66k|    JOCTET *iccBuf = NULL;
  390|  7.66k|    unsigned int iccLen = 0;
  391|       |
  392|  7.66k|    if ((*src->read_icc_profile) (cinfo, src, &iccBuf, &iccLen) && iccBuf &&
  ------------------
  |  Branch (392:9): [True: 7, False: 7.66k]
  |  Branch (392:68): [True: 7, False: 0]
  ------------------
  393|      7|        iccLen)
  ------------------
  |  Branch (393:9): [True: 7, False: 0]
  ------------------
  394|      7|      tj3SetICCProfile(handle, (unsigned char *)iccBuf, iccLen);
  395|  7.66k|  }
  396|  20.8k|  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
  397|       |
  398|  20.8k|  *width = cinfo->image_width;  *height = cinfo->image_height;
  399|  20.8k|  *pixelFormat = cs2pf[cinfo->in_color_space];
  400|       |
  401|  20.8k|  pitch = PAD((*width) * tjPixelSize[*pixelFormat], align);
  ------------------
  |  |   57|  20.8k|#define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
  ------------------
  402|       |
  403|  20.8k|  if (
  404|       |#if ULLONG_MAX > SIZE_MAX
  405|       |      (unsigned long long)pitch * (unsigned long long)(*height) *
  406|       |      (unsigned long long)sizeof(_JSAMPLE) >
  407|       |      (unsigned long long)((size_t)-1) ||
  408|       |#endif
  409|  20.8k|      (dstBuf = (_JSAMPLE *)malloc(pitch * (*height) *
  ------------------
  |  Branch (409:7): [True: 0, False: 20.8k]
  ------------------
  410|  20.8k|                                   sizeof(_JSAMPLE))) == NULL)
  411|  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|}
  |  |  ------------------
  ------------------
  412|       |
  413|  20.8k|  CATCH_LIBJPEG2();
  ------------------
  |  |  303|  20.8k|#define CATCH_LIBJPEG2() { \
  |  |  304|  20.8k|  if (setjmp(this2->jerr.setjmp_buffer)) { \
  |  |  305|  9.42k|    memcpy(this->errStr, this2->errStr, JMSG_LENGTH_MAX); \
  |  |  ------------------
  |  |  |  |  792|  9.42k|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  306|  9.42k|    this->jerr.warning = this2->jerr.warning; \
  |  |  307|  9.42k|    this->isInstanceError = this2->isInstanceError; \
  |  |  308|  9.42k|    retval = -1;  goto bailout; \
  |  |  309|  9.42k|  } \
  |  |  310|  20.8k|}
  ------------------
  |  Branch (413:3): [True: 9.42k, False: 11.4k]
  ------------------
  414|       |
  415|  26.4M|  while (cinfo->next_scanline < cinfo->image_height) {
  ------------------
  |  Branch (415:10): [True: 26.4M, False: 11.4k]
  ------------------
  416|  26.4M|    int i, nlines = (*src->get_pixel_rows) (cinfo, src);
  417|       |
  418|  52.7M|    for (i = 0; i < nlines; i++) {
  ------------------
  |  Branch (418:17): [True: 26.3M, False: 26.4M]
  ------------------
  419|  26.3M|      _JSAMPLE *dstptr;
  ------------------
  |  |   45|  26.3M|#define _JSAMPLE  J12SAMPLE
  ------------------
  420|  26.3M|      int row;
  421|       |
  422|  26.3M|      row = cinfo->next_scanline + i;
  423|  26.3M|      if (invert) dstptr = &dstBuf[((*height) - row - 1) * pitch];
  ------------------
  |  Branch (423:11): [True: 3.89M, False: 22.4M]
  ------------------
  424|  22.4M|      else dstptr = &dstBuf[row * pitch];
  425|  26.3M|      memcpy(dstptr, src->_buffer[i],
  ------------------
  |  |   47|  26.3M|#define _buffer  buffer12
  ------------------
  426|  26.3M|             (*width) * tjPixelSize[*pixelFormat] * sizeof(_JSAMPLE));
  427|  26.3M|    }
  428|  26.4M|    cinfo->next_scanline += nlines;
  429|  26.4M|  }
  430|       |
  431|  47.9k|bailout:
  432|  47.9k|  if (src)
  ------------------
  |  Branch (432:7): [True: 47.3k, False: 637]
  ------------------
  433|  47.3k|    (*src->finish_input) (cinfo, src);
  434|  47.9k|  tj3Destroy(handle2);
  435|  47.9k|  if (retval < 0) { free(dstBuf);  dstBuf = NULL; }
  ------------------
  |  Branch (435:7): [True: 36.5k, False: 11.4k]
  ------------------
  436|  47.9k|  return dstBuf;
  437|  11.4k|}

tj3InitVersion:
  596|  54.8k|{
  597|  54.8k|  static const char FUNCTION_NAME[] = "tj3Init";
  598|  54.8k|  tjinstance *this = NULL;
  599|  54.8k|  tjhandle retval = NULL;
  600|       |
  601|  54.8k|  if (initType < 0 || initType >= TJ_NUMINIT || apiVersion < 1000000 ||
  ------------------
  |  |   86|   109k|#define TJ_NUMINIT  3
  ------------------
  |  Branch (601:7): [True: 0, False: 54.8k]
  |  Branch (601:23): [True: 0, False: 54.8k]
  |  Branch (601:49): [True: 0, False: 54.8k]
  ------------------
  602|  54.8k|      apiVersion > 999999999)
  ------------------
  |  Branch (602:7): [True: 0, False: 54.8k]
  ------------------
  603|  54.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|}
  ------------------
  604|       |
  605|  54.8k|  if ((this = (tjinstance *)malloc(sizeof(tjinstance))) == NULL)
  ------------------
  |  Branch (605:7): [True: 0, False: 54.8k]
  ------------------
  606|  54.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|}
  ------------------
  607|  54.8k|  memset(this, 0, sizeof(tjinstance));
  608|  54.8k|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
  ------------------
  |  |   42|  54.8k|#define SNPRINTF  snprintf
  ------------------
                SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
  ------------------
  |  |  792|  54.8k|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  ------------------
  609|       |
  610|  54.8k|  this->quality = -1;
  611|  54.8k|  this->subsamp = TJSAMP_UNKNOWN;
  612|  54.8k|  this->jpegWidth = -1;
  613|  54.8k|  this->jpegHeight = -1;
  614|  54.8k|  this->precision = 8;
  615|  54.8k|  this->colorspace = TJCS_DEFAULT;
  616|  54.8k|  this->losslessPSV = 1;
  617|  54.8k|  this->xDensity = 1;
  618|  54.8k|  this->yDensity = 1;
  619|  54.8k|  this->scalingFactor = TJUNSCALED;
  620|  54.8k|  this->saveMarkers = 2;
  621|       |
  622|  54.8k|  this->apiVersion = apiVersion;
  623|  54.8k|  this->numSamp = apiVersion >= 3002000 ? TJ_NUMSAMP : 7;
  ------------------
  |  |  111|  6.85k|#define TJ_NUMSAMP  9
  ------------------
  |  Branch (623:19): [True: 6.85k, False: 47.9k]
  ------------------
  624|       |
  625|  54.8k|  switch (initType) {
  ------------------
  |  Branch (625:11): [True: 54.8k, False: 0]
  ------------------
  626|  54.8k|  case TJINIT_COMPRESS:  return _tjInitCompress(this);
  ------------------
  |  Branch (626:3): [True: 54.8k, False: 0]
  ------------------
  627|      0|  case TJINIT_DECOMPRESS:  return _tjInitDecompress(this);
  ------------------
  |  Branch (627:3): [True: 0, False: 54.8k]
  ------------------
  628|      0|  case TJINIT_TRANSFORM:
  ------------------
  |  Branch (628:3): [True: 0, False: 54.8k]
  ------------------
  629|      0|    retval = _tjInitCompress(this);
  630|      0|    if (!retval) return NULL;
  ------------------
  |  Branch (630:9): [True: 0, False: 0]
  ------------------
  631|      0|    retval = _tjInitDecompress(this);
  632|      0|    return retval;
  633|  54.8k|  }
  634|       |
  635|      0|bailout:
  636|      0|  return retval;
  637|  54.8k|}
tj3Init:
  641|  47.9k|{
  642|  47.9k|  return tj3InitVersion(initType, 3001000);
  643|  47.9k|}
tj3Destroy:
  648|  54.8k|{
  649|  54.8k|  tjinstance *this = (tjinstance *)handle;
  650|  54.8k|  j_compress_ptr cinfo = NULL;
  651|  54.8k|  j_decompress_ptr dinfo = NULL;
  652|       |
  653|  54.8k|  if (!this) return;
  ------------------
  |  Branch (653:7): [True: 0, False: 54.8k]
  ------------------
  654|       |
  655|  54.8k|  cinfo = &this->cinfo;  dinfo = &this->dinfo;
  656|  54.8k|  this->jerr.warning = FALSE;
  ------------------
  |  |  207|  54.8k|#define FALSE   0               /* values of boolean */
  ------------------
  657|  54.8k|  this->isInstanceError = FALSE;
  ------------------
  |  |  207|  54.8k|#define FALSE   0               /* values of boolean */
  ------------------
  658|       |
  659|       |  /* NOTE: jpeg_destroy_*() can never throw a libjpeg error in libjpeg-turbo's
  660|       |     implementation, so this is a belt-and-suspenders measure. */
  661|  54.8k|  if (setjmp(this->jerr.setjmp_buffer)) goto destroy_decompress;
  ------------------
  |  Branch (661:7): [True: 0, False: 54.8k]
  ------------------
  662|  54.8k|  if (this->init & COMPRESS) jpeg_destroy_compress(cinfo);
  ------------------
  |  Branch (662:7): [True: 54.8k, False: 0]
  ------------------
  663|  54.8k|destroy_decompress:
  664|  54.8k|  if (setjmp(this->jerr.setjmp_buffer)) goto bailout;
  ------------------
  |  Branch (664:7): [True: 0, False: 54.8k]
  ------------------
  665|  54.8k|  if (this->init & DECOMPRESS) jpeg_destroy_decompress(dinfo);
  ------------------
  |  Branch (665:7): [True: 0, False: 54.8k]
  ------------------
  666|  54.8k|bailout:
  667|  54.8k|  free(this->iccBuf);
  668|  54.8k|  free(this->decompICCBuf);
  669|  54.8k|  free(this);
  670|  54.8k|}
tj3Set:
  744|   426k|{
  745|   426k|  static const char FUNCTION_NAME[] = "tj3Set";
  746|   426k|  int retval = 0;
  747|       |
  748|   426k|  GET_TJINSTANCE(handle, -1);
  ------------------
  |  |  350|   426k|  tjinstance *this = (tjinstance *)handle; \
  |  |  351|   426k|  \
  |  |  352|   426k|  if (!this) { \
  |  |  ------------------
  |  |  |  Branch (352:7): [True: 0, False: 426k]
  |  |  ------------------
  |  |  353|      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 */
  |  |  ------------------
  |  |  354|      0|    return errorReturn; \
  |  |  355|      0|  } \
  |  |  356|   426k|  this->jerr.warning = FALSE; \
  |  |  ------------------
  |  |  |  |  207|   426k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  357|   426k|  this->isInstanceError = FALSE;
  |  |  ------------------
  |  |  |  |  207|   426k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  ------------------
  749|       |
  750|   426k|  switch (param) {
  751|      0|  case TJPARAM_STOPONWARNING:
  ------------------
  |  Branch (751:3): [True: 0, False: 426k]
  ------------------
  752|      0|    SET_BOOL_PARAM(jerr.stopOnWarning);
  ------------------
  |  |  736|      0|#define SET_BOOL_PARAM(field) { \
  |  |  737|      0|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (737:7): [True: 0, False: 0]
  |  |  |  Branch (737:20): [True: 0, False: 0]
  |  |  ------------------
  |  |  738|      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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  739|      0|  this->field = (boolean)value; \
  |  |  740|      0|}
  ------------------
  753|      0|    break;
  754|  47.9k|  case TJPARAM_BOTTOMUP:
  ------------------
  |  Branch (754:3): [True: 47.9k, False: 378k]
  ------------------
  755|  47.9k|    SET_BOOL_PARAM(bottomUp);
  ------------------
  |  |  736|  47.9k|#define SET_BOOL_PARAM(field) { \
  |  |  737|  47.9k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (737:7): [True: 0, False: 47.9k]
  |  |  |  Branch (737:20): [True: 0, False: 47.9k]
  |  |  ------------------
  |  |  738|  47.9k|    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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  739|  47.9k|  this->field = (boolean)value; \
  |  |  740|  47.9k|}
  ------------------
  756|  47.9k|    break;
  757|  47.9k|  case TJPARAM_NOREALLOC:
  ------------------
  |  Branch (757:3): [True: 47.9k, False: 378k]
  ------------------
  758|  47.9k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (758:9): [True: 0, False: 47.9k]
  ------------------
  759|  47.9k|      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|}
  |  |  ------------------
  ------------------
  760|  47.9k|    SET_BOOL_PARAM(noRealloc);
  ------------------
  |  |  736|  47.9k|#define SET_BOOL_PARAM(field) { \
  |  |  737|  47.9k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (737:7): [True: 0, False: 47.9k]
  |  |  |  Branch (737:20): [True: 0, False: 47.9k]
  |  |  ------------------
  |  |  738|  47.9k|    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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  739|  47.9k|  this->field = (boolean)value; \
  |  |  740|  47.9k|}
  ------------------
  761|  47.9k|    break;
  762|  21.2k|  case TJPARAM_QUALITY:
  ------------------
  |  Branch (762:3): [True: 21.2k, False: 405k]
  ------------------
  763|  21.2k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (763:9): [True: 0, False: 21.2k]
  ------------------
  764|  21.2k|      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|}
  |  |  ------------------
  ------------------
  765|  21.2k|    SET_PARAM(quality, 1, 100);
  ------------------
  |  |  730|  21.2k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|  21.2k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 21.2k]
  |  |  |  Branch (731:28): [True: 21.2k, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 21.2k]
  |  |  ------------------
  |  |  732|  21.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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|  21.2k|  this->field = value; \
  |  |  734|  21.2k|}
  ------------------
  766|  21.2k|    break;
  767|  21.2k|  case TJPARAM_SUBSAMP:
  ------------------
  |  Branch (767:3): [True: 21.2k, False: 405k]
  ------------------
  768|  21.2k|    SET_PARAM(subsamp, 0, this->numSamp - 1);
  ------------------
  |  |  730|  21.2k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|  21.2k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 21.2k]
  |  |  |  Branch (731:28): [True: 21.2k, False: 0]
  |  |  |  Branch (731:44): [True: 0, False: 21.2k]
  |  |  ------------------
  |  |  732|  21.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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|  21.2k|  this->field = value; \
  |  |  734|  21.2k|}
  ------------------
  769|  21.2k|    break;
  770|      0|  case TJPARAM_JPEGWIDTH:
  ------------------
  |  Branch (770:3): [True: 0, False: 426k]
  ------------------
  771|      0|    if (!(this->init & DECOMPRESS))
  ------------------
  |  Branch (771:9): [True: 0, False: 0]
  ------------------
  772|      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|}
  |  |  ------------------
  ------------------
  773|      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|}
  |  |  ------------------
  ------------------
  774|      0|    break;
  775|      0|  case TJPARAM_JPEGHEIGHT:
  ------------------
  |  Branch (775:3): [True: 0, False: 426k]
  ------------------
  776|      0|    if (!(this->init & DECOMPRESS))
  ------------------
  |  Branch (776:9): [True: 0, False: 0]
  ------------------
  777|      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|}
  |  |  ------------------
  ------------------
  778|      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|}
  |  |  ------------------
  ------------------
  779|      0|    break;
  780|      0|  case TJPARAM_PRECISION:
  ------------------
  |  Branch (780:3): [True: 0, False: 426k]
  ------------------
  781|      0|    SET_PARAM(precision, 2, 16);
  ------------------
  |  |  730|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 0]
  |  |  |  Branch (731:28): [True: 0, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  732|      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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|      0|  this->field = value; \
  |  |  734|      0|}
  ------------------
  782|      0|    break;
  783|  47.9k|  case TJPARAM_COLORSPACE:
  ------------------
  |  Branch (783:3): [True: 47.9k, False: 378k]
  ------------------
  784|  47.9k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (784:9): [True: 0, False: 47.9k]
  ------------------
  785|  47.9k|      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|}
  |  |  ------------------
  ------------------
  786|  47.9k|    SET_PARAM(colorspace, TJCS_DEFAULT, TJ_NUMCS - 1);
  ------------------
  |  |  730|  47.9k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|  47.9k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 47.9k]
  |  |  |  Branch (731:28): [True: 47.9k, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 47.9k]
  |  |  ------------------
  |  |  732|  47.9k|    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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|  47.9k|  this->field = value; \
  |  |  734|  47.9k|}
  ------------------
  787|  47.9k|    break;
  788|      0|  case TJPARAM_FASTUPSAMPLE:
  ------------------
  |  Branch (788:3): [True: 0, False: 426k]
  ------------------
  789|      0|    if (!(this->init & DECOMPRESS))
  ------------------
  |  Branch (789:9): [True: 0, False: 0]
  ------------------
  790|      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|}
  |  |  ------------------
  ------------------
  791|      0|    SET_BOOL_PARAM(fastUpsample);
  ------------------
  |  |  736|      0|#define SET_BOOL_PARAM(field) { \
  |  |  737|      0|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (737:7): [True: 0, False: 0]
  |  |  |  Branch (737:20): [True: 0, False: 0]
  |  |  ------------------
  |  |  738|      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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  739|      0|  this->field = (boolean)value; \
  |  |  740|      0|}
  ------------------
  792|      0|    break;
  793|  47.9k|  case TJPARAM_FASTDCT:
  ------------------
  |  Branch (793:3): [True: 47.9k, False: 378k]
  ------------------
  794|  47.9k|    SET_BOOL_PARAM(fastDCT);
  ------------------
  |  |  736|  47.9k|#define SET_BOOL_PARAM(field) { \
  |  |  737|  47.9k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (737:7): [True: 0, False: 47.9k]
  |  |  |  Branch (737:20): [True: 0, False: 47.9k]
  |  |  ------------------
  |  |  738|  47.9k|    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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  739|  47.9k|  this->field = (boolean)value; \
  |  |  740|  47.9k|}
  ------------------
  795|  47.9k|    break;
  796|      0|  case TJPARAM_OPTIMIZE:
  ------------------
  |  Branch (796:3): [True: 0, False: 426k]
  ------------------
  797|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (797:9): [True: 0, False: 0]
  ------------------
  798|      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|}
  |  |  ------------------
  ------------------
  799|      0|    SET_BOOL_PARAM(optimize);
  ------------------
  |  |  736|      0|#define SET_BOOL_PARAM(field) { \
  |  |  737|      0|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (737:7): [True: 0, False: 0]
  |  |  |  Branch (737:20): [True: 0, False: 0]
  |  |  ------------------
  |  |  738|      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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  739|      0|  this->field = (boolean)value; \
  |  |  740|      0|}
  ------------------
  800|      0|    break;
  801|  47.9k|  case TJPARAM_PROGRESSIVE:
  ------------------
  |  Branch (801:3): [True: 47.9k, False: 378k]
  ------------------
  802|  47.9k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (802:9): [True: 0, False: 47.9k]
  ------------------
  803|  47.9k|      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|}
  |  |  ------------------
  ------------------
  804|  47.9k|    SET_BOOL_PARAM(progressive);
  ------------------
  |  |  736|  47.9k|#define SET_BOOL_PARAM(field) { \
  |  |  737|  47.9k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (737:7): [True: 0, False: 47.9k]
  |  |  |  Branch (737:20): [True: 0, False: 47.9k]
  |  |  ------------------
  |  |  738|  47.9k|    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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  739|  47.9k|  this->field = (boolean)value; \
  |  |  740|  47.9k|}
  ------------------
  805|  47.9k|    break;
  806|      0|  case TJPARAM_SCANLIMIT:
  ------------------
  |  Branch (806:3): [True: 0, False: 426k]
  ------------------
  807|      0|    if (!(this->init & DECOMPRESS))
  ------------------
  |  Branch (807:9): [True: 0, False: 0]
  ------------------
  808|      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|}
  |  |  ------------------
  ------------------
  809|      0|    SET_PARAM(scanLimit, 0, -1);
  ------------------
  |  |  730|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 0]
  |  |  |  Branch (731:28): [Folded, False: 0]
  |  |  |  Branch (731:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  732|      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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|      0|  this->field = value; \
  |  |  734|      0|}
  ------------------
  810|      0|    break;
  811|  47.9k|  case TJPARAM_ARITHMETIC:
  ------------------
  |  Branch (811:3): [True: 47.9k, False: 378k]
  ------------------
  812|  47.9k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (812:9): [True: 0, False: 47.9k]
  ------------------
  813|  47.9k|      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|}
  |  |  ------------------
  ------------------
  814|  47.9k|    SET_BOOL_PARAM(arithmetic);
  ------------------
  |  |  736|  47.9k|#define SET_BOOL_PARAM(field) { \
  |  |  737|  47.9k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (737:7): [True: 0, False: 47.9k]
  |  |  |  Branch (737:20): [True: 0, False: 47.9k]
  |  |  ------------------
  |  |  738|  47.9k|    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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  739|  47.9k|  this->field = (boolean)value; \
  |  |  740|  47.9k|}
  ------------------
  815|  47.9k|    break;
  816|      0|  case TJPARAM_LOSSLESS:
  ------------------
  |  Branch (816:3): [True: 0, False: 426k]
  ------------------
  817|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (817:9): [True: 0, False: 0]
  ------------------
  818|      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|}
  |  |  ------------------
  ------------------
  819|      0|    SET_BOOL_PARAM(lossless);
  ------------------
  |  |  736|      0|#define SET_BOOL_PARAM(field) { \
  |  |  737|      0|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (737:7): [True: 0, False: 0]
  |  |  |  Branch (737:20): [True: 0, False: 0]
  |  |  ------------------
  |  |  738|      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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  739|      0|  this->field = (boolean)value; \
  |  |  740|      0|}
  ------------------
  820|      0|    break;
  821|      0|  case TJPARAM_LOSSLESSPSV:
  ------------------
  |  Branch (821:3): [True: 0, False: 426k]
  ------------------
  822|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (822:9): [True: 0, False: 0]
  ------------------
  823|      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|}
  |  |  ------------------
  ------------------
  824|      0|    SET_PARAM(losslessPSV, 1, 7);
  ------------------
  |  |  730|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 0]
  |  |  |  Branch (731:28): [True: 0, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  732|      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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|      0|  this->field = value; \
  |  |  734|      0|}
  ------------------
  825|      0|    break;
  826|      0|  case TJPARAM_LOSSLESSPT:
  ------------------
  |  Branch (826:3): [True: 0, False: 426k]
  ------------------
  827|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (827:9): [True: 0, False: 0]
  ------------------
  828|      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|}
  |  |  ------------------
  ------------------
  829|      0|    SET_PARAM(losslessPt, 0, 15);
  ------------------
  |  |  730|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 0]
  |  |  |  Branch (731:28): [True: 0, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  732|      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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|      0|  this->field = value; \
  |  |  734|      0|}
  ------------------
  830|      0|    break;
  831|      0|  case TJPARAM_RESTARTBLOCKS:
  ------------------
  |  Branch (831:3): [True: 0, False: 426k]
  ------------------
  832|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (832:9): [True: 0, False: 0]
  ------------------
  833|      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|}
  |  |  ------------------
  ------------------
  834|      0|    SET_PARAM(restartIntervalBlocks, 0, 65535);
  ------------------
  |  |  730|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 0]
  |  |  |  Branch (731:28): [True: 0, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  732|      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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|      0|  this->field = value; \
  |  |  734|      0|}
  ------------------
  835|      0|    if (value != 0) this->restartIntervalRows = 0;
  ------------------
  |  Branch (835:9): [True: 0, False: 0]
  ------------------
  836|      0|    break;
  837|  47.9k|  case TJPARAM_RESTARTROWS:
  ------------------
  |  Branch (837:3): [True: 47.9k, False: 378k]
  ------------------
  838|  47.9k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (838:9): [True: 0, False: 47.9k]
  ------------------
  839|  47.9k|      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|}
  |  |  ------------------
  ------------------
  840|  47.9k|    SET_PARAM(restartIntervalRows, 0, 65535);
  ------------------
  |  |  730|  47.9k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|  47.9k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 47.9k]
  |  |  |  Branch (731:28): [True: 47.9k, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 47.9k]
  |  |  ------------------
  |  |  732|  47.9k|    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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|  47.9k|  this->field = value; \
  |  |  734|  47.9k|}
  ------------------
  841|  47.9k|    if (value != 0) this->restartIntervalBlocks = 0;
  ------------------
  |  Branch (841:9): [True: 13.7k, False: 34.2k]
  ------------------
  842|  47.9k|    break;
  843|      0|  case TJPARAM_XDENSITY:
  ------------------
  |  Branch (843:3): [True: 0, False: 426k]
  ------------------
  844|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (844:9): [True: 0, False: 0]
  ------------------
  845|      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|}
  |  |  ------------------
  ------------------
  846|      0|    SET_PARAM(xDensity, 1, 65535);
  ------------------
  |  |  730|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 0]
  |  |  |  Branch (731:28): [True: 0, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  732|      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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|      0|  this->field = value; \
  |  |  734|      0|}
  ------------------
  847|      0|    break;
  848|      0|  case TJPARAM_YDENSITY:
  ------------------
  |  Branch (848:3): [True: 0, False: 426k]
  ------------------
  849|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (849:9): [True: 0, False: 0]
  ------------------
  850|      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|}
  |  |  ------------------
  ------------------
  851|      0|    SET_PARAM(yDensity, 1, 65535);
  ------------------
  |  |  730|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 0]
  |  |  |  Branch (731:28): [True: 0, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  732|      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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|      0|  this->field = value; \
  |  |  734|      0|}
  ------------------
  852|      0|    break;
  853|      0|  case TJPARAM_DENSITYUNITS:
  ------------------
  |  Branch (853:3): [True: 0, False: 426k]
  ------------------
  854|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (854:9): [True: 0, False: 0]
  ------------------
  855|      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|}
  |  |  ------------------
  ------------------
  856|      0|    SET_PARAM(densityUnits, 0, 2);
  ------------------
  |  |  730|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 0]
  |  |  |  Branch (731:28): [True: 0, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  732|      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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|      0|  this->field = value; \
  |  |  734|      0|}
  ------------------
  857|      0|    break;
  858|      0|  case TJPARAM_MAXMEMORY:
  ------------------
  |  Branch (858:3): [True: 0, False: 426k]
  ------------------
  859|      0|    SET_PARAM(maxMemory, 0, (int)(min(LONG_MAX / 1048576L, (long)INT_MAX)));
  ------------------
  |  |  730|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 0]
  |  |  |  Branch (731:28): [Folded, False: 0]
  |  |  |  Branch (731:28): [True: 0, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 0]
  |  |  |  Branch (731:52): [Folded, False: 0]
  |  |  ------------------
  |  |  732|      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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|      0|  this->field = value; \
  |  |  734|      0|}
  ------------------
  860|      0|    break;
  861|  47.9k|  case TJPARAM_MAXPIXELS:
  ------------------
  |  Branch (861:3): [True: 47.9k, False: 378k]
  ------------------
  862|  47.9k|    SET_PARAM(maxPixels, 0, -1);
  ------------------
  |  |  730|  47.9k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|  47.9k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 47.9k]
  |  |  |  Branch (731:28): [Folded, False: 47.9k]
  |  |  |  Branch (731:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  732|  47.9k|    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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|  47.9k|  this->field = value; \
  |  |  734|  47.9k|}
  ------------------
  863|  47.9k|    break;
  864|      0|  case TJPARAM_SAVEMARKERS:
  ------------------
  |  Branch (864:3): [True: 0, False: 426k]
  ------------------
  865|      0|    SET_PARAM(saveMarkers, 0, 4);
  ------------------
  |  |  730|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 0]
  |  |  |  Branch (731:28): [True: 0, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  732|      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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  733|      0|  this->field = value; \
  |  |  734|      0|}
  ------------------
  866|      0|    break;
  867|      0|  default:
  ------------------
  |  Branch (867:3): [True: 0, False: 426k]
  ------------------
  868|      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|}
  |  |  ------------------
  ------------------
  869|   426k|  }
  870|       |
  871|   426k|bailout:
  872|   426k|  return retval;
  873|   426k|}
tj3Get:
  878|  21.2k|{
  879|  21.2k|  tjinstance *this = (tjinstance *)handle;
  880|  21.2k|  if (!this) return -1;
  ------------------
  |  Branch (880:7): [True: 0, False: 21.2k]
  ------------------
  881|       |
  882|  21.2k|  switch (param) {
  ------------------
  |  Branch (882:11): [True: 21.2k, False: 0]
  ------------------
  883|      0|  case TJPARAM_STOPONWARNING:
  ------------------
  |  Branch (883:3): [True: 0, False: 21.2k]
  ------------------
  884|      0|    return this->jerr.stopOnWarning;
  885|      0|  case TJPARAM_BOTTOMUP:
  ------------------
  |  Branch (885:3): [True: 0, False: 21.2k]
  ------------------
  886|      0|    return this->bottomUp;
  887|  21.2k|  case TJPARAM_NOREALLOC:
  ------------------
  |  Branch (887:3): [True: 21.2k, False: 0]
  ------------------
  888|  21.2k|    return this->noRealloc;
  889|      0|  case TJPARAM_QUALITY:
  ------------------
  |  Branch (889:3): [True: 0, False: 21.2k]
  ------------------
  890|      0|    return this->quality;
  891|      0|  case TJPARAM_SUBSAMP:
  ------------------
  |  Branch (891:3): [True: 0, False: 21.2k]
  ------------------
  892|      0|    return this->subsamp;
  893|      0|  case TJPARAM_JPEGWIDTH:
  ------------------
  |  Branch (893:3): [True: 0, False: 21.2k]
  ------------------
  894|      0|    return this->jpegWidth;
  895|      0|  case TJPARAM_JPEGHEIGHT:
  ------------------
  |  Branch (895:3): [True: 0, False: 21.2k]
  ------------------
  896|      0|    return this->jpegHeight;
  897|      0|  case TJPARAM_PRECISION:
  ------------------
  |  Branch (897:3): [True: 0, False: 21.2k]
  ------------------
  898|      0|    return this->precision;
  899|      0|  case TJPARAM_COLORSPACE:
  ------------------
  |  Branch (899:3): [True: 0, False: 21.2k]
  ------------------
  900|      0|    return this->colorspace;
  901|      0|  case TJPARAM_FASTUPSAMPLE:
  ------------------
  |  Branch (901:3): [True: 0, False: 21.2k]
  ------------------
  902|      0|    return this->fastUpsample;
  903|      0|  case TJPARAM_FASTDCT:
  ------------------
  |  Branch (903:3): [True: 0, False: 21.2k]
  ------------------
  904|      0|    return this->fastDCT;
  905|      0|  case TJPARAM_OPTIMIZE:
  ------------------
  |  Branch (905:3): [True: 0, False: 21.2k]
  ------------------
  906|      0|    return this->optimize;
  907|      0|  case TJPARAM_PROGRESSIVE:
  ------------------
  |  Branch (907:3): [True: 0, False: 21.2k]
  ------------------
  908|      0|    return this->progressive;
  909|      0|  case TJPARAM_SCANLIMIT:
  ------------------
  |  Branch (909:3): [True: 0, False: 21.2k]
  ------------------
  910|      0|    return this->scanLimit;
  911|      0|  case TJPARAM_ARITHMETIC:
  ------------------
  |  Branch (911:3): [True: 0, False: 21.2k]
  ------------------
  912|      0|    return this->arithmetic;
  913|      0|  case TJPARAM_LOSSLESS:
  ------------------
  |  Branch (913:3): [True: 0, False: 21.2k]
  ------------------
  914|      0|    return this->lossless;
  915|      0|  case TJPARAM_LOSSLESSPSV:
  ------------------
  |  Branch (915:3): [True: 0, False: 21.2k]
  ------------------
  916|      0|    return this->losslessPSV;
  917|      0|  case TJPARAM_LOSSLESSPT:
  ------------------
  |  Branch (917:3): [True: 0, False: 21.2k]
  ------------------
  918|      0|    return this->losslessPt;
  919|      0|  case TJPARAM_RESTARTBLOCKS:
  ------------------
  |  Branch (919:3): [True: 0, False: 21.2k]
  ------------------
  920|      0|    return this->restartIntervalBlocks;
  921|      0|  case TJPARAM_RESTARTROWS:
  ------------------
  |  Branch (921:3): [True: 0, False: 21.2k]
  ------------------
  922|      0|    return this->restartIntervalRows;
  923|      0|  case TJPARAM_XDENSITY:
  ------------------
  |  Branch (923:3): [True: 0, False: 21.2k]
  ------------------
  924|      0|    return this->xDensity;
  925|      0|  case TJPARAM_YDENSITY:
  ------------------
  |  Branch (925:3): [True: 0, False: 21.2k]
  ------------------
  926|      0|    return this->yDensity;
  927|      0|  case TJPARAM_DENSITYUNITS:
  ------------------
  |  Branch (927:3): [True: 0, False: 21.2k]
  ------------------
  928|      0|    return this->densityUnits;
  929|      0|  case TJPARAM_MAXMEMORY:
  ------------------
  |  Branch (929:3): [True: 0, False: 21.2k]
  ------------------
  930|      0|    return this->maxMemory;
  931|      0|  case TJPARAM_MAXPIXELS:
  ------------------
  |  Branch (931:3): [True: 0, False: 21.2k]
  ------------------
  932|      0|    return this->maxPixels;
  933|      0|  case TJPARAM_SAVEMARKERS:
  ------------------
  |  Branch (933:3): [True: 0, False: 21.2k]
  ------------------
  934|      0|    return this->saveMarkers;
  935|  21.2k|  }
  936|       |
  937|      0|  return -1;
  938|  21.2k|}
tj3Alloc:
  948|  3.01k|{
  949|  3.01k|  return MALLOC(bytes);
  ------------------
  |  |  520|  3.01k|#define MALLOC(size)  malloc(size)
  ------------------
  950|  3.01k|}
tj3Free:
  961|  56.2k|{
  962|  56.2k|  free(buf);
  963|  56.2k|}
tj3JPEGBufSize:
  974|  21.2k|{
  975|  21.2k|  static const char FUNCTION_NAME[] = "tj3JPEGBufSize";
  976|  21.2k|  unsigned long long retval = 0;
  977|  21.2k|  int mcuw, mcuh, chromasf;
  978|       |
  979|  21.2k|  if (width < 1 || height < 1 || jpegSubsamp < TJSAMP_UNKNOWN ||
  ------------------
  |  Branch (979:7): [True: 0, False: 21.2k]
  |  Branch (979:20): [True: 0, False: 21.2k]
  |  Branch (979:34): [True: 0, False: 21.2k]
  ------------------
  980|  21.2k|      jpegSubsamp >= TJ_NUMSAMP)
  ------------------
  |  |  111|  21.2k|#define TJ_NUMSAMP  9
  ------------------
  |  Branch (980:7): [True: 0, False: 21.2k]
  ------------------
  981|  21.2k|    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|}
  ------------------
  982|       |
  983|  21.2k|  if (jpegSubsamp == TJSAMP_UNKNOWN)
  ------------------
  |  Branch (983:7): [True: 0, False: 21.2k]
  ------------------
  984|      0|    jpegSubsamp = TJSAMP_444;
  985|       |
  986|       |  /* This allows for rare corner cases in which a JPEG image can actually be
  987|       |     larger than the uncompressed input (we wouldn't mention it if it hadn't
  988|       |     happened before.) */
  989|  21.2k|  mcuw = tjMCUWidth[jpegSubsamp];
  990|  21.2k|  mcuh = tjMCUHeight[jpegSubsamp];
  991|  21.2k|  chromasf = jpegSubsamp == TJSAMP_GRAY ? 0 : 4 * 64 / (mcuw * mcuh);
  ------------------
  |  Branch (991:14): [True: 6.44k, False: 14.8k]
  ------------------
  992|  21.2k|  retval = (unsigned long long)PAD(width, mcuw) * PAD(height, mcuh) *
  ------------------
  |  |   57|  21.2k|#define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
  ------------------
                retval = (unsigned long long)PAD(width, mcuw) * PAD(height, mcuh) *
  ------------------
  |  |   57|  21.2k|#define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
  ------------------
  993|  21.2k|           (2ULL + chromasf) + 2048ULL;
  994|       |#if ULLONG_MAX > ULONG_MAX
  995|       |  if (retval > (unsigned long long)((unsigned long)-1))
  996|       |    THROWG("Image is too large", 0);
  997|       |#endif
  998|       |
  999|  21.2k|bailout:
 1000|  21.2k|  return (size_t)retval;
 1001|  21.2k|}
tj3SetICCProfile:
 1240|  17.7k|{
 1241|  17.7k|  static const char FUNCTION_NAME[] = "tj3SetICCProfile";
 1242|  17.7k|  int retval = 0;
 1243|       |
 1244|  17.7k|  GET_TJINSTANCE(handle, -1)
  ------------------
  |  |  350|  17.7k|  tjinstance *this = (tjinstance *)handle; \
  |  |  351|  17.7k|  \
  |  |  352|  17.7k|  if (!this) { \
  |  |  ------------------
  |  |  |  Branch (352:7): [True: 0, False: 17.7k]
  |  |  ------------------
  |  |  353|      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 */
  |  |  ------------------
  |  |  354|      0|    return errorReturn; \
  |  |  355|      0|  } \
  |  |  356|  17.7k|  this->jerr.warning = FALSE; \
  |  |  ------------------
  |  |  |  |  207|  17.7k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  357|  17.7k|  this->isInstanceError = FALSE;
  |  |  ------------------
  |  |  |  |  207|  17.7k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  ------------------
 1245|  17.7k|  if ((this->init & COMPRESS) == 0)
  ------------------
  |  Branch (1245:7): [True: 0, False: 17.7k]
  ------------------
 1246|  17.7k|    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|}
  |  |  ------------------
  ------------------
 1247|       |
 1248|  17.7k|  if (iccBuf == this->iccBuf && iccSize == this->iccSize)
  ------------------
  |  Branch (1248:7): [True: 0, False: 17.7k]
  |  Branch (1248:33): [True: 0, False: 0]
  ------------------
 1249|      0|    return 0;
 1250|       |
 1251|  17.7k|  free(this->iccBuf);
 1252|  17.7k|  this->iccBuf = NULL;
 1253|  17.7k|  this->iccSize = 0;
 1254|  17.7k|  if (iccBuf && iccSize) {
  ------------------
  |  Branch (1254:7): [True: 17.7k, False: 0]
  |  Branch (1254:17): [True: 17.7k, False: 0]
  ------------------
 1255|  17.7k|    if ((this->iccBuf = (unsigned char *)malloc(iccSize)) == NULL)
  ------------------
  |  Branch (1255:9): [True: 0, False: 17.7k]
  ------------------
 1256|  17.7k|      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|}
  |  |  ------------------
  ------------------
 1257|  17.7k|    memcpy(this->iccBuf, iccBuf, iccSize);
 1258|  17.7k|    this->iccSize = iccSize;
 1259|  17.7k|  }
 1260|       |
 1261|  17.7k|bailout:
 1262|  17.7k|  return retval;
 1263|  17.7k|}
turbojpeg.c:_tjInitCompress:
 1200|  54.8k|{
 1201|  54.8k|  static unsigned char buffer[1];
 1202|  54.8k|  unsigned char *buf = buffer;
 1203|  54.8k|  size_t size = 1;
 1204|       |
 1205|       |  /* This is also straight out of example.c */
 1206|  54.8k|  this->cinfo.err = jpeg_std_error(&this->jerr.pub);
 1207|  54.8k|  this->jerr.pub.error_exit = my_error_exit;
 1208|  54.8k|  this->jerr.pub.output_message = my_output_message;
 1209|  54.8k|  this->jerr.emit_message = this->jerr.pub.emit_message;
 1210|  54.8k|  this->jerr.pub.emit_message = my_emit_message;
 1211|  54.8k|  this->jerr.pub.addon_message_table = turbojpeg_message_table;
 1212|  54.8k|  this->jerr.pub.first_addon_message = JMSG_FIRSTADDONCODE;
 1213|  54.8k|  this->jerr.pub.last_addon_message = JMSG_LASTADDONCODE;
 1214|  54.8k|  this->jerr.tjHandle = (tjhandle)this;
 1215|       |
 1216|  54.8k|  if (setjmp(this->jerr.setjmp_buffer)) {
  ------------------
  |  Branch (1216:7): [True: 0, False: 54.8k]
  ------------------
 1217|       |    /* If we get here, the JPEG code has signaled an error. */
 1218|      0|    free(this);
 1219|      0|    return NULL;
 1220|      0|  }
 1221|       |
 1222|  54.8k|  jpeg_create_compress(&this->cinfo);
  ------------------
  |  |  969|  54.8k|  jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
  |  |  ------------------
  |  |  |  |    4|  54.8k|#define JPEG_LIB_VERSION  62
  |  |  ------------------
  |  |  970|  54.8k|                      (size_t)sizeof(struct jpeg_compress_struct))
  ------------------
 1223|       |  /* Make an initial call so it will create the destination manager */
 1224|  54.8k|  jpeg_mem_dest_tj(&this->cinfo, &buf, &size, 0);
 1225|       |
 1226|  54.8k|  this->init |= COMPRESS;
 1227|  54.8k|  return (tjhandle)this;
 1228|  54.8k|}
turbojpeg.c:my_error_exit:
   81|  35.9k|{
   82|  35.9k|  my_error_ptr myerr = (my_error_ptr)cinfo->err;
   83|       |
   84|  35.9k|  (*cinfo->err->output_message) (cinfo);
   85|  35.9k|  longjmp(myerr->setjmp_buffer, 1);
   86|  35.9k|}
turbojpeg.c:my_output_message:
  149|  35.9k|{
  150|  35.9k|  my_error_ptr myerr = (my_error_ptr)cinfo->err;
  151|  35.9k|  tjinstance *this = (tjinstance *)myerr->tjHandle;
  152|       |
  153|  35.9k|  if (this) {
  ------------------
  |  Branch (153:7): [True: 35.9k, False: 0]
  ------------------
  154|  35.9k|    this->isInstanceError = TRUE;
  ------------------
  |  |  210|  35.9k|#define TRUE    1
  ------------------
  155|  35.9k|    (*cinfo->err->format_message) (cinfo, this->errStr);
  156|  35.9k|  } else
  157|      0|    (*cinfo->err->format_message) (cinfo, errStr);
  158|  35.9k|}
turbojpeg.c:my_emit_message:
   89|  34.1k|{
   90|  34.1k|  my_error_ptr myerr = (my_error_ptr)cinfo->err;
   91|       |
   92|  34.1k|  myerr->emit_message(cinfo, msg_level);
   93|  34.1k|  if (msg_level < 0) {
  ------------------
  |  Branch (93:7): [True: 0, False: 34.1k]
  ------------------
   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|  34.1k|}
turbojpeg.c:setCompDefaults:
  379|  21.2k|{
  380|  21.2k|  int colorspace = yuv ? TJCS_DEFAULT : this->colorspace;
  ------------------
  |  Branch (380:20): [True: 0, False: 21.2k]
  ------------------
  381|       |
  382|  21.2k|  this->cinfo.in_color_space = pf2cs[pixelFormat];
  383|  21.2k|  this->cinfo.input_components = tjPixelSize[pixelFormat];
  384|  21.2k|  jpeg_set_defaults(&this->cinfo);
  385|       |
  386|  21.2k|  this->cinfo.restart_interval = this->restartIntervalBlocks;
  387|  21.2k|  this->cinfo.restart_in_rows = this->restartIntervalRows;
  388|  21.2k|  this->cinfo.X_density = (UINT16)this->xDensity;
  389|  21.2k|  this->cinfo.Y_density = (UINT16)this->yDensity;
  390|  21.2k|  this->cinfo.density_unit = (UINT8)this->densityUnits;
  391|  21.2k|  this->cinfo.mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
  392|       |
  393|  21.2k|  if (this->lossless && !yuv) {
  ------------------
  |  Branch (393:7): [True: 0, False: 21.2k]
  |  Branch (393:25): [True: 0, False: 0]
  ------------------
  394|      0|#ifdef C_LOSSLESS_SUPPORTED
  395|      0|    jpeg_enable_lossless(&this->cinfo, this->losslessPSV, this->losslessPt);
  396|      0|#endif
  397|      0|    return;
  398|      0|  }
  399|       |
  400|  21.2k|  jpeg_set_quality(&this->cinfo, this->quality, TRUE);
  ------------------
  |  |  210|  21.2k|#define TRUE    1
  ------------------
  401|  21.2k|  this->cinfo.dct_method = this->fastDCT ? JDCT_FASTEST : JDCT_ISLOW;
  ------------------
  |  |  304|  3.01k|#define JDCT_FASTEST  JDCT_IFAST
  ------------------
  |  Branch (401:28): [True: 3.01k, False: 18.2k]
  ------------------
  402|       |
  403|  21.2k|  switch (colorspace) {
  404|  2.92k|  case TJCS_RGB:
  ------------------
  |  Branch (404:3): [True: 2.92k, False: 18.3k]
  ------------------
  405|  2.92k|    jpeg_set_colorspace(&this->cinfo, JCS_RGB);  break;
  406|  3.01k|  case TJCS_YCbCr:
  ------------------
  |  Branch (406:3): [True: 3.01k, False: 18.2k]
  ------------------
  407|  3.01k|    jpeg_set_colorspace(&this->cinfo, JCS_YCbCr);  break;
  408|  2.92k|  case TJCS_GRAY:
  ------------------
  |  Branch (408:3): [True: 2.92k, False: 18.3k]
  ------------------
  409|  2.92k|    jpeg_set_colorspace(&this->cinfo, JCS_GRAYSCALE);  break;
  410|      0|  case TJCS_CMYK:
  ------------------
  |  Branch (410:3): [True: 0, False: 21.2k]
  ------------------
  411|      0|    jpeg_set_colorspace(&this->cinfo, JCS_CMYK);  break;
  412|  2.92k|  case TJCS_YCCK:
  ------------------
  |  Branch (412:3): [True: 2.92k, False: 18.3k]
  ------------------
  413|  2.92k|    jpeg_set_colorspace(&this->cinfo, JCS_YCCK);  break;
  414|  9.45k|  default:
  ------------------
  |  Branch (414:3): [True: 9.45k, False: 11.7k]
  ------------------
  415|  9.45k|    if (this->subsamp == TJSAMP_GRAY)
  ------------------
  |  Branch (415:9): [True: 3.51k, False: 5.93k]
  ------------------
  416|  3.51k|      jpeg_set_colorspace(&this->cinfo, JCS_GRAYSCALE);
  417|  5.93k|    else if (pixelFormat == TJPF_CMYK)
  ------------------
  |  Branch (417:14): [True: 0, False: 5.93k]
  ------------------
  418|      0|      jpeg_set_colorspace(&this->cinfo, JCS_YCCK);
  419|  5.93k|    else
  420|  5.93k|      jpeg_set_colorspace(&this->cinfo, JCS_YCbCr);
  421|  21.2k|  }
  422|       |
  423|  21.2k|  if (this->cinfo.data_precision == 8)
  ------------------
  |  Branch (423:7): [True: 0, False: 21.2k]
  ------------------
  424|      0|    this->cinfo.optimize_coding = this->optimize;
  425|  21.2k|#ifdef C_PROGRESSIVE_SUPPORTED
  426|  21.2k|  if (this->progressive) jpeg_simple_progression(&this->cinfo);
  ------------------
  |  Branch (426:7): [True: 6.44k, False: 14.8k]
  ------------------
  427|  21.2k|#endif
  428|  21.2k|  this->cinfo.arith_code = this->arithmetic;
  429|       |
  430|  21.2k|  this->cinfo.comp_info[0].h_samp_factor = tjMCUWidth[this->subsamp] / 8;
  431|  21.2k|  this->cinfo.comp_info[1].h_samp_factor = 1;
  432|  21.2k|  this->cinfo.comp_info[2].h_samp_factor = 1;
  433|  21.2k|  if (this->cinfo.num_components > 3)
  ------------------
  |  Branch (433:7): [True: 2.92k, False: 18.3k]
  ------------------
  434|  2.92k|    this->cinfo.comp_info[3].h_samp_factor = tjMCUWidth[this->subsamp] / 8;
  435|  21.2k|  this->cinfo.comp_info[0].v_samp_factor = tjMCUHeight[this->subsamp] / 8;
  436|  21.2k|  this->cinfo.comp_info[1].v_samp_factor = 1;
  437|  21.2k|  this->cinfo.comp_info[2].v_samp_factor = 1;
  438|  21.2k|  if (this->cinfo.num_components > 3)
  ------------------
  |  Branch (438:7): [True: 2.92k, False: 18.3k]
  ------------------
  439|  2.92k|    this->cinfo.comp_info[3].v_samp_factor = tjMCUHeight[this->subsamp] / 8;
  440|  21.2k|}

