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

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

rdpng-12.c:rgb_to_cmyk:
   29|  19.8M|{
   30|  19.8M|  double ctmp = 1.0 - ((double)r / (double)maxval);
   31|  19.8M|  double mtmp = 1.0 - ((double)g / (double)maxval);
   32|  19.8M|  double ytmp = 1.0 - ((double)b / (double)maxval);
   33|  19.8M|  double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
  ------------------
  |  |  515|  39.6M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 2.24M, False: 17.5M]
  |  |  |  Branch (515:27): [True: 1.19M, False: 18.6M]
  |  |  |  Branch (515:39): [True: 861k, False: 1.38M]
  |  |  ------------------
  ------------------
   34|       |
   35|  19.8M|  if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
  ------------------
  |  Branch (35:7): [True: 11.9M, False: 7.87M]
  ------------------
   36|  7.87M|  else {
   37|  7.87M|    ctmp = (ctmp - ktmp) / (1.0 - ktmp);
   38|  7.87M|    mtmp = (mtmp - ktmp) / (1.0 - ktmp);
   39|  7.87M|    ytmp = (ytmp - ktmp) / (1.0 - ktmp);
   40|  7.87M|  }
   41|  19.8M|  *c = (_JSAMPLE)((double)maxval - ctmp * (double)maxval + 0.5);
   42|  19.8M|  *m = (_JSAMPLE)((double)maxval - mtmp * (double)maxval + 0.5);
   43|  19.8M|  *y = (_JSAMPLE)((double)maxval - ytmp * (double)maxval + 0.5);
   44|  19.8M|  *k = (_JSAMPLE)((double)maxval - ktmp * (double)maxval + 0.5);
   45|  19.8M|}
rdppm-12.c:rgb_to_cmyk:
   29|  24.3M|{
   30|  24.3M|  double ctmp = 1.0 - ((double)r / (double)maxval);
   31|  24.3M|  double mtmp = 1.0 - ((double)g / (double)maxval);
   32|  24.3M|  double ytmp = 1.0 - ((double)b / (double)maxval);
   33|  24.3M|  double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
  ------------------
  |  |  515|  48.7M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 1.99M, False: 22.3M]
  |  |  |  Branch (515:27): [True: 1.25M, False: 23.1M]
  |  |  |  Branch (515:39): [True: 918k, False: 1.07M]
  |  |  ------------------
  ------------------
   34|       |
   35|  24.3M|  if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
  ------------------
  |  Branch (35:7): [True: 14.2M, False: 10.1M]
  ------------------
   36|  10.1M|  else {
   37|  10.1M|    ctmp = (ctmp - ktmp) / (1.0 - ktmp);
   38|  10.1M|    mtmp = (mtmp - ktmp) / (1.0 - ktmp);
   39|  10.1M|    ytmp = (ytmp - ktmp) / (1.0 - ktmp);
   40|  10.1M|  }
   41|  24.3M|  *c = (_JSAMPLE)((double)maxval - ctmp * (double)maxval + 0.5);
   42|  24.3M|  *m = (_JSAMPLE)((double)maxval - mtmp * (double)maxval + 0.5);
   43|  24.3M|  *y = (_JSAMPLE)((double)maxval - ytmp * (double)maxval + 0.5);
   44|  24.3M|  *k = (_JSAMPLE)((double)maxval - ktmp * (double)maxval + 0.5);
   45|  24.3M|}

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

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

jinit_arith_encoder:
  913|  6.10k|{
  914|  6.10k|  arith_entropy_ptr entropy;
  915|  6.10k|  int i;
  916|       |
  917|  6.10k|  entropy = (arith_entropy_ptr)
  918|  6.10k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  6.10k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  919|  6.10k|                                sizeof(arith_entropy_encoder));
  920|  6.10k|  cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
  921|  6.10k|  entropy->pub.start_pass = start_pass;
  922|  6.10k|  entropy->pub.finish_pass = finish_pass;
  923|       |
  924|       |  /* Mark tables unallocated */
  925|   103k|  for (i = 0; i < NUM_ARITH_TBLS; i++) {
  ------------------
  |  |   70|   103k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (925:15): [True: 97.6k, False: 6.10k]
  ------------------
  926|  97.6k|    entropy->dc_stats[i] = NULL;
  927|  97.6k|    entropy->ac_stats[i] = NULL;
  928|  97.6k|  }
  929|       |
  930|       |  /* Initialize index for fixed probability estimation */
  931|  6.10k|  entropy->fixed_bin[0] = 113;
  932|  6.10k|}
jcarith.c:start_pass:
  829|  57.9k|{
  830|  57.9k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  831|  57.9k|  int ci, tbl;
  832|  57.9k|  jpeg_component_info *compptr;
  833|       |
  834|  57.9k|  if (gather_statistics)
  ------------------
  |  Branch (834:7): [True: 0, False: 57.9k]
  ------------------
  835|       |    /* Make sure to avoid that in the master control logic!
  836|       |     * We are fully adaptive here and need no extra
  837|       |     * statistics gathering pass!
  838|       |     */
  839|      0|    ERREXIT(cinfo, JERR_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  840|       |
  841|       |  /* We assume jcmaster.c already validated the progressive scan parameters. */
  842|       |
  843|       |  /* Select execution routines */
  844|  57.9k|  if (cinfo->progressive_mode) {
  ------------------
  |  Branch (844:7): [True: 54.9k, False: 3.05k]
  ------------------
  845|  54.9k|    if (cinfo->Ah == 0) {
  ------------------
  |  Branch (845:9): [True: 27.4k, False: 27.4k]
  ------------------
  846|  27.4k|      if (cinfo->Ss == 0)
  ------------------
  |  Branch (846:11): [True: 3.05k, False: 24.4k]
  ------------------
  847|  3.05k|        entropy->pub.encode_mcu = encode_mcu_DC_first;
  848|  24.4k|      else
  849|  24.4k|        entropy->pub.encode_mcu = encode_mcu_AC_first;
  850|  27.4k|    } else {
  851|  27.4k|      if (cinfo->Ss == 0)
  ------------------
  |  Branch (851:11): [True: 3.05k, False: 24.4k]
  ------------------
  852|  3.05k|        entropy->pub.encode_mcu = encode_mcu_DC_refine;
  853|  24.4k|      else
  854|  24.4k|        entropy->pub.encode_mcu = encode_mcu_AC_refine;
  855|  27.4k|    }
  856|  54.9k|  } else
  857|  3.05k|    entropy->pub.encode_mcu = encode_mcu;
  858|       |
  859|       |  /* Allocate & initialize requested statistics areas */
  860|   140k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (860:16): [True: 82.3k, False: 57.9k]
  ------------------
  861|  82.3k|    compptr = cinfo->cur_comp_info[ci];
  862|       |    /* DC needs no table for refinement scan */
  863|  82.3k|    if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
  ------------------
  |  Branch (863:9): [True: 9.15k, False: 73.2k]
  |  Branch (863:42): [True: 24.4k, False: 48.8k]
  |  Branch (863:60): [True: 12.2k, False: 12.2k]
  ------------------
  864|  21.3k|      tbl = compptr->dc_tbl_no;
  865|  21.3k|      if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
  ------------------
  |  |   70|  21.3k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (865:11): [True: 0, False: 21.3k]
  |  Branch (865:22): [True: 0, False: 21.3k]
  ------------------
  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|  21.3k|      if (entropy->dc_stats[tbl] == NULL)
  ------------------
  |  Branch (867:11): [True: 9.15k, False: 12.2k]
  ------------------
  868|  9.15k|        entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
  869|  9.15k|          ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
  ------------------
  |  |  889|  9.15k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                        ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
  ------------------
  |  |   69|  9.15k|#define DC_STAT_BINS  64
  ------------------
  870|  21.3k|      memset(entropy->dc_stats[tbl], 0, DC_STAT_BINS);
  ------------------
  |  |   69|  21.3k|#define DC_STAT_BINS  64
  ------------------
  871|       |      /* Initialize DC predictions to 0 */
  872|  21.3k|      entropy->last_dc_val[ci] = 0;
  873|  21.3k|      entropy->dc_context[ci] = 0;
  874|  21.3k|    }
  875|       |    /* AC needs no table when not present */
  876|  82.3k|    if (cinfo->progressive_mode == 0 || cinfo->Se) {
  ------------------
  |  Branch (876:9): [True: 9.15k, False: 73.2k]
  |  Branch (876:41): [True: 48.8k, False: 24.4k]
  ------------------
  877|  57.9k|      tbl = compptr->ac_tbl_no;
  878|  57.9k|      if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
  ------------------
  |  |   70|  57.9k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (878:11): [True: 0, False: 57.9k]
  |  Branch (878:22): [True: 0, False: 57.9k]
  ------------------
  879|      0|        ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  880|  57.9k|      if (entropy->ac_stats[tbl] == NULL)
  ------------------
  |  Branch (880:11): [True: 9.15k, False: 48.8k]
  ------------------
  881|  9.15k|        entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
  882|  9.15k|          ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
  ------------------
  |  |  889|  9.15k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                        ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
  ------------------
  |  |   70|  9.15k|#define AC_STAT_BINS  256
  ------------------
  883|  57.9k|      memset(entropy->ac_stats[tbl], 0, AC_STAT_BINS);
  ------------------
  |  |   70|  57.9k|#define AC_STAT_BINS  256
  ------------------
  884|       |#ifdef CALCULATE_SPECTRAL_CONDITIONING
  885|       |      if (cinfo->progressive_mode)
  886|       |        /* Section G.1.3.2: Set appropriate arithmetic conditioning value Kx */
  887|       |        cinfo->arith_ac_K[tbl] = cinfo->Ss +
  888|       |                                 ((8 + cinfo->Se - cinfo->Ss) >> 4);
  889|       |#endif
  890|  57.9k|    }
  891|  82.3k|  }
  892|       |
  893|       |  /* Initialize arithmetic encoding variables */
  894|  57.9k|  entropy->c = 0;
  895|  57.9k|  entropy->a = 0x10000L;
  896|  57.9k|  entropy->sc = 0;
  897|  57.9k|  entropy->zc = 0;
  898|  57.9k|  entropy->ct = 11;
  899|  57.9k|  entropy->buffer = -1;  /* empty */
  900|       |
  901|       |  /* Initialize restart stuff */
  902|  57.9k|  entropy->restarts_to_go = cinfo->restart_interval;
  903|  57.9k|  entropy->next_restart_num = 0;
  904|  57.9k|}
jcarith.c:encode_mcu_DC_first:
  369|   933k|{
  370|   933k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  371|   933k|  JBLOCKROW block;
  372|   933k|  unsigned char *st;
  373|   933k|  int blkn, ci, tbl;
  374|   933k|  int v, v2, m;
  375|   933k|  ISHIFT_TEMPS
  376|       |
  377|       |  /* Emit restart marker if needed */
  378|   933k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (378:7): [True: 933k, False: 0]
  ------------------
  379|   933k|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (379:9): [True: 301k, False: 632k]
  ------------------
  380|   301k|      emit_restart(cinfo, entropy->next_restart_num);
  381|   301k|      entropy->restarts_to_go = cinfo->restart_interval;
  382|   301k|      entropy->next_restart_num++;
  383|   301k|      entropy->next_restart_num &= 7;
  384|   301k|    }
  385|   933k|    entropy->restarts_to_go--;
  386|   933k|  }
  387|       |
  388|       |  /* Encode the MCU data blocks */
  389|  6.53M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (389:18): [True: 5.60M, False: 933k]
  ------------------
  390|  5.60M|    block = MCU_data[blkn];
  391|  5.60M|    ci = cinfo->MCU_membership[blkn];
  392|  5.60M|    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.60M|    m = IRIGHT_SHIFT((int)((*block)[0]), cinfo->Al);
  ------------------
  |  |  117|  5.60M|#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.60M|    st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
  403|       |
  404|       |    /* Figure F.4: Encode_DC_DIFF */
  405|  5.60M|    if ((v = m - entropy->last_dc_val[ci]) == 0) {
  ------------------
  |  Branch (405:9): [True: 3.81M, False: 1.79M]
  ------------------
  406|  3.81M|      arith_encode(cinfo, st, 0);
  407|  3.81M|      entropy->dc_context[ci] = 0;      /* zero diff category */
  408|  3.81M|    } else {
  409|  1.79M|      entropy->last_dc_val[ci] = m;
  410|  1.79M|      arith_encode(cinfo, st, 1);
  411|       |      /* Figure F.6: Encoding nonzero value v */
  412|       |      /* Figure F.7: Encoding the sign of v */
  413|  1.79M|      if (v > 0) {
  ------------------
  |  Branch (413:11): [True: 617k, False: 1.17M]
  ------------------
  414|   617k|        arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
  415|   617k|        st += 2;                        /* Table F.4: SP = S0 + 2 */
  416|   617k|        entropy->dc_context[ci] = 4;    /* small positive diff category */
  417|  1.17M|      } else {
  418|  1.17M|        v = -v;
  419|  1.17M|        arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
  420|  1.17M|        st += 3;                        /* Table F.4: SN = S0 + 3 */
  421|  1.17M|        entropy->dc_context[ci] = 8;    /* small negative diff category */
  422|  1.17M|      }
  423|       |      /* Figure F.8: Encoding the magnitude category of v */
  424|  1.79M|      m = 0;
  425|  1.79M|      if (v -= 1) {
  ------------------
  |  Branch (425:11): [True: 1.58M, False: 206k]
  ------------------
  426|  1.58M|        arith_encode(cinfo, st, 1);
  427|  1.58M|        m = 1;
  428|  1.58M|        v2 = v;
  429|  1.58M|        st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
  430|  5.65M|        while (v2 >>= 1) {
  ------------------
  |  Branch (430:16): [True: 4.06M, False: 1.58M]
  ------------------
  431|  4.06M|          arith_encode(cinfo, st, 1);
  432|  4.06M|          m <<= 1;
  433|  4.06M|          st += 1;
  434|  4.06M|        }
  435|  1.58M|      }
  436|  1.79M|      arith_encode(cinfo, st, 0);
  437|       |      /* Section F.1.4.4.1.2: Establish dc_context conditioning category */
  438|  1.79M|      if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
  ------------------
  |  Branch (438:11): [True: 0, False: 1.79M]
  ------------------
  439|      0|        entropy->dc_context[ci] = 0;    /* zero diff category */
  440|  1.79M|      else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
  ------------------
  |  Branch (440:16): [True: 1.41M, False: 380k]
  ------------------
  441|  1.41M|        entropy->dc_context[ci] += 8;   /* large diff category */
  442|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  443|  1.79M|      st += 14;
  444|  5.85M|      while (m >>= 1)
  ------------------
  |  Branch (444:14): [True: 4.06M, False: 1.79M]
  ------------------
  445|  4.06M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (445:33): [True: 2.64M, False: 1.42M]
  ------------------
  446|  1.79M|    }
  447|  5.60M|  }
  448|       |
  449|   933k|  return TRUE;
  ------------------
  |  |  210|   933k|#define TRUE    1
  ------------------
  450|   933k|}
jcarith.c:emit_restart:
  326|  8.15M|{
  327|  8.15M|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  328|  8.15M|  int ci;
  329|  8.15M|  jpeg_component_info *compptr;
  330|       |
  331|  8.15M|  finish_pass(cinfo);
  332|       |
  333|  8.15M|  emit_byte(0xFF, cinfo);
  334|  8.15M|  emit_byte(JPEG_RST0 + restart_num, cinfo);
  ------------------
  |  | 1166|  8.15M|#define JPEG_RST0       0xD0    /* RST0 marker code */
  ------------------
  335|       |
  336|       |  /* Re-initialize statistics areas */
  337|  18.7M|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (337:16): [True: 10.5M, False: 8.15M]
  ------------------
  338|  10.5M|    compptr = cinfo->cur_comp_info[ci];
  339|       |    /* DC needs no table for refinement scan */
  340|  10.5M|    if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
  ------------------
  |  Branch (340:9): [True: 905k, False: 9.65M]
  |  Branch (340:42): [True: 2.41M, False: 7.24M]
  |  Branch (340:60): [True: 1.20M, False: 1.20M]
  ------------------
  341|  2.11M|      memset(entropy->dc_stats[compptr->dc_tbl_no], 0, DC_STAT_BINS);
  ------------------
  |  |   69|  2.11M|#define DC_STAT_BINS  64
  ------------------
  342|       |      /* Reset DC predictions to 0 */
  343|  2.11M|      entropy->last_dc_val[ci] = 0;
  344|  2.11M|      entropy->dc_context[ci] = 0;
  345|  2.11M|    }
  346|       |    /* AC needs no table when not present */
  347|  10.5M|    if (cinfo->progressive_mode == 0 || cinfo->Se) {
  ------------------
  |  Branch (347:9): [True: 905k, False: 9.65M]
  |  Branch (347:41): [True: 7.24M, False: 2.41M]
  ------------------
  348|  8.15M|      memset(entropy->ac_stats[compptr->ac_tbl_no], 0, AC_STAT_BINS);
  ------------------
  |  |   70|  8.15M|#define AC_STAT_BINS  256
  ------------------
  349|  8.15M|    }
  350|  10.5M|  }
  351|       |
  352|       |  /* Reset arithmetic encoding variables */
  353|  8.15M|  entropy->c = 0;
  354|  8.15M|  entropy->a = 0x10000L;
  355|  8.15M|  entropy->sc = 0;
  356|  8.15M|  entropy->zc = 0;
  357|  8.15M|  entropy->ct = 11;
  358|  8.15M|  entropy->buffer = -1;  /* empty */
  359|  8.15M|}
jcarith.c:emit_byte:
  124|   121M|{
  125|   121M|  struct jpeg_destination_mgr *dest = cinfo->dest;
  126|       |
  127|   121M|  *dest->next_output_byte++ = (JOCTET)val;
  128|   121M|  if (--dest->free_in_buffer == 0)
  ------------------
  |  Branch (128:7): [True: 3.94k, False: 121M]
  ------------------
  129|  3.94k|    if (!(*dest->empty_output_buffer) (cinfo))
  ------------------
  |  Branch (129:9): [True: 0, False: 3.94k]
  ------------------
  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|   121M|}
jcarith.c:arith_encode:
  226|  1.08G|{
  227|  1.08G|  register arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
  228|  1.08G|  register unsigned char nl, nm;
  229|  1.08G|  register JLONG qe, temp;
  230|  1.08G|  register int sv;
  231|       |
  232|       |  /* Fetch values from our compact representation of Table D.2:
  233|       |   * Qe values and probability estimation state machine
  234|       |   */
  235|  1.08G|  sv = *st;
  236|  1.08G|  qe = jpeg_aritab[sv & 0x7F];  /* => Qe_Value */
  237|  1.08G|  nl = qe & 0xFF;  qe >>= 8;    /* Next_Index_LPS + Switch_MPS */
  238|  1.08G|  nm = qe & 0xFF;  qe >>= 8;    /* Next_Index_MPS */
  239|       |
  240|       |  /* Encode & estimation procedures per sections D.1.4 & D.1.5 */
  241|  1.08G|  e->a -= qe;
  242|  1.08G|  if (val != (sv >> 7)) {
  ------------------
  |  Branch (242:7): [True: 314M, False: 766M]
  ------------------
  243|       |    /* Encode the less probable symbol */
  244|   314M|    if (e->a >= qe) {
  ------------------
  |  Branch (244:9): [True: 244M, False: 70.1M]
  ------------------
  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|   244M|      e->c += e->a;
  250|   244M|      e->a = qe;
  251|   244M|    }
  252|   314M|    *st = (sv & 0x80) ^ nl;     /* Estimate_after_LPS */
  253|   766M|  } else {
  254|       |    /* Encode the more probable symbol */
  255|   766M|    if (e->a >= 0x8000L)
  ------------------
  |  Branch (255:9): [True: 432M, False: 334M]
  ------------------
  256|   432M|      return;  /* A >= 0x8000 -> ready, no renormalization required */
  257|   334M|    if (e->a < qe) {
  ------------------
  |  Branch (257:9): [True: 78.6M, False: 256M]
  ------------------
  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|  78.6M|      e->c += e->a;
  262|  78.6M|      e->a = qe;
  263|  78.6M|    }
  264|   334M|    *st = (sv & 0x80) ^ nm;     /* Estimate_after_MPS */
  265|   334M|  }
  266|       |
  267|       |  /* Renormalization & data output per section D.1.6 */
  268|   793M|  do {
  269|   793M|    e->a <<= 1;
  270|   793M|    e->c <<= 1;
  271|   793M|    if (--e->ct == 0) {
  ------------------
  |  Branch (271:9): [True: 96.2M, False: 697M]
  ------------------
  272|       |      /* Another byte is ready for output */
  273|  96.2M|      temp = e->c >> 19;
  274|  96.2M|      if (temp > 0xFF) {
  ------------------
  |  Branch (274:11): [True: 3.80M, False: 92.4M]
  ------------------
  275|       |        /* Handle overflow over all stacked 0xFF bytes */
  276|  3.80M|        if (e->buffer >= 0) {
  ------------------
  |  Branch (276:13): [True: 3.80M, False: 0]
  ------------------
  277|  3.80M|          if (e->zc)
  ------------------
  |  Branch (277:15): [True: 14.9k, False: 3.79M]
  ------------------
  278|  15.3k|            do emit_byte(0x00, cinfo);
  279|  15.3k|            while (--e->zc);
  ------------------
  |  Branch (279:20): [True: 404, False: 14.9k]
  ------------------
  280|  3.80M|          emit_byte(e->buffer + 1, cinfo);
  281|  3.80M|          if (e->buffer + 1 == 0xFF)
  ------------------
  |  Branch (281:15): [True: 16.3k, False: 3.78M]
  ------------------
  282|  16.3k|            emit_byte(0x00, cinfo);
  283|  3.80M|        }
  284|  3.80M|        e->zc += e->sc;  /* carry-over converts stacked 0xFF bytes to 0x00 */
  285|  3.80M|        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.80M|        e->buffer = temp & 0xFF;  /* new output byte, might overflow later */
  290|  92.4M|      } else if (temp == 0xFF) {
  ------------------
  |  Branch (290:18): [True: 698k, False: 91.7M]
  ------------------
  291|   698k|        ++e->sc;  /* stack 0xFF byte (which might overflow later) */
  292|  91.7M|      } else {
  293|       |        /* Output all stacked 0xFF bytes, they will not overflow any more */
  294|  91.7M|        if (e->buffer == 0)
  ------------------
  |  Branch (294:13): [True: 526k, False: 91.2M]
  ------------------
  295|   526k|          ++e->zc;
  296|  91.2M|        else if (e->buffer >= 0) {
  ------------------
  |  Branch (296:18): [True: 88.7M, False: 2.55M]
  ------------------
  297|  88.7M|          if (e->zc)
  ------------------
  |  Branch (297:15): [True: 355k, False: 88.3M]
  ------------------
  298|   457k|            do emit_byte(0x00, cinfo);
  299|   457k|            while (--e->zc);
  ------------------
  |  Branch (299:20): [True: 102k, False: 355k]
  ------------------
  300|  88.7M|          emit_byte(e->buffer, cinfo);
  301|  88.7M|        }
  302|  91.7M|        if (e->sc) {
  ------------------
  |  Branch (302:13): [True: 659k, False: 91.1M]
  ------------------
  303|   659k|          if (e->zc)
  ------------------
  |  Branch (303:15): [True: 1.97k, False: 657k]
  ------------------
  304|  2.13k|            do emit_byte(0x00, cinfo);
  305|  2.13k|            while (--e->zc);
  ------------------
  |  Branch (305:20): [True: 159, False: 1.97k]
  ------------------
  306|   674k|          do {
  307|   674k|            emit_byte(0xFF, cinfo);
  308|   674k|            emit_byte(0x00, cinfo);
  309|   674k|          } while (--e->sc);
  ------------------
  |  Branch (309:20): [True: 14.9k, False: 659k]
  ------------------
  310|   659k|        }
  311|  91.7M|        e->buffer = temp & 0xFF;  /* new output byte (can still overflow) */
  312|  91.7M|      }
  313|  96.2M|      e->c &= 0x7FFFFL;
  314|  96.2M|      e->ct += 8;
  315|  96.2M|    }
  316|   793M|  } while (e->a < 0x8000L);
  ------------------
  |  Branch (316:12): [True: 144M, False: 649M]
  ------------------
  317|   649M|}
jcarith.c:encode_mcu_AC_first:
  460|  9.60M|{
  461|  9.60M|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  462|  9.60M|  JBLOCKROW block;
  463|  9.60M|  unsigned char *st;
  464|  9.60M|  int tbl, k, ke;
  465|  9.60M|  int v, v2, m;
  466|       |
  467|       |  /* Emit restart marker if needed */
  468|  9.60M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (468:7): [True: 9.60M, False: 0]
  ------------------
  469|  9.60M|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (469:9): [True: 3.62M, False: 5.98M]
  ------------------
  470|  3.62M|      emit_restart(cinfo, entropy->next_restart_num);
  471|  3.62M|      entropy->restarts_to_go = cinfo->restart_interval;
  472|  3.62M|      entropy->next_restart_num++;
  473|  3.62M|      entropy->next_restart_num &= 7;
  474|  3.62M|    }
  475|  9.60M|    entropy->restarts_to_go--;
  476|  9.60M|  }
  477|       |
  478|       |  /* Encode the MCU data block */
  479|  9.60M|  block = MCU_data[0];
  480|  9.60M|  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|   275M|  for (ke = cinfo->Se; ke > 0; ke--)
  ------------------
  |  Branch (485:24): [True: 268M, False: 6.90M]
  ------------------
  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|   268M|    if ((v = (*block)[jpeg_natural_order[ke]]) >= 0) {
  ------------------
  |  Branch (490:9): [True: 261M, False: 6.51M]
  ------------------
  491|   261M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (491:11): [True: 1.28M, False: 260M]
  ------------------
  492|   261M|    } else {
  493|  6.51M|      v = -v;
  494|  6.51M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (494:11): [True: 1.42M, False: 5.09M]
  ------------------
  495|  6.51M|    }
  496|       |
  497|       |  /* Figure F.5: Encode_AC_Coefficients */
  498|  26.8M|  for (k = cinfo->Ss; k <= ke; k++) {
  ------------------
  |  Branch (498:23): [True: 17.2M, False: 9.60M]
  ------------------
  499|  17.2M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  500|  17.2M|    arith_encode(cinfo, st, 0);         /* EOB decision */
  501|  54.1M|    for (;;) {
  502|  54.1M|      if ((v = (*block)[jpeg_natural_order[k]]) >= 0) {
  ------------------
  |  Branch (502:11): [True: 35.1M, False: 18.9M]
  ------------------
  503|  35.1M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (503:13): [True: 8.41M, False: 26.7M]
  ------------------
  504|  8.41M|          arith_encode(cinfo, st + 1, 1);
  505|  8.41M|          arith_encode(cinfo, entropy->fixed_bin, 0);
  506|  8.41M|          break;
  507|  8.41M|        }
  508|  35.1M|      } else {
  509|  18.9M|        v = -v;
  510|  18.9M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (510:13): [True: 8.82M, False: 10.1M]
  ------------------
  511|  8.82M|          arith_encode(cinfo, st + 1, 1);
  512|  8.82M|          arith_encode(cinfo, entropy->fixed_bin, 1);
  513|  8.82M|          break;
  514|  8.82M|        }
  515|  18.9M|      }
  516|  36.8M|      arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  517|  36.8M|    }
  518|  17.2M|    st += 2;
  519|       |    /* Figure F.8: Encoding the magnitude category of v */
  520|  17.2M|    m = 0;
  521|  17.2M|    if (v -= 1) {
  ------------------
  |  Branch (521:9): [True: 6.27M, False: 10.9M]
  ------------------
  522|  6.27M|      arith_encode(cinfo, st, 1);
  523|  6.27M|      m = 1;
  524|  6.27M|      v2 = v;
  525|  6.27M|      if (v2 >>= 1) {
  ------------------
  |  Branch (525:11): [True: 2.98M, False: 3.29M]
  ------------------
  526|  2.98M|        arith_encode(cinfo, st, 1);
  527|  2.98M|        m <<= 1;
  528|  2.98M|        st = entropy->ac_stats[tbl] +
  529|  2.98M|             (k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
  ------------------
  |  Branch (529:15): [True: 833k, False: 2.14M]
  ------------------
  530|  4.05M|        while (v2 >>= 1) {
  ------------------
  |  Branch (530:16): [True: 1.07M, False: 2.98M]
  ------------------
  531|  1.07M|          arith_encode(cinfo, st, 1);
  532|  1.07M|          m <<= 1;
  533|  1.07M|          st += 1;
  534|  1.07M|        }
  535|  2.98M|      }
  536|  6.27M|    }
  537|  17.2M|    arith_encode(cinfo, st, 0);
  538|       |    /* Figure F.9: Encoding the magnitude bit pattern of v */
  539|  17.2M|    st += 14;
  540|  21.2M|    while (m >>= 1)
  ------------------
  |  Branch (540:12): [True: 4.05M, False: 17.2M]
  ------------------
  541|  4.05M|      arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (541:31): [True: 1.31M, False: 2.74M]
  ------------------
  542|  17.2M|  }
  543|       |  /* Encode EOB decision only if k <= cinfo->Se */
  544|  9.60M|  if (k <= cinfo->Se) {
  ------------------
  |  Branch (544:7): [True: 8.80M, False: 799k]
  ------------------
  545|  8.80M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  546|  8.80M|    arith_encode(cinfo, st, 1);
  547|  8.80M|  }
  548|       |
  549|  9.60M|  return TRUE;
  ------------------
  |  |  210|  9.60M|#define TRUE    1
  ------------------
  550|  9.60M|}
jcarith.c:encode_mcu_DC_refine:
  559|   933k|{
  560|   933k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  561|   933k|  unsigned char *st;
  562|   933k|  int Al, blkn;
  563|       |
  564|       |  /* Emit restart marker if needed */
  565|   933k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (565:7): [True: 933k, False: 0]
  ------------------
  566|   933k|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (566:9): [True: 301k, False: 632k]
  ------------------
  567|   301k|      emit_restart(cinfo, entropy->next_restart_num);
  568|   301k|      entropy->restarts_to_go = cinfo->restart_interval;
  569|   301k|      entropy->next_restart_num++;
  570|   301k|      entropy->next_restart_num &= 7;
  571|   301k|    }
  572|   933k|    entropy->restarts_to_go--;
  573|   933k|  }
  574|       |
  575|   933k|  st = entropy->fixed_bin;      /* use fixed probability estimation */
  576|   933k|  Al = cinfo->Al;
  577|       |
  578|       |  /* Encode the MCU data blocks */
  579|  6.53M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (579:18): [True: 5.60M, False: 933k]
  ------------------
  580|       |    /* We simply emit the Al'th bit of the DC coefficient value. */
  581|  5.60M|    arith_encode(cinfo, st, (MCU_data[blkn][0][0] >> Al) & 1);
  582|  5.60M|  }
  583|       |
  584|   933k|  return TRUE;
  ------------------
  |  |  210|   933k|#define TRUE    1
  ------------------
  585|   933k|}
jcarith.c:encode_mcu_AC_refine:
  594|  9.60M|{
  595|  9.60M|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  596|  9.60M|  JBLOCKROW block;
  597|  9.60M|  unsigned char *st;
  598|  9.60M|  int tbl, k, ke, kex;
  599|  9.60M|  int v;
  600|       |
  601|       |  /* Emit restart marker if needed */
  602|  9.60M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (602:7): [True: 9.60M, False: 0]
  ------------------
  603|  9.60M|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (603:9): [True: 3.62M, False: 5.98M]
  ------------------
  604|  3.62M|      emit_restart(cinfo, entropy->next_restart_num);
  605|  3.62M|      entropy->restarts_to_go = cinfo->restart_interval;
  606|  3.62M|      entropy->next_restart_num++;
  607|  3.62M|      entropy->next_restart_num &= 7;
  608|  3.62M|    }
  609|  9.60M|    entropy->restarts_to_go--;
  610|  9.60M|  }
  611|       |
  612|       |  /* Encode the MCU data block */
  613|  9.60M|  block = MCU_data[0];
  614|  9.60M|  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|   476M|  for (ke = cinfo->Se; ke > 0; ke--)
  ------------------
  |  Branch (619:24): [True: 469M, False: 6.66M]
  ------------------
  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|   469M|    if ((v = (*block)[jpeg_natural_order[ke]]) >= 0) {
  ------------------
  |  Branch (624:9): [True: 466M, False: 2.73M]
  ------------------
  625|   466M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (625:11): [True: 1.34M, False: 465M]
  ------------------
  626|   466M|    } else {
  627|  2.73M|      v = -v;
  628|  2.73M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (628:11): [True: 1.59M, False: 1.14M]
  ------------------
  629|  2.73M|    }
  630|       |
  631|       |  /* Establish EOBx (previous stage end-of-block) index */
  632|  25.6M|  for (kex = ke; kex > 0; kex--)
  ------------------
  |  Branch (632:18): [True: 18.9M, False: 6.74M]
  ------------------
  633|  18.9M|    if ((v = (*block)[jpeg_natural_order[kex]]) >= 0) {
  ------------------
  |  Branch (633:9): [True: 12.9M, False: 6.00M]
  ------------------
  634|  12.9M|      if (v >>= cinfo->Ah) break;
  ------------------
  |  Branch (634:11): [True: 1.35M, False: 11.5M]
  ------------------
  635|  12.9M|    } else {
  636|  6.00M|      v = -v;
  637|  6.00M|      if (v >>= cinfo->Ah) break;
  ------------------
  |  Branch (637:11): [True: 1.51M, False: 4.48M]
  ------------------
  638|  6.00M|    }
  639|       |
  640|       |  /* Figure G.10: Encode_AC_Coefficients_SA */
  641|  89.7M|  for (k = cinfo->Ss; k <= ke; k++) {
  ------------------
  |  Branch (641:23): [True: 80.1M, False: 9.60M]
  ------------------
  642|  80.1M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  643|  80.1M|    if (k > kex)
  ------------------
  |  Branch (643:9): [True: 5.82M, False: 74.3M]
  ------------------
  644|  5.82M|      arith_encode(cinfo, st, 0);       /* EOB decision */
  645|   138M|    for (;;) {
  646|   138M|      if ((v = (*block)[jpeg_natural_order[k]]) >= 0) {
  ------------------
  |  Branch (646:11): [True: 92.1M, False: 46.8M]
  ------------------
  647|  92.1M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (647:13): [True: 39.5M, False: 52.6M]
  ------------------
  648|  39.5M|          if (v >> 1)                   /* previously nonzero coef */
  ------------------
  |  Branch (648:15): [True: 24.6M, False: 14.9M]
  ------------------
  649|  24.6M|            arith_encode(cinfo, st + 2, (v & 1));
  650|  14.9M|          else {                        /* newly nonzero coef */
  651|  14.9M|            arith_encode(cinfo, st + 1, 1);
  652|  14.9M|            arith_encode(cinfo, entropy->fixed_bin, 0);
  653|  14.9M|          }
  654|  39.5M|          break;
  655|  39.5M|        }
  656|  92.1M|      } else {
  657|  46.8M|        v = -v;
  658|  46.8M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (658:13): [True: 40.6M, False: 6.17M]
  ------------------
  659|  40.6M|          if (v >> 1)                   /* previously nonzero coef */
  ------------------
  |  Branch (659:15): [True: 25.4M, False: 15.1M]
  ------------------
  660|  25.4M|            arith_encode(cinfo, st + 2, (v & 1));
  661|  15.1M|          else {                        /* newly nonzero coef */
  662|  15.1M|            arith_encode(cinfo, st + 1, 1);
  663|  15.1M|            arith_encode(cinfo, entropy->fixed_bin, 1);
  664|  15.1M|          }
  665|  40.6M|          break;
  666|  40.6M|        }
  667|  46.8M|      }
  668|  58.7M|      arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  669|  58.7M|    }
  670|  80.1M|  }
  671|       |  /* Encode EOB decision only if k <= cinfo->Se */
  672|  9.60M|  if (k <= cinfo->Se) {
  ------------------
  |  Branch (672:7): [True: 8.71M, False: 896k]
  ------------------
  673|  8.71M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  674|  8.71M|    arith_encode(cinfo, st, 1);
  675|  8.71M|  }
  676|       |
  677|  9.60M|  return TRUE;
  ------------------
  |  |  210|  9.60M|#define TRUE    1
  ------------------
  678|  9.60M|}
jcarith.c:encode_mcu:
  687|   616k|{
  688|   616k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  689|   616k|  jpeg_component_info *compptr;
  690|   616k|  JBLOCKROW block;
  691|   616k|  unsigned char *st;
  692|   616k|  int blkn, ci, tbl, k, ke;
  693|   616k|  int v, v2, m;
  694|       |
  695|       |  /* Emit restart marker if needed */
  696|   616k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (696:7): [True: 616k, False: 0]
  ------------------
  697|   616k|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (697:9): [True: 301k, False: 314k]
  ------------------
  698|   301k|      emit_restart(cinfo, entropy->next_restart_num);
  699|   301k|      entropy->restarts_to_go = cinfo->restart_interval;
  700|   301k|      entropy->next_restart_num++;
  701|   301k|      entropy->next_restart_num &= 7;
  702|   301k|    }
  703|   616k|    entropy->restarts_to_go--;
  704|   616k|  }
  705|       |
  706|       |  /* Encode the MCU data blocks */
  707|  4.31M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (707:18): [True: 3.70M, False: 616k]
  ------------------
  708|  3.70M|    block = MCU_data[blkn];
  709|  3.70M|    ci = cinfo->MCU_membership[blkn];
  710|  3.70M|    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.70M|    tbl = compptr->dc_tbl_no;
  715|       |
  716|       |    /* Table F.4: Point to statistics bin S0 for DC coefficient coding */
  717|  3.70M|    st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
  718|       |
  719|       |    /* Figure F.4: Encode_DC_DIFF */
  720|  3.70M|    if ((v = (*block)[0] - entropy->last_dc_val[ci]) == 0) {
  ------------------
  |  Branch (720:9): [True: 1.56M, False: 2.13M]
  ------------------
  721|  1.56M|      arith_encode(cinfo, st, 0);
  722|  1.56M|      entropy->dc_context[ci] = 0;      /* zero diff category */
  723|  2.13M|    } else {
  724|  2.13M|      entropy->last_dc_val[ci] = (*block)[0];
  725|  2.13M|      arith_encode(cinfo, st, 1);
  726|       |      /* Figure F.6: Encoding nonzero value v */
  727|       |      /* Figure F.7: Encoding the sign of v */
  728|  2.13M|      if (v > 0) {
  ------------------
  |  Branch (728:11): [True: 666k, False: 1.46M]
  ------------------
  729|   666k|        arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
  730|   666k|        st += 2;                        /* Table F.4: SP = S0 + 2 */
  731|   666k|        entropy->dc_context[ci] = 4;    /* small positive diff category */
  732|  1.46M|      } else {
  733|  1.46M|        v = -v;
  734|  1.46M|        arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
  735|  1.46M|        st += 3;                        /* Table F.4: SN = S0 + 3 */
  736|  1.46M|        entropy->dc_context[ci] = 8;    /* small negative diff category */
  737|  1.46M|      }
  738|       |      /* Figure F.8: Encoding the magnitude category of v */
  739|  2.13M|      m = 0;
  740|  2.13M|      if (v -= 1) {
  ------------------
  |  Branch (740:11): [True: 2.13M, False: 4.20k]
  ------------------
  741|  2.13M|        arith_encode(cinfo, st, 1);
  742|  2.13M|        m = 1;
  743|  2.13M|        v2 = v;
  744|  2.13M|        st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
  745|  19.7M|        while (v2 >>= 1) {
  ------------------
  |  Branch (745:16): [True: 17.6M, False: 2.13M]
  ------------------
  746|  17.6M|          arith_encode(cinfo, st, 1);
  747|  17.6M|          m <<= 1;
  748|  17.6M|          st += 1;
  749|  17.6M|        }
  750|  2.13M|      }
  751|  2.13M|      arith_encode(cinfo, st, 0);
  752|       |      /* Section F.1.4.4.1.2: Establish dc_context conditioning category */
  753|  2.13M|      if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
  ------------------
  |  Branch (753:11): [True: 0, False: 2.13M]
  ------------------
  754|      0|        entropy->dc_context[ci] = 0;    /* zero diff category */
  755|  2.13M|      else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
  ------------------
  |  Branch (755:16): [True: 2.12M, False: 8.84k]
  ------------------
  756|  2.12M|        entropy->dc_context[ci] += 8;   /* large diff category */
  757|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  758|  2.13M|      st += 14;
  759|  19.7M|      while (m >>= 1)
  ------------------
  |  Branch (759:14): [True: 17.6M, False: 2.13M]
  ------------------
  760|  17.6M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (760:33): [True: 11.0M, False: 6.61M]
  ------------------
  761|  2.13M|    }
  762|       |
  763|       |    /* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */
  764|       |
  765|  3.70M|    tbl = compptr->ac_tbl_no;
  766|       |
  767|       |    /* Establish EOB (end-of-block) index */
  768|   157M|    for (ke = DCTSIZE2 - 1; ke > 0; ke--)
  ------------------
  |  |   67|  3.70M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (768:29): [True: 155M, False: 2.04M]
  ------------------
  769|   155M|      if ((*block)[jpeg_natural_order[ke]]) break;
  ------------------
  |  Branch (769:11): [True: 1.65M, False: 153M]
  ------------------
  770|       |
  771|       |    /* Figure F.5: Encode_AC_Coefficients */
  772|  59.1M|    for (k = 1; k <= ke; k++) {
  ------------------
  |  Branch (772:17): [True: 55.4M, False: 3.70M]
  ------------------
  773|  55.4M|      st = entropy->ac_stats[tbl] + 3 * (k - 1);
  774|  55.4M|      arith_encode(cinfo, st, 0);       /* EOB decision */
  775|  79.2M|      while ((v = (*block)[jpeg_natural_order[k]]) == 0) {
  ------------------
  |  Branch (775:14): [True: 23.8M, False: 55.4M]
  ------------------
  776|  23.8M|        arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  777|  23.8M|      }
  778|  55.4M|      arith_encode(cinfo, st + 1, 1);
  779|       |      /* Figure F.6: Encoding nonzero value v */
  780|       |      /* Figure F.7: Encoding the sign of v */
  781|  55.4M|      if (v > 0) {
  ------------------
  |  Branch (781:11): [True: 27.3M, False: 28.1M]
  ------------------
  782|  27.3M|        arith_encode(cinfo, entropy->fixed_bin, 0);
  783|  28.1M|      } else {
  784|  28.1M|        v = -v;
  785|  28.1M|        arith_encode(cinfo, entropy->fixed_bin, 1);
  786|  28.1M|      }
  787|  55.4M|      st += 2;
  788|       |      /* Figure F.8: Encoding the magnitude category of v */
  789|  55.4M|      m = 0;
  790|  55.4M|      if (v -= 1) {
  ------------------
  |  Branch (790:11): [True: 51.5M, False: 3.88M]
  ------------------
  791|  51.5M|        arith_encode(cinfo, st, 1);
  792|  51.5M|        m = 1;
  793|  51.5M|        v2 = v;
  794|  51.5M|        if (v2 >>= 1) {
  ------------------
  |  Branch (794:13): [True: 48.3M, False: 3.16M]
  ------------------
  795|  48.3M|          arith_encode(cinfo, st, 1);
  796|  48.3M|          m <<= 1;
  797|  48.3M|          st = entropy->ac_stats[tbl] +
  798|  48.3M|               (k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
  ------------------
  |  Branch (798:17): [True: 5.85M, False: 42.5M]
  ------------------
  799|   199M|          while (v2 >>= 1) {
  ------------------
  |  Branch (799:18): [True: 150M, False: 48.3M]
  ------------------
  800|   150M|            arith_encode(cinfo, st, 1);
  801|   150M|            m <<= 1;
  802|   150M|            st += 1;
  803|   150M|          }
  804|  48.3M|        }
  805|  51.5M|      }
  806|  55.4M|      arith_encode(cinfo, st, 0);
  807|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  808|  55.4M|      st += 14;
  809|   254M|      while (m >>= 1)
  ------------------
  |  Branch (809:14): [True: 199M, False: 55.4M]
  ------------------
  810|   199M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (810:33): [True: 90.7M, False: 108M]
  ------------------
  811|  55.4M|    }
  812|       |    /* Encode EOB decision only if k <= DCTSIZE2 - 1 */
  813|  3.70M|    if (k <= DCTSIZE2 - 1) {
  ------------------
  |  |   67|  3.70M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (813:9): [True: 2.98M, False: 719k]
  ------------------
  814|  2.98M|      st = entropy->ac_stats[tbl] + 3 * (k - 1);
  815|  2.98M|      arith_encode(cinfo, st, 1);
  816|  2.98M|    }
  817|  3.70M|  }
  818|       |
  819|   616k|  return TRUE;
  ------------------
  |  |  210|   616k|#define TRUE    1
  ------------------
  820|   616k|}
jcarith.c:finish_pass:
  140|  8.20M|{
  141|  8.20M|  arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
  142|  8.20M|  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|  8.20M|  if ((temp = (e->a - 1 + e->c) & 0xFFFF0000UL) < e->c)
  ------------------
  |  Branch (148:7): [True: 6.04M, False: 2.16M]
  ------------------
  149|  6.04M|    e->c = temp + 0x8000L;
  150|  2.16M|  else
  151|  2.16M|    e->c = temp;
  152|       |  /* Send remaining bytes to output */
  153|  8.20M|  e->c <<= e->ct;
  154|  8.20M|  if (e->c & 0xF8000000UL) {
  ------------------
  |  Branch (154:7): [True: 131k, False: 8.07M]
  ------------------
  155|       |    /* One final overflow has to be handled */
  156|   131k|    if (e->buffer >= 0) {
  ------------------
  |  Branch (156:9): [True: 131k, False: 0]
  ------------------
  157|   131k|      if (e->zc)
  ------------------
  |  Branch (157:11): [True: 8.62k, False: 122k]
  ------------------
  158|  8.88k|        do emit_byte(0x00, cinfo);
  159|  8.88k|        while (--e->zc);
  ------------------
  |  Branch (159:16): [True: 261, False: 8.62k]
  ------------------
  160|   131k|      emit_byte(e->buffer + 1, cinfo);
  161|   131k|      if (e->buffer + 1 == 0xFF)
  ------------------
  |  Branch (161:11): [True: 723, False: 130k]
  ------------------
  162|    723|        emit_byte(0x00, cinfo);
  163|   131k|    }
  164|   131k|    e->zc += e->sc;  /* carry-over converts stacked 0xFF bytes to 0x00 */
  165|   131k|    e->sc = 0;
  166|  8.07M|  } else {
  167|  8.07M|    if (e->buffer == 0)
  ------------------
  |  Branch (167:9): [True: 73.1k, False: 8.00M]
  ------------------
  168|  73.1k|      ++e->zc;
  169|  8.00M|    else if (e->buffer >= 0) {
  ------------------
  |  Branch (169:14): [True: 2.35M, False: 5.64M]
  ------------------
  170|  2.35M|      if (e->zc)
  ------------------
  |  Branch (170:11): [True: 9.64k, False: 2.34M]
  ------------------
  171|  11.3k|        do emit_byte(0x00, cinfo);
  172|  11.3k|        while (--e->zc);
  ------------------
  |  Branch (172:16): [True: 1.65k, False: 9.64k]
  ------------------
  173|  2.35M|      emit_byte(e->buffer, cinfo);
  174|  2.35M|    }
  175|  8.07M|    if (e->sc) {
  ------------------
  |  Branch (175:9): [True: 5.83k, False: 8.07M]
  ------------------
  176|  5.83k|      if (e->zc)
  ------------------
  |  Branch (176:11): [True: 73, False: 5.76k]
  ------------------
  177|     86|        do emit_byte(0x00, cinfo);
  178|     86|        while (--e->zc);
  ------------------
  |  Branch (178:16): [True: 13, False: 73]
  ------------------
  179|  6.09k|      do {
  180|  6.09k|        emit_byte(0xFF, cinfo);
  181|  6.09k|        emit_byte(0x00, cinfo);
  182|  6.09k|      } while (--e->sc);
  ------------------
  |  Branch (182:16): [True: 260, False: 5.83k]
  ------------------
  183|  5.83k|    }
  184|  8.07M|  }
  185|       |  /* Output final bytes only if they are not 0x00 */
  186|  8.20M|  if (e->c & 0x7FFF800L) {
  ------------------
  |  Branch (186:7): [True: 8.14M, False: 67.0k]
  ------------------
  187|  8.14M|    if (e->zc)  /* output final pending zero bytes */
  ------------------
  |  Branch (187:9): [True: 72.4k, False: 8.06M]
  ------------------
  188|  85.4k|      do emit_byte(0x00, cinfo);
  189|  85.4k|      while (--e->zc);
  ------------------
  |  Branch (189:14): [True: 13.0k, False: 72.4k]
  ------------------
  190|  8.14M|    emit_byte((e->c >> 19) & 0xFF, cinfo);
  191|  8.14M|    if (((e->c >> 19) & 0xFF) == 0xFF)
  ------------------
  |  Branch (191:9): [True: 4.25k, False: 8.13M]
  ------------------
  192|  4.25k|      emit_byte(0x00, cinfo);
  193|  8.14M|    if (e->c & 0x7F800L) {
  ------------------
  |  Branch (193:9): [True: 474k, False: 7.66M]
  ------------------
  194|   474k|      emit_byte((e->c >> 11) & 0xFF, cinfo);
  195|   474k|      if (((e->c >> 11) & 0xFF) == 0xFF)
  ------------------
  |  Branch (195:11): [True: 0, False: 474k]
  ------------------
  196|      0|        emit_byte(0x00, cinfo);
  197|   474k|    }
  198|  8.14M|  }
  199|  8.20M|}

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

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

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

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

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

jpeg_write_icc_profile:
   51|  18.6k|{
   52|  18.6k|  unsigned int num_markers;     /* total number of markers we'll write */
   53|  18.6k|  int cur_marker = 1;           /* per spec, counting starts at 1 */
   54|  18.6k|  unsigned int length;          /* number of bytes to write in this marker */
   55|       |
   56|  18.6k|  if (icc_data_ptr == NULL || icc_data_len == 0)
  ------------------
  |  Branch (56:7): [True: 0, False: 18.6k]
  |  Branch (56:31): [True: 0, False: 18.6k]
  ------------------
   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|  18.6k|  if (cinfo->global_state < CSTATE_SCANNING)
  ------------------
  |  |   45|  18.6k|#define CSTATE_SCANNING  101    /* start_compress done, write_scanlines OK */
  ------------------
  |  Branch (58:7): [True: 0, False: 18.6k]
  ------------------
   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|  18.6k|  num_markers = icc_data_len / MAX_DATA_BYTES_IN_MARKER;
  ------------------
  |  |   38|  18.6k|#define MAX_DATA_BYTES_IN_MARKER  (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN)
  |  |  ------------------
  |  |  |  |   37|  18.6k|#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|  18.6k|#define ICC_OVERHEAD_LEN  14            /* size of non-profile data in APP2 */
  |  |  ------------------
  ------------------
   63|  18.6k|  if (num_markers * MAX_DATA_BYTES_IN_MARKER != icc_data_len)
  ------------------
  |  |   38|  18.6k|#define MAX_DATA_BYTES_IN_MARKER  (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN)
  |  |  ------------------
  |  |  |  |   37|  18.6k|#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|  18.6k|#define ICC_OVERHEAD_LEN  14            /* size of non-profile data in APP2 */
  |  |  ------------------
  ------------------
  |  Branch (63:7): [True: 18.6k, False: 0]
  ------------------
   64|  18.6k|    num_markers++;
   65|       |
   66|  37.3k|  while (icc_data_len > 0) {
  ------------------
  |  Branch (66:10): [True: 18.6k, False: 18.6k]
  ------------------
   67|       |    /* length of profile to put in this marker */
   68|  18.6k|    length = icc_data_len;
   69|  18.6k|    if (length > MAX_DATA_BYTES_IN_MARKER)
  ------------------
  |  |   38|  18.6k|#define MAX_DATA_BYTES_IN_MARKER  (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN)
  |  |  ------------------
  |  |  |  |   37|  18.6k|#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|  18.6k|#define ICC_OVERHEAD_LEN  14            /* size of non-profile data in APP2 */
  |  |  ------------------
  ------------------
  |  Branch (69:9): [True: 0, False: 18.6k]
  ------------------
   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|  18.6k|    icc_data_len -= length;
   72|       |
   73|       |    /* Write the JPEG marker header (APP2 code and marker length) */
   74|  18.6k|    jpeg_write_m_header(cinfo, ICC_MARKER,
  ------------------
  |  |   35|  18.6k|#define ICC_MARKER  (JPEG_APP0 + 2)     /* JPEG marker code for ICC */
  |  |  ------------------
  |  |  |  | 1168|  18.6k|#define JPEG_APP0       0xE0    /* APP0 marker code */
  |  |  ------------------
  ------------------
   75|  18.6k|                        (unsigned int)(length + ICC_OVERHEAD_LEN));
  ------------------
  |  |   36|  18.6k|#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|  18.6k|    jpeg_write_m_byte(cinfo, 0x49);
   82|  18.6k|    jpeg_write_m_byte(cinfo, 0x43);
   83|  18.6k|    jpeg_write_m_byte(cinfo, 0x43);
   84|  18.6k|    jpeg_write_m_byte(cinfo, 0x5F);
   85|  18.6k|    jpeg_write_m_byte(cinfo, 0x50);
   86|  18.6k|    jpeg_write_m_byte(cinfo, 0x52);
   87|  18.6k|    jpeg_write_m_byte(cinfo, 0x4F);
   88|  18.6k|    jpeg_write_m_byte(cinfo, 0x46);
   89|  18.6k|    jpeg_write_m_byte(cinfo, 0x49);
   90|  18.6k|    jpeg_write_m_byte(cinfo, 0x4C);
   91|  18.6k|    jpeg_write_m_byte(cinfo, 0x45);
   92|  18.6k|    jpeg_write_m_byte(cinfo, 0x0);
   93|       |
   94|       |    /* Add the sequencing info */
   95|  18.6k|    jpeg_write_m_byte(cinfo, cur_marker);
   96|  18.6k|    jpeg_write_m_byte(cinfo, (int)num_markers);
   97|       |
   98|       |    /* Add the profile data */
   99|   615k|    while (length--) {
  ------------------
  |  Branch (99:12): [True: 596k, False: 18.6k]
  ------------------
  100|   596k|      jpeg_write_m_byte(cinfo, *icc_data_ptr);
  101|   596k|      icc_data_ptr++;
  102|   596k|    }
  103|  18.6k|    cur_marker++;
  104|  18.6k|  }
  105|  18.6k|}

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

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

jinit_marker_writer:
  652|  22.1k|{
  653|  22.1k|  my_marker_ptr marker;
  654|       |
  655|       |  /* Create the subobject */
  656|  22.1k|  marker = (my_marker_ptr)
  657|  22.1k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.1k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  658|  22.1k|                                sizeof(my_marker_writer));
  659|  22.1k|  cinfo->marker = (struct jpeg_marker_writer *)marker;
  660|       |  /* Initialize method pointers */
  661|  22.1k|  marker->pub.write_file_header = write_file_header;
  662|  22.1k|  marker->pub.write_frame_header = write_frame_header;
  663|  22.1k|  marker->pub.write_scan_header = write_scan_header;
  664|  22.1k|  marker->pub.write_file_trailer = write_file_trailer;
  665|  22.1k|  marker->pub.write_tables_only = write_tables_only;
  666|  22.1k|  marker->pub.write_marker_header = write_marker_header;
  667|  22.1k|  marker->pub.write_marker_byte = write_marker_byte;
  668|       |  /* Initialize private state */
  669|  22.1k|  marker->last_restart_interval = 0;
  670|  22.1k|}
jcmarker.c:write_file_header:
  476|  22.1k|{
  477|  22.1k|  my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
  478|       |
  479|  22.1k|  emit_marker(cinfo, M_SOI);    /* first the SOI */
  480|       |
  481|       |  /* SOI is defined to reset restart interval to 0 */
  482|  22.1k|  marker->last_restart_interval = 0;
  483|       |
  484|  22.1k|  if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */
  ------------------
  |  Branch (484:7): [True: 16.0k, False: 6.10k]
  ------------------
  485|  16.0k|    emit_jfif_app0(cinfo);
  486|  22.1k|  if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */
  ------------------
  |  Branch (486:7): [True: 6.10k, False: 16.0k]
  ------------------
  487|  6.10k|    emit_adobe_app14(cinfo);
  488|  22.1k|}
jcmarker.c:emit_marker:
  131|   357k|{
  132|   357k|  emit_byte(cinfo, 0xFF);
  133|   357k|  emit_byte(cinfo, (int)mark);
  134|   357k|}
jcmarker.c:emit_byte:
  117|  7.44M|{
  118|  7.44M|  struct jpeg_destination_mgr *dest = cinfo->dest;
  119|       |
  120|  7.44M|  *(dest->next_output_byte)++ = (JOCTET)val;
  121|  7.44M|  if (--dest->free_in_buffer == 0) {
  ------------------
  |  Branch (121:7): [True: 102, False: 7.44M]
  ------------------
  122|    102|    if (!(*dest->empty_output_buffer) (cinfo))
  ------------------
  |  Branch (122:9): [True: 0, False: 102]
  ------------------
  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|    102|  }
  125|  7.44M|}
jcmarker.c:emit_jfif_app0:
  357|  16.0k|{
  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|  16.0k|  emit_marker(cinfo, M_APP0);
  371|       |
  372|  16.0k|  emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */
  373|       |
  374|  16.0k|  emit_byte(cinfo, 0x4A);       /* Identifier: ASCII "JFIF" */
  375|  16.0k|  emit_byte(cinfo, 0x46);
  376|  16.0k|  emit_byte(cinfo, 0x49);
  377|  16.0k|  emit_byte(cinfo, 0x46);
  378|  16.0k|  emit_byte(cinfo, 0);
  379|  16.0k|  emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */
  380|  16.0k|  emit_byte(cinfo, cinfo->JFIF_minor_version);
  381|  16.0k|  emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */
  382|  16.0k|  emit_2bytes(cinfo, (int)cinfo->X_density);
  383|  16.0k|  emit_2bytes(cinfo, (int)cinfo->Y_density);
  384|  16.0k|  emit_byte(cinfo, 0);          /* No thumbnail image */
  385|  16.0k|  emit_byte(cinfo, 0);
  386|  16.0k|}
jcmarker.c:emit_2bytes:
  140|   414k|{
  141|   414k|  emit_byte(cinfo, (value >> 8) & 0xFF);
  142|   414k|  emit_byte(cinfo, value & 0xFF);
  143|   414k|}
jcmarker.c:emit_adobe_app14:
  392|  6.10k|{
  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|  6.10k|  emit_marker(cinfo, M_APP14);
  410|       |
  411|  6.10k|  emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */
  412|       |
  413|  6.10k|  emit_byte(cinfo, 0x41);       /* Identifier: ASCII "Adobe" */
  414|  6.10k|  emit_byte(cinfo, 0x64);
  415|  6.10k|  emit_byte(cinfo, 0x6F);
  416|  6.10k|  emit_byte(cinfo, 0x62);
  417|  6.10k|  emit_byte(cinfo, 0x65);
  418|  6.10k|  emit_2bytes(cinfo, 100);      /* Version */
  419|  6.10k|  emit_2bytes(cinfo, 0);        /* Flags0 */
  420|  6.10k|  emit_2bytes(cinfo, 0);        /* Flags1 */
  421|  6.10k|  switch (cinfo->jpeg_color_space) {
  422|      0|  case JCS_YCbCr:
  ------------------
  |  Branch (422:3): [True: 0, False: 6.10k]
  ------------------
  423|      0|    emit_byte(cinfo, 1);        /* Color transform = 1 */
  424|      0|    break;
  425|  3.05k|  case JCS_YCCK:
  ------------------
  |  Branch (425:3): [True: 3.05k, False: 3.05k]
  ------------------
  426|  3.05k|    emit_byte(cinfo, 2);        /* Color transform = 2 */
  427|  3.05k|    break;
  428|  3.05k|  default:
  ------------------
  |  Branch (428:3): [True: 3.05k, False: 3.05k]
  ------------------
  429|  3.05k|    emit_byte(cinfo, 0);        /* Color transform = 0 */
  430|  3.05k|    break;
  431|  6.10k|  }
  432|  6.10k|}
jcmarker.c:write_frame_header:
  501|  22.1k|{
  502|  22.1k|  int ci, prec = 0;
  503|  22.1k|  boolean is_baseline;
  504|  22.1k|  jpeg_component_info *compptr;
  505|       |
  506|  22.1k|  if (!cinfo->master->lossless) {
  ------------------
  |  Branch (506:7): [True: 22.1k, False: 0]
  ------------------
  507|       |    /* Emit DQT for each quantization table.
  508|       |     * Note that emit_dqt() suppresses any duplicate tables.
  509|       |     */
  510|  78.2k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (510:46): [True: 56.0k, False: 22.1k]
  ------------------
  511|  56.0k|         ci++, compptr++) {
  512|  56.0k|      prec += emit_dqt(cinfo, compptr->quant_tbl_no);
  513|  56.0k|    }
  514|       |    /* now prec is nonzero iff there are any 16-bit quant tables. */
  515|  22.1k|  }
  516|       |
  517|       |  /* Check for a non-baseline specification.
  518|       |   * Note we assume that Huffman table numbers won't be changed later.
  519|       |   */
  520|  22.1k|  if (cinfo->arith_code || cinfo->progressive_mode ||
  ------------------
  |  Branch (520:7): [True: 6.10k, False: 16.0k]
  |  Branch (520:28): [True: 3.71k, False: 12.3k]
  ------------------
  521|  22.1k|      cinfo->master->lossless || cinfo->data_precision != 8) {
  ------------------
  |  Branch (521:7): [True: 0, False: 12.3k]
  |  Branch (521:34): [True: 12.3k, False: 0]
  ------------------
  522|  22.1k|    is_baseline = FALSE;
  ------------------
  |  |  207|  22.1k|#define FALSE   0               /* values of boolean */
  ------------------
  523|  22.1k|  } 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|  22.1k|  if (cinfo->arith_code) {
  ------------------
  |  Branch (538:7): [True: 6.10k, False: 16.0k]
  ------------------
  539|  6.10k|    if (cinfo->progressive_mode)
  ------------------
  |  Branch (539:9): [True: 3.05k, False: 3.05k]
  ------------------
  540|  3.05k|      emit_sof(cinfo, M_SOF10); /* SOF code for progressive arithmetic */
  541|  3.05k|    else
  542|  3.05k|      emit_sof(cinfo, M_SOF9);  /* SOF code for sequential arithmetic */
  543|  16.0k|  } else {
  544|  16.0k|    if (cinfo->progressive_mode)
  ------------------
  |  Branch (544:9): [True: 3.71k, False: 12.3k]
  ------------------
  545|  3.71k|      emit_sof(cinfo, M_SOF2);  /* SOF code for progressive Huffman */
  546|  12.3k|    else if (cinfo->master->lossless)
  ------------------
  |  Branch (546:14): [True: 0, False: 12.3k]
  ------------------
  547|      0|      emit_sof(cinfo, M_SOF3);  /* SOF code for lossless Huffman */
  548|  12.3k|    else if (is_baseline)
  ------------------
  |  Branch (548:14): [True: 0, False: 12.3k]
  ------------------
  549|      0|      emit_sof(cinfo, M_SOF0);  /* SOF code for baseline implementation */
  550|  12.3k|    else
  551|  12.3k|      emit_sof(cinfo, M_SOF1);  /* SOF code for non-baseline Huffman file */
  552|  16.0k|  }
  553|  22.1k|}
jcmarker.c:emit_dqt:
  154|  56.0k|{
  155|  56.0k|  JQUANT_TBL *qtbl = cinfo->quant_tbl_ptrs[index];
  156|  56.0k|  int prec;
  157|  56.0k|  int i;
  158|       |
  159|  56.0k|  if (qtbl == NULL)
  ------------------
  |  Branch (159:7): [True: 0, False: 56.0k]
  ------------------
  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|  56.0k|  prec = 0;
  163|  3.64M|  for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  3.64M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (163:15): [True: 3.58M, False: 56.0k]
  ------------------
  164|  3.58M|    if (qtbl->quantval[i] > 255)
  ------------------
  |  Branch (164:9): [True: 0, False: 3.58M]
  ------------------
  165|      0|      prec = 1;
  166|  3.58M|  }
  167|       |
  168|  56.0k|  if (!qtbl->sent_table) {
  ------------------
  |  Branch (168:7): [True: 34.5k, False: 21.5k]
  ------------------
  169|  34.5k|    emit_marker(cinfo, M_DQT);
  170|       |
  171|  34.5k|    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|  34.5k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (171:24): [True: 0, False: 34.5k]
  ------------------
  172|       |
  173|  34.5k|    emit_byte(cinfo, index + (prec << 4));
  174|       |
  175|  2.24M|    for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  2.24M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (175:17): [True: 2.21M, False: 34.5k]
  ------------------
  176|       |      /* The table entries must be emitted in zigzag order. */
  177|  2.21M|      unsigned int qval = qtbl->quantval[jpeg_natural_order[i]];
  178|  2.21M|      if (prec)
  ------------------
  |  Branch (178:11): [True: 0, False: 2.21M]
  ------------------
  179|      0|        emit_byte(cinfo, (int)(qval >> 8));
  180|  2.21M|      emit_byte(cinfo, (int)(qval & 0xFF));
  181|  2.21M|    }
  182|       |
  183|  34.5k|    qtbl->sent_table = TRUE;
  ------------------
  |  |  210|  34.5k|#define TRUE    1
  ------------------
  184|  34.5k|  }
  185|       |
  186|  56.0k|  return prec;
  187|  56.0k|}
jcmarker.c:emit_sof:
  292|  22.1k|{
  293|  22.1k|  int ci;
  294|  22.1k|  jpeg_component_info *compptr;
  295|       |
  296|  22.1k|  emit_marker(cinfo, code);
  297|       |
  298|  22.1k|  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|  22.1k|  if ((long)cinfo->_jpeg_height > 65535L || (long)cinfo->_jpeg_width > 65535L)
  ------------------
  |  |   31|  22.1k|#define _jpeg_height  image_height
  ------------------
                if ((long)cinfo->_jpeg_height > 65535L || (long)cinfo->_jpeg_width > 65535L)
  ------------------
  |  |   30|  22.1k|#define _jpeg_width  image_width
  ------------------
  |  Branch (301:7): [True: 0, False: 22.1k]
  |  Branch (301:45): [True: 0, False: 22.1k]
  ------------------
  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|  22.1k|  emit_byte(cinfo, cinfo->data_precision);
  305|  22.1k|  emit_2bytes(cinfo, (int)cinfo->_jpeg_height);
  ------------------
  |  |   31|  22.1k|#define _jpeg_height  image_height
  ------------------
  306|  22.1k|  emit_2bytes(cinfo, (int)cinfo->_jpeg_width);
  ------------------
  |  |   30|  22.1k|#define _jpeg_width  image_width
  ------------------
  307|       |
  308|  22.1k|  emit_byte(cinfo, cinfo->num_components);
  309|       |
  310|  78.2k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (310:44): [True: 56.0k, False: 22.1k]
  ------------------
  311|  56.0k|       ci++, compptr++) {
  312|  56.0k|    emit_byte(cinfo, compptr->component_id);
  313|  56.0k|    emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor);
  314|  56.0k|    emit_byte(cinfo, compptr->quant_tbl_no);
  315|  56.0k|  }
  316|  22.1k|}
jcmarker.c:write_scan_header:
  564|  92.6k|{
  565|  92.6k|  my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
  566|  92.6k|  int i;
  567|  92.6k|  jpeg_component_info *compptr;
  568|       |
  569|  92.6k|  if (cinfo->arith_code) {
  ------------------
  |  Branch (569:7): [True: 57.9k, False: 34.6k]
  ------------------
  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|  57.9k|    emit_dac(cinfo);
  575|  57.9k|  } else {
  576|       |    /* Emit Huffman tables.
  577|       |     * Note that emit_dht() suppresses any duplicate tables.
  578|       |     */
  579|  87.9k|    for (i = 0; i < cinfo->comps_in_scan; i++) {
  ------------------
  |  Branch (579:17): [True: 53.3k, False: 34.6k]
  ------------------
  580|  53.3k|      compptr = cinfo->cur_comp_info[i];
  581|       |      /* DC needs no table for refinement scan */
  582|  53.3k|      if ((cinfo->Ss == 0 && cinfo->Ah == 0) || cinfo->master->lossless)
  ------------------
  |  Branch (582:12): [True: 38.4k, False: 14.8k]
  |  Branch (582:30): [True: 34.7k, False: 3.71k]
  |  Branch (582:49): [True: 0, False: 18.5k]
  ------------------
  583|  34.7k|        emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
  ------------------
  |  |  207|  34.7k|#define FALSE   0               /* values of boolean */
  ------------------
  584|       |      /* AC needs no table when not present, and lossless mode uses only DC
  585|       |         tables. */
  586|  53.3k|      if (cinfo->Se && !cinfo->master->lossless)
  ------------------
  |  Branch (586:11): [True: 45.8k, False: 7.43k]
  |  Branch (586:24): [True: 45.8k, False: 0]
  ------------------
  587|  45.8k|        emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
  ------------------
  |  |  210|  45.8k|#define TRUE    1
  ------------------
  588|  53.3k|    }
  589|  34.6k|  }
  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|  92.6k|  if (cinfo->restart_interval != marker->last_restart_interval) {
  ------------------
  |  Branch (594:7): [True: 6.10k, False: 86.5k]
  ------------------
  595|  6.10k|    emit_dri(cinfo);
  596|  6.10k|    marker->last_restart_interval = cinfo->restart_interval;
  597|  6.10k|  }
  598|       |
  599|  92.6k|  emit_sos(cinfo);
  600|  92.6k|}
jcmarker.c:emit_dac:
  233|  57.9k|{
  234|  57.9k|#ifdef C_ARITH_CODING_SUPPORTED
  235|  57.9k|  char dc_in_use[NUM_ARITH_TBLS];
  236|  57.9k|  char ac_in_use[NUM_ARITH_TBLS];
  237|  57.9k|  int length, i;
  238|  57.9k|  jpeg_component_info *compptr;
  239|       |
  240|   985k|  for (i = 0; i < NUM_ARITH_TBLS; i++)
  ------------------
  |  |   70|   985k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (240:15): [True: 927k, False: 57.9k]
  ------------------
  241|   927k|    dc_in_use[i] = ac_in_use[i] = 0;
  242|       |
  243|   140k|  for (i = 0; i < cinfo->comps_in_scan; i++) {
  ------------------
  |  Branch (243:15): [True: 82.3k, False: 57.9k]
  ------------------
  244|  82.3k|    compptr = cinfo->cur_comp_info[i];
  245|       |    /* DC needs no table for refinement scan */
  246|  82.3k|    if (cinfo->Ss == 0 && cinfo->Ah == 0)
  ------------------
  |  Branch (246:9): [True: 33.5k, False: 48.8k]
  |  Branch (246:27): [True: 21.3k, False: 12.2k]
  ------------------
  247|  21.3k|      dc_in_use[compptr->dc_tbl_no] = 1;
  248|       |    /* AC needs no table when not present */
  249|  82.3k|    if (cinfo->Se)
  ------------------
  |  Branch (249:9): [True: 57.9k, False: 24.4k]
  ------------------
  250|  57.9k|      ac_in_use[compptr->ac_tbl_no] = 1;
  251|  82.3k|  }
  252|       |
  253|  57.9k|  length = 0;
  254|   985k|  for (i = 0; i < NUM_ARITH_TBLS; i++)
  ------------------
  |  |   70|   985k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (254:15): [True: 927k, False: 57.9k]
  ------------------
  255|   927k|    length += dc_in_use[i] + ac_in_use[i];
  256|       |
  257|  57.9k|  if (length) {
  ------------------
  |  Branch (257:7): [True: 54.9k, False: 3.05k]
  ------------------
  258|  54.9k|    emit_marker(cinfo, M_DAC);
  259|       |
  260|  54.9k|    emit_2bytes(cinfo, length * 2 + 2);
  261|       |
  262|   933k|    for (i = 0; i < NUM_ARITH_TBLS; i++) {
  ------------------
  |  |   70|   933k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (262:17): [True: 878k, False: 54.9k]
  ------------------
  263|   878k|      if (dc_in_use[i]) {
  ------------------
  |  Branch (263:11): [True: 9.15k, False: 869k]
  ------------------
  264|  9.15k|        emit_byte(cinfo, i);
  265|  9.15k|        emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i] << 4));
  266|  9.15k|      }
  267|   878k|      if (ac_in_use[i]) {
  ------------------
  |  Branch (267:11): [True: 51.8k, False: 826k]
  ------------------
  268|  51.8k|        emit_byte(cinfo, i + 0x10);
  269|  51.8k|        emit_byte(cinfo, cinfo->arith_ac_K[i]);
  270|  51.8k|      }
  271|   878k|    }
  272|  54.9k|  }
  273|  57.9k|#endif /* C_ARITH_CODING_SUPPORTED */
  274|  57.9k|}
jcmarker.c:emit_dht:
  193|  80.6k|{
  194|  80.6k|  JHUFF_TBL *htbl;
  195|  80.6k|  int length, i;
  196|       |
  197|  80.6k|  if (is_ac) {
  ------------------
  |  Branch (197:7): [True: 45.8k, False: 34.7k]
  ------------------
  198|  45.8k|    htbl = cinfo->ac_huff_tbl_ptrs[index];
  199|  45.8k|    index += 0x10;              /* output index has AC bit set */
  200|  45.8k|  } else {
  201|  34.7k|    htbl = cinfo->dc_huff_tbl_ptrs[index];
  202|  34.7k|  }
  203|       |
  204|  80.6k|  if (htbl == NULL)
  ------------------
  |  Branch (204:7): [True: 0, False: 80.6k]
  ------------------
  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|  80.6k|  if (!htbl->sent_table) {
  ------------------
  |  Branch (207:7): [True: 61.9k, False: 18.6k]
  ------------------
  208|  61.9k|    emit_marker(cinfo, M_DHT);
  209|       |
  210|  61.9k|    length = 0;
  211|  1.05M|    for (i = 1; i <= 16; i++)
  ------------------
  |  Branch (211:17): [True: 991k, False: 61.9k]
  ------------------
  212|   991k|      length += htbl->bits[i];
  213|       |
  214|  61.9k|    emit_2bytes(cinfo, length + 2 + 1 + 16);
  215|  61.9k|    emit_byte(cinfo, index);
  216|       |
  217|  1.05M|    for (i = 1; i <= 16; i++)
  ------------------
  |  Branch (217:17): [True: 991k, False: 61.9k]
  ------------------
  218|   991k|      emit_byte(cinfo, htbl->bits[i]);
  219|       |
  220|   630k|    for (i = 0; i < length; i++)
  ------------------
  |  Branch (220:17): [True: 568k, False: 61.9k]
  ------------------
  221|   568k|      emit_byte(cinfo, htbl->huffval[i]);
  222|       |
  223|  61.9k|    htbl->sent_table = TRUE;
  ------------------
  |  |  210|  61.9k|#define TRUE    1
  ------------------
  224|  61.9k|  }
  225|  80.6k|}
jcmarker.c:emit_dri:
  280|  6.10k|{
  281|  6.10k|  emit_marker(cinfo, M_DRI);
  282|       |
  283|  6.10k|  emit_2bytes(cinfo, 4);        /* fixed length */
  284|       |
  285|  6.10k|  emit_2bytes(cinfo, (int)cinfo->restart_interval);
  286|  6.10k|}
jcmarker.c:emit_sos:
  322|  92.6k|{
  323|  92.6k|  int i, td, ta;
  324|  92.6k|  jpeg_component_info *compptr;
  325|       |
  326|  92.6k|  emit_marker(cinfo, M_SOS);
  327|       |
  328|  92.6k|  emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */
  329|       |
  330|  92.6k|  emit_byte(cinfo, cinfo->comps_in_scan);
  331|       |
  332|   228k|  for (i = 0; i < cinfo->comps_in_scan; i++) {
  ------------------
  |  Branch (332:15): [True: 135k, False: 92.6k]
  ------------------
  333|   135k|    compptr = cinfo->cur_comp_info[i];
  334|   135k|    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|   135k|    td = cinfo->Ss == 0 && cinfo->Ah == 0 ? compptr->dc_tbl_no : 0;
  ------------------
  |  Branch (341:10): [True: 72.0k, False: 63.6k]
  |  Branch (341:28): [True: 56.0k, False: 15.9k]
  ------------------
  342|       |    /* AC needs no table when not present */
  343|   135k|    ta = cinfo->Se ? compptr->ac_tbl_no : 0;
  ------------------
  |  Branch (343:10): [True: 103k, False: 31.8k]
  ------------------
  344|       |
  345|   135k|    emit_byte(cinfo, (td << 4) + ta);
  346|   135k|  }
  347|       |
  348|  92.6k|  emit_byte(cinfo, cinfo->Ss);
  349|  92.6k|  emit_byte(cinfo, cinfo->Se);
  350|  92.6k|  emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al);
  351|  92.6k|}
jcmarker.c:write_file_trailer:
  609|  22.1k|{
  610|  22.1k|  emit_marker(cinfo, M_EOI);
  611|  22.1k|}
jcmarker.c:write_marker_header:
  446|  18.6k|{
  447|  18.6k|  if (datalen > (unsigned int)65533)            /* safety check */
  ------------------
  |  Branch (447:7): [True: 0, False: 18.6k]
  ------------------
  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|  18.6k|  emit_marker(cinfo, (JPEG_MARKER)marker);
  451|       |
  452|  18.6k|  emit_2bytes(cinfo, (int)(datalen + 2));       /* total length */
  453|  18.6k|}
jcmarker.c:write_marker_byte:
  458|   858k|{
  459|   858k|  emit_byte(cinfo, val);
  460|   858k|}

jinit_c_master_control:
  722|  22.1k|{
  723|  22.1k|  my_master_ptr master = (my_master_ptr)cinfo->master;
  724|  22.1k|  boolean empty_huff_tables = TRUE;
  ------------------
  |  |  210|  22.1k|#define TRUE    1
  ------------------
  725|  22.1k|  int i;
  726|       |
  727|       |#ifdef WITH_PROFILE
  728|       |  master->pub.total_start = getTime();
  729|       |#endif
  730|       |
  731|  22.1k|  master->pub.prepare_for_pass = prepare_for_pass;
  732|  22.1k|  master->pub.pass_startup = pass_startup;
  733|  22.1k|  master->pub.finish_pass = finish_pass_master;
  734|  22.1k|  master->pub.is_last_pass = FALSE;
  ------------------
  |  |  207|  22.1k|#define FALSE   0               /* values of boolean */
  ------------------
  735|       |
  736|  22.1k|  if (cinfo->scan_info != NULL) {
  ------------------
  |  Branch (736:7): [True: 6.76k, False: 15.4k]
  ------------------
  737|  6.76k|#ifdef NEED_SCAN_SCRIPT
  738|  6.76k|    validate_script(cinfo);
  739|       |#else
  740|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  741|       |#endif
  742|  15.4k|  } else {
  743|  15.4k|    cinfo->progressive_mode = FALSE;
  ------------------
  |  |  207|  15.4k|#define FALSE   0               /* values of boolean */
  ------------------
  744|  15.4k|    cinfo->num_scans = 1;
  745|  15.4k|  }
  746|       |
  747|  22.1k|#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|  22.1k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (753:7): [True: 0, False: 22.1k]
  ------------------
  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|  22.1k|#endif
  765|       |
  766|       |  /* Validate parameters, determine derived values */
  767|  22.1k|  initial_setup(cinfo, transcode_only);
  768|       |
  769|  22.1k|  if (cinfo->arith_code)
  ------------------
  |  Branch (769:7): [True: 6.10k, False: 16.0k]
  ------------------
  770|  6.10k|    cinfo->optimize_coding = FALSE;
  ------------------
  |  |  207|  6.10k|#define FALSE   0               /* values of boolean */
  ------------------
  771|  16.0k|  else {
  772|  16.0k|    if (cinfo->master->lossless ||      /*  TEMPORARY HACK ??? */
  ------------------
  |  Branch (772:9): [True: 0, False: 16.0k]
  ------------------
  773|  16.0k|        cinfo->progressive_mode)
  ------------------
  |  Branch (773:9): [True: 3.71k, False: 12.3k]
  ------------------
  774|  3.71k|      cinfo->optimize_coding = TRUE; /* assume default tables no good for
  ------------------
  |  |  210|  3.71k|#define TRUE    1
  ------------------
  775|       |                                        progressive mode or lossless mode */
  776|  16.0k|    for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|  16.0k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (776:17): [True: 16.0k, False: 0]
  ------------------
  777|  16.0k|      if (cinfo->dc_huff_tbl_ptrs[i] != NULL ||
  ------------------
  |  Branch (777:11): [True: 16.0k, False: 0]
  ------------------
  778|  16.0k|          cinfo->ac_huff_tbl_ptrs[i] != NULL) {
  ------------------
  |  Branch (778:11): [True: 0, False: 0]
  ------------------
  779|  16.0k|        empty_huff_tables = FALSE;
  ------------------
  |  |  207|  16.0k|#define FALSE   0               /* values of boolean */
  ------------------
  780|  16.0k|        break;
  781|  16.0k|      }
  782|  16.0k|    }
  783|  16.0k|    if (cinfo->data_precision == 12 && !cinfo->optimize_coding &&
  ------------------
  |  Branch (783:9): [True: 16.0k, False: 0]
  |  Branch (783:40): [True: 0, False: 16.0k]
  ------------------
  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|  16.0k|  }
  788|       |
  789|       |  /* Initialize my private state */
  790|  22.1k|  if (transcode_only) {
  ------------------
  |  Branch (790:7): [True: 0, False: 22.1k]
  ------------------
  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|  22.1k|  } else {
  797|       |    /* for normal compression, first pass is always this type: */
  798|  22.1k|    master->pass_type = main_pass;
  799|  22.1k|  }
  800|  22.1k|  master->scan_number = 0;
  801|  22.1k|  master->pass_number = 0;
  802|  22.1k|  if (cinfo->optimize_coding)
  ------------------
  |  Branch (802:7): [True: 16.0k, False: 6.10k]
  ------------------
  803|  16.0k|    master->total_passes = cinfo->num_scans * 2;
  804|  6.10k|  else
  805|  6.10k|    master->total_passes = cinfo->num_scans;
  806|       |
  807|  22.1k|  master->jpeg_version = PACKAGE_NAME " version " VERSION " (build " BUILD ")";
  ------------------
  |  |   17|  22.1k|#define PACKAGE_NAME  "libjpeg-turbo"
  ------------------
  808|  22.1k|}
jcmaster.c:prepare_for_pass:
  579|   123k|{
  580|   123k|  my_master_ptr master = (my_master_ptr)cinfo->master;
  581|       |
  582|   123k|  switch (master->pass_type) {
  583|  22.1k|  case main_pass:
  ------------------
  |  Branch (583:3): [True: 22.1k, False: 101k]
  ------------------
  584|       |    /* Initial pass: will collect input data, and do either Huffman
  585|       |     * optimization or data output for the first scan.
  586|       |     */
  587|  22.1k|    select_scan_parameters(cinfo);
  588|  22.1k|    per_scan_setup(cinfo);
  589|  22.1k|    if (!cinfo->raw_data_in) {
  ------------------
  |  Branch (589:9): [True: 22.1k, False: 0]
  ------------------
  590|  22.1k|      (*cinfo->cconvert->start_pass) (cinfo);
  591|  22.1k|      (*cinfo->downsample->start_pass) (cinfo);
  592|  22.1k|      (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU);
  593|  22.1k|    }
  594|  22.1k|    (*cinfo->fdct->start_pass) (cinfo);
  595|  22.1k|    (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding);
  596|  22.1k|    (*cinfo->coef->start_pass) (cinfo,
  597|  22.1k|                                (master->total_passes > 1 ?
  ------------------
  |  Branch (597:34): [True: 19.1k, False: 3.05k]
  ------------------
  598|  19.1k|                                 JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
  599|  22.1k|    (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
  600|  22.1k|    if (cinfo->optimize_coding) {
  ------------------
  |  Branch (600:9): [True: 16.0k, False: 6.10k]
  ------------------
  601|       |      /* No immediate data output; postpone writing frame/scan headers */
  602|  16.0k|      master->pub.call_pass_startup = FALSE;
  ------------------
  |  |  207|  16.0k|#define FALSE   0               /* values of boolean */
  ------------------
  603|  16.0k|    } else {
  604|       |      /* Will write frame/scan headers at first jpeg_write_scanlines call */
  605|  6.10k|      master->pub.call_pass_startup = TRUE;
  ------------------
  |  |  210|  6.10k|#define TRUE    1
  ------------------
  606|  6.10k|    }
  607|  22.1k|    break;
  608|      0|#ifdef ENTROPY_OPT_SUPPORTED
  609|  18.5k|  case huff_opt_pass:
  ------------------
  |  Branch (609:3): [True: 18.5k, False: 104k]
  ------------------
  610|       |    /* Do Huffman optimization for a scan after the first one. */
  611|  18.5k|    select_scan_parameters(cinfo);
  612|  18.5k|    per_scan_setup(cinfo);
  613|  18.5k|    if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code ||
  ------------------
  |  Branch (613:9): [True: 14.8k, False: 3.71k]
  |  Branch (613:27): [True: 0, False: 3.71k]
  |  Branch (613:45): [True: 0, False: 3.71k]
  ------------------
  614|  14.8k|        cinfo->master->lossless) {
  ------------------
  |  Branch (614:9): [True: 0, False: 3.71k]
  ------------------
  615|  14.8k|      (*cinfo->entropy->start_pass) (cinfo, TRUE);
  ------------------
  |  |  210|  14.8k|#define TRUE    1
  ------------------
  616|  14.8k|      (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
  617|  14.8k|      master->pub.call_pass_startup = FALSE;
  ------------------
  |  |  207|  14.8k|#define FALSE   0               /* values of boolean */
  ------------------
  618|  14.8k|      break;
  619|  14.8k|    }
  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.71k|    master->pass_type = output_pass;
  624|  3.71k|    master->pass_number++;
  625|  3.71k|    FALLTHROUGH                 /*FALLTHROUGH*/
  ------------------
  |  |   41|  3.71k|#define FALLTHROUGH  __attribute__((fallthrough));
  ------------------
  626|  3.71k|#endif
  627|  86.5k|  case output_pass:
  ------------------
  |  Branch (627:3): [True: 82.8k, False: 40.7k]
  ------------------
  628|       |    /* Do a data-output pass. */
  629|       |    /* We need not repeat per-scan setup if prior optimization pass did it. */
  630|  86.5k|    if (!cinfo->optimize_coding) {
  ------------------
  |  Branch (630:9): [True: 51.8k, False: 34.6k]
  ------------------
  631|  51.8k|      select_scan_parameters(cinfo);
  632|  51.8k|      per_scan_setup(cinfo);
  633|  51.8k|    }
  634|  86.5k|    (*cinfo->entropy->start_pass) (cinfo, FALSE);
  ------------------
  |  |  207|  86.5k|#define FALSE   0               /* values of boolean */
  ------------------
  635|  86.5k|    (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
  636|       |    /* We emit frame/scan headers now */
  637|  86.5k|    if (master->scan_number == 0)
  ------------------
  |  Branch (637:9): [True: 16.0k, False: 70.4k]
  ------------------
  638|  16.0k|      (*cinfo->marker->write_frame_header) (cinfo);
  639|  86.5k|    (*cinfo->marker->write_scan_header) (cinfo);
  640|  86.5k|    master->pub.call_pass_startup = FALSE;
  ------------------
  |  |  207|  86.5k|#define FALSE   0               /* values of boolean */
  ------------------
  641|  86.5k|    break;
  642|      0|  default:
  ------------------
  |  Branch (642:3): [True: 0, False: 123k]
  ------------------
  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|   123k|  }
  645|       |
  646|   123k|  master->pub.is_last_pass = (master->pass_number == master->total_passes - 1);
  647|       |
  648|       |  /* Set up progress monitor's pass info if present */
  649|   123k|  if (cinfo->progress != NULL) {
  ------------------
  |  Branch (649:7): [True: 0, False: 123k]
  ------------------
  650|      0|    cinfo->progress->completed_passes = master->pass_number;
  651|      0|    cinfo->progress->total_passes = master->total_passes;
  652|      0|  }
  653|   123k|}
jcmaster.c:select_scan_parameters:
  444|  92.6k|{
  445|  92.6k|  int ci;
  446|       |
  447|  92.6k|#ifdef NEED_SCAN_SCRIPT
  448|  92.6k|  if (cinfo->scan_info != NULL) {
  ------------------
  |  Branch (448:7): [True: 77.1k, False: 15.4k]
  ------------------
  449|       |    /* Prepare for current scan --- the script is already validated */
  450|  77.1k|    my_master_ptr master = (my_master_ptr)cinfo->master;
  451|  77.1k|    const jpeg_scan_info *scanptr = cinfo->scan_info + master->scan_number;
  452|       |
  453|  77.1k|    cinfo->comps_in_scan = scanptr->comps_in_scan;
  454|   172k|    for (ci = 0; ci < scanptr->comps_in_scan; ci++) {
  ------------------
  |  Branch (454:18): [True: 95.4k, False: 77.1k]
  ------------------
  455|  95.4k|      cinfo->cur_comp_info[ci] =
  456|  95.4k|        &cinfo->comp_info[scanptr->component_index[ci]];
  457|  95.4k|    }
  458|  77.1k|    cinfo->Ss = scanptr->Ss;
  459|  77.1k|    cinfo->Se = scanptr->Se;
  460|  77.1k|    cinfo->Ah = scanptr->Ah;
  461|  77.1k|    cinfo->Al = scanptr->Al;
  462|  77.1k|  } else
  463|  15.4k|#endif
  464|  15.4k|  {
  465|       |    /* Prepare for single sequential-JPEG scan containing all components */
  466|  15.4k|    if (cinfo->num_components > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  15.4k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (466:9): [True: 0, False: 15.4k]
  ------------------
  467|      0|      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
  ------------------
  |  |  247|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  248|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  249|      0|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  250|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  468|  15.4k|               MAX_COMPS_IN_SCAN);
  469|  15.4k|    cinfo->comps_in_scan = cinfo->num_components;
  470|  55.6k|    for (ci = 0; ci < cinfo->num_components; ci++) {
  ------------------
  |  Branch (470:18): [True: 40.1k, False: 15.4k]
  ------------------
  471|  40.1k|      cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
  472|  40.1k|    }
  473|  15.4k|    if (!cinfo->master->lossless) {
  ------------------
  |  Branch (473:9): [True: 15.4k, False: 0]
  ------------------
  474|  15.4k|      cinfo->Ss = 0;
  475|  15.4k|      cinfo->Se = DCTSIZE2 - 1;
  ------------------
  |  |   67|  15.4k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  476|  15.4k|      cinfo->Ah = 0;
  477|  15.4k|      cinfo->Al = 0;
  478|  15.4k|    }
  479|  15.4k|  }
  480|  92.6k|}
jcmaster.c:per_scan_setup:
  487|  92.6k|{
  488|  92.6k|  int ci, mcublks, tmp;
  489|  92.6k|  jpeg_component_info *compptr;
  490|  92.6k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  92.6k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (490:19): [True: 0, False: 92.6k]
  ------------------
  491|       |
  492|  92.6k|  if (cinfo->comps_in_scan == 1) {
  ------------------
  |  Branch (492:7): [True: 74.1k, False: 18.4k]
  ------------------
  493|       |
  494|       |    /* Noninterleaved (single-component) scan */
  495|  74.1k|    compptr = cinfo->cur_comp_info[0];
  496|       |
  497|       |    /* Overall image size in MCUs */
  498|  74.1k|    cinfo->MCUs_per_row = compptr->width_in_blocks;
  499|  74.1k|    cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
  500|       |
  501|       |    /* For noninterleaved scan, always one block per MCU */
  502|  74.1k|    compptr->MCU_width = 1;
  503|  74.1k|    compptr->MCU_height = 1;
  504|  74.1k|    compptr->MCU_blocks = 1;
  505|  74.1k|    compptr->MCU_sample_width = data_unit;
  506|  74.1k|    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|  74.1k|    tmp = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
  511|  74.1k|    if (tmp == 0) tmp = compptr->v_samp_factor;
  ------------------
  |  Branch (511:9): [True: 54.1k, False: 19.9k]
  ------------------
  512|  74.1k|    compptr->last_row_height = tmp;
  513|       |
  514|       |    /* Prepare array describing MCU composition */
  515|  74.1k|    cinfo->blocks_in_MCU = 1;
  516|  74.1k|    cinfo->MCU_membership[0] = 0;
  517|       |
  518|  74.1k|  } else {
  519|       |
  520|       |    /* Interleaved (multi-component) scan */
  521|  18.4k|    if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  18.4k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (521:9): [True: 0, False: 18.4k]
  |  Branch (521:38): [True: 0, False: 18.4k]
  ------------------
  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|  18.4k|               MAX_COMPS_IN_SCAN);
  524|       |
  525|       |    /* Overall image size in MCUs */
  526|  18.4k|    cinfo->MCUs_per_row = (JDIMENSION)
  527|  18.4k|      jdiv_round_up((long)cinfo->_jpeg_width,
  ------------------
  |  |   30|  18.4k|#define _jpeg_width  image_width
  ------------------
  528|  18.4k|                    (long)(cinfo->max_h_samp_factor * data_unit));
  529|  18.4k|    cinfo->MCU_rows_in_scan = (JDIMENSION)
  530|  18.4k|      jdiv_round_up((long)cinfo->_jpeg_height,
  ------------------
  |  |   31|  18.4k|#define _jpeg_height  image_height
  ------------------
  531|  18.4k|                    (long)(cinfo->max_v_samp_factor * data_unit));
  532|       |
  533|  18.4k|    cinfo->blocks_in_MCU = 0;
  534|       |
  535|  80.0k|    for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (535:18): [True: 61.5k, False: 18.4k]
  ------------------
  536|  61.5k|      compptr = cinfo->cur_comp_info[ci];
  537|       |      /* Sampling factors give # of blocks of component in each MCU */
  538|  61.5k|      compptr->MCU_width = compptr->h_samp_factor;
  539|  61.5k|      compptr->MCU_height = compptr->v_samp_factor;
  540|  61.5k|      compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
  541|  61.5k|      compptr->MCU_sample_width = compptr->MCU_width * data_unit;
  542|       |      /* Figure number of non-dummy blocks in last MCU column & row */
  543|  61.5k|      tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
  544|  61.5k|      if (tmp == 0) tmp = compptr->MCU_width;
  ------------------
  |  Branch (544:11): [True: 53.5k, False: 7.99k]
  ------------------
  545|  61.5k|      compptr->last_col_width = tmp;
  546|  61.5k|      tmp = (int)(compptr->height_in_blocks % compptr->MCU_height);
  547|  61.5k|      if (tmp == 0) tmp = compptr->MCU_height;
  ------------------
  |  Branch (547:11): [True: 49.0k, False: 12.4k]
  ------------------
  548|  61.5k|      compptr->last_row_height = tmp;
  549|       |      /* Prepare array describing MCU composition */
  550|  61.5k|      mcublks = compptr->MCU_blocks;
  551|  61.5k|      if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU)
  ------------------
  |  |   80|  61.5k|#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on data units/MCU */
  ------------------
  |  Branch (551:11): [True: 0, False: 61.5k]
  ------------------
  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|   156k|      while (mcublks-- > 0) {
  ------------------
  |  Branch (553:14): [True: 95.1k, False: 61.5k]
  ------------------
  554|  95.1k|        cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
  555|  95.1k|      }
  556|  61.5k|    }
  557|       |
  558|  18.4k|  }
  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|  92.6k|  if (cinfo->restart_in_rows > 0) {
  ------------------
  |  Branch (562:7): [True: 57.9k, False: 34.6k]
  ------------------
  563|  57.9k|    long nominal = (long)cinfo->restart_in_rows * (long)cinfo->MCUs_per_row;
  564|  57.9k|    cinfo->restart_interval = (unsigned int)MIN(nominal, 65535L);
  ------------------
  |  |  515|  57.9k|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 57.9k, False: 0]
  |  |  ------------------
  ------------------
  565|  57.9k|  }
  566|  92.6k|}
jcmaster.c:pass_startup:
  668|  6.10k|{
  669|  6.10k|  cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */
  ------------------
  |  |  207|  6.10k|#define FALSE   0               /* values of boolean */
  ------------------
  670|       |
  671|  6.10k|  (*cinfo->marker->write_frame_header) (cinfo);
  672|  6.10k|  (*cinfo->marker->write_scan_header) (cinfo);
  673|  6.10k|}
jcmaster.c:finish_pass_master:
  682|   123k|{
  683|   123k|  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|   123k|  (*cinfo->entropy->finish_pass) (cinfo);
  689|       |
  690|       |  /* Update state for next pass */
  691|   123k|  switch (master->pass_type) {
  ------------------
  |  Branch (691:11): [True: 123k, False: 0]
  ------------------
  692|  22.1k|  case main_pass:
  ------------------
  |  Branch (692:3): [True: 22.1k, False: 101k]
  ------------------
  693|       |    /* next pass is either output of scan 0 (after optimization)
  694|       |     * or output of scan 1 (if no optimization).
  695|       |     */
  696|  22.1k|    master->pass_type = output_pass;
  697|  22.1k|    if (!cinfo->optimize_coding)
  ------------------
  |  Branch (697:9): [True: 6.10k, False: 16.0k]
  ------------------
  698|  6.10k|      master->scan_number++;
  699|  22.1k|    break;
  700|  14.8k|  case huff_opt_pass:
  ------------------
  |  Branch (700:3): [True: 14.8k, False: 108k]
  ------------------
  701|       |    /* next pass is always output of current scan */
  702|  14.8k|    master->pass_type = output_pass;
  703|  14.8k|    break;
  704|  86.5k|  case output_pass:
  ------------------
  |  Branch (704:3): [True: 86.5k, False: 37.0k]
  ------------------
  705|       |    /* next pass is either optimization or output of next scan */
  706|  86.5k|    if (cinfo->optimize_coding)
  ------------------
  |  Branch (706:9): [True: 34.6k, False: 51.8k]
  ------------------
  707|  34.6k|      master->pass_type = huff_opt_pass;
  708|  86.5k|    master->scan_number++;
  709|  86.5k|    break;
  710|   123k|  }
  711|       |
  712|   123k|  master->pass_number++;
  713|   123k|}
jcmaster.c:validate_script:
  280|  6.76k|{
  281|  6.76k|  const jpeg_scan_info *scanptr;
  282|  6.76k|  int scanno, ncomps, ci, thisi;
  283|  6.76k|  int Ss, Se, Ah, Al;
  284|  6.76k|  boolean component_sent[MAX_COMPONENTS];
  285|  6.76k|#ifdef C_PROGRESSIVE_SUPPORTED
  286|  6.76k|  int coefi, *last_bitpos_ptr;
  287|  6.76k|  int last_bitpos[MAX_COMPONENTS][DCTSIZE2];
  288|       |  /* -1 until that coefficient has been seen; then last Al for it */
  289|  6.76k|#endif
  290|       |
  291|  6.76k|  if (cinfo->num_scans <= 0)
  ------------------
  |  Branch (291:7): [True: 0, False: 6.76k]
  ------------------
  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.76k|  scanptr = cinfo->scan_info;
  300|  6.76k|  if (scanptr->Ss != 0 && scanptr->Se == 0) {
  ------------------
  |  Branch (300:7): [True: 0, False: 6.76k]
  |  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.76k|  else if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2 - 1) {
  ------------------
  |  |   67|  6.76k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (313:12): [True: 0, False: 6.76k]
  |  Branch (313:32): [True: 6.76k, False: 0]
  ------------------
  314|  6.76k|#ifdef C_PROGRESSIVE_SUPPORTED
  315|  6.76k|    cinfo->progressive_mode = TRUE;
  ------------------
  |  |  210|  6.76k|#define TRUE    1
  ------------------
  316|  6.76k|    cinfo->master->lossless = FALSE;
  ------------------
  |  |  207|  6.76k|#define FALSE   0               /* values of boolean */
  ------------------
  317|  6.76k|    last_bitpos_ptr = &last_bitpos[0][0];
  318|  22.6k|    for (ci = 0; ci < cinfo->num_components; ci++)
  ------------------
  |  Branch (318:18): [True: 15.9k, False: 6.76k]
  ------------------
  319|  1.03M|      for (coefi = 0; coefi < DCTSIZE2; coefi++)
  ------------------
  |  |   67|  1.03M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (319:23): [True: 1.01M, False: 15.9k]
  ------------------
  320|  1.01M|        *last_bitpos_ptr++ = -1;
  321|       |#else
  322|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  323|       |#endif
  324|  6.76k|  } 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|  83.9k|  for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) {
  ------------------
  |  Branch (330:20): [True: 77.1k, False: 6.76k]
  ------------------
  331|       |    /* Validate component indexes */
  332|  77.1k|    ncomps = scanptr->comps_in_scan;
  333|  77.1k|    if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  77.1k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (333:9): [True: 0, False: 77.1k]
  |  Branch (333:24): [True: 0, False: 77.1k]
  ------------------
  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|   172k|    for (ci = 0; ci < ncomps; ci++) {
  ------------------
  |  Branch (335:18): [True: 95.4k, False: 77.1k]
  ------------------
  336|  95.4k|      thisi = scanptr->component_index[ci];
  337|  95.4k|      if (thisi < 0 || thisi >= cinfo->num_components)
  ------------------
  |  Branch (337:11): [True: 0, False: 95.4k]
  |  Branch (337:24): [True: 0, False: 95.4k]
  ------------------
  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|  95.4k|      if (ci > 0 && thisi <= scanptr->component_index[ci - 1])
  ------------------
  |  Branch (340:11): [True: 18.3k, False: 77.1k]
  |  Branch (340:21): [True: 0, False: 18.3k]
  ------------------
  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|  95.4k|    }
  343|       |    /* Validate progression parameters */
  344|  77.1k|    Ss = scanptr->Ss;
  345|  77.1k|    Se = scanptr->Se;
  346|  77.1k|    Ah = scanptr->Ah;
  347|  77.1k|    Al = scanptr->Al;
  348|  77.1k|    if (cinfo->progressive_mode) {
  ------------------
  |  Branch (348:9): [True: 77.1k, False: 0]
  ------------------
  349|  77.1k|#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|  77.1k|      int max_Ah_Al = cinfo->data_precision == 12 ? 13 : 10;
  ------------------
  |  Branch (357:23): [True: 77.1k, False: 0]
  ------------------
  358|       |
  359|  77.1k|      if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
  ------------------
  |  |   67|   154k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
                    if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
  ------------------
  |  |   67|   154k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (359:11): [True: 0, False: 77.1k]
  |  Branch (359:21): [True: 0, False: 77.1k]
  |  Branch (359:39): [True: 0, False: 77.1k]
  |  Branch (359:50): [True: 0, False: 77.1k]
  ------------------
  360|  77.1k|          Ah < 0 || Ah > max_Ah_Al || Al < 0 || Al > max_Ah_Al)
  ------------------
  |  Branch (360:11): [True: 0, False: 77.1k]
  |  Branch (360:21): [True: 0, False: 77.1k]
  |  Branch (360:39): [True: 0, False: 77.1k]
  |  Branch (360:49): [True: 0, False: 77.1k]
  ------------------
  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|  77.1k|      if (Ss == 0) {
  ------------------
  |  Branch (362:11): [True: 13.5k, False: 63.6k]
  ------------------
  363|  13.5k|        if (Se != 0)            /* DC and AC together not OK */
  ------------------
  |  Branch (363:13): [True: 0, False: 13.5k]
  ------------------
  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|  63.6k|      } else {
  366|  63.6k|        if (ncomps != 1)        /* AC scans must be for only one component */
  ------------------
  |  Branch (366:13): [True: 0, False: 63.6k]
  ------------------
  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|  63.6k|      }
  369|   172k|      for (ci = 0; ci < ncomps; ci++) {
  ------------------
  |  Branch (369:20): [True: 95.4k, False: 77.1k]
  ------------------
  370|  95.4k|        last_bitpos_ptr = &last_bitpos[scanptr->component_index[ci]][0];
  371|  95.4k|        if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */
  ------------------
  |  Branch (371:13): [True: 63.6k, False: 31.8k]
  |  Branch (371:24): [True: 0, False: 63.6k]
  ------------------
  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|  3.13M|        for (coefi = Ss; coefi <= Se; coefi++) {
  ------------------
  |  Branch (373:26): [True: 3.03M, False: 95.4k]
  ------------------
  374|  3.03M|          if (last_bitpos_ptr[coefi] < 0) {
  ------------------
  |  Branch (374:15): [True: 1.01M, False: 2.02M]
  ------------------
  375|       |            /* first scan of this coefficient */
  376|  1.01M|            if (Ah != 0)
  ------------------
  |  Branch (376:17): [True: 0, False: 1.01M]
  ------------------
  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|  2.02M|          } else {
  379|       |            /* not first scan */
  380|  2.02M|            if (Ah != last_bitpos_ptr[coefi] || Al != Ah - 1)
  ------------------
  |  Branch (380:17): [True: 0, False: 2.02M]
  |  Branch (380:49): [True: 0, False: 2.02M]
  ------------------
  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|  2.02M|          }
  383|  3.03M|          last_bitpos_ptr[coefi] = Al;
  384|  3.03M|        }
  385|  95.4k|      }
  386|  77.1k|#endif
  387|  77.1k|    } 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|  77.1k|  }
  416|       |
  417|       |  /* Now verify that everything got sent. */
  418|  6.76k|  if (cinfo->progressive_mode) {
  ------------------
  |  Branch (418:7): [True: 6.76k, False: 0]
  ------------------
  419|  6.76k|#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|  22.6k|    for (ci = 0; ci < cinfo->num_components; ci++) {
  ------------------
  |  Branch (425:18): [True: 15.9k, False: 6.76k]
  ------------------
  426|  15.9k|      if (last_bitpos[ci][0] < 0)
  ------------------
  |  Branch (426:11): [True: 0, False: 15.9k]
  ------------------
  427|      0|        ERREXIT(cinfo, JERR_MISSING_DATA);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  428|  15.9k|    }
  429|  6.76k|#endif
  430|  6.76k|  } 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.76k|}
jcmaster.c:initial_setup:
  166|  22.1k|{
  167|  22.1k|  int ci;
  168|  22.1k|  jpeg_component_info *compptr;
  169|  22.1k|  long samplesperrow;
  170|  22.1k|  JDIMENSION jd_samplesperrow;
  171|  22.1k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  22.1k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (171:19): [True: 0, False: 22.1k]
  ------------------
  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|  22.1k|  if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0 ||
  ------------------
  |  |   31|  22.1k|#define _jpeg_height  image_height
  ------------------
                if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0 ||
  ------------------
  |  |   30|  22.1k|#define _jpeg_width  image_width
  ------------------
  |  Branch (181:7): [True: 0, False: 22.1k]
  |  Branch (181:35): [True: 0, False: 22.1k]
  ------------------
  182|  22.1k|      cinfo->num_components <= 0 || cinfo->input_components <= 0)
  ------------------
  |  Branch (182:7): [True: 0, False: 22.1k]
  |  Branch (182:37): [True: 0, False: 22.1k]
  ------------------
  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|  22.1k|  if ((long)cinfo->_jpeg_height > (long)JPEG_MAX_DIMENSION ||
  ------------------
  |  |   31|  22.1k|#define _jpeg_height  image_height
  ------------------
                if ((long)cinfo->_jpeg_height > (long)JPEG_MAX_DIMENSION ||
  ------------------
  |  |  158|  44.3k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (186:7): [True: 0, False: 22.1k]
  ------------------
  187|  22.1k|      (long)cinfo->_jpeg_width > (long)JPEG_MAX_DIMENSION)
  ------------------
  |  |   30|  22.1k|#define _jpeg_width  image_width
  ------------------
                    (long)cinfo->_jpeg_width > (long)JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  22.1k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (187:7): [True: 0, False: 22.1k]
  ------------------
  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|  22.1k|  samplesperrow = (long)cinfo->image_width * (long)cinfo->input_components;
  192|  22.1k|  jd_samplesperrow = (JDIMENSION)samplesperrow;
  193|  22.1k|  if ((long)jd_samplesperrow != samplesperrow)
  ------------------
  |  Branch (193:7): [True: 0, False: 22.1k]
  ------------------
  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|  22.1k|#ifdef C_LOSSLESS_SUPPORTED
  200|  22.1k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (200:7): [True: 0, False: 22.1k]
  ------------------
  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|  22.1k|#endif
  205|  22.1k|  {
  206|  22.1k|    if (cinfo->data_precision != 8 && cinfo->data_precision != 12)
  ------------------
  |  Branch (206:9): [True: 22.1k, False: 0]
  |  Branch (206:39): [True: 0, False: 22.1k]
  ------------------
  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|  22.1k|  }
  209|       |
  210|       |  /* Check that number of components won't exceed internal array sizes */
  211|  22.1k|  if (cinfo->num_components > MAX_COMPONENTS)
  ------------------
  |  |   30|  22.1k|#define MAX_COMPONENTS  10      /* maximum number of image components */
  ------------------
  |  Branch (211:7): [True: 0, False: 22.1k]
  ------------------
  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|  22.1k|             MAX_COMPONENTS);
  214|       |
  215|       |  /* Compute maximum sampling factors; check factor validity */
  216|  22.1k|  cinfo->max_h_samp_factor = 1;
  217|  22.1k|  cinfo->max_v_samp_factor = 1;
  218|  78.2k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (218:44): [True: 56.0k, False: 22.1k]
  ------------------
  219|  56.0k|       ci++, compptr++) {
  220|  56.0k|    if (compptr->h_samp_factor <= 0 ||
  ------------------
  |  Branch (220:9): [True: 0, False: 56.0k]
  ------------------
  221|  56.0k|        compptr->h_samp_factor > MAX_SAMP_FACTOR ||
  ------------------
  |  |   72|   112k|#define MAX_SAMP_FACTOR     4   /* JPEG limit on sampling factors */
  ------------------
  |  Branch (221:9): [True: 0, False: 56.0k]
  ------------------
  222|  56.0k|        compptr->v_samp_factor <= 0 ||
  ------------------
  |  Branch (222:9): [True: 0, False: 56.0k]
  ------------------
  223|  56.0k|        compptr->v_samp_factor > MAX_SAMP_FACTOR)
  ------------------
  |  |   72|  56.0k|#define MAX_SAMP_FACTOR     4   /* JPEG limit on sampling factors */
  ------------------
  |  Branch (223:9): [True: 0, False: 56.0k]
  ------------------
  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|  56.0k|    cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
  ------------------
  |  |  513|  56.0k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 18.4k, False: 37.6k]
  |  |  ------------------
  ------------------
  226|  56.0k|                                   compptr->h_samp_factor);
  227|  56.0k|    cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
  ------------------
  |  |  513|  56.0k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 12.2k, False: 43.8k]
  |  |  ------------------
  ------------------
  228|  56.0k|                                   compptr->v_samp_factor);
  229|  56.0k|  }
  230|       |
  231|       |  /* Compute dimensions of components */
  232|  78.2k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (232:44): [True: 56.0k, False: 22.1k]
  ------------------
  233|  56.0k|       ci++, compptr++) {
  234|       |    /* Fill in the correct component_index value; don't rely on application */
  235|  56.0k|    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|  56.0k|    compptr->DCT_scaled_size = data_unit;
  241|  56.0k|#endif
  242|       |    /* Size in data units */
  243|  56.0k|    compptr->width_in_blocks = (JDIMENSION)
  244|  56.0k|      jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
  ------------------
  |  |   30|  56.0k|#define _jpeg_width  image_width
  ------------------
  245|  56.0k|                    (long)(cinfo->max_h_samp_factor * data_unit));
  246|  56.0k|    compptr->height_in_blocks = (JDIMENSION)
  247|  56.0k|      jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
  ------------------
  |  |   31|  56.0k|#define _jpeg_height  image_height
  ------------------
  248|  56.0k|                    (long)(cinfo->max_v_samp_factor * data_unit));
  249|       |    /* Size in samples */
  250|  56.0k|    compptr->downsampled_width = (JDIMENSION)
  251|  56.0k|      jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
  ------------------
  |  |   30|  56.0k|#define _jpeg_width  image_width
  ------------------
  252|  56.0k|                    (long)cinfo->max_h_samp_factor);
  253|  56.0k|    compptr->downsampled_height = (JDIMENSION)
  254|  56.0k|      jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
  ------------------
  |  |   31|  56.0k|#define _jpeg_height  image_height
  ------------------
  255|  56.0k|                    (long)cinfo->max_v_samp_factor);
  256|       |    /* Mark component needed (this flag isn't actually used for compression) */
  257|  56.0k|    compptr->component_needed = TRUE;
  ------------------
  |  |  210|  56.0k|#define TRUE    1
  ------------------
  258|  56.0k|  }
  259|       |
  260|       |  /* Compute number of fully interleaved MCU rows (number of times that
  261|       |   * main controller will call coefficient or difference controller).
  262|       |   */
  263|  22.1k|  cinfo->total_iMCU_rows = (JDIMENSION)
  264|  22.1k|    jdiv_round_up((long)cinfo->_jpeg_height,
  ------------------
  |  |   31|  22.1k|#define _jpeg_height  image_height
  ------------------
  265|  22.1k|                  (long)(cinfo->max_v_samp_factor * data_unit));
  266|  22.1k|}

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

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

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

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

j12init_downsampler:
  468|  22.1k|{
  469|  22.1k|  my_downsample_ptr downsample;
  470|  22.1k|  int ci;
  471|  22.1k|  jpeg_component_info *compptr;
  472|  22.1k|#ifdef INPUT_SMOOTHING_SUPPORTED
  473|  22.1k|  boolean smoothok = TRUE;
  ------------------
  |  |  210|  22.1k|#define TRUE    1
  ------------------
  474|  22.1k|#endif
  475|       |
  476|  22.1k|#ifdef C_LOSSLESS_SUPPORTED
  477|  22.1k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (477:7): [True: 0, False: 22.1k]
  ------------------
  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|  22.1k|#endif
  487|  22.1k|  {
  488|  22.1k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  22.1k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (488:9): [True: 0, False: 22.1k]
  ------------------
  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|  22.1k|  }
  491|       |
  492|  22.1k|  downsample = (my_downsample_ptr)
  493|  22.1k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  22.1k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  494|  22.1k|                                sizeof(my_downsampler));
  495|  22.1k|  cinfo->downsample = (struct jpeg_downsampler *)downsample;
  496|  22.1k|  downsample->pub.start_pass = start_pass_downsample;
  497|  22.1k|  downsample->pub._downsample = sep_downsample;
  ------------------
  |  |  136|  22.1k|#define _downsample  downsample_12
  ------------------
  498|  22.1k|  downsample->pub.need_context_rows = FALSE;
  ------------------
  |  |  207|  22.1k|#define FALSE   0               /* values of boolean */
  ------------------
  499|       |
  500|  22.1k|  if (cinfo->CCIR601_sampling)
  ------------------
  |  Branch (500:7): [True: 0, False: 22.1k]
  ------------------
  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|  78.2k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (504:44): [True: 56.0k, False: 22.1k]
  ------------------
  505|  56.0k|       ci++, compptr++) {
  506|  56.0k|    if (compptr->h_samp_factor == cinfo->max_h_samp_factor &&
  ------------------
  |  Branch (506:9): [True: 37.6k, False: 18.4k]
  ------------------
  507|  37.6k|        compptr->v_samp_factor == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (507:9): [True: 31.5k, False: 6.10k]
  ------------------
  508|  31.5k|#ifdef INPUT_SMOOTHING_SUPPORTED
  509|  31.5k|      if (cinfo->smoothing_factor) {
  ------------------
  |  Branch (509:11): [True: 0, False: 31.5k]
  ------------------
  510|      0|        downsample->methods[ci] = fullsize_smooth_downsample;
  511|      0|        downsample->pub.need_context_rows = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  512|      0|      } else
  513|  31.5k|#endif
  514|  31.5k|        downsample->methods[ci] = fullsize_downsample;
  515|  31.5k|    } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
  ------------------
  |  Branch (515:16): [True: 12.3k, False: 12.2k]
  ------------------
  516|  12.3k|               compptr->v_samp_factor == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (516:16): [True: 6.27k, False: 6.10k]
  ------------------
  517|  6.27k|#ifdef INPUT_SMOOTHING_SUPPORTED
  518|  6.27k|      smoothok = FALSE;
  ------------------
  |  |  207|  6.27k|#define FALSE   0               /* values of boolean */
  ------------------
  519|  6.27k|#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.27k|        downsample->methods[ci] = h2v1_downsample;
  526|  18.3k|    } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
  ------------------
  |  Branch (526:16): [True: 6.10k, False: 12.2k]
  ------------------
  527|  6.10k|               compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (527:16): [True: 6.10k, False: 0]
  ------------------
  528|  6.10k|#ifdef INPUT_SMOOTHING_SUPPORTED
  529|  6.10k|      if (cinfo->smoothing_factor) {
  ------------------
  |  Branch (529:11): [True: 0, False: 6.10k]
  ------------------
  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|  6.10k|#endif
  534|  6.10k|      {
  535|       |#ifdef WITH_SIMD
  536|       |        if (jsimd_set_h2v2_downsample(cinfo))
  537|       |          downsample->methods[ci] = jsimd_h2v2_downsample;
  538|       |        else
  539|       |#endif
  540|  6.10k|          downsample->methods[ci] = h2v2_downsample;
  541|  6.10k|      }
  542|  12.2k|    } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 &&
  ------------------
  |  Branch (542:16): [True: 12.2k, False: 0]
  ------------------
  543|  12.2k|               (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) {
  ------------------
  |  Branch (543:16): [True: 12.2k, False: 0]
  ------------------
  544|  12.2k|#ifdef INPUT_SMOOTHING_SUPPORTED
  545|  12.2k|      smoothok = FALSE;
  ------------------
  |  |  207|  12.2k|#define FALSE   0               /* values of boolean */
  ------------------
  546|  12.2k|#endif
  547|  12.2k|      downsample->methods[ci] = int_downsample;
  548|  12.2k|    } 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|  56.0k|  }
  551|       |
  552|  22.1k|#ifdef INPUT_SMOOTHING_SUPPORTED
  553|  22.1k|  if (cinfo->smoothing_factor && !smoothok)
  ------------------
  |  Branch (553:7): [True: 0, False: 22.1k]
  |  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|  22.1k|#endif
  556|  22.1k|}
jcsample-12.c:start_pass_downsample:
   89|  22.1k|{
   90|       |  /* no work for now */
   91|  22.1k|}
jcsample-12.c:sep_downsample:
  130|  28.0M|{
  131|  28.0M|  my_downsample_ptr downsample = (my_downsample_ptr)cinfo->downsample;
  132|  28.0M|  int ci;
  133|  28.0M|  jpeg_component_info *compptr;
  134|  28.0M|  _JSAMPARRAY in_ptr, out_ptr;
  ------------------
  |  |  114|  28.0M|#define _JSAMPARRAY  J12SAMPARRAY
  ------------------
  135|       |
  136|  97.2M|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (136:44): [True: 69.2M, False: 28.0M]
  ------------------
  137|  69.2M|       ci++, compptr++) {
  138|  69.2M|    in_ptr = input_buf[ci] + in_row_index;
  139|  69.2M|    out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor);
  140|  69.2M|    (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr);
  141|  69.2M|  }
  142|  28.0M|}
jcsample-12.c:expand_right_edge:
  102|  69.2M|{
  103|  69.2M|  register _JSAMPROW ptr;
  104|  69.2M|  register _JSAMPLE pixval;
  105|  69.2M|  register int count;
  106|  69.2M|  int row;
  107|  69.2M|  int numcols = (int)(output_cols - input_cols);
  108|       |
  109|  69.2M|  if (numcols > 0) {
  ------------------
  |  Branch (109:7): [True: 68.6M, False: 614k]
  ------------------
  110|   154M|    for (row = 0; row < num_rows; row++) {
  ------------------
  |  Branch (110:19): [True: 85.4M, False: 68.6M]
  ------------------
  111|  85.4M|      ptr = image_data[row] + input_cols;
  112|  85.4M|      pixval = ptr[-1];
  113|   992M|      for (count = numcols; count > 0; count--)
  ------------------
  |  Branch (113:29): [True: 906M, False: 85.4M]
  ------------------
  114|   906M|        *ptr++ = pixval;
  115|  85.4M|    }
  116|  68.6M|  }
  117|  69.2M|}
jcsample-12.c:fullsize_downsample:
  203|  40.1M|{
  204|  40.1M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  40.1M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (204:19): [True: 0, False: 40.1M]
  ------------------
  205|       |
  206|       |  /* Copy the data */
  207|  40.1M|  _jcopy_sample_rows(input_data, 0, output_data, 0, cinfo->max_v_samp_factor,
  ------------------
  |  |  181|  40.1M|#define _jcopy_sample_rows  j12copy_sample_rows
  ------------------
  208|  40.1M|                     cinfo->image_width);
  209|       |  /* Edge-expand */
  210|  40.1M|  expand_right_edge(output_data, cinfo->max_v_samp_factor, cinfo->image_width,
  211|  40.1M|                    compptr->width_in_blocks * data_unit);
  212|  40.1M|}
jcsample-12.c:h2v1_downsample:
  230|  9.69M|{
  231|  9.69M|  int outrow;
  232|  9.69M|  JDIMENSION outcol;
  233|  9.69M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  9.69M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (233:19): [True: 0, False: 9.69M]
  ------------------
  234|  9.69M|  JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
  235|  9.69M|  register _JSAMPROW inptr, outptr;
  236|  9.69M|  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|  9.69M|  expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
  243|  9.69M|                    output_cols * 2);
  244|       |
  245|  19.3M|  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  ------------------
  |  Branch (245:20): [True: 9.69M, False: 9.69M]
  ------------------
  246|  9.69M|    outptr = output_data[outrow];
  247|  9.69M|    inptr = input_data[outrow];
  248|  9.69M|    bias = 0;                   /* bias = 0,1,0,1,... for successive samples */
  249|   114M|    for (outcol = 0; outcol < output_cols; outcol++) {
  ------------------
  |  Branch (249:22): [True: 105M, False: 9.69M]
  ------------------
  250|   105M|      *outptr++ = (_JSAMPLE)((inptr[0] + inptr[1] + bias) >> 1);
  251|   105M|      bias ^= 1;                /* 0=>1, 1=>0 */
  252|   105M|      inptr += 2;
  253|   105M|    }
  254|  9.69M|  }
  255|  9.69M|}
jcsample-12.c:h2v2_downsample:
  267|  4.84M|{
  268|  4.84M|  int inrow, outrow;
  269|  4.84M|  JDIMENSION outcol;
  270|  4.84M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  4.84M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (270:19): [True: 0, False: 4.84M]
  ------------------
  271|  4.84M|  JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
  272|  4.84M|  register _JSAMPROW inptr0, inptr1, outptr;
  273|  4.84M|  register int bias;
  274|       |
  275|       |  /* Expand input data enough to let all the output samples be generated
  276|       |   * by the standard loop.  Special-casing padded output would be more
  277|       |   * efficient.
  278|       |   */
  279|  4.84M|  expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
  280|  4.84M|                    output_cols * 2);
  281|       |
  282|  4.84M|  inrow = 0;
  283|  9.69M|  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  ------------------
  |  Branch (283:20): [True: 4.84M, False: 4.84M]
  ------------------
  284|  4.84M|    outptr = output_data[outrow];
  285|  4.84M|    inptr0 = input_data[inrow];
  286|  4.84M|    inptr1 = input_data[inrow + 1];
  287|  4.84M|    bias = 1;                   /* bias = 1,2,1,2,... for successive samples */
  288|  58.5M|    for (outcol = 0; outcol < output_cols; outcol++) {
  ------------------
  |  Branch (288:22): [True: 53.7M, False: 4.84M]
  ------------------
  289|  53.7M|      *outptr++ = (_JSAMPLE)
  290|  53.7M|        ((inptr0[0] + inptr0[1] + inptr1[0] + inptr1[1] + bias) >> 2);
  291|  53.7M|      bias ^= 3;                /* 1=>2, 2=>1 */
  292|  53.7M|      inptr0 += 2;  inptr1 += 2;
  293|  53.7M|    }
  294|  4.84M|    inrow += 2;
  295|  4.84M|  }
  296|  4.84M|}
jcsample-12.c:int_downsample:
  155|  14.5M|{
  156|  14.5M|  int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v;
  157|  14.5M|  JDIMENSION outcol, outcol_h;  /* outcol_h == outcol*h_expand */
  158|  14.5M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  14.5M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (158:19): [True: 0, False: 14.5M]
  ------------------
  159|  14.5M|  JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
  160|  14.5M|  _JSAMPROW inptr, outptr;
  ------------------
  |  |  113|  14.5M|#define _JSAMPROW  J12SAMPROW
  ------------------
  161|  14.5M|  JLONG outvalue;
  162|       |
  163|  14.5M|  h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor;
  164|  14.5M|  v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor;
  165|  14.5M|  numpix = h_expand * v_expand;
  166|  14.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|  14.5M|  expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
  173|  14.5M|                    output_cols * h_expand);
  174|       |
  175|  14.5M|  inrow = 0;
  176|  29.0M|  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  ------------------
  |  Branch (176:20): [True: 14.5M, False: 14.5M]
  ------------------
  177|  14.5M|    outptr = output_data[outrow];
  178|   174M|    for (outcol = 0, outcol_h = 0; outcol < output_cols;
  ------------------
  |  Branch (178:36): [True: 160M, False: 14.5M]
  ------------------
  179|   160M|         outcol++, outcol_h += h_expand) {
  180|   160M|      outvalue = 0;
  181|   389M|      for (v = 0; v < v_expand; v++) {
  ------------------
  |  Branch (181:19): [True: 229M, False: 160M]
  ------------------
  182|   229M|        inptr = input_data[inrow + v] + outcol_h;
  183|   731M|        for (h = 0; h < h_expand; h++) {
  ------------------
  |  Branch (183:21): [True: 502M, False: 229M]
  ------------------
  184|   502M|          outvalue += (JLONG)(*inptr++);
  185|   502M|        }
  186|   229M|      }
  187|   160M|      *outptr++ = (_JSAMPLE)((outvalue + numpix2) / numpix);
  188|   160M|    }
  189|  14.5M|    inrow += v_expand;
  190|  14.5M|  }
  191|  14.5M|}

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

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

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

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

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

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

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

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

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

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

j12init_read_ppm:
  924|  16.3k|{
  925|  16.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|  16.3k|  if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  ------------------
  |  |   12|  32.7k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (930:7): [True: 0, False: 16.3k]
  ------------------
  931|  16.3k|      cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  ------------------
  |  |   12|  16.3k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (931:7): [True: 0, False: 16.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|  16.3k|  source = (ppm_source_ptr)
  937|  16.3k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  16.3k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  938|  16.3k|                                sizeof(ppm_source_struct));
  939|       |  /* Fill in method ptrs, except get_pixel_rows which start_input sets */
  940|  16.3k|  source->pub.start_input = start_input_ppm;
  941|  16.3k|  source->pub.read_icc_profile = read_icc_profile_ppm;
  942|  16.3k|  source->pub.finish_input = finish_input_ppm;
  943|  16.3k|  source->pub.max_pixels = 0;
  944|       |
  945|  16.3k|  return (cjpeg_source_ptr)source;
  946|  16.3k|}
rdppm-12.c:start_input_ppm:
  703|  16.3k|{
  704|  16.3k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  705|  16.3k|  int c;
  706|  16.3k|  unsigned int w, h, maxval;
  707|  16.3k|  boolean need_iobuffer, use_raw_buffer, need_rescale;
  708|       |
  709|  16.3k|  if (getc(source->pub.input_file) != 'P')
  ------------------
  |  Branch (709:7): [True: 0, False: 16.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|  16.3k|  c = getc(source->pub.input_file); /* subformat discriminator character */
  713|       |
  714|       |  /* detect unsupported variants (ie, PBM) before trying to read header */
  715|  16.3k|  switch (c) {
  716|  1.48k|  case '2':                     /* it's a text-format PGM file */
  ------------------
  |  Branch (716:3): [True: 1.48k, False: 14.8k]
  ------------------
  717|  3.05k|  case '3':                     /* it's a text-format PPM file */
  ------------------
  |  Branch (717:3): [True: 1.57k, False: 14.7k]
  ------------------
  718|  12.2k|  case '5':                     /* it's a raw-format PGM file */
  ------------------
  |  Branch (718:3): [True: 9.16k, False: 7.19k]
  ------------------
  719|  16.3k|  case '6':                     /* it's a raw-format PPM file */
  ------------------
  |  Branch (719:3): [True: 4.10k, False: 12.2k]
  ------------------
  720|  16.3k|    break;
  721|     35|  default:
  ------------------
  |  Branch (721:3): [True: 35, False: 16.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|  16.3k|  }
  725|       |
  726|       |  /* fetch the remaining header info */
  727|  16.3k|  w = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  728|  16.3k|  h = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  729|  16.3k|  maxval = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  730|       |
  731|  16.3k|  if (w <= 0 || h <= 0 || maxval <= 0) /* error check */
  ------------------
  |  Branch (731:7): [True: 1.16k, False: 15.1k]
  |  Branch (731:17): [True: 14, False: 15.1k]
  |  Branch (731:27): [True: 7, False: 15.1k]
  ------------------
  732|     28|    ERREXIT(cinfo, JERR_PPM_NOT);
  ------------------
  |  |  240|     28|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     28|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  733|  16.3k|  if (w > JPEG_MAX_DIMENSION || h > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  32.6k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
                if (w > JPEG_MAX_DIMENSION || h > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  15.1k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (733:7): [True: 1.19k, False: 15.1k]
  |  Branch (733:33): [True: 7, False: 15.1k]
  ------------------
  734|     14|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, JPEG_MAX_DIMENSION);
  ------------------
  |  |  243|     14|  ((cinfo)->err->msg_code = (code), \
  |  |  244|     14|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|     14|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  735|  16.3k|  if (sinfo->max_pixels && (unsigned long long)w * h > sinfo->max_pixels)
  ------------------
  |  Branch (735:7): [True: 15.1k, False: 1.20k]
  |  Branch (735:28): [True: 245, False: 14.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|  16.3k|  cinfo->image_width = (JDIMENSION)w;
  739|  16.3k|  cinfo->image_height = (JDIMENSION)h;
  740|  16.3k|  source->maxval = maxval;
  741|       |
  742|       |  /* initialize flags to most common settings */
  743|  16.3k|  need_iobuffer = TRUE;         /* do we need an I/O buffer? */
  ------------------
  |  |  210|  16.3k|#define TRUE    1
  ------------------
  744|  16.3k|  use_raw_buffer = FALSE;       /* do we map input buffer onto I/O buffer? */
  ------------------
  |  |  207|  16.3k|#define FALSE   0               /* values of boolean */
  ------------------
  745|  16.3k|  need_rescale = TRUE;          /* do we need a rescale array? */
  ------------------
  |  |  210|  16.3k|#define TRUE    1
  ------------------
  746|       |
  747|  16.3k|  switch (c) {
  ------------------
  |  Branch (747:11): [True: 14.8k, False: 1.44k]
  ------------------
  748|  1.10k|  case '2':                     /* it's a text-format PGM file */
  ------------------
  |  Branch (748:3): [True: 1.10k, False: 15.2k]
  ------------------
  749|  1.10k|    if (cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (749:9): [True: 0, False: 1.10k]
  ------------------
  750|  1.10k|        cinfo->in_color_space == JCS_RGB)
  ------------------
  |  Branch (750:9): [True: 0, False: 1.10k]
  ------------------
  751|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  752|  1.10k|    TRACEMS3(cinfo, 1, JTRC_PGM_TEXT, w, h, maxval);
  ------------------
  |  |  309|  1.10k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.10k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.10k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  1.10k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  1.10k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  1.10k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  753|  1.10k|    if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (753:9): [True: 158, False: 948]
  ------------------
  754|    158|      source->pub.get_pixel_rows = get_text_gray_row;
  755|    948|    else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|    948|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 948]
  |  |  |  Branch (78:22): [True: 790, False: 158]
  |  |  |  Branch (78:43): [True: 790, False: 0]
  |  |  ------------------
  ------------------
  756|    790|      source->pub.get_pixel_rows = get_text_gray_rgb_row;
  757|    158|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (757:14): [True: 158, False: 0]
  ------------------
  758|    158|      source->pub.get_pixel_rows = get_text_gray_cmyk_row;
  759|      0|    else
  760|      0|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  761|  1.10k|    need_iobuffer = FALSE;
  ------------------
  |  |  207|  1.10k|#define FALSE   0               /* values of boolean */
  ------------------
  762|  1.10k|    break;
  763|       |
  764|  1.19k|  case '3':                     /* it's a text-format PPM file */
  ------------------
  |  Branch (764:3): [True: 1.19k, False: 15.1k]
  ------------------
  765|  1.19k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (765:9): [True: 0, False: 1.19k]
  ------------------
  766|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  767|  1.19k|    TRACEMS3(cinfo, 1, JTRC_PPM_TEXT, w, h, maxval);
  ------------------
  |  |  309|  1.19k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.19k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.19k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  1.19k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  1.19k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  1.19k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  768|  1.19k|    if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  1.19k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 1.19k]
  |  |  |  Branch (78:22): [True: 855, False: 342]
  |  |  |  Branch (78:43): [True: 855, False: 0]
  |  |  ------------------
  ------------------
  769|    855|      source->pub.get_pixel_rows = get_text_rgb_row;
  770|    342|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (770:14): [True: 171, False: 171]
  ------------------
  771|    171|      source->pub.get_pixel_rows = get_text_rgb_cmyk_row;
  772|    171|    else
  773|    171|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    171|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    171|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  774|  1.19k|    need_iobuffer = FALSE;
  ------------------
  |  |  207|  1.19k|#define FALSE   0               /* values of boolean */
  ------------------
  775|  1.19k|    break;
  776|       |
  777|  8.73k|  case '5':                     /* it's a raw-format PGM file */
  ------------------
  |  Branch (777:3): [True: 8.73k, False: 7.58k]
  ------------------
  778|  8.73k|    if (cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (778:9): [True: 0, False: 8.73k]
  ------------------
  779|  8.73k|        cinfo->in_color_space == JCS_RGB)
  ------------------
  |  Branch (779:9): [True: 0, False: 8.73k]
  ------------------
  780|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  781|  8.73k|    TRACEMS3(cinfo, 1, JTRC_PGM, w, h, maxval);
  ------------------
  |  |  309|  8.73k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  8.73k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 8.73k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  8.73k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  8.73k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  8.73k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  782|  8.73k|    if (maxval > 255) {
  ------------------
  |  Branch (782:9): [True: 1.16k, False: 7.56k]
  ------------------
  783|  1.16k|      if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (783:11): [True: 167, False: 1.00k]
  ------------------
  784|    167|        source->pub.get_pixel_rows = get_word_gray_row;
  785|  1.00k|      else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  1.00k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 1.00k]
  |  |  |  Branch (78:22): [True: 835, False: 167]
  |  |  |  Branch (78:43): [True: 835, False: 0]
  |  |  ------------------
  ------------------
  786|    835|        source->pub.get_pixel_rows = get_word_gray_rgb_row;
  787|    167|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (787:16): [True: 167, False: 0]
  ------------------
  788|    167|        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|  7.56k|    } else {
  800|  7.56k|      if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (800:11): [True: 1.08k, False: 6.48k]
  ------------------
  801|  1.08k|        source->pub.get_pixel_rows = get_scaled_gray_row;
  802|  6.48k|      else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  6.48k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 6.48k]
  |  |  |  Branch (78:22): [True: 5.40k, False: 1.08k]
  |  |  |  Branch (78:43): [True: 5.40k, False: 0]
  |  |  ------------------
  ------------------
  803|  5.40k|        source->pub.get_pixel_rows = get_gray_rgb_row;
  804|  1.08k|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (804:16): [True: 1.08k, False: 0]
  ------------------
  805|  1.08k|        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|  7.56k|    }
  809|  8.73k|    break;
  810|       |
  811|  3.83k|  case '6':                     /* it's a raw-format PPM file */
  ------------------
  |  Branch (811:3): [True: 3.83k, False: 12.4k]
  ------------------
  812|  3.83k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (812:9): [True: 0, False: 3.83k]
  ------------------
  813|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  814|  3.83k|    TRACEMS3(cinfo, 1, JTRC_PPM, w, h, maxval);
  ------------------
  |  |  309|  3.83k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  3.83k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 3.83k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  3.83k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  3.83k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  3.83k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  815|  3.83k|    if (maxval > 255) {
  ------------------
  |  Branch (815:9): [True: 1.77k, False: 2.05k]
  ------------------
  816|  1.77k|      if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  1.77k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 1.77k]
  |  |  |  Branch (78:22): [True: 1.27k, False: 508]
  |  |  |  Branch (78:43): [True: 1.27k, False: 0]
  |  |  ------------------
  ------------------
  817|  1.27k|        source->pub.get_pixel_rows = get_word_rgb_row;
  818|    508|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (818:16): [True: 254, False: 254]
  ------------------
  819|    254|        source->pub.get_pixel_rows = get_word_rgb_cmyk_row;
  820|    254|      else
  821|    254|        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    254|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    254|   (*(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.05k|    } else {
  836|  2.05k|      if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  2.05k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 2.05k]
  |  |  |  Branch (78:22): [True: 1.47k, False: 588]
  |  |  |  Branch (78:43): [True: 1.47k, False: 0]
  |  |  ------------------
  ------------------
  837|  1.47k|        source->pub.get_pixel_rows = get_rgb_row;
  838|    588|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (838:16): [True: 294, False: 294]
  ------------------
  839|    294|        source->pub.get_pixel_rows = get_rgb_cmyk_row;
  840|    294|      else
  841|    294|        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    294|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    294|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  842|  2.05k|    }
  843|  3.83k|    break;
  844|  16.3k|  }
  845|       |
  846|  14.1k|  if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  14.1k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 14.1k]
  |  |  |  Branch (78:22): [True: 10.6k, False: 3.53k]
  |  |  |  Branch (78:43): [True: 10.6k, False: 0]
  |  |  ------------------
  ------------------
  847|  10.6k|    cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
  848|  3.53k|  else if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (848:12): [True: 1.40k, False: 2.12k]
  ------------------
  849|  1.40k|    cinfo->input_components = 1;
  850|  2.12k|  else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (850:12): [True: 2.12k, False: 0]
  ------------------
  851|  2.12k|    cinfo->input_components = 4;
  852|       |
  853|       |  /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */
  854|  14.1k|  if (need_iobuffer) {
  ------------------
  |  Branch (854:7): [True: 12.0k, False: 2.13k]
  ------------------
  855|  12.0k|    if (c == '6')
  ------------------
  |  Branch (855:9): [True: 3.28k, False: 8.73k]
  ------------------
  856|  3.28k|      source->buffer_width = (size_t)w * 3 * (maxval <= 255 ? 1 : 2);
  ------------------
  |  Branch (856:47): [True: 1.76k, False: 1.52k]
  ------------------
  857|  8.73k|    else
  858|  8.73k|      source->buffer_width = (size_t)w * (maxval <= 255 ? 1 : 2);
  ------------------
  |  Branch (858:43): [True: 7.56k, False: 1.16k]
  ------------------
  859|  12.0k|    source->iobuffer = (unsigned char *)
  860|  12.0k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  12.0k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  861|  12.0k|                                  source->buffer_width);
  862|  12.0k|  }
  863|       |
  864|       |  /* Create compressor input buffer. */
  865|  14.1k|  if (use_raw_buffer) {
  ------------------
  |  Branch (865:7): [True: 0, False: 14.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|  14.1k|  } else {
  872|       |    /* Need to translate anyway, so make a separate sample buffer. */
  873|  14.1k|    source->pub._buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  ------------------
  |  |  210|  14.1k|#define _buffer  buffer12
  ------------------
  874|  14.1k|      ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  14.1k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  875|  14.1k|       (JDIMENSION)w * cinfo->input_components, (JDIMENSION)1);
  876|  14.1k|    source->pub.buffer_height = 1;
  877|  14.1k|  }
  878|       |
  879|       |  /* Compute the rescaling array if required. */
  880|  14.1k|  if (need_rescale) {
  ------------------
  |  Branch (880:7): [True: 14.1k, False: 0]
  ------------------
  881|  14.1k|    size_t val, half_maxval;
  882|       |
  883|       |    /* On 16-bit-int machines we have to be careful of maxval = 65535 */
  884|  14.1k|    source->rescale = (_JSAMPLE *)
  885|  14.1k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  14.1k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  886|  14.1k|                                  (MAX(maxval, 255) + 1L) * sizeof(_JSAMPLE));
  ------------------
  |  |  513|  14.1k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 3.60k, False: 10.5k]
  |  |  ------------------
  ------------------
  887|  14.1k|    memset(source->rescale, 0, (MAX(maxval, 255) + 1L) * sizeof(_JSAMPLE));
  ------------------
  |  |  513|  14.1k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 3.60k, False: 10.5k]
  |  |  ------------------
  ------------------
  888|  14.1k|    half_maxval = (size_t)maxval / 2;
  889|  28.6M|    for (val = 0; val <= (size_t)maxval; val++) {
  ------------------
  |  Branch (889:19): [True: 28.6M, False: 14.1k]
  ------------------
  890|       |      /* The multiplication here must be done in 32 bits to avoid overflow */
  891|  28.6M|      source->rescale[val] =
  892|  28.6M|        (_JSAMPLE)((val * ((1 << cinfo->data_precision) - 1) + half_maxval) /
  893|  28.6M|                   maxval);
  894|  28.6M|    }
  895|  14.1k|  }
  896|  14.1k|}
rdppm-12.c:read_pbm_integer:
   92|   123k|{
   93|   123k|  register int ch;
   94|   123k|  register unsigned int val;
   95|       |
   96|       |  /* Skip any leading whitespace */
   97|   130k|  do {
   98|   130k|    ch = pbm_getc(infile);
   99|   130k|    if (ch == EOF)
  ------------------
  |  Branch (99:9): [True: 2.63k, False: 128k]
  ------------------
  100|  2.63k|      ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|  2.63k|  ((cinfo)->err->msg_code = (code), \
  |  |  241|  2.63k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  101|   130k|  } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
  ------------------
  |  Branch (101:12): [True: 3.91k, False: 127k]
  |  Branch (101:25): [True: 1.02k, False: 126k]
  |  Branch (101:39): [True: 3.97k, False: 122k]
  |  Branch (101:53): [True: 1.02k, False: 121k]
  ------------------
  102|       |
  103|   123k|  if (ch < '0' || ch > '9')
  ------------------
  |  Branch (103:7): [True: 2.75k, False: 120k]
  |  Branch (103:19): [True: 169, False: 120k]
  ------------------
  104|    286|    ERREXIT(cinfo, JERR_PPM_NONNUMERIC);
  ------------------
  |  |  240|    286|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    286|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  105|       |
  106|   123k|  val = ch - '0';
  107|   164k|  while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') {
  ------------------
  |  Branch (107:10): [True: 100k, False: 63.4k]
  |  Branch (107:44): [True: 40.7k, False: 60.2k]
  ------------------
  108|  40.7k|    val *= 10;
  109|  40.7k|    val += ch - '0';
  110|  40.7k|    if (val > maxval)
  ------------------
  |  Branch (110:9): [True: 126, False: 40.6k]
  ------------------
  111|    126|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    126|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    126|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  112|  40.7k|  }
  113|       |
  114|   123k|  return val;
  115|   123k|}
rdppm-12.c:pbm_getc:
   73|   292k|{
   74|   292k|  register int ch;
   75|       |
   76|   292k|  ch = getc(infile);
   77|   292k|  if (ch == '#') {
  ------------------
  |  Branch (77:7): [True: 3.48k, False: 288k]
  ------------------
   78|  49.3k|    do {
   79|  49.3k|      ch = getc(infile);
   80|  49.3k|    } while (ch != '\n' && ch != EOF);
  ------------------
  |  Branch (80:14): [True: 46.2k, False: 3.12k]
  |  Branch (80:28): [True: 45.8k, False: 363]
  ------------------
   81|  3.48k|  }
   82|   292k|  return ch;
   83|   292k|}
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.68k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (142:34): [True: 2.30k, False: 1.38k]
  ------------------
  143|  2.30k|    *ptr++ = rescale[read_pbm_integer(cinfo, infile, maxval)];
  144|  2.30k|  }
  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|    646|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 420, False: 226]
  |  |  ------------------
  |  |  151|    420|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|    420|    alpha_set_op \
  |  |  153|    420|    ptr += ps; \
  |  |  154|    420|  } \
  |  |  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|  2.58k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 1.68k, False: 904]
  |  |  ------------------
  |  |  151|  1.68k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  1.68k|    alpha_set_op \
  |  |  153|  1.68k|    ptr += ps; \
  |  |  154|  1.68k|  } \
  |  |  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.04k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 1.88k, False: 1.15k]
  |  |  ------------------
  |  |  151|  1.88k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  1.88k|    alpha_set_op \
  |  |  153|  1.88k|    ptr += ps; \
  |  |  154|  1.88k|  } \
  |  |  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.1k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 7.54k, False: 4.61k]
  |  |  ------------------
  |  |  151|  7.54k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  7.54k|    alpha_set_op \
  |  |  153|  7.54k|    ptr += ps; \
  |  |  154|  7.54k|  } \
  |  |  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|    646|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (206:36): [True: 420, False: 226]
  ------------------
  207|    420|      _JSAMPLE gray = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  108|    420|#define _JSAMPLE  J12SAMPLE
  ------------------
  208|    420|      rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
  209|    420|      ptr += 4;
  210|    420|    }
  211|  1.15k|  } else {
  212|  3.04k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (212:36): [True: 1.88k, False: 1.15k]
  ------------------
  213|  1.88k|      _JSAMPLE gray = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  108|  1.88k|#define _JSAMPLE  J12SAMPLE
  ------------------
  214|  1.88k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  215|  1.88k|                  ptr + 1, ptr + 2, ptr + 3);
  216|  1.88k|      ptr += 4;
  217|  1.88k|    }
  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.39k, False: 5.79k]
  ------------------
  251|  1.39k|    if (aindex >= 0)
  ------------------
  |  Branch (251:9): [True: 279, False: 1.11k]
  ------------------
  252|    279|      RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
  ------------------
  |  |  223|    279|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  1.76k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 1.48k, False: 279]
  |  |  ------------------
  |  |  225|  1.48k|    ptr[rindex] = read_op; \
  |  |  226|  1.48k|    ptr[gindex] = read_op; \
  |  |  227|  1.48k|    ptr[bindex] = read_op; \
  |  |  228|  1.48k|    alpha_set_op \
  |  |  229|  1.48k|    ptr += ps; \
  |  |  230|  1.48k|  } \
  |  |  231|    279|}
  ------------------
  253|  1.39k|                    ptr[aindex] = (_JSAMPLE)maxval;)
  254|  1.11k|    else
  255|  1.11k|      RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
  ------------------
  |  |  223|  1.11k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  7.04k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 5.92k, False: 1.11k]
  |  |  ------------------
  |  |  225|  5.92k|    ptr[rindex] = read_op; \
  |  |  226|  5.92k|    ptr[gindex] = read_op; \
  |  |  227|  5.92k|    ptr[bindex] = read_op; \
  |  |  228|  5.92k|    alpha_set_op \
  |  |  229|  5.92k|    ptr += ps; \
  |  |  230|  5.92k|  } \
  |  |  231|  1.11k|}
  ------------------
  256|  5.79k|  } else {
  257|  5.79k|    if (aindex >= 0)
  ------------------
  |  Branch (257:9): [True: 1.15k, False: 4.63k]
  ------------------
  258|  1.15k|      RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
  ------------------
  |  |  223|  1.15k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  3.13k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 1.97k, False: 1.15k]
  |  |  ------------------
  |  |  225|  1.97k|    ptr[rindex] = read_op; \
  |  |  226|  1.97k|    ptr[gindex] = read_op; \
  |  |  227|  1.97k|    ptr[bindex] = read_op; \
  |  |  228|  1.97k|    alpha_set_op \
  |  |  229|  1.97k|    ptr += ps; \
  |  |  230|  1.97k|  } \
  |  |  231|  1.15k|}
  ------------------
  259|  5.79k|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  260|  4.63k|    else
  261|  4.63k|      RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
  ------------------
  |  |  223|  4.63k|#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.91k, False: 4.63k]
  |  |  ------------------
  |  |  225|  7.91k|    ptr[rindex] = read_op; \
  |  |  226|  7.91k|    ptr[gindex] = read_op; \
  |  |  227|  7.91k|    ptr[bindex] = read_op; \
  |  |  228|  7.91k|    alpha_set_op \
  |  |  229|  7.91k|    ptr += ps; \
  |  |  230|  7.91k|  } \
  |  |  231|  4.63k|}
  ------------------
  262|  5.79k|  }
  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: 279, False: 1.15k]
  ------------------
  281|  1.76k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (281:36): [True: 1.48k, False: 279]
  ------------------
  282|  1.48k|      _JSAMPLE r = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  108|  1.48k|#define _JSAMPLE  J12SAMPLE
  ------------------
  283|  1.48k|      _JSAMPLE g = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  108|  1.48k|#define _JSAMPLE  J12SAMPLE
  ------------------
  284|  1.48k|      _JSAMPLE b = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  108|  1.48k|#define _JSAMPLE  J12SAMPLE
  ------------------
  285|  1.48k|      rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
  286|  1.48k|      ptr += 4;
  287|  1.48k|    }
  288|  1.15k|  } else {
  289|  3.13k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (289:36): [True: 1.97k, False: 1.15k]
  ------------------
  290|  1.97k|      _JSAMPLE r = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  108|  1.97k|#define _JSAMPLE  J12SAMPLE
  ------------------
  291|  1.97k|      _JSAMPLE g = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  108|  1.97k|#define _JSAMPLE  J12SAMPLE
  ------------------
  292|  1.97k|      _JSAMPLE b = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  108|  1.97k|#define _JSAMPLE  J12SAMPLE
  ------------------
  293|  1.97k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  294|  1.97k|                  ptr + 2, ptr + 3);
  295|  1.97k|      ptr += 4;
  296|  1.97k|    }
  297|  1.15k|  }
  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: 83, False: 34.5k]
  ------------------
  500|     83|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     83|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     83|   (*(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.9k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (503:34): [True: 36.2k, False: 34.6k]
  ------------------
  504|  36.2k|    register unsigned int temp;
  505|  36.2k|    temp  = (*bufferptr++) << 8;
  506|  36.2k|    temp |= (*bufferptr++);
  507|  36.2k|    if (temp > maxval)
  ------------------
  |  Branch (507:9): [True: 69, False: 36.2k]
  ------------------
  508|     69|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     69|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     69|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  509|  36.2k|    *ptr++ = rescale[temp];
  510|  36.2k|  }
  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: 415, False: 172k]
  ------------------
  532|    415|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    415|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    415|   (*(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|   354k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (535:34): [True: 181k, False: 173k]
  ------------------
  536|   181k|    register unsigned int temp;
  537|   181k|    temp  = (*bufferptr++) << 8;
  538|   181k|    temp |= (*bufferptr++);
  539|   181k|    if (temp > maxval)
  ------------------
  |  Branch (539:9): [True: 345, False: 181k]
  ------------------
  540|    345|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    345|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    345|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  541|   181k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = rescale[temp];
  542|   181k|    if (aindex >= 0)
  ------------------
  |  Branch (542:9): [True: 36.2k, False: 145k]
  ------------------
  543|  36.2k|      ptr[aindex] = (1 << cinfo->data_precision) - 1;
  544|   181k|    ptr += ps;
  545|   181k|  }
  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: 83, False: 34.5k]
  ------------------
  562|     83|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     83|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     83|   (*(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: 281, False: 34.3k]
  ------------------
  566|  1.05k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (566:36): [True: 775, False: 281]
  ------------------
  567|    775|      register unsigned int gray;
  568|    775|      gray  = (*bufferptr++) << 8;
  569|    775|      gray |= (*bufferptr++);
  570|    775|      if (gray > maxval)
  ------------------
  |  Branch (570:11): [True: 22, False: 753]
  ------------------
  571|     22|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     22|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     22|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  572|    775|      rgb_to_cmyk(maxval, (_JSAMPLE)gray, (_JSAMPLE)gray, (_JSAMPLE)gray, ptr,
  573|    775|                  ptr + 1, ptr + 2, ptr + 3);
  574|    775|      ptr += 4;
  575|    775|    }
  576|  34.3k|  } else {
  577|  69.8k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (577:36): [True: 35.5k, False: 34.3k]
  ------------------
  578|  35.5k|      register unsigned int temp;
  579|  35.5k|      _JSAMPLE gray;
  ------------------
  |  |  108|  35.5k|#define _JSAMPLE  J12SAMPLE
  ------------------
  580|  35.5k|      temp  = (*bufferptr++) << 8;
  581|  35.5k|      temp |= (*bufferptr++);
  582|  35.5k|      if (temp > maxval)
  ------------------
  |  Branch (582:11): [True: 47, False: 35.4k]
  ------------------
  583|     47|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     47|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     47|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  584|  35.5k|      gray = rescale[temp];
  585|  35.5k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  586|  35.5k|                  ptr + 1, ptr + 2, ptr + 3);
  587|  35.5k|      ptr += 4;
  588|  35.5k|    }
  589|  34.3k|  }
  590|  34.6k|  return 1;
  591|  34.6k|}
rdppm-12.c:get_scaled_gray_row:
  305|  3.68M|{
  306|  3.68M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  307|  3.68M|  register _JSAMPROW ptr;
  308|  3.68M|  register unsigned char *bufferptr;
  309|  3.68M|  register _JSAMPLE *rescale = source->rescale;
  310|  3.68M|  JDIMENSION col;
  311|       |
  312|  3.68M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  3.68M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (312:7): [True: 72, False: 3.68M]
  ------------------
  313|     72|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     72|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     72|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  314|  3.68M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  3.68M|#define _buffer  buffer12
  ------------------
  315|  3.68M|  bufferptr = source->iobuffer;
  316|  22.1M|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (316:34): [True: 18.4M, False: 3.68M]
  ------------------
  317|  18.4M|    *ptr++ = rescale[*bufferptr++];
  318|  18.4M|  }
  319|  3.68M|  return 1;
  320|  3.68M|}
rdppm-12.c:get_gray_rgb_row:
  327|  18.4M|{
  328|  18.4M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  329|  18.4M|  register _JSAMPROW ptr;
  330|  18.4M|  register unsigned char *bufferptr;
  331|  18.4M|  register _JSAMPLE *rescale = source->rescale;
  332|  18.4M|  JDIMENSION col;
  333|  18.4M|  unsigned int maxval = source->maxval;
  334|  18.4M|  register int rindex = rgb_red[cinfo->in_color_space];
  335|  18.4M|  register int gindex = rgb_green[cinfo->in_color_space];
  336|  18.4M|  register int bindex = rgb_blue[cinfo->in_color_space];
  337|  18.4M|  register int aindex = alpha_index[cinfo->in_color_space];
  338|  18.4M|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  339|       |
  340|  18.4M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  18.4M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (340:7): [True: 360, False: 18.4M]
  ------------------
  341|    360|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    360|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    360|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  342|  18.4M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  18.4M|#define _buffer  buffer12
  ------------------
  343|  18.4M|  bufferptr = source->iobuffer;
  344|  18.4M|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (344:7): [True: 0, False: 18.4M]
  ------------------
  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|  18.4M|  } else {
  350|  18.4M|    if (aindex >= 0)
  ------------------
  |  Branch (350:9): [True: 3.68M, False: 14.7M]
  ------------------
  351|  3.68M|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  149|  3.68M|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  22.1M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 18.4M, False: 3.68M]
  |  |  ------------------
  |  |  151|  18.4M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  18.4M|    alpha_set_op \
  |  |  153|  18.4M|    ptr += ps; \
  |  |  154|  18.4M|  } \
  |  |  155|  3.68M|}
  ------------------
  352|  18.4M|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  353|  14.7M|    else
  354|  14.7M|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++], {})
  ------------------
  |  |  149|  14.7M|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  88.6M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 73.9M, False: 14.7M]
  |  |  ------------------
  |  |  151|  73.9M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  73.9M|    alpha_set_op \
  |  |  153|  73.9M|    ptr += ps; \
  |  |  154|  73.9M|  } \
  |  |  155|  14.7M|}
  ------------------
  355|  18.4M|  }
  356|  18.4M|  return 1;
  357|  18.4M|}
rdppm-12.c:get_gray_cmyk_row:
  364|  3.68M|{
  365|  3.68M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  366|  3.68M|  register _JSAMPROW ptr;
  367|  3.68M|  register unsigned char *bufferptr;
  368|  3.68M|  register _JSAMPLE *rescale = source->rescale;
  369|  3.68M|  JDIMENSION col;
  370|  3.68M|  unsigned int maxval = source->maxval;
  371|       |
  372|  3.68M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  3.68M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (372:7): [True: 72, False: 3.68M]
  ------------------
  373|     72|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     72|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     72|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  374|  3.68M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  3.68M|#define _buffer  buffer12
  ------------------
  375|  3.68M|  bufferptr = source->iobuffer;
  376|  3.68M|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (376:7): [True: 0, False: 3.68M]
  ------------------
  377|      0|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (377:36): [True: 0, False: 0]
  ------------------
  378|      0|      _JSAMPLE gray = *bufferptr++;
  ------------------
  |  |  108|      0|#define _JSAMPLE  J12SAMPLE
  ------------------
  379|      0|      rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
  380|      0|      ptr += 4;
  381|      0|    }
  382|  3.68M|  } else {
  383|  22.1M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (383:36): [True: 18.4M, False: 3.68M]
  ------------------
  384|  18.4M|      _JSAMPLE gray = rescale[*bufferptr++];
  ------------------
  |  |  108|  18.4M|#define _JSAMPLE  J12SAMPLE
  ------------------
  385|  18.4M|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  386|  18.4M|                  ptr + 1, ptr + 2, ptr + 3);
  387|  18.4M|      ptr += 4;
  388|  18.4M|    }
  389|  3.68M|  }
  390|  3.68M|  return 1;
  391|  3.68M|}
rdppm-12.c:get_word_rgb_row:
  597|  15.9k|{
  598|  15.9k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  599|  15.9k|  register _JSAMPROW ptr;
  600|  15.9k|  register unsigned char *bufferptr;
  601|  15.9k|  register _JSAMPLE *rescale = source->rescale;
  602|  15.9k|  JDIMENSION col;
  603|  15.9k|  unsigned int maxval = source->maxval;
  604|  15.9k|  register int rindex = rgb_red[cinfo->in_color_space];
  605|  15.9k|  register int gindex = rgb_green[cinfo->in_color_space];
  606|  15.9k|  register int bindex = rgb_blue[cinfo->in_color_space];
  607|  15.9k|  register int aindex = alpha_index[cinfo->in_color_space];
  608|  15.9k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  609|       |
  610|  15.9k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  15.9k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (610:7): [True: 540, False: 15.4k]
  ------------------
  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.9k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  15.9k|#define _buffer  buffer12
  ------------------
  613|  15.9k|  bufferptr = source->iobuffer;
  614|  42.0k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (614:34): [True: 26.0k, False: 15.9k]
  ------------------
  615|  26.0k|    register unsigned int temp;
  616|  26.0k|    temp  = (*bufferptr++) << 8;
  617|  26.0k|    temp |= (*bufferptr++);
  618|  26.0k|    if (temp > maxval)
  ------------------
  |  Branch (618:9): [True: 270, False: 25.7k]
  ------------------
  619|    270|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    270|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    270|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  620|  26.0k|    ptr[rindex] = rescale[temp];
  621|  26.0k|    temp  = (*bufferptr++) << 8;
  622|  26.0k|    temp |= (*bufferptr++);
  623|  26.0k|    if (temp > maxval)
  ------------------
  |  Branch (623:9): [True: 220, False: 25.8k]
  ------------------
  624|    220|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    220|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    220|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  625|  26.0k|    ptr[gindex] = rescale[temp];
  626|  26.0k|    temp  = (*bufferptr++) << 8;
  627|  26.0k|    temp |= (*bufferptr++);
  628|  26.0k|    if (temp > maxval)
  ------------------
  |  Branch (628:9): [True: 185, False: 25.8k]
  ------------------
  629|    185|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    185|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    185|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  630|  26.0k|    ptr[bindex] = rescale[temp];
  631|  26.0k|    if (aindex >= 0)
  ------------------
  |  Branch (631:9): [True: 5.07k, False: 20.9k]
  ------------------
  632|  5.07k|      ptr[aindex] = (1 << cinfo->data_precision) - 1;
  633|  26.0k|    ptr += ps;
  634|  26.0k|  }
  635|  15.9k|  return 1;
  636|  15.9k|}
rdppm-12.c:get_word_rgb_cmyk_row:
  642|  3.19k|{
  643|  3.19k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  644|  3.19k|  register _JSAMPROW ptr;
  645|  3.19k|  register unsigned char *bufferptr;
  646|  3.19k|  register _JSAMPLE *rescale = source->rescale;
  647|  3.19k|  JDIMENSION col;
  648|  3.19k|  unsigned int maxval = source->maxval;
  649|       |
  650|  3.19k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  3.19k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (650:7): [True: 108, False: 3.08k]
  ------------------
  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.19k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  3.19k|#define _buffer  buffer12
  ------------------
  653|  3.19k|  bufferptr = source->iobuffer;
  654|  3.19k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (654:7): [True: 818, False: 2.37k]
  ------------------
  655|  2.87k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (655:36): [True: 2.06k, False: 818]
  ------------------
  656|  2.06k|      register unsigned int r, g, b;
  657|  2.06k|      r  = (*bufferptr++) << 8;
  658|  2.06k|      r |= (*bufferptr++);
  659|  2.06k|      if (r > maxval)
  ------------------
  |  Branch (659:11): [True: 17, False: 2.04k]
  ------------------
  660|     17|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     17|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     17|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  661|  2.06k|      g  = (*bufferptr++) << 8;
  662|  2.06k|      g |= (*bufferptr++);
  663|  2.06k|      if (g > maxval)
  ------------------
  |  Branch (663:11): [True: 20, False: 2.04k]
  ------------------
  664|     20|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     20|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     20|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  665|  2.06k|      b  = (*bufferptr++) << 8;
  666|  2.06k|      b |= (*bufferptr++);
  667|  2.06k|      if (b > maxval)
  ------------------
  |  Branch (667:11): [True: 16, False: 2.04k]
  ------------------
  668|     16|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     16|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     16|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  669|  2.06k|      rgb_to_cmyk(maxval, (_JSAMPLE)r, (_JSAMPLE)g, (_JSAMPLE)b, ptr, ptr + 1,
  670|  2.06k|                  ptr + 2, ptr + 3);
  671|  2.06k|      ptr += 4;
  672|  2.06k|    }
  673|  2.37k|  } else {
  674|  5.52k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (674:36): [True: 3.14k, False: 2.37k]
  ------------------
  675|  3.14k|      register unsigned int r, g, b;
  676|  3.14k|      r  = (*bufferptr++) << 8;
  677|  3.14k|      r |= (*bufferptr++);
  678|  3.14k|      if (r > maxval)
  ------------------
  |  Branch (678:11): [True: 37, False: 3.11k]
  ------------------
  679|     37|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     37|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     37|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  680|  3.14k|      g  = (*bufferptr++) << 8;
  681|  3.14k|      g |= (*bufferptr++);
  682|  3.14k|      if (g > maxval)
  ------------------
  |  Branch (682:11): [True: 24, False: 3.12k]
  ------------------
  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.14k|      b  = (*bufferptr++) << 8;
  685|  3.14k|      b |= (*bufferptr++);
  686|  3.14k|      if (b > maxval)
  ------------------
  |  Branch (686:11): [True: 21, False: 3.12k]
  ------------------
  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.14k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, rescale[r], rescale[g],
  689|  3.14k|                  rescale[b], ptr, ptr + 1, ptr + 2, ptr + 3);
  690|  3.14k|      ptr += 4;
  691|  3.14k|    }
  692|  2.37k|  }
  693|  3.19k|  return 1;
  694|  3.19k|}
rdppm-12.c:get_rgb_row:
  397|  5.14M|{
  398|  5.14M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  399|  5.14M|  register _JSAMPROW ptr;
  400|  5.14M|  register unsigned char *bufferptr;
  401|  5.14M|  register _JSAMPLE *rescale = source->rescale;
  402|  5.14M|  JDIMENSION col;
  403|  5.14M|  unsigned int maxval = source->maxval;
  404|  5.14M|  register int rindex = rgb_red[cinfo->in_color_space];
  405|  5.14M|  register int gindex = rgb_green[cinfo->in_color_space];
  406|  5.14M|  register int bindex = rgb_blue[cinfo->in_color_space];
  407|  5.14M|  register int aindex = alpha_index[cinfo->in_color_space];
  408|  5.14M|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  409|       |
  410|  5.14M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  5.14M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (410:7): [True: 455, False: 5.14M]
  ------------------
  411|    455|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    455|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    455|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  412|  5.14M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  5.14M|#define _buffer  buffer12
  ------------------
  413|  5.14M|  bufferptr = source->iobuffer;
  414|  5.14M|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (414:7): [True: 0, False: 5.14M]
  ------------------
  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|  5.14M|  } else {
  420|  5.14M|    if (aindex >= 0)
  ------------------
  |  Branch (420:9): [True: 1.02M, False: 4.11M]
  ------------------
  421|  1.02M|      RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  223|  1.02M|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  6.87M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 5.84M, False: 1.02M]
  |  |  ------------------
  |  |  225|  5.84M|    ptr[rindex] = read_op; \
  |  |  226|  5.84M|    ptr[gindex] = read_op; \
  |  |  227|  5.84M|    ptr[bindex] = read_op; \
  |  |  228|  5.84M|    alpha_set_op \
  |  |  229|  5.84M|    ptr += ps; \
  |  |  230|  5.84M|  } \
  |  |  231|  1.02M|}
  ------------------
  422|  5.14M|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  423|  4.11M|    else
  424|  4.11M|      RGB_READ_LOOP(rescale[*bufferptr++], {})
  ------------------
  |  |  223|  4.11M|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  27.4M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 23.3M, False: 4.11M]
  |  |  ------------------
  |  |  225|  23.3M|    ptr[rindex] = read_op; \
  |  |  226|  23.3M|    ptr[gindex] = read_op; \
  |  |  227|  23.3M|    ptr[bindex] = read_op; \
  |  |  228|  23.3M|    alpha_set_op \
  |  |  229|  23.3M|    ptr += ps; \
  |  |  230|  23.3M|  } \
  |  |  231|  4.11M|}
  ------------------
  425|  5.14M|  }
  426|  5.14M|  return 1;
  427|  5.14M|}
rdppm-12.c:get_rgb_cmyk_row:
  434|  1.02M|{
  435|  1.02M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  436|  1.02M|  register _JSAMPROW ptr;
  437|  1.02M|  register unsigned char *bufferptr;
  438|  1.02M|  register _JSAMPLE *rescale = source->rescale;
  439|  1.02M|  JDIMENSION col;
  440|  1.02M|  unsigned int maxval = source->maxval;
  441|       |
  442|  1.02M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  1.02M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (442:7): [True: 91, False: 1.02M]
  ------------------
  443|     91|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     91|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     91|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  444|  1.02M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  210|  1.02M|#define _buffer  buffer12
  ------------------
  445|  1.02M|  bufferptr = source->iobuffer;
  446|  1.02M|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (446:7): [True: 0, False: 1.02M]
  ------------------
  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|  1.02M|  } else {
  455|  6.87M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (455:36): [True: 5.84M, False: 1.02M]
  ------------------
  456|  5.84M|      _JSAMPLE r = rescale[*bufferptr++];
  ------------------
  |  |  108|  5.84M|#define _JSAMPLE  J12SAMPLE
  ------------------
  457|  5.84M|      _JSAMPLE g = rescale[*bufferptr++];
  ------------------
  |  |  108|  5.84M|#define _JSAMPLE  J12SAMPLE
  ------------------
  458|  5.84M|      _JSAMPLE b = rescale[*bufferptr++];
  ------------------
  |  |  108|  5.84M|#define _JSAMPLE  J12SAMPLE
  ------------------
  459|  5.84M|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  460|  5.84M|                  ptr + 2, ptr + 3);
  461|  5.84M|      ptr += 4;
  462|  5.84M|    }
  463|  1.02M|  }
  464|  1.02M|  return 1;
  465|  1.02M|}
rdppm-12.c:finish_input_ppm:
  913|  16.3k|{
  914|       |  /* no work */
  915|  16.3k|}

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

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

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

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

z_inflateResetKeep:
  100|   137k|int ZEXPORT inflateResetKeep(z_streamp strm) {
  101|   137k|    struct inflate_state FAR *state;
  102|       |
  103|   137k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (103:9): [True: 0, False: 137k]
  ------------------
  104|   137k|    state = (struct inflate_state FAR *)strm->state;
  105|   137k|    strm->total_in = strm->total_out = state->total = 0;
  106|   137k|    strm->msg = Z_NULL;
  ------------------
  |  |  216|   137k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  107|   137k|    strm->data_type = 0;
  108|   137k|    if (state->wrap)        /* to support ill-conceived Java test suite */
  ------------------
  |  Branch (108:9): [True: 137k, False: 0]
  ------------------
  109|   137k|        strm->adler = state->wrap & 1;
  110|   137k|    state->mode = HEAD;
  111|   137k|    state->last = 0;
  112|   137k|    state->havedict = 0;
  113|   137k|    state->flags = -1;
  114|   137k|    state->dmax = 32768U;
  115|   137k|    state->head = Z_NULL;
  ------------------
  |  |  216|   137k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  116|   137k|    state->hold = 0;
  117|   137k|    state->bits = 0;
  118|   137k|    state->lencode = state->distcode = state->next = state->codes;
  119|   137k|    state->sane = 1;
  120|   137k|    state->back = -1;
  121|   137k|    Tracev((stderr, "inflate: reset\n"));
  122|   137k|    return Z_OK;
  ------------------
  |  |  181|   137k|#define Z_OK            0
  ------------------
  123|   137k|}
z_inflateReset:
  125|   137k|int ZEXPORT inflateReset(z_streamp strm) {
  126|   137k|    struct inflate_state FAR *state;
  127|       |
  128|   137k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (128:9): [True: 0, False: 137k]
  ------------------
  129|   137k|    state = (struct inflate_state FAR *)strm->state;
  130|   137k|    state->wsize = 0;
  131|   137k|    state->whave = 0;
  132|   137k|    state->wnext = 0;
  133|   137k|    return inflateResetKeep(strm);
  ------------------
  |  |  132|   137k|#  define inflateResetKeep      z_inflateResetKeep
  ------------------
  134|   137k|}
z_inflateReset2:
  136|   137k|int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
  137|   137k|    int wrap;
  138|   137k|    struct inflate_state FAR *state;
  139|       |
  140|       |    /* get the state */
  141|   137k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (141:9): [True: 0, False: 137k]
  ------------------
  142|   137k|    state = (struct inflate_state FAR *)strm->state;
  143|       |
  144|       |    /* extract wrap request from windowBits parameter */
  145|   137k|    if (windowBits < 0) {
  ------------------
  |  Branch (145:9): [True: 0, False: 137k]
  ------------------
  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|   137k|    else {
  152|   137k|        wrap = (windowBits >> 4) + 5;
  153|       |#ifdef GUNZIP
  154|       |        if (windowBits < 48)
  155|       |            windowBits &= 15;
  156|       |#endif
  157|   137k|    }
  158|       |
  159|       |    /* set number of window bits, free window if different */
  160|   137k|    if (windowBits && (windowBits < 8 || windowBits > 15))
  ------------------
  |  Branch (160:9): [True: 137k, False: 0]
  |  Branch (160:24): [True: 0, False: 137k]
  |  Branch (160:42): [True: 0, False: 137k]
  ------------------
  161|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  162|   137k|    if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
  ------------------
  |  |  216|   275k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (162:9): [True: 0, False: 137k]
  |  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|   137k|    state->wrap = wrap;
  169|   137k|    state->wbits = (unsigned)windowBits;
  170|   137k|    return inflateReset(strm);
  ------------------
  |  |  130|   137k|#  define inflateReset          z_inflateReset
  ------------------
  171|   137k|}
z_inflateInit2_:
  174|   137k|                          const char *version, int stream_size) {
  175|   137k|    int ret;
  176|   137k|    struct inflate_state FAR *state;
  177|       |
  178|   137k|    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
  ------------------
  |  |  216|   275k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
                  if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
  ------------------
  |  |   44|   137k|#define ZLIB_VERSION "1.3.2"
  ------------------
  |  Branch (178:9): [True: 0, False: 137k]
  |  Branch (178:30): [True: 0, False: 137k]
  ------------------
  179|   137k|        stream_size != (int)(sizeof(z_stream)))
  ------------------
  |  Branch (179:9): [True: 0, False: 137k]
  ------------------
  180|      0|        return Z_VERSION_ERROR;
  ------------------
  |  |  189|      0|#define Z_VERSION_ERROR (-6)
  ------------------
  181|   137k|    if (strm == Z_NULL) return Z_STREAM_ERROR;
  ------------------
  |  |  216|   137k|#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: 137k]
  ------------------
  182|   137k|    strm->msg = Z_NULL;                 /* in case we return an error */
  ------------------
  |  |  216|   137k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  183|   137k|    if (strm->zalloc == (alloc_func)0) {
  ------------------
  |  Branch (183:9): [True: 0, False: 137k]
  ------------------
  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|   137k|    if (strm->zfree == (free_func)0)
  ------------------
  |  Branch (191:9): [True: 0, False: 137k]
  ------------------
  192|       |#ifdef Z_SOLO
  193|       |        return Z_STREAM_ERROR;
  194|       |#else
  195|      0|        strm->zfree = zcfree;
  ------------------
  |  |  151|      0|#    define zcfree                z_zcfree
  ------------------
  196|   137k|#endif
  197|   137k|    state = (struct inflate_state FAR *)
  198|   137k|            ZALLOC(strm, 1, sizeof(struct inflate_state));
  ------------------
  |  |  253|   137k|           (*((strm)->zalloc))((strm)->opaque, (items), (size))
  ------------------
  199|   137k|    if (state == Z_NULL) return Z_MEM_ERROR;
  ------------------
  |  |  216|   137k|#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: 137k]
  ------------------
  200|   137k|    zmemzero(state, sizeof(struct inflate_state));
  ------------------
  |  |  218|   137k|#    define zmemzero(dest, len) memset(dest, 0, len)
  ------------------
  201|   137k|    Tracev((stderr, "inflate: allocated\n"));
  202|   137k|    strm->state = (struct internal_state FAR *)state;
  203|   137k|    state->strm = strm;
  204|   137k|    state->window = Z_NULL;
  ------------------
  |  |  216|   137k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  205|   137k|    state->mode = HEAD;     /* to pass state test in inflateReset2() */
  206|   137k|    ret = inflateReset2(strm, windowBits);
  ------------------
  |  |  131|   137k|#  define inflateReset2         z_inflateReset2
  ------------------
  207|   137k|    if (ret != Z_OK) {
  ------------------
  |  |  181|   137k|#define Z_OK            0
  ------------------
  |  Branch (207:9): [True: 0, False: 137k]
  ------------------
  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|   137k|    return ret;
  212|   137k|}
z_inflate:
  474|   940k|int ZEXPORT inflate(z_streamp strm, int flush) {
  475|   940k|    struct inflate_state FAR *state;
  476|   940k|    z_const unsigned char FAR *next;    /* next input */
  477|   940k|    unsigned char FAR *put;     /* next output */
  478|   940k|    unsigned have, left;        /* available input and output */
  479|   940k|    unsigned long hold;         /* bit buffer */
  480|   940k|    unsigned bits;              /* bits in bit buffer */
  481|   940k|    unsigned in, out;           /* save starting available input and output */
  482|   940k|    unsigned copy;              /* number of stored or match bytes to copy */
  483|   940k|    unsigned char FAR *from;    /* where to copy match bytes from */
  484|   940k|    code here;                  /* current decoding table entry */
  485|   940k|    code last;                  /* parent table entry */
  486|   940k|    unsigned len;               /* length to copy for repeats, bits to drop */
  487|   940k|    int ret;                    /* return code */
  488|       |#ifdef GUNZIP
  489|       |    unsigned char hbuf[4];      /* buffer for gzip header crc calculation */
  490|       |#endif
  491|   940k|    static const unsigned short order[19] = /* permutation of code lengths */
  492|   940k|        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
  493|       |
  494|   940k|    if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
  ------------------
  |  |  216|  1.88M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (494:9): [True: 0, False: 940k]
  |  Branch (494:36): [True: 0, False: 940k]
  ------------------
  495|   940k|        (strm->next_in == Z_NULL && strm->avail_in != 0))
  ------------------
  |  |  216|  1.88M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (495:10): [True: 1.18k, False: 938k]
  |  Branch (495:37): [True: 0, False: 1.18k]
  ------------------
  496|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  497|       |
  498|   940k|    state = (struct inflate_state FAR *)strm->state;
  499|   940k|    if (state->mode == TYPE) state->mode = TYPEDO;      /* skip check */
  ------------------
  |  Branch (499:9): [True: 560, False: 939k]
  ------------------
  500|   940k|    LOAD();
  ------------------
  |  |  329|   940k|    do { \
  |  |  330|   940k|        put = strm->next_out; \
  |  |  331|   940k|        left = strm->avail_out; \
  |  |  332|   940k|        next = strm->next_in; \
  |  |  333|   940k|        have = strm->avail_in; \
  |  |  334|   940k|        hold = state->hold; \
  |  |  335|   940k|        bits = state->bits; \
  |  |  336|   940k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (336:14): [Folded, False: 940k]
  |  |  ------------------
  ------------------
  501|   940k|    in = have;
  502|   940k|    out = left;
  503|   940k|    ret = Z_OK;
  ------------------
  |  |  181|   940k|#define Z_OK            0
  ------------------
  504|   940k|    for (;;)
  505|  4.62M|        switch (state->mode) {
  506|   139k|        case HEAD:
  ------------------
  |  Branch (506:9): [True: 139k, False: 4.48M]
  ------------------
  507|   139k|            if (state->wrap == 0) {
  ------------------
  |  Branch (507:17): [True: 0, False: 139k]
  ------------------
  508|      0|                state->mode = TYPEDO;
  509|      0|                break;
  510|      0|            }
  511|   139k|            NEEDBITS(16);
  ------------------
  |  |  369|   139k|    do { \
  |  |  370|   412k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 276k, False: 136k]
  |  |  ------------------
  |  |  371|   276k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   276k|    do { \
  |  |  |  |  360|   276k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 3.32k, False: 272k]
  |  |  |  |  ------------------
  |  |  |  |  361|   276k|        have--; \
  |  |  |  |  362|   272k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   272k|        bits += 8; \
  |  |  |  |  364|   272k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 272k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   139k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 136k]
  |  |  ------------------
  ------------------
  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|   136k|            if (
  527|   136k|#endif
  528|   136k|                ((BITS(8) << 8) + (hold >> 8)) % 31) {
  ------------------
  |  |  376|   136k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  |  Branch (528:17): [True: 8.98k, False: 127k]
  ------------------
  529|  8.98k|                strm->msg = (z_const char *)"incorrect header check";
  530|  8.98k|                state->mode = BAD;
  531|  8.98k|                break;
  532|  8.98k|            }
  533|   127k|            if (BITS(4) != Z_DEFLATED) {
  ------------------
  |  |  376|   127k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
                          if (BITS(4) != Z_DEFLATED) {
  ------------------
  |  |  213|   127k|#define Z_DEFLATED   8
  ------------------
  |  Branch (533:17): [True: 482, False: 126k]
  ------------------
  534|    482|                strm->msg = (z_const char *)"unknown compression method";
  535|    482|                state->mode = BAD;
  536|    482|                break;
  537|    482|            }
  538|   126k|            DROPBITS(4);
  ------------------
  |  |  380|   126k|    do { \
  |  |  381|   126k|        hold >>= (n); \
  |  |  382|   126k|        bits -= (unsigned)(n); \
  |  |  383|   126k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 126k]
  |  |  ------------------
  ------------------
  539|   126k|            len = BITS(4) + 8;
  ------------------
  |  |  376|   126k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  540|   126k|            if (state->wbits == 0)
  ------------------
  |  Branch (540:17): [True: 0, False: 126k]
  ------------------
  541|      0|                state->wbits = len;
  542|   126k|            if (len > 15 || len > state->wbits) {
  ------------------
  |  Branch (542:17): [True: 77, False: 126k]
  |  Branch (542:29): [True: 0, False: 126k]
  ------------------
  543|     77|                strm->msg = (z_const char *)"invalid window size";
  544|     77|                state->mode = BAD;
  545|     77|                break;
  546|     77|            }
  547|   126k|            state->dmax = 1U << len;
  548|   126k|            state->flags = 0;               /* indicate zlib header */
  549|   126k|            Tracev((stderr, "inflate:   zlib header ok\n"));
  550|   126k|            strm->adler = state->check = adler32(0L, Z_NULL, 0);
  ------------------
  |  |   34|   126k|#  define adler32               z_adler32
  ------------------
                          strm->adler = state->check = adler32(0L, Z_NULL, 0);
  ------------------
  |  |  216|   126k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  551|   126k|            state->mode = hold & 0x200 ? DICTID : TYPE;
  ------------------
  |  Branch (551:27): [True: 170, False: 126k]
  ------------------
  552|   126k|            INITBITS();
  ------------------
  |  |  351|   126k|    do { \
  |  |  352|   126k|        hold = 0; \
  |  |  353|   126k|        bits = 0; \
  |  |  354|   126k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 126k]
  |  |  ------------------
  ------------------
  553|   126k|            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|    230|        case DICTID:
  ------------------
  |  Branch (694:9): [True: 230, False: 4.62M]
  ------------------
  695|    230|            NEEDBITS(32);
  ------------------
  |  |  369|    230|    do { \
  |  |  370|    817|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 685, False: 132]
  |  |  ------------------
  |  |  371|    685|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|    685|    do { \
  |  |  |  |  360|    685|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 98, False: 587]
  |  |  |  |  ------------------
  |  |  |  |  361|    685|        have--; \
  |  |  |  |  362|    587|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|    587|        bits += 8; \
  |  |  |  |  364|    587|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 587]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|    230|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 132]
  |  |  ------------------
  ------------------
  696|    132|            strm->adler = state->check = ZSWAP32(hold);
  ------------------
  |  |  258|    132|#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
  |  |  259|    132|                    (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
  ------------------
  697|    132|            INITBITS();
  ------------------
  |  |  351|    132|    do { \
  |  |  352|    132|        hold = 0; \
  |  |  353|    132|        bits = 0; \
  |  |  354|    132|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 132]
  |  |  ------------------
  ------------------
  698|    132|            state->mode = DICT;
  699|       |                /* fallthrough */
  700|    132|        case DICT:
  ------------------
  |  Branch (700:9): [True: 0, False: 4.62M]
  ------------------
  701|    132|            if (state->havedict == 0) {
  ------------------
  |  Branch (701:17): [True: 132, False: 0]
  ------------------
  702|    132|                RESTORE();
  ------------------
  |  |  340|    132|    do { \
  |  |  341|    132|        strm->next_out = put; \
  |  |  342|    132|        strm->avail_out = left; \
  |  |  343|    132|        strm->next_in = next; \
  |  |  344|    132|        strm->avail_in = have; \
  |  |  345|    132|        state->hold = hold; \
  |  |  346|    132|        state->bits = bits; \
  |  |  347|    132|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 132]
  |  |  ------------------
  ------------------
  703|    132|                return Z_NEED_DICT;
  ------------------
  |  |  183|    132|#define Z_NEED_DICT     2
  ------------------
  704|    132|            }
  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|   221k|        case TYPE:
  ------------------
  |  Branch (708:9): [True: 221k, False: 4.40M]
  ------------------
  709|   221k|            if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  177|   443k|#define Z_BLOCK         5
  ------------------
                          if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|   221k|#define Z_TREES         6
  ------------------
  |  Branch (709:17): [True: 0, False: 221k]
  |  Branch (709:37): [True: 0, False: 221k]
  ------------------
  710|       |                /* fallthrough */
  711|   222k|        case TYPEDO:
  ------------------
  |  Branch (711:9): [True: 1.09k, False: 4.62M]
  ------------------
  712|   222k|            if (state->last) {
  ------------------
  |  Branch (712:17): [True: 86.6k, False: 136k]
  ------------------
  713|  86.6k|                BYTEBITS();
  ------------------
  |  |  387|  86.6k|    do { \
  |  |  388|  86.6k|        hold >>= bits & 7; \
  |  |  389|  86.6k|        bits -= bits & 7; \
  |  |  390|  86.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (390:14): [Folded, False: 86.6k]
  |  |  ------------------
  ------------------
  714|  86.6k|                state->mode = CHECK;
  715|  86.6k|                break;
  716|  86.6k|            }
  717|   136k|            NEEDBITS(3);
  ------------------
  |  |  369|   136k|    do { \
  |  |  370|   263k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 128k, False: 135k]
  |  |  ------------------
  |  |  371|   136k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   128k|    do { \
  |  |  |  |  360|   128k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.13k, False: 127k]
  |  |  |  |  ------------------
  |  |  |  |  361|   128k|        have--; \
  |  |  |  |  362|   127k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   127k|        bits += 8; \
  |  |  |  |  364|   127k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 127k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   136k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 135k]
  |  |  ------------------
  ------------------
  718|   135k|            state->last = BITS(1);
  ------------------
  |  |  376|   135k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  719|   135k|            DROPBITS(1);
  ------------------
  |  |  380|   135k|    do { \
  |  |  381|   135k|        hold >>= (n); \
  |  |  382|   135k|        bits -= (unsigned)(n); \
  |  |  383|   135k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 135k]
  |  |  ------------------
  ------------------
  720|   135k|            switch (BITS(2)) {
  ------------------
  |  |  376|   135k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  721|  8.11k|            case 0:                             /* stored block */
  ------------------
  |  Branch (721:13): [True: 8.11k, False: 126k]
  ------------------
  722|  8.11k|                Tracev((stderr, "inflate:     stored block%s\n",
  723|  8.11k|                        state->last ? " (last)" : ""));
  724|  8.11k|                state->mode = STORED;
  725|  8.11k|                break;
  726|   104k|            case 1:                             /* fixed block */
  ------------------
  |  Branch (726:13): [True: 104k, False: 30.7k]
  ------------------
  727|   104k|                inflate_fixed(state);
  ------------------
  |  |  141|   104k|#  define inflate_fixed         z_inflate_fixed
  ------------------
  728|   104k|                Tracev((stderr, "inflate:     fixed codes block%s\n",
  729|   104k|                        state->last ? " (last)" : ""));
  730|   104k|                state->mode = LEN_;             /* decode codes */
  731|   104k|                if (flush == Z_TREES) {
  ------------------
  |  |  178|   104k|#define Z_TREES         6
  ------------------
  |  Branch (731:21): [True: 0, False: 104k]
  ------------------
  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|   104k|                break;
  736|   104k|            case 2:                             /* dynamic block */
  ------------------
  |  Branch (736:13): [True: 22.0k, False: 112k]
  ------------------
  737|  22.0k|                Tracev((stderr, "inflate:     dynamic codes block%s\n",
  738|  22.0k|                        state->last ? " (last)" : ""));
  739|  22.0k|                state->mode = TABLE;
  740|  22.0k|                break;
  741|    572|            default:
  ------------------
  |  Branch (741:13): [True: 572, False: 134k]
  ------------------
  742|    572|                strm->msg = (z_const char *)"invalid block type";
  743|    572|                state->mode = BAD;
  744|   135k|            }
  745|   135k|            DROPBITS(2);
  ------------------
  |  |  380|   135k|    do { \
  |  |  381|   135k|        hold >>= (n); \
  |  |  382|   135k|        bits -= (unsigned)(n); \
  |  |  383|   135k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 135k]
  |  |  ------------------
  ------------------
  746|   135k|            break;
  747|  8.19k|        case STORED:
  ------------------
  |  Branch (747:9): [True: 8.19k, False: 4.61M]
  ------------------
  748|  8.19k|            BYTEBITS();                         /* go to byte boundary */
  ------------------
  |  |  387|  8.19k|    do { \
  |  |  388|  8.19k|        hold >>= bits & 7; \
  |  |  389|  8.19k|        bits -= bits & 7; \
  |  |  390|  8.19k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (390:14): [Folded, False: 8.19k]
  |  |  ------------------
  ------------------
  749|  8.19k|            NEEDBITS(32);
  ------------------
  |  |  369|  8.19k|    do { \
  |  |  370|  40.2k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 32.3k, False: 7.97k]
  |  |  ------------------
  |  |  371|  32.3k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  32.3k|    do { \
  |  |  |  |  360|  32.3k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 217, False: 32.0k]
  |  |  |  |  ------------------
  |  |  |  |  361|  32.3k|        have--; \
  |  |  |  |  362|  32.0k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  32.0k|        bits += 8; \
  |  |  |  |  364|  32.0k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 32.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  8.19k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 7.97k]
  |  |  ------------------
  ------------------
  750|  7.97k|            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
  ------------------
  |  Branch (750:17): [True: 6.87k, False: 1.10k]
  ------------------
  751|  6.87k|                strm->msg = (z_const char *)"invalid stored block lengths";
  752|  6.87k|                state->mode = BAD;
  753|  6.87k|                break;
  754|  6.87k|            }
  755|  1.10k|            state->length = (unsigned)hold & 0xffff;
  756|  1.10k|            Tracev((stderr, "inflate:       stored length %u\n",
  757|  1.10k|                    state->length));
  758|  1.10k|            INITBITS();
  ------------------
  |  |  351|  1.10k|    do { \
  |  |  352|  1.10k|        hold = 0; \
  |  |  353|  1.10k|        bits = 0; \
  |  |  354|  1.10k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 1.10k]
  |  |  ------------------
  ------------------
  759|  1.10k|            state->mode = COPY_;
  760|  1.10k|            if (flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|  1.10k|#define Z_TREES         6
  ------------------
  |  Branch (760:17): [True: 0, False: 1.10k]
  ------------------
  761|       |                /* fallthrough */
  762|  1.10k|        case COPY_:
  ------------------
  |  Branch (762:9): [True: 0, False: 4.62M]
  ------------------
  763|  1.10k|            state->mode = COPY;
  764|       |                /* fallthrough */
  765|  24.0k|        case COPY:
  ------------------
  |  Branch (765:9): [True: 22.9k, False: 4.60M]
  ------------------
  766|  24.0k|            copy = state->length;
  767|  24.0k|            if (copy) {
  ------------------
  |  Branch (767:17): [True: 23.3k, False: 698]
  ------------------
  768|  23.3k|                if (copy > have) copy = have;
  ------------------
  |  Branch (768:21): [True: 22.2k, False: 1.08k]
  ------------------
  769|  23.3k|                if (copy > left) copy = left;
  ------------------
  |  Branch (769:21): [True: 21.4k, False: 1.90k]
  ------------------
  770|  23.3k|                if (copy == 0) goto inf_leave;
  ------------------
  |  Branch (770:21): [True: 11.7k, False: 11.6k]
  ------------------
  771|  11.6k|                zmemcpy(put, next, copy);
  ------------------
  |  |  216|  11.6k|#    define zmemcpy memcpy
  ------------------
  772|  11.6k|                have -= copy;
  773|  11.6k|                next += copy;
  774|  11.6k|                left -= copy;
  775|  11.6k|                put += copy;
  776|  11.6k|                state->length -= copy;
  777|  11.6k|                break;
  778|  23.3k|            }
  779|    698|            Tracev((stderr, "inflate:       stored end\n"));
  780|    698|            state->mode = TYPE;
  781|    698|            break;
  782|  24.0k|        case TABLE:
  ------------------
  |  Branch (782:9): [True: 24.0k, False: 4.60M]
  ------------------
  783|  24.0k|            NEEDBITS(14);
  ------------------
  |  |  369|  24.0k|    do { \
  |  |  370|  68.1k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 46.0k, False: 22.0k]
  |  |  ------------------
  |  |  371|  46.0k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  46.0k|    do { \
  |  |  |  |  360|  46.0k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 2.00k, False: 44.0k]
  |  |  |  |  ------------------
  |  |  |  |  361|  46.0k|        have--; \
  |  |  |  |  362|  44.0k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  44.0k|        bits += 8; \
  |  |  |  |  364|  44.0k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 44.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  24.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 22.0k]
  |  |  ------------------
  ------------------
  784|  22.0k|            state->nlen = BITS(5) + 257;
  ------------------
  |  |  376|  22.0k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  785|  22.0k|            DROPBITS(5);
  ------------------
  |  |  380|  22.0k|    do { \
  |  |  381|  22.0k|        hold >>= (n); \
  |  |  382|  22.0k|        bits -= (unsigned)(n); \
  |  |  383|  22.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 22.0k]
  |  |  ------------------
  ------------------
  786|  22.0k|            state->ndist = BITS(5) + 1;
  ------------------
  |  |  376|  22.0k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  787|  22.0k|            DROPBITS(5);
  ------------------
  |  |  380|  22.0k|    do { \
  |  |  381|  22.0k|        hold >>= (n); \
  |  |  382|  22.0k|        bits -= (unsigned)(n); \
  |  |  383|  22.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 22.0k]
  |  |  ------------------
  ------------------
  788|  22.0k|            state->ncode = BITS(4) + 4;
  ------------------
  |  |  376|  22.0k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  789|  22.0k|            DROPBITS(4);
  ------------------
  |  |  380|  22.0k|    do { \
  |  |  381|  22.0k|        hold >>= (n); \
  |  |  382|  22.0k|        bits -= (unsigned)(n); \
  |  |  383|  22.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 22.0k]
  |  |  ------------------
  ------------------
  790|  22.0k|#ifndef PKZIP_BUG_WORKAROUND
  791|  22.0k|            if (state->nlen > 286 || state->ndist > 30) {
  ------------------
  |  Branch (791:17): [True: 26, False: 22.0k]
  |  Branch (791:38): [True: 1.25k, False: 20.7k]
  ------------------
  792|  1.27k|                strm->msg = (z_const char *)
  793|  1.27k|                    "too many length or distance symbols";
  794|  1.27k|                state->mode = BAD;
  795|  1.27k|                break;
  796|  1.27k|            }
  797|  20.7k|#endif
  798|  20.7k|            Tracev((stderr, "inflate:       table sizes ok\n"));
  799|  20.7k|            state->have = 0;
  800|  20.7k|            state->mode = LENLENS;
  801|       |                /* fallthrough */
  802|  25.6k|        case LENLENS:
  ------------------
  |  Branch (802:9): [True: 4.84k, False: 4.62M]
  ------------------
  803|   319k|            while (state->have < state->ncode) {
  ------------------
  |  Branch (803:20): [True: 298k, False: 20.6k]
  ------------------
  804|   298k|                NEEDBITS(3);
  ------------------
  |  |  369|   298k|    do { \
  |  |  370|   396k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 102k, False: 294k]
  |  |  ------------------
  |  |  371|   298k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   102k|    do { \
  |  |  |  |  360|   102k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 4.96k, False: 97.7k]
  |  |  |  |  ------------------
  |  |  |  |  361|   102k|        have--; \
  |  |  |  |  362|  97.7k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  97.7k|        bits += 8; \
  |  |  |  |  364|  97.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 97.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   298k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 294k]
  |  |  ------------------
  ------------------
  805|   294k|                state->lens[order[state->have++]] = (unsigned short)BITS(3);
  ------------------
  |  |  376|   294k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  806|   294k|                DROPBITS(3);
  ------------------
  |  |  380|   294k|    do { \
  |  |  381|   294k|        hold >>= (n); \
  |  |  382|   294k|        bits -= (unsigned)(n); \
  |  |  383|   294k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 294k]
  |  |  ------------------
  ------------------
  807|   294k|            }
  808|   119k|            while (state->have < 19)
  ------------------
  |  Branch (808:20): [True: 98.9k, False: 20.6k]
  ------------------
  809|  98.9k|                state->lens[order[state->have++]] = 0;
  810|  20.6k|            state->next = state->codes;
  811|  20.6k|            state->lencode = state->distcode = (const code FAR *)(state->next);
  812|  20.6k|            state->lenbits = 7;
  813|  20.6k|            ret = inflate_table(CODES, state->lens, 19, &(state->next),
  ------------------
  |  |  140|  20.6k|#  define inflate_table         z_inflate_table
  ------------------
  814|  20.6k|                                &(state->lenbits), state->work);
  815|  20.6k|            if (ret) {
  ------------------
  |  Branch (815:17): [True: 2.65k, False: 17.9k]
  ------------------
  816|  2.65k|                strm->msg = (z_const char *)"invalid code lengths set";
  817|  2.65k|                state->mode = BAD;
  818|  2.65k|                break;
  819|  2.65k|            }
  820|  17.9k|            Tracev((stderr, "inflate:       code lengths ok\n"));
  821|  17.9k|            state->have = 0;
  822|  17.9k|            state->mode = CODELENS;
  823|       |                /* fallthrough */
  824|  33.2k|        case CODELENS:
  ------------------
  |  Branch (824:9): [True: 15.3k, False: 4.61M]
  ------------------
  825|  1.21M|            while (state->have < state->nlen + state->ndist) {
  ------------------
  |  Branch (825:20): [True: 1.19M, False: 13.6k]
  ------------------
  826|  1.56M|                for (;;) {
  827|  1.56M|                    here = state->lencode[BITS(state->lenbits)];
  ------------------
  |  |  376|  1.56M|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  828|  1.56M|                    if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (828:25): [True: 1.18M, False: 378k]
  ------------------
  829|   378k|                    PULLBYTE();
  ------------------
  |  |  359|   378k|    do { \
  |  |  360|   378k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 11.7k, False: 367k]
  |  |  ------------------
  |  |  361|   378k|        have--; \
  |  |  362|   367k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|   367k|        bits += 8; \
  |  |  364|   367k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 367k]
  |  |  ------------------
  ------------------
  830|   378k|                }
  831|  1.18M|                if (here.val < 16) {
  ------------------
  |  Branch (831:21): [True: 1.03M, False: 147k]
  ------------------
  832|  1.03M|                    DROPBITS(here.bits);
  ------------------
  |  |  380|  1.03M|    do { \
  |  |  381|  1.03M|        hold >>= (n); \
  |  |  382|  1.03M|        bits -= (unsigned)(n); \
  |  |  383|  1.03M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 1.03M]
  |  |  ------------------
  ------------------
  833|  1.03M|                    state->lens[state->have++] = here.val;
  834|  1.03M|                }
  835|   147k|                else {
  836|   147k|                    if (here.val == 16) {
  ------------------
  |  Branch (836:25): [True: 49.7k, False: 98.2k]
  ------------------
  837|  49.7k|                        NEEDBITS(here.bits + 2);
  ------------------
  |  |  369|  49.7k|    do { \
  |  |  370|  65.0k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 16.8k, False: 48.1k]
  |  |  ------------------
  |  |  371|  49.7k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  16.8k|    do { \
  |  |  |  |  360|  16.8k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.51k, False: 15.3k]
  |  |  |  |  ------------------
  |  |  |  |  361|  16.8k|        have--; \
  |  |  |  |  362|  15.3k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  15.3k|        bits += 8; \
  |  |  |  |  364|  15.3k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 15.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  49.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 48.1k]
  |  |  ------------------
  ------------------
  838|  48.1k|                        DROPBITS(here.bits);
  ------------------
  |  |  380|  48.1k|    do { \
  |  |  381|  48.1k|        hold >>= (n); \
  |  |  382|  48.1k|        bits -= (unsigned)(n); \
  |  |  383|  48.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 48.1k]
  |  |  ------------------
  ------------------
  839|  48.1k|                        if (state->have == 0) {
  ------------------
  |  Branch (839:29): [True: 49, False: 48.1k]
  ------------------
  840|     49|                            strm->msg = (z_const char *)
  841|     49|                                "invalid bit length repeat";
  842|     49|                            state->mode = BAD;
  843|     49|                            break;
  844|     49|                        }
  845|  48.1k|                        len = state->lens[state->have - 1];
  846|  48.1k|                        copy = 3 + BITS(2);
  ------------------
  |  |  376|  48.1k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  847|  48.1k|                        DROPBITS(2);
  ------------------
  |  |  380|  48.1k|    do { \
  |  |  381|  48.1k|        hold >>= (n); \
  |  |  382|  48.1k|        bits -= (unsigned)(n); \
  |  |  383|  48.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 48.1k]
  |  |  ------------------
  ------------------
  848|  48.1k|                    }
  849|  98.2k|                    else if (here.val == 17) {
  ------------------
  |  Branch (849:30): [True: 33.7k, False: 64.4k]
  ------------------
  850|  33.7k|                        NEEDBITS(here.bits + 3);
  ------------------
  |  |  369|  33.7k|    do { \
  |  |  370|  51.0k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 18.3k, False: 32.7k]
  |  |  ------------------
  |  |  371|  33.7k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  18.3k|    do { \
  |  |  |  |  360|  18.3k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.02k, False: 17.2k]
  |  |  |  |  ------------------
  |  |  |  |  361|  18.3k|        have--; \
  |  |  |  |  362|  17.2k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  17.2k|        bits += 8; \
  |  |  |  |  364|  17.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 17.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  33.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 32.7k]
  |  |  ------------------
  ------------------
  851|  32.7k|                        DROPBITS(here.bits);
  ------------------
  |  |  380|  32.7k|    do { \
  |  |  381|  32.7k|        hold >>= (n); \
  |  |  382|  32.7k|        bits -= (unsigned)(n); \
  |  |  383|  32.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 32.7k]
  |  |  ------------------
  ------------------
  852|  32.7k|                        len = 0;
  853|  32.7k|                        copy = 3 + BITS(3);
  ------------------
  |  |  376|  32.7k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  854|  32.7k|                        DROPBITS(3);
  ------------------
  |  |  380|  32.7k|    do { \
  |  |  381|  32.7k|        hold >>= (n); \
  |  |  382|  32.7k|        bits -= (unsigned)(n); \
  |  |  383|  32.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 32.7k]
  |  |  ------------------
  ------------------
  855|  32.7k|                    }
  856|  64.4k|                    else {
  857|  64.4k|                        NEEDBITS(here.bits + 7);
  ------------------
  |  |  369|  64.4k|    do { \
  |  |  370|   117k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 54.8k, False: 62.6k]
  |  |  ------------------
  |  |  371|  64.4k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  54.8k|    do { \
  |  |  |  |  360|  54.8k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.80k, False: 53.0k]
  |  |  |  |  ------------------
  |  |  |  |  361|  54.8k|        have--; \
  |  |  |  |  362|  53.0k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  53.0k|        bits += 8; \
  |  |  |  |  364|  53.0k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 53.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  64.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 62.6k]
  |  |  ------------------
  ------------------
  858|  62.6k|                        DROPBITS(here.bits);
  ------------------
  |  |  380|  62.6k|    do { \
  |  |  381|  62.6k|        hold >>= (n); \
  |  |  382|  62.6k|        bits -= (unsigned)(n); \
  |  |  383|  62.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 62.6k]
  |  |  ------------------
  ------------------
  859|  62.6k|                        len = 0;
  860|  62.6k|                        copy = 11 + BITS(7);
  ------------------
  |  |  376|  62.6k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  861|  62.6k|                        DROPBITS(7);
  ------------------
  |  |  380|  62.6k|    do { \
  |  |  381|  62.6k|        hold >>= (n); \
  |  |  382|  62.6k|        bits -= (unsigned)(n); \
  |  |  383|  62.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 62.6k]
  |  |  ------------------
  ------------------
  862|  62.6k|                    }
  863|   143k|                    if (state->have + copy > state->nlen + state->ndist) {
  ------------------
  |  Branch (863:25): [True: 3.46k, False: 140k]
  ------------------
  864|  3.46k|                        strm->msg = (z_const char *)
  865|  3.46k|                            "invalid bit length repeat";
  866|  3.46k|                        state->mode = BAD;
  867|  3.46k|                        break;
  868|  3.46k|                    }
  869|  4.25M|                    while (copy--)
  ------------------
  |  Branch (869:28): [True: 4.11M, False: 140k]
  ------------------
  870|  4.11M|                        state->lens[state->have++] = (unsigned short)len;
  871|   140k|                }
  872|  1.18M|            }
  873|       |
  874|       |            /* handle error breaks in while */
  875|  17.2k|            if (state->mode == BAD) break;
  ------------------
  |  Branch (875:17): [True: 3.51k, False: 13.6k]
  ------------------
  876|       |
  877|       |            /* check for end-of-block code (better have one) */
  878|  13.6k|            if (state->lens[256] == 0) {
  ------------------
  |  Branch (878:17): [True: 186, False: 13.5k]
  ------------------
  879|    186|                strm->msg = (z_const char *)
  880|    186|                    "invalid code -- missing end-of-block";
  881|    186|                state->mode = BAD;
  882|    186|                break;
  883|    186|            }
  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|  13.5k|            state->next = state->codes;
  889|  13.5k|            state->lencode = (const code FAR *)(state->next);
  890|  13.5k|            state->lenbits = 9;
  891|  13.5k|            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
  ------------------
  |  |  140|  13.5k|#  define inflate_table         z_inflate_table
  ------------------
  892|  13.5k|                                &(state->lenbits), state->work);
  893|  13.5k|            if (ret) {
  ------------------
  |  Branch (893:17): [True: 1.19k, False: 12.3k]
  ------------------
  894|  1.19k|                strm->msg = (z_const char *)"invalid literal/lengths set";
  895|  1.19k|                state->mode = BAD;
  896|  1.19k|                break;
  897|  1.19k|            }
  898|  12.3k|            state->distcode = (const code FAR *)(state->next);
  899|  12.3k|            state->distbits = 6;
  900|  12.3k|            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
  ------------------
  |  |  140|  12.3k|#  define inflate_table         z_inflate_table
  ------------------
  901|  12.3k|                            &(state->next), &(state->distbits), state->work);
  902|  12.3k|            if (ret) {
  ------------------
  |  Branch (902:17): [True: 455, False: 11.8k]
  ------------------
  903|    455|                strm->msg = (z_const char *)"invalid distances set";
  904|    455|                state->mode = BAD;
  905|    455|                break;
  906|    455|            }
  907|  11.8k|            Tracev((stderr, "inflate:       codes ok\n"));
  908|  11.8k|            state->mode = LEN_;
  909|  11.8k|            if (flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|  11.8k|#define Z_TREES         6
  ------------------
  |  Branch (909:17): [True: 0, False: 11.8k]
  ------------------
  910|       |                /* fallthrough */
  911|   116k|        case LEN_:
  ------------------
  |  Branch (911:9): [True: 104k, False: 4.52M]
  ------------------
  912|   116k|            state->mode = LEN;
  913|       |                /* fallthrough */
  914|  1.60M|        case LEN:
  ------------------
  |  Branch (914:9): [True: 1.48M, False: 3.13M]
  ------------------
  915|  1.60M|            if (have >= 6 && left >= 258) {
  ------------------
  |  Branch (915:17): [True: 1.30M, False: 298k]
  |  Branch (915:30): [True: 404k, False: 899k]
  ------------------
  916|   404k|                RESTORE();
  ------------------
  |  |  340|   404k|    do { \
  |  |  341|   404k|        strm->next_out = put; \
  |  |  342|   404k|        strm->avail_out = left; \
  |  |  343|   404k|        strm->next_in = next; \
  |  |  344|   404k|        strm->avail_in = have; \
  |  |  345|   404k|        state->hold = hold; \
  |  |  346|   404k|        state->bits = bits; \
  |  |  347|   404k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 404k]
  |  |  ------------------
  ------------------
  917|   404k|                inflate_fast(strm, out);
  ------------------
  |  |  139|   404k|#  define inflate_fast          z_inflate_fast
  ------------------
  918|   404k|                LOAD();
  ------------------
  |  |  329|   404k|    do { \
  |  |  330|   404k|        put = strm->next_out; \
  |  |  331|   404k|        left = strm->avail_out; \
  |  |  332|   404k|        next = strm->next_in; \
  |  |  333|   404k|        have = strm->avail_in; \
  |  |  334|   404k|        hold = state->hold; \
  |  |  335|   404k|        bits = state->bits; \
  |  |  336|   404k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (336:14): [Folded, False: 404k]
  |  |  ------------------
  ------------------
  919|   404k|                if (state->mode == TYPE)
  ------------------
  |  Branch (919:21): [True: 92.2k, False: 311k]
  ------------------
  920|  92.2k|                    state->back = -1;
  921|   404k|                break;
  922|   404k|            }
  923|  1.19M|            state->back = 0;
  924|  1.62M|            for (;;) {
  925|  1.62M|                here = state->lencode[BITS(state->lenbits)];
  ------------------
  |  |  376|  1.62M|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  926|  1.62M|                if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (926:21): [True: 1.18M, False: 448k]
  ------------------
  927|   448k|                PULLBYTE();
  ------------------
  |  |  359|   448k|    do { \
  |  |  360|   448k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 17.2k, False: 431k]
  |  |  ------------------
  |  |  361|   448k|        have--; \
  |  |  362|   431k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|   431k|        bits += 8; \
  |  |  364|   431k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 431k]
  |  |  ------------------
  ------------------
  928|   448k|            }
  929|  1.18M|            if (here.op && (here.op & 0xf0) == 0) {
  ------------------
  |  Branch (929:17): [True: 829k, False: 351k]
  |  Branch (929:28): [True: 23.2k, False: 806k]
  ------------------
  930|  23.2k|                last = here;
  931|  28.0k|                for (;;) {
  932|  28.0k|                    here = state->lencode[last.val +
  933|  28.0k|                            (BITS(last.bits + last.op) >> last.bits)];
  ------------------
  |  |  376|  28.0k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  934|  28.0k|                    if ((unsigned)(last.bits + here.bits) <= bits) break;
  ------------------
  |  Branch (934:25): [True: 22.9k, False: 5.15k]
  ------------------
  935|  5.15k|                    PULLBYTE();
  ------------------
  |  |  359|  5.15k|    do { \
  |  |  360|  5.15k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 301, False: 4.85k]
  |  |  ------------------
  |  |  361|  5.15k|        have--; \
  |  |  362|  4.85k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|  4.85k|        bits += 8; \
  |  |  364|  4.85k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 4.85k]
  |  |  ------------------
  ------------------
  936|  5.15k|                }
  937|  22.9k|                DROPBITS(last.bits);
  ------------------
  |  |  380|  22.9k|    do { \
  |  |  381|  22.9k|        hold >>= (n); \
  |  |  382|  22.9k|        bits -= (unsigned)(n); \
  |  |  383|  22.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 22.9k]
  |  |  ------------------
  ------------------
  938|  22.9k|                state->back += last.bits;
  939|  22.9k|            }
  940|  1.18M|            DROPBITS(here.bits);
  ------------------
  |  |  380|  1.18M|    do { \
  |  |  381|  1.18M|        hold >>= (n); \
  |  |  382|  1.18M|        bits -= (unsigned)(n); \
  |  |  383|  1.18M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 1.18M]
  |  |  ------------------
  ------------------
  941|  1.18M|            state->back += here.bits;
  942|  1.18M|            state->length = (unsigned)here.val;
  943|  1.18M|            if ((int)(here.op) == 0) {
  ------------------
  |  Branch (943:17): [True: 361k, False: 819k]
  ------------------
  944|   361k|                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
  945|   361k|                        "inflate:         literal '%c'\n" :
  946|   361k|                        "inflate:         literal 0x%02x\n", here.val));
  947|   361k|                state->mode = LIT;
  948|   361k|                break;
  949|   361k|            }
  950|   819k|            if (here.op & 32) {
  ------------------
  |  Branch (950:17): [True: 2.42k, False: 816k]
  ------------------
  951|  2.42k|                Tracevv((stderr, "inflate:         end of block\n"));
  952|  2.42k|                state->back = -1;
  953|  2.42k|                state->mode = TYPE;
  954|  2.42k|                break;
  955|  2.42k|            }
  956|   816k|            if (here.op & 64) {
  ------------------
  |  Branch (956:17): [True: 91, False: 816k]
  ------------------
  957|     91|                strm->msg = (z_const char *)"invalid literal/length code";
  958|     91|                state->mode = BAD;
  959|     91|                break;
  960|     91|            }
  961|   816k|            state->extra = (unsigned)(here.op) & 15;
  962|   816k|            state->mode = LENEXT;
  963|       |                /* fallthrough */
  964|   820k|        case LENEXT:
  ------------------
  |  Branch (964:9): [True: 3.92k, False: 4.62M]
  ------------------
  965|   820k|            if (state->extra) {
  ------------------
  |  Branch (965:17): [True: 121k, False: 698k]
  ------------------
  966|   121k|                NEEDBITS(state->extra);
  ------------------
  |  |  369|   121k|    do { \
  |  |  370|   170k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 52.3k, False: 117k]
  |  |  ------------------
  |  |  371|   121k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  52.3k|    do { \
  |  |  |  |  360|  52.3k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 4.25k, False: 48.1k]
  |  |  |  |  ------------------
  |  |  |  |  361|  52.3k|        have--; \
  |  |  |  |  362|  48.1k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  48.1k|        bits += 8; \
  |  |  |  |  364|  48.1k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 48.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   121k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 117k]
  |  |  ------------------
  ------------------
  967|   117k|                state->length += BITS(state->extra);
  ------------------
  |  |  376|   117k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  968|   117k|                DROPBITS(state->extra);
  ------------------
  |  |  380|   117k|    do { \
  |  |  381|   117k|        hold >>= (n); \
  |  |  382|   117k|        bits -= (unsigned)(n); \
  |  |  383|   117k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 117k]
  |  |  ------------------
  ------------------
  969|   117k|                state->back += state->extra;
  970|   117k|            }
  971|   816k|            Tracevv((stderr, "inflate:         length %u\n", state->length));
  972|   816k|            state->was = state->length;
  973|   816k|            state->mode = DIST;
  974|       |                /* fallthrough */
  975|   826k|        case DIST:
  ------------------
  |  Branch (975:9): [True: 9.69k, False: 4.61M]
  ------------------
  976|  1.00M|            for (;;) {
  977|  1.00M|                here = state->distcode[BITS(state->distbits)];
  ------------------
  |  |  376|  1.00M|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  978|  1.00M|                if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (978:21): [True: 805k, False: 195k]
  ------------------
  979|   195k|                PULLBYTE();
  ------------------
  |  |  359|   195k|    do { \
  |  |  360|   195k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 20.6k, False: 175k]
  |  |  ------------------
  |  |  361|   195k|        have--; \
  |  |  362|   175k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|   175k|        bits += 8; \
  |  |  364|   175k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 175k]
  |  |  ------------------
  ------------------
  980|   195k|            }
  981|   805k|            if ((here.op & 0xf0) == 0) {
  ------------------
  |  Branch (981:17): [True: 36.2k, False: 769k]
  ------------------
  982|  36.2k|                last = here;
  983|  51.8k|                for (;;) {
  984|  51.8k|                    here = state->distcode[last.val +
  985|  51.8k|                            (BITS(last.bits + last.op) >> last.bits)];
  ------------------
  |  |  376|  51.8k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  986|  51.8k|                    if ((unsigned)(last.bits + here.bits) <= bits) break;
  ------------------
  |  Branch (986:25): [True: 35.4k, False: 16.4k]
  ------------------
  987|  16.4k|                    PULLBYTE();
  ------------------
  |  |  359|  16.4k|    do { \
  |  |  360|  16.4k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 802, False: 15.6k]
  |  |  ------------------
  |  |  361|  16.4k|        have--; \
  |  |  362|  15.6k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|  15.6k|        bits += 8; \
  |  |  364|  15.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
  988|  16.4k|                }
  989|  35.4k|                DROPBITS(last.bits);
  ------------------
  |  |  380|  35.4k|    do { \
  |  |  381|  35.4k|        hold >>= (n); \
  |  |  382|  35.4k|        bits -= (unsigned)(n); \
  |  |  383|  35.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 35.4k]
  |  |  ------------------
  ------------------
  990|  35.4k|                state->back += last.bits;
  991|  35.4k|            }
  992|   804k|            DROPBITS(here.bits);
  ------------------
  |  |  380|   804k|    do { \
  |  |  381|   804k|        hold >>= (n); \
  |  |  382|   804k|        bits -= (unsigned)(n); \
  |  |  383|   804k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 804k]
  |  |  ------------------
  ------------------
  993|   804k|            state->back += here.bits;
  994|   804k|            if (here.op & 64) {
  ------------------
  |  Branch (994:17): [True: 132, False: 804k]
  ------------------
  995|    132|                strm->msg = (z_const char *)"invalid distance code";
  996|    132|                state->mode = BAD;
  997|    132|                break;
  998|    132|            }
  999|   804k|            state->offset = (unsigned)here.val;
 1000|   804k|            state->extra = (unsigned)(here.op) & 15;
 1001|   804k|            state->mode = DISTEXT;
 1002|       |                /* fallthrough */
 1003|   810k|        case DISTEXT:
  ------------------
  |  Branch (1003:9): [True: 5.87k, False: 4.61M]
  ------------------
 1004|   810k|            if (state->extra) {
  ------------------
  |  Branch (1004:17): [True: 163k, False: 646k]
  ------------------
 1005|   163k|                NEEDBITS(state->extra);
  ------------------
  |  |  369|   163k|    do { \
  |  |  370|   305k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 148k, False: 157k]
  |  |  ------------------
  |  |  371|   163k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   148k|    do { \
  |  |  |  |  360|   148k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 6.69k, False: 141k]
  |  |  |  |  ------------------
  |  |  |  |  361|   148k|        have--; \
  |  |  |  |  362|   141k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   141k|        bits += 8; \
  |  |  |  |  364|   141k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 141k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   163k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 157k]
  |  |  ------------------
  ------------------
 1006|   157k|                state->offset += BITS(state->extra);
  ------------------
  |  |  376|   157k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
 1007|   157k|                DROPBITS(state->extra);
  ------------------
  |  |  380|   157k|    do { \
  |  |  381|   157k|        hold >>= (n); \
  |  |  382|   157k|        bits -= (unsigned)(n); \
  |  |  383|   157k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 157k]
  |  |  ------------------
  ------------------
 1008|   157k|                state->back += state->extra;
 1009|   157k|            }
 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|   803k|            Tracevv((stderr, "inflate:         distance %u\n", state->offset));
 1018|   803k|            state->mode = MATCH;
 1019|       |                /* fallthrough */
 1020|  2.88M|        case MATCH:
  ------------------
  |  Branch (1020:9): [True: 2.08M, False: 2.54M]
  ------------------
 1021|  2.88M|            if (left == 0) goto inf_leave;
  ------------------
  |  Branch (1021:17): [True: 726k, False: 2.16M]
  ------------------
 1022|  2.16M|            copy = out - left;
 1023|  2.16M|            if (state->offset > copy) {         /* copy from window */
  ------------------
  |  Branch (1023:17): [True: 824k, False: 1.33M]
  ------------------
 1024|   824k|                copy = state->offset - copy;
 1025|   824k|                if (copy > state->whave) {
  ------------------
  |  Branch (1025:21): [True: 764, False: 823k]
  ------------------
 1026|    764|                    if (state->sane) {
  ------------------
  |  Branch (1026:25): [True: 764, False: 0]
  ------------------
 1027|    764|                        strm->msg = (z_const char *)
 1028|    764|                            "invalid distance too far back";
 1029|    764|                        state->mode = BAD;
 1030|    764|                        break;
 1031|    764|                    }
 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|    764|                }
 1046|   823k|                if (copy > state->wnext) {
  ------------------
  |  Branch (1046:21): [True: 34.2k, False: 789k]
  ------------------
 1047|  34.2k|                    copy -= state->wnext;
 1048|  34.2k|                    from = state->window + (state->wsize - copy);
 1049|  34.2k|                }
 1050|   789k|                else
 1051|   789k|                    from = state->window + (state->wnext - copy);
 1052|   823k|                if (copy > state->length) copy = state->length;
  ------------------
  |  Branch (1052:21): [True: 169k, False: 653k]
  ------------------
 1053|   823k|            }
 1054|  1.33M|            else {                              /* copy from output */
 1055|  1.33M|                from = put - state->offset;
 1056|  1.33M|                copy = state->length;
 1057|  1.33M|            }
 1058|  2.16M|            if (copy > left) copy = left;
  ------------------
  |  Branch (1058:17): [True: 717k, False: 1.44M]
  ------------------
 1059|  2.16M|            left -= copy;
 1060|  2.16M|            state->length -= copy;
 1061|   177M|            do {
 1062|   177M|                *put++ = *from++;
 1063|   177M|            } while (--copy);
  ------------------
  |  Branch (1063:22): [True: 175M, False: 2.16M]
  ------------------
 1064|  2.16M|            if (state->length == 0) state->mode = LEN;
  ------------------
  |  Branch (1064:17): [True: 800k, False: 1.35M]
  ------------------
 1065|  2.16M|            break;
 1066|   369k|        case LIT:
  ------------------
  |  Branch (1066:9): [True: 369k, False: 4.25M]
  ------------------
 1067|   369k|            if (left == 0) goto inf_leave;
  ------------------
  |  Branch (1067:17): [True: 8.16k, False: 360k]
  ------------------
 1068|   360k|            *put++ = (unsigned char)(state->length);
 1069|   360k|            left--;
 1070|   360k|            state->mode = LEN;
 1071|   360k|            break;
 1072|  86.8k|        case CHECK:
  ------------------
  |  Branch (1072:9): [True: 86.8k, False: 4.53M]
  ------------------
 1073|  86.8k|            if (state->wrap) {
  ------------------
  |  Branch (1073:17): [True: 86.8k, False: 0]
  ------------------
 1074|  86.8k|                NEEDBITS(32);
  ------------------
  |  |  369|  86.8k|    do { \
  |  |  370|   432k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 346k, False: 86.3k]
  |  |  ------------------
  |  |  371|   346k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   346k|    do { \
  |  |  |  |  360|   346k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 414, False: 346k]
  |  |  |  |  ------------------
  |  |  |  |  361|   346k|        have--; \
  |  |  |  |  362|   346k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   346k|        bits += 8; \
  |  |  |  |  364|   346k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 346k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  86.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 86.3k]
  |  |  ------------------
  ------------------
 1075|  86.3k|                out -= left;
 1076|  86.3k|                strm->total_out += out;
 1077|  86.3k|                state->total += out;
 1078|  86.3k|                if ((state->wrap & 4) && out)
  ------------------
  |  Branch (1078:21): [True: 86.3k, False: 0]
  |  Branch (1078:42): [True: 85.7k, False: 665]
  ------------------
 1079|  85.7k|                    strm->adler = state->check =
 1080|  85.7k|                        UPDATE_CHECK(state->check, put - out, out);
  ------------------
  |  |  305|  85.7k|#  define UPDATE_CHECK(check, buf, len) adler32(check, buf, len)
  |  |  ------------------
  |  |  |  |   34|  85.7k|#  define adler32               z_adler32
  |  |  ------------------
  ------------------
 1081|  86.3k|                out = left;
 1082|  86.3k|                if ((state->wrap & 4) && (
  ------------------
  |  Branch (1082:21): [True: 86.3k, False: 0]
  |  Branch (1082:42): [True: 9.55k, False: 76.8k]
  ------------------
 1083|       |#ifdef GUNZIP
 1084|       |                     state->flags ? hold :
 1085|       |#endif
 1086|  86.3k|                     ZSWAP32(hold)) != state->check) {
  ------------------
  |  |  258|  86.3k|#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
  |  |  259|  86.3k|                    (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
  ------------------
 1087|  9.55k|                    strm->msg = (z_const char *)"incorrect data check";
 1088|  9.55k|                    state->mode = BAD;
 1089|  9.55k|                    break;
 1090|  9.55k|                }
 1091|  76.8k|                INITBITS();
  ------------------
  |  |  351|  76.8k|    do { \
  |  |  352|  76.8k|        hold = 0; \
  |  |  353|  76.8k|        bits = 0; \
  |  |  354|  76.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 76.8k]
  |  |  ------------------
  ------------------
 1092|  76.8k|                Tracev((stderr, "inflate:   check matches trailer\n"));
 1093|  76.8k|            }
 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|  76.8k|            state->mode = DONE;
 1110|       |                /* fallthrough */
 1111|  76.8k|        case DONE:
  ------------------
  |  Branch (1111:9): [True: 7, False: 4.62M]
  ------------------
 1112|  76.8k|            ret = Z_STREAM_END;
  ------------------
  |  |  182|  76.8k|#define Z_STREAM_END    1
  ------------------
 1113|  76.8k|            goto inf_leave;
 1114|  38.1k|        case BAD:
  ------------------
  |  Branch (1114:9): [True: 38.1k, False: 4.58M]
  ------------------
 1115|  38.1k|            ret = Z_DATA_ERROR;
  ------------------
  |  |  186|  38.1k|#define Z_DATA_ERROR   (-3)
  ------------------
 1116|  38.1k|            goto inf_leave;
 1117|      0|        case MEM:
  ------------------
  |  Branch (1117:9): [True: 0, False: 4.62M]
  ------------------
 1118|      0|            return Z_MEM_ERROR;
  ------------------
  |  |  187|      0|#define Z_MEM_ERROR    (-4)
  ------------------
 1119|      0|        case SYNC:
  ------------------
  |  Branch (1119:9): [True: 0, False: 4.62M]
  ------------------
 1120|       |                /* fallthrough */
 1121|      0|        default:
  ------------------
  |  Branch (1121:9): [True: 0, False: 4.62M]
  ------------------
 1122|      0|            return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
 1123|  4.62M|        }
 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|   939k|  inf_leave:
 1132|   939k|    RESTORE();
  ------------------
  |  |  340|   939k|    do { \
  |  |  341|   939k|        strm->next_out = put; \
  |  |  342|   939k|        strm->avail_out = left; \
  |  |  343|   939k|        strm->next_in = next; \
  |  |  344|   939k|        strm->avail_in = have; \
  |  |  345|   939k|        state->hold = hold; \
  |  |  346|   939k|        state->bits = bits; \
  |  |  347|   939k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 939k]
  |  |  ------------------
  ------------------
 1133|   939k|    if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
  ------------------
  |  Branch (1133:9): [True: 777k, False: 162k]
  |  Branch (1133:26): [True: 32.3k, False: 130k]
  |  Branch (1133:52): [True: 24.0k, False: 8.30k]
  ------------------
 1134|  24.0k|            (state->mode < CHECK || flush != Z_FINISH)))
  ------------------
  |  |  176|    112|#define Z_FINISH        4
  ------------------
  |  Branch (1134:14): [True: 23.9k, False: 112]
  |  Branch (1134:37): [True: 112, False: 0]
  ------------------
 1135|   801k|        if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
  ------------------
  |  Branch (1135:13): [True: 0, False: 801k]
  ------------------
 1136|      0|            state->mode = MEM;
 1137|      0|            return Z_MEM_ERROR;
  ------------------
  |  |  187|      0|#define Z_MEM_ERROR    (-4)
  ------------------
 1138|      0|        }
 1139|   939k|    in -= strm->avail_in;
 1140|   939k|    out -= strm->avail_out;
 1141|   939k|    strm->total_in += in;
 1142|   939k|    strm->total_out += out;
 1143|   939k|    state->total += out;
 1144|   939k|    if ((state->wrap & 4) && out)
  ------------------
  |  Branch (1144:9): [True: 939k, False: 0]
  |  Branch (1144:30): [True: 792k, False: 147k]
  ------------------
 1145|   792k|        strm->adler = state->check =
 1146|   792k|            UPDATE_CHECK(state->check, strm->next_out - out, out);
  ------------------
  |  |  305|   792k|#  define UPDATE_CHECK(check, buf, len) adler32(check, buf, len)
  |  |  ------------------
  |  |  |  |   34|   792k|#  define adler32               z_adler32
  |  |  ------------------
  ------------------
 1147|   939k|    strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
  ------------------
  |  Branch (1147:43): [True: 891k, False: 48.5k]
  ------------------
 1148|   939k|                      (state->mode == TYPE ? 128 : 0) +
  ------------------
  |  Branch (1148:24): [True: 588, False: 939k]
  ------------------
 1149|   939k|                      (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
  ------------------
  |  Branch (1149:24): [True: 0, False: 939k]
  |  Branch (1149:47): [True: 0, False: 939k]
  ------------------
 1150|   939k|    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
  ------------------
  |  |  176|   915k|#define Z_FINISH        4
  ------------------
                  if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
  ------------------
  |  |  181|  24.8k|#define Z_OK            0
  ------------------
  |  Branch (1150:11): [True: 480k, False: 459k]
  |  Branch (1150:22): [True: 24.8k, False: 455k]
  |  Branch (1150:35): [True: 0, False: 915k]
  |  Branch (1150:57): [True: 24.7k, False: 109]
  ------------------
 1151|  24.7k|        ret = Z_BUF_ERROR;
  ------------------
  |  |  188|  24.7k|#define Z_BUF_ERROR    (-5)
  ------------------
 1152|   939k|    return ret;
 1153|   939k|}
z_inflateEnd:
 1155|   154k|int ZEXPORT inflateEnd(z_streamp strm) {
 1156|   154k|    struct inflate_state FAR *state;
 1157|   154k|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (1157:9): [True: 16.0k, False: 137k]
  ------------------
 1158|  16.0k|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|  16.0k|#define Z_STREAM_ERROR (-2)
  ------------------
 1159|   137k|    state = (struct inflate_state FAR *)strm->state;
 1160|   137k|    if (state->window != Z_NULL) ZFREE(strm, state->window);
  ------------------
  |  |  216|   137k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
                  if (state->window != Z_NULL) ZFREE(strm, state->window);
  ------------------
  |  |  254|  24.0k|#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  ------------------
  |  Branch (1160:9): [True: 24.0k, False: 113k]
  ------------------
 1161|   137k|    ZFREE(strm, strm->state);
  ------------------
  |  |  254|   137k|#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  ------------------
 1162|   137k|    strm->state = Z_NULL;
  ------------------
  |  |  216|   137k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
 1163|   137k|    Tracev((stderr, "inflate: end\n"));
 1164|   137k|    return Z_OK;
  ------------------
  |  |  181|   137k|#define Z_OK            0
  ------------------
 1165|   154k|}
z_inflateValidate:
 1385|   137k|int ZEXPORT inflateValidate(z_streamp strm, int check) {
 1386|   137k|    struct inflate_state FAR *state;
 1387|       |
 1388|   137k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (1388:9): [True: 0, False: 137k]
  ------------------
 1389|   137k|    state = (struct inflate_state FAR *)strm->state;
 1390|   137k|    if (check && state->wrap)
  ------------------
  |  Branch (1390:9): [True: 137k, False: 0]
  |  Branch (1390:18): [True: 137k, False: 0]
  ------------------
 1391|   137k|        state->wrap |= 4;
 1392|      0|    else
 1393|      0|        state->wrap &= ~4;
 1394|   137k|    return Z_OK;
  ------------------
  |  |  181|   137k|#define Z_OK            0
  ------------------
 1395|   137k|}
inflate.c:inflateStateCheck:
   88|  1.64M|local int inflateStateCheck(z_streamp strm) {
   89|  1.64M|    struct inflate_state FAR *state;
   90|  1.64M|    if (strm == Z_NULL ||
  ------------------
  |  |  216|  3.29M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (90:9): [True: 0, False: 1.64M]
  ------------------
   91|  1.64M|        strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
  ------------------
  |  Branch (91:9): [True: 16.0k, False: 1.63M]
  |  Branch (91:42): [True: 0, False: 1.63M]
  ------------------
   92|  16.0k|        return 1;
   93|  1.63M|    state = (struct inflate_state FAR *)strm->state;
   94|  1.63M|    if (state == Z_NULL || state->strm != strm ||
  ------------------
  |  |  216|  3.26M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (94:9): [True: 0, False: 1.63M]
  |  Branch (94:28): [True: 0, False: 1.63M]
  ------------------
   95|  1.63M|        state->mode < HEAD || state->mode > SYNC)
  ------------------
  |  Branch (95:9): [True: 0, False: 1.63M]
  |  Branch (95:31): [True: 0, False: 1.63M]
  ------------------
   96|      0|        return 1;
   97|  1.63M|    return 0;
   98|  1.63M|}
inflate.c:updatewindow:
  252|   801k|local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
  253|   801k|    struct inflate_state FAR *state;
  254|   801k|    unsigned dist;
  255|       |
  256|   801k|    state = (struct inflate_state FAR *)strm->state;
  257|       |
  258|       |    /* if it hasn't been done already, allocate space for the window */
  259|   801k|    if (state->window == Z_NULL) {
  ------------------
  |  |  216|   801k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (259:9): [True: 24.0k, False: 777k]
  ------------------
  260|  24.0k|        state->window = (unsigned char FAR *)
  261|  24.0k|                        ZALLOC(strm, 1U << state->wbits,
  ------------------
  |  |  253|  24.0k|           (*((strm)->zalloc))((strm)->opaque, (items), (size))
  ------------------
  262|  24.0k|                               sizeof(unsigned char));
  263|  24.0k|        if (state->window == Z_NULL) return 1;
  ------------------
  |  |  216|  24.0k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (263:13): [True: 0, False: 24.0k]
  ------------------
  264|  24.0k|    }
  265|       |
  266|       |    /* if window not in use yet, initialize */
  267|   801k|    if (state->wsize == 0) {
  ------------------
  |  Branch (267:9): [True: 24.0k, False: 777k]
  ------------------
  268|  24.0k|        state->wsize = 1U << state->wbits;
  269|  24.0k|        state->wnext = 0;
  270|  24.0k|        state->whave = 0;
  271|  24.0k|    }
  272|       |
  273|       |    /* copy state->wsize or less output bytes into the circular window */
  274|   801k|    if (copy >= state->wsize) {
  ------------------
  |  Branch (274:9): [True: 19.5k, False: 781k]
  ------------------
  275|  19.5k|        zmemcpy(state->window, end - state->wsize, state->wsize);
  ------------------
  |  |  216|  19.5k|#    define zmemcpy memcpy
  ------------------
  276|  19.5k|        state->wnext = 0;
  277|  19.5k|        state->whave = state->wsize;
  278|  19.5k|    }
  279|   781k|    else {
  280|   781k|        dist = state->wsize - state->wnext;
  281|   781k|        if (dist > copy) dist = copy;
  ------------------
  |  Branch (281:13): [True: 768k, False: 12.8k]
  ------------------
  282|   781k|        zmemcpy(state->window + state->wnext, end - copy, dist);
  ------------------
  |  |  216|   781k|#    define zmemcpy memcpy
  ------------------
  283|   781k|        copy -= dist;
  284|   781k|        if (copy) {
  ------------------
  |  Branch (284:13): [True: 7.11k, False: 774k]
  ------------------
  285|  7.11k|            zmemcpy(state->window, end - copy, copy);
  ------------------
  |  |  216|  7.11k|#    define zmemcpy memcpy
  ------------------
  286|  7.11k|            state->wnext = copy;
  287|  7.11k|            state->whave = state->wsize;
  288|  7.11k|        }
  289|   774k|        else {
  290|   774k|            state->wnext += dist;
  291|   774k|            if (state->wnext == state->wsize) state->wnext = 0;
  ------------------
  |  Branch (291:17): [True: 5.69k, False: 768k]
  ------------------
  292|   774k|            if (state->whave < state->wsize) state->whave += dist;
  ------------------
  |  Branch (292:17): [True: 509k, False: 265k]
  ------------------
  293|   774k|        }
  294|   781k|    }
  295|   801k|    return 0;
  296|   801k|}

z_inflate_table:
   48|  46.4k|                                unsigned FAR *bits, unsigned short FAR *work) {
   49|  46.4k|    unsigned len;               /* a code's length in bits */
   50|  46.4k|    unsigned sym;               /* index of code symbols */
   51|  46.4k|    unsigned min, max;          /* minimum and maximum code lengths */
   52|  46.4k|    unsigned root;              /* number of index bits for root table */
   53|  46.4k|    unsigned curr;              /* number of index bits for current table */
   54|  46.4k|    unsigned drop;              /* code bits to drop for sub-table */
   55|  46.4k|    int left;                   /* number of prefix codes available */
   56|  46.4k|    unsigned used;              /* code entries in table used */
   57|  46.4k|    unsigned huff;              /* Huffman code */
   58|  46.4k|    unsigned incr;              /* for incrementing code, index */
   59|  46.4k|    unsigned fill;              /* index for replicating entries */
   60|  46.4k|    unsigned low;               /* low bits for current root entry */
   61|  46.4k|    unsigned mask;              /* mask for low root bits */
   62|  46.4k|    code here;                  /* table entry for duplication */
   63|  46.4k|    code FAR *next;             /* next available space in table */
   64|  46.4k|    const unsigned short FAR *base = NULL;  /* base value table to use */
   65|  46.4k|    const unsigned short FAR *extra = NULL; /* extra bits table to use */
   66|  46.4k|    unsigned match = 0;         /* use base and extra for symbol >= match */
   67|  46.4k|    unsigned short count[MAXBITS+1];    /* number of codes of each length */
   68|  46.4k|    unsigned short offs[MAXBITS+1];     /* offsets in table for each length */
   69|  46.4k|    static const unsigned short lbase[31] = { /* Length codes 257..285 base */
   70|  46.4k|        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
   71|  46.4k|        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
   72|  46.4k|    static const unsigned short lext[31] = { /* Length codes 257..285 extra */
   73|  46.4k|        16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
   74|  46.4k|        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 75};
   75|  46.4k|    static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
   76|  46.4k|        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
   77|  46.4k|        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
   78|  46.4k|        8193, 12289, 16385, 24577, 0, 0};
   79|  46.4k|    static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
   80|  46.4k|        16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
   81|  46.4k|        23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
   82|  46.4k|        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|   789k|    for (len = 0; len <= MAXBITS; len++)
  ------------------
  |  |   23|   789k|#define MAXBITS 15
  ------------------
  |  Branch (116:19): [True: 743k, False: 46.4k]
  ------------------
  117|   743k|        count[len] = 0;
  118|  4.54M|    for (sym = 0; sym < codes; sym++)
  ------------------
  |  Branch (118:19): [True: 4.49M, False: 46.4k]
  ------------------
  119|  4.49M|        count[lens[sym]]++;
  120|       |
  121|       |    /* bound code lengths, force root to be within code lengths */
  122|  46.4k|    root = *bits;
  123|   477k|    for (max = MAXBITS; max >= 1; max--)
  ------------------
  |  |   23|  46.4k|#define MAXBITS 15
  ------------------
  |  Branch (123:25): [True: 477k, False: 221]
  ------------------
  124|   477k|        if (count[max] != 0) break;
  ------------------
  |  Branch (124:13): [True: 46.2k, False: 431k]
  ------------------
  125|  46.4k|    if (root > max) root = max;
  ------------------
  |  Branch (125:9): [True: 32.9k, False: 13.4k]
  ------------------
  126|  46.4k|    if (max == 0) {                     /* no symbols to code at all */
  ------------------
  |  Branch (126:9): [True: 221, False: 46.2k]
  ------------------
  127|    221|        here.op = (unsigned char)64;    /* invalid code marker */
  128|    221|        here.bits = (unsigned char)1;
  129|    221|        here.val = (unsigned short)0;
  130|    221|        *(*table)++ = here;             /* make a table to force an error */
  131|    221|        *(*table)++ = here;
  132|    221|        *bits = 1;
  133|    221|        return 0;     /* no symbols, but wait for decoding to report error */
  134|    221|    }
  135|  75.9k|    for (min = 1; min < max; min++)
  ------------------
  |  Branch (135:19): [True: 74.6k, False: 1.24k]
  ------------------
  136|  74.6k|        if (count[min] != 0) break;
  ------------------
  |  Branch (136:13): [True: 44.9k, False: 29.6k]
  ------------------
  137|  46.2k|    if (root < min) root = min;
  ------------------
  |  Branch (137:9): [True: 82, False: 46.1k]
  ------------------
  138|       |
  139|       |    /* check for an over-subscribed or incomplete set of lengths */
  140|  46.2k|    left = 1;
  141|   706k|    for (len = 1; len <= MAXBITS; len++) {
  ------------------
  |  |   23|   706k|#define MAXBITS 15
  ------------------
  |  Branch (141:19): [True: 662k, False: 43.3k]
  ------------------
  142|   662k|        left <<= 1;
  143|   662k|        left -= count[len];
  144|   662k|        if (left < 0) return -1;        /* over-subscribed */
  ------------------
  |  Branch (144:13): [True: 2.84k, False: 660k]
  ------------------
  145|   662k|    }
  146|  43.3k|    if (left > 0 && (type == CODES || max != 1))
  ------------------
  |  Branch (146:9): [True: 1.74k, False: 41.6k]
  |  Branch (146:22): [True: 362, False: 1.38k]
  |  Branch (146:39): [True: 1.10k, False: 286]
  ------------------
  147|  1.46k|        return -1;                      /* incomplete set */
  148|       |
  149|       |    /* generate offsets into symbol table for each length for sorting */
  150|  41.9k|    offs[1] = 0;
  151|   628k|    for (len = 1; len < MAXBITS; len++)
  ------------------
  |  |   23|   628k|#define MAXBITS 15
  ------------------
  |  Branch (151:19): [True: 587k, False: 41.9k]
  ------------------
  152|   587k|        offs[len + 1] = offs[len] + count[len];
  153|       |
  154|       |    /* sort symbols by length, by symbol order within each length */
  155|  4.14M|    for (sym = 0; sym < codes; sym++)
  ------------------
  |  Branch (155:19): [True: 4.10M, False: 41.9k]
  ------------------
  156|  4.10M|        if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
  ------------------
  |  Branch (156:13): [True: 902k, False: 3.20M]
  ------------------
  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|  41.9k|    switch (type) {
  ------------------
  |  Branch (190:13): [True: 41.9k, False: 0]
  ------------------
  191|  17.7k|    case CODES:
  ------------------
  |  Branch (191:5): [True: 17.7k, False: 24.1k]
  ------------------
  192|  17.7k|        match = 20;
  193|  17.7k|        break;
  194|  12.3k|    case LENS:
  ------------------
  |  Branch (194:5): [True: 12.3k, False: 29.6k]
  ------------------
  195|  12.3k|        base = lbase;
  196|  12.3k|        extra = lext;
  197|  12.3k|        match = 257;
  198|  12.3k|        break;
  199|  11.8k|    case DISTS:
  ------------------
  |  Branch (199:5): [True: 11.8k, False: 30.0k]
  ------------------
  200|  11.8k|        base = dbase;
  201|  11.8k|        extra = dext;
  202|  41.9k|    }
  203|       |
  204|       |    /* initialize state for loop */
  205|  41.9k|    huff = 0;                   /* starting code */
  206|  41.9k|    sym = 0;                    /* starting code symbol */
  207|  41.9k|    len = min;                  /* starting code length */
  208|  41.9k|    next = *table;              /* current table to fill in */
  209|  41.9k|    curr = root;                /* current table index bits */
  210|  41.9k|    drop = 0;                   /* current bits to drop from code for index */
  211|  41.9k|    low = (unsigned)(-1);       /* trigger new sub-table when len > root */
  212|  41.9k|    used = 1U << root;          /* use root table entries */
  213|  41.9k|    mask = used - 1;            /* mask for comparing low */
  214|       |
  215|       |    /* check available table space */
  216|  41.9k|    if ((type == LENS && used > ENOUGH_LENS) ||
  ------------------
  |  |   49|  12.3k|#define ENOUGH_LENS 852
  ------------------
  |  Branch (216:10): [True: 12.3k, False: 29.6k]
  |  Branch (216:26): [True: 0, False: 12.3k]
  ------------------
  217|  41.9k|        (type == DISTS && used > ENOUGH_DISTS))
  ------------------
  |  |   50|  11.8k|#define ENOUGH_DISTS 592
  ------------------
  |  Branch (217:10): [True: 11.8k, False: 30.0k]
  |  Branch (217:27): [True: 0, False: 11.8k]
  ------------------
  218|      0|        return 1;
  219|       |
  220|       |    /* process all codes and make table entries */
  221|   902k|    for (;;) {
  222|       |        /* create table entry */
  223|   902k|        here.bits = (unsigned char)(len - drop);
  224|   902k|        if (work[sym] + 1U < match) {
  ------------------
  |  Branch (224:13): [True: 623k, False: 278k]
  ------------------
  225|   623k|            here.op = (unsigned char)0;
  226|   623k|            here.val = work[sym];
  227|   623k|        }
  228|   278k|        else if (work[sym] >= match) {
  ------------------
  |  Branch (228:18): [True: 266k, False: 12.3k]
  ------------------
  229|   266k|            here.op = (unsigned char)(extra[work[sym] - match]);
  230|   266k|            here.val = base[work[sym] - match];
  231|   266k|        }
  232|  12.3k|        else {
  233|  12.3k|            here.op = (unsigned char)(32 + 64);         /* end of block */
  234|  12.3k|            here.val = 0;
  235|  12.3k|        }
  236|       |
  237|       |        /* replicate for those indices with low len bits equal to huff */
  238|   902k|        incr = 1U << (len - drop);
  239|   902k|        fill = 1U << curr;
  240|   902k|        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.60M, False: 902k]
  ------------------
  245|       |
  246|       |        /* backwards increment the len-bit code huff */
  247|   902k|        incr = 1U << (len - 1);
  248|  1.76M|        while (huff & incr)
  ------------------
  |  Branch (248:16): [True: 860k, False: 902k]
  ------------------
  249|   860k|            incr >>= 1;
  250|   902k|        if (incr != 0) {
  ------------------
  |  Branch (250:13): [True: 860k, False: 41.6k]
  ------------------
  251|   860k|            huff &= incr - 1;
  252|   860k|            huff += incr;
  253|   860k|        }
  254|  41.6k|        else
  255|  41.6k|            huff = 0;
  256|       |
  257|       |        /* go to next symbol, update count, len */
  258|   902k|        sym++;
  259|   902k|        if (--(count[len]) == 0) {
  ------------------
  |  Branch (259:13): [True: 195k, False: 706k]
  ------------------
  260|   195k|            if (len == max) break;
  ------------------
  |  Branch (260:17): [True: 41.9k, False: 153k]
  ------------------
  261|   153k|            len = lens[work[sym]];
  262|   153k|        }
  263|       |
  264|       |        /* create new sub-table if needed */
  265|   860k|        if (len > root && (huff & mask) != low) {
  ------------------
  |  Branch (265:13): [True: 81.2k, False: 778k]
  |  Branch (265:27): [True: 29.4k, False: 51.8k]
  ------------------
  266|       |            /* if first time, transition to sub-tables */
  267|  29.4k|            if (drop == 0)
  ------------------
  |  Branch (267:17): [True: 6.84k, False: 22.5k]
  ------------------
  268|  6.84k|                drop = root;
  269|       |
  270|       |            /* increment past last table */
  271|  29.4k|            next += min;            /* here min is 1 << curr */
  272|       |
  273|       |            /* determine length of next table */
  274|  29.4k|            curr = len - drop;
  275|  29.4k|            left = (int)(1 << curr);
  276|  33.7k|            while (curr + drop < max) {
  ------------------
  |  Branch (276:20): [True: 24.6k, False: 9.10k]
  ------------------
  277|  24.6k|                left -= count[curr + drop];
  278|  24.6k|                if (left <= 0) break;
  ------------------
  |  Branch (278:21): [True: 20.3k, False: 4.30k]
  ------------------
  279|  4.30k|                curr++;
  280|  4.30k|                left <<= 1;
  281|  4.30k|            }
  282|       |
  283|       |            /* check for enough space */
  284|  29.4k|            used += 1U << curr;
  285|  29.4k|            if ((type == LENS && used > ENOUGH_LENS) ||
  ------------------
  |  |   49|  19.1k|#define ENOUGH_LENS 852
  ------------------
  |  Branch (285:18): [True: 19.1k, False: 10.2k]
  |  Branch (285:34): [True: 0, False: 19.1k]
  ------------------
  286|  29.4k|                (type == DISTS && used > ENOUGH_DISTS))
  ------------------
  |  |   50|  10.2k|#define ENOUGH_DISTS 592
  ------------------
  |  Branch (286:18): [True: 10.2k, False: 19.1k]
  |  Branch (286:35): [True: 0, False: 10.2k]
  ------------------
  287|      0|                return 1;
  288|       |
  289|       |            /* point entry in root table to sub-table */
  290|  29.4k|            low = huff & mask;
  291|  29.4k|            (*table)[low].op = (unsigned char)curr;
  292|  29.4k|            (*table)[low].bits = (unsigned char)root;
  293|  29.4k|            (*table)[low].val = (unsigned short)(next - *table);
  294|  29.4k|        }
  295|   860k|    }
  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|  41.9k|    if (huff != 0) {
  ------------------
  |  Branch (300:9): [True: 286, False: 41.6k]
  ------------------
  301|    286|        here.op = (unsigned char)64;            /* invalid code marker */
  302|    286|        here.bits = (unsigned char)(len - drop);
  303|    286|        here.val = (unsigned short)0;
  304|    286|        next[huff] = here;
  305|    286|    }
  306|       |
  307|       |    /* set return parameters */
  308|  41.9k|    *table += used;
  309|  41.9k|    *bits = root;
  310|  41.9k|    return 0;
  311|  41.9k|}
z_inflate_fixed:
  364|   104k|void inflate_fixed(struct inflate_state FAR *state) {
  365|       |#ifdef BUILDFIXED
  366|       |    z_once(&built, buildtables);
  367|       |#endif /* BUILDFIXED */
  368|   104k|    state->lencode = lenfix;
  369|   104k|    state->lenbits = 9;
  370|   104k|    state->distcode = distfix;
  371|   104k|    state->distbits = 5;
  372|   104k|}

tj3Compress12:
   80|  22.1k|{
   81|  22.1k|  static const char FUNCTION_NAME[] = GET_STRING(tj3Compress, BITS_IN_JSAMPLE);
  ------------------
  |  |   71|  22.1k|#define GET_STRING(name, suffix)  _GET_STRING(name, suffix)
  |  |  ------------------
  |  |  |  |   70|  22.1k|#define _GET_STRING(name, suffix)  #name #suffix
  |  |  ------------------
  ------------------
   82|  22.1k|  int i, retval = 0;
   83|  22.1k|  boolean alloc = TRUE;
  ------------------
  |  |  210|  22.1k|#define TRUE    1
  ------------------
   84|  22.1k|  _JSAMPROW *row_pointer = NULL;
  ------------------
  |  |   46|  22.1k|#define _JSAMPROW  J12SAMPROW
  ------------------
   85|       |
   86|  22.1k|  GET_CINSTANCE(handle)
  ------------------
  |  |  326|  22.1k|  tjinstance *this = (tjinstance *)handle; \
  |  |  327|  22.1k|  j_compress_ptr cinfo = NULL; \
  |  |  328|  22.1k|  \
  |  |  329|  22.1k|  if (!this) { \
  |  |  ------------------
  |  |  |  Branch (329:7): [True: 0, False: 22.1k]
  |  |  ------------------
  |  |  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|  22.1k|  cinfo = &this->cinfo; \
  |  |  334|  22.1k|  this->jerr.warning = FALSE; \
  |  |  ------------------
  |  |  |  |  207|  22.1k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  335|  22.1k|  this->isInstanceError = FALSE;
  |  |  ------------------
  |  |  |  |  207|  22.1k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  ------------------
   87|  22.1k|  if ((this->init & COMPRESS) == 0)
  ------------------
  |  Branch (87:7): [True: 0, False: 22.1k]
  ------------------
   88|  22.1k|    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|  22.1k|  if (srcBuf == NULL || width <= 0 || pitch < 0 || height <= 0 ||
  ------------------
  |  Branch (90:7): [True: 0, False: 22.1k]
  |  Branch (90:25): [True: 0, False: 22.1k]
  |  Branch (90:39): [True: 0, False: 22.1k]
  |  Branch (90:52): [True: 0, False: 22.1k]
  ------------------
   91|  22.1k|      pixelFormat < 0 || pixelFormat >= TJ_NUMPF || jpegBuf == NULL ||
  ------------------
  |  |  283|  44.3k|#define TJ_NUMPF  12
  ------------------
  |  Branch (91:7): [True: 0, False: 22.1k]
  |  Branch (91:26): [True: 0, False: 22.1k]
  |  Branch (91:53): [True: 0, False: 22.1k]
  ------------------
   92|  22.1k|      jpegSize == NULL)
  ------------------
  |  Branch (92:7): [True: 0, False: 22.1k]
  ------------------
   93|  22.1k|    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|  22.1k|  if (!this->lossless && this->quality == -1)
  ------------------
  |  Branch (95:7): [True: 22.1k, False: 0]
  |  Branch (95:26): [True: 0, False: 22.1k]
  ------------------
   96|  22.1k|    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|  22.1k|  if (!this->lossless && this->subsamp == TJSAMP_UNKNOWN)
  ------------------
  |  Branch (97:7): [True: 22.1k, False: 0]
  |  Branch (97:26): [True: 0, False: 22.1k]
  ------------------
   98|  22.1k|    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|  22.1k|  if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
  ------------------
  |  Branch (100:7): [True: 22.1k, False: 0]
  ------------------
  101|      0|  else if (pitch < width * tjPixelSize[pixelFormat])
  ------------------
  |  Branch (101:12): [True: 0, False: 0]
  ------------------
  102|  22.1k|    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|  22.1k|  if ((row_pointer = (_JSAMPROW *)malloc(sizeof(_JSAMPROW) * height)) == NULL)
  ------------------
  |  Branch (104:7): [True: 0, False: 22.1k]
  ------------------
  105|  22.1k|    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|  22.1k|  CATCH_LIBJPEG(this);
  ------------------
  |  |  293|  22.1k|#define CATCH_LIBJPEG(this) { \
  |  |  294|  22.1k|  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|  22.1k|}
  ------------------
  |  Branch (107:3): [True: 3, False: 22.1k]
  ------------------
  108|       |
  109|  22.1k|  cinfo->image_width = width;
  110|  22.1k|  cinfo->image_height = height;
  111|  22.1k|  cinfo->data_precision = BITS_IN_JSAMPLE;
  ------------------
  |  | 1270|  22.1k|#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|  22.1k|  if (this->lossless && this->precision >= BITS_IN_JSAMPLE - 3 &&
  ------------------
  |  | 1270|      0|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (116:7): [True: 0, False: 22.1k]
  |  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|  22.1k|  setCompDefaults(this, pixelFormat, FALSE);
  ------------------
  |  |  207|  22.1k|#define FALSE   0               /* values of boolean */
  ------------------
  122|  22.1k|  if (this->noRealloc) alloc = FALSE;
  ------------------
  |  |  207|  3.13k|#define FALSE   0               /* values of boolean */
  ------------------
  |  Branch (122:7): [True: 3.13k, False: 19.0k]
  ------------------
  123|  22.1k|  jpeg_mem_dest_tj(cinfo, jpegBuf, jpegSize, alloc);
  124|       |
  125|  22.1k|  jpeg_start_compress(cinfo, TRUE);
  ------------------
  |  |  210|  22.1k|#define TRUE    1
  ------------------
  126|  22.1k|  if (this->iccBuf != NULL && this->iccSize != 0)
  ------------------
  |  Branch (126:7): [True: 18.6k, False: 3.53k]
  |  Branch (126:31): [True: 18.6k, False: 0]
  ------------------
  127|  18.6k|    jpeg_write_icc_profile(cinfo, this->iccBuf, (unsigned int)this->iccSize);
  128|  32.8M|  for (i = 0; i < height; i++) {
  ------------------
  |  Branch (128:15): [True: 32.8M, False: 22.1k]
  ------------------
  129|  32.8M|    if (this->bottomUp)
  ------------------
  |  Branch (129:9): [True: 4.84M, False: 28.0M]
  ------------------
  130|  4.84M|      row_pointer[i] = (_JSAMPROW)&srcBuf[(height - i - 1) * (size_t)pitch];
  131|  28.0M|    else
  132|  28.0M|      row_pointer[i] = (_JSAMPROW)&srcBuf[i * (size_t)pitch];
  133|  32.8M|  }
  134|  44.3k|  while (cinfo->next_scanline < cinfo->image_height)
  ------------------
  |  Branch (134:10): [True: 22.1k, False: 22.1k]
  ------------------
  135|  22.1k|    _jpeg_write_scanlines(cinfo, &row_pointer[cinfo->next_scanline],
  ------------------
  |  |   55|  22.1k|#define _jpeg_write_scanlines  jpeg12_write_scanlines
  ------------------
  136|  22.1k|                          cinfo->image_height - cinfo->next_scanline);
  137|  22.1k|  jpeg_finish_compress(cinfo);
  138|       |
  139|  22.1k|bailout:
  140|  22.1k|  if (cinfo->global_state > CSTATE_START && alloc)
  ------------------
  |  |   44|  44.3k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (140:7): [True: 3, False: 22.1k]
  |  Branch (140:45): [True: 3, False: 0]
  ------------------
  141|      3|    (*cinfo->dest->term_destination) (cinfo);
  142|  22.1k|  if (cinfo->global_state > CSTATE_START || retval == -1)
  ------------------
  |  |   44|  44.3k|#define CSTATE_START     100    /* after create_compress */
  ------------------
  |  Branch (142:7): [True: 3, False: 22.1k]
  |  Branch (142:45): [True: 0, False: 22.1k]
  ------------------
  143|      3|    jpeg_abort_compress(cinfo);
  144|  22.1k|  free(row_pointer);
  145|  22.1k|  if (this->jerr.warning) retval = -1;
  ------------------
  |  Branch (145:7): [True: 0, False: 22.1k]
  ------------------
  146|  22.1k|  return retval;
  147|  22.1k|}
_tj3LoadImageFromFileHandle12:
  306|  49.2k|{
  307|  49.2k|  static const char FUNCTION_NAME[] =
  308|  49.2k|    GET_STRING(tj3LoadImage, BITS_IN_JSAMPLE);
  ------------------
  |  |   71|  49.2k|#define GET_STRING(name, suffix)  _GET_STRING(name, suffix)
  |  |  ------------------
  |  |  |  |   70|  49.2k|#define _GET_STRING(name, suffix)  #name #suffix
  |  |  ------------------
  ------------------
  309|       |
  310|  49.2k|  int retval = 0, tempc;
  311|  49.2k|  size_t pitch;
  312|  49.2k|  tjhandle handle2 = NULL;
  313|  49.2k|  tjinstance *this2;
  314|  49.2k|  j_compress_ptr cinfo = NULL;
  315|  49.2k|  cjpeg_source_ptr src = NULL;
  316|  49.2k|  _JSAMPLE *dstBuf = NULL;
  ------------------
  |  |   45|  49.2k|#define _JSAMPLE  J12SAMPLE
  ------------------
  317|  49.2k|  boolean invert;
  318|       |
  319|  49.2k|  GET_TJINSTANCE(handle, NULL)
  ------------------
  |  |  350|  49.2k|  tjinstance *this = (tjinstance *)handle; \
  |  |  351|  49.2k|  \
  |  |  352|  49.2k|  if (!this) { \
  |  |  ------------------
  |  |  |  Branch (352:7): [True: 0, False: 49.2k]
  |  |  ------------------
  |  |  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|  49.2k|  this->jerr.warning = FALSE; \
  |  |  ------------------
  |  |  |  |  207|  49.2k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  357|  49.2k|  this->isInstanceError = FALSE;
  |  |  ------------------
  |  |  |  |  207|  49.2k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  ------------------
  320|       |
  321|  49.2k|  if (!file || !width || align < 1 || !height || !pixelFormat ||
  ------------------
  |  Branch (321:7): [True: 0, False: 49.2k]
  |  Branch (321:16): [True: 0, False: 49.2k]
  |  Branch (321:26): [True: 0, False: 49.2k]
  |  Branch (321:39): [True: 0, False: 49.2k]
  |  Branch (321:50): [True: 0, False: 49.2k]
  ------------------
  322|  49.2k|      *pixelFormat < TJPF_UNKNOWN || *pixelFormat >= TJ_NUMPF)
  ------------------
  |  |  283|  49.2k|#define TJ_NUMPF  12
  ------------------
  |  Branch (322:7): [True: 0, False: 49.2k]
  |  Branch (322:38): [True: 0, False: 49.2k]
  ------------------
  323|  49.2k|    THROW("Invalid argument");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  324|  49.2k|  if ((align & (align - 1)) != 0)
  ------------------
  |  Branch (324:7): [True: 0, False: 49.2k]
  ------------------
  325|  49.2k|    THROW("Alignment must be a power of 2");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  326|       |
  327|       |  /* The instance handle passed to this function is used only for parameter
  328|       |     retrieval.  Create a new temporary instance to avoid interfering with the
  329|       |     libjpeg state of the primary instance. */
  330|  49.2k|  if ((handle2 = tj3Init(TJINIT_COMPRESS)) == NULL) return NULL;
  ------------------
  |  Branch (330:7): [True: 0, False: 49.2k]
  ------------------
  331|  49.2k|  this2 = (tjinstance *)handle2;
  332|  49.2k|  cinfo = &this2->cinfo;
  333|       |
  334|  49.2k|  if ((tempc = getc(file)) < 0 || ungetc(tempc, file) == EOF)
  ------------------
  |  Branch (334:7): [True: 0, False: 49.2k]
  |  Branch (334:35): [True: 0, False: 49.2k]
  ------------------
  335|      0|    THROW_UNIX("Could not read input file")
  ------------------
  |  |  270|      0|#define THROW_UNIX(m) { \
  |  |  271|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s\n%s", FUNCTION_NAME, m, \
  |  |  ------------------
  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  ------------------
  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s\n%s", FUNCTION_NAME, m, \
  |  |  ------------------
  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  272|      0|           strerror(errno)); \
  |  |  273|      0|  this->isInstanceError = TRUE; \
  |  |  ------------------
  |  |  |  |  210|      0|#define TRUE    1
  |  |  ------------------
  |  |  274|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s\n%s", FUNCTION_NAME, m, \
  |  |  ------------------
  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  ------------------
  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s\n%s", FUNCTION_NAME, m, \
  |  |  ------------------
  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  275|      0|           strerror(errno)); \
  |  |  276|      0|  retval = -1;  goto bailout; \
  |  |  277|      0|}
  ------------------
  336|  49.2k|  else if (tempc == EOF)
  ------------------
  |  Branch (336:12): [True: 0, False: 49.2k]
  ------------------
  337|  49.2k|    THROW("Input file contains no data");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  338|       |
  339|  49.2k|  CATCH_LIBJPEG2();
  ------------------
  |  |  303|  49.2k|#define CATCH_LIBJPEG2() { \
  |  |  304|  49.2k|  if (setjmp(this2->jerr.setjmp_buffer)) { \
  |  |  305|     14|    memcpy(this->errStr, this2->errStr, JMSG_LENGTH_MAX); \
  |  |  ------------------
  |  |  |  |  792|     14|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  306|     14|    this->jerr.warning = this2->jerr.warning; \
  |  |  307|     14|    this->isInstanceError = this2->isInstanceError; \
  |  |  308|     14|    retval = -1;  goto bailout; \
  |  |  309|     14|  } \
  |  |  310|  49.2k|}
  ------------------
  |  Branch (339:3): [True: 14, False: 49.2k]
  ------------------
  340|       |
  341|  49.2k|  cinfo->data_precision = BITS_IN_JSAMPLE;
  ------------------
  |  | 1270|  49.2k|#define BITS_IN_JSAMPLE  12
  ------------------
  342|  49.2k|  if (*pixelFormat == TJPF_UNKNOWN) cinfo->in_color_space = JCS_UNKNOWN;
  ------------------
  |  Branch (342:7): [True: 0, False: 49.2k]
  ------------------
  343|  49.2k|  else cinfo->in_color_space = pf2cs[*pixelFormat];
  344|  49.2k|  if (tempc == 'B') {
  ------------------
  |  Branch (344:7): [True: 14, False: 49.2k]
  ------------------
  345|     14|    if ((src = jinit_read_bmp(cinfo, FALSE)) == NULL)
  ------------------
  |  |  207|     14|#define FALSE   0               /* values of boolean */
  ------------------
  |  Branch (345:9): [True: 0, False: 14]
  ------------------
  346|     14|      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|     14|    invert = !this->bottomUp;
  348|  49.2k|  } else if (tempc == 0x89) {
  ------------------
  |  Branch (348:14): [True: 32.1k, False: 17.0k]
  ------------------
  349|       |#if BITS_IN_JSAMPLE == 8
  350|       |    if (this->precision >= 2 && this->precision <= BITS_IN_JSAMPLE)
  351|       |#else
  352|  32.1k|    if (this->precision >= BITS_IN_JSAMPLE - 3 &&
  ------------------
  |  | 1270|  32.1k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (352:9): [True: 0, False: 32.1k]
  ------------------
  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|  32.1k|    if ((src = _jinit_read_png(cinfo)) == NULL)
  ------------------
  |  |   48|  32.1k|#define _jinit_read_png  j12init_read_png
  ------------------
  |  Branch (356:9): [True: 0, False: 32.1k]
  ------------------
  357|  32.1k|      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|  32.1k|    invert = this->bottomUp;
  359|  32.1k|  } else if (tempc == 'P') {
  ------------------
  |  Branch (359:14): [True: 16.3k, False: 721]
  ------------------
  360|       |#if BITS_IN_JSAMPLE == 8
  361|       |    if (this->precision >= 2 && this->precision <= BITS_IN_JSAMPLE)
  362|       |#else
  363|  16.3k|    if (this->precision >= BITS_IN_JSAMPLE - 3 &&
  ------------------
  |  | 1270|  16.3k|#define BITS_IN_JSAMPLE  12
  ------------------
  |  Branch (363:9): [True: 0, False: 16.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|  16.3k|    if ((src = _jinit_read_ppm(cinfo)) == NULL)
  ------------------
  |  |   50|  16.3k|#define _jinit_read_ppm  j12init_read_ppm
  ------------------
  |  Branch (367:9): [True: 0, False: 16.3k]
  ------------------
  368|  16.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|  16.3k|    invert = this->bottomUp;
  370|  16.3k|  } else
  371|  48.4k|    THROW("Unsupported file type");
  ------------------
  |  |  283|    721|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|    721|#define THROWRV(m, rv) { \
  |  |  |  |  280|    721|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|    721|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|    721|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|    721|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|    721|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|    721|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|    721|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|    721|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|    721|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|    721|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|    721|}
  |  |  |  |  ------------------
  |  |  |  |  282|    721|}
  |  |  ------------------
  ------------------
  372|       |
  373|  48.4k|  CATCH_LIBJPEG2();
  ------------------
  |  |  303|  48.4k|#define CATCH_LIBJPEG2() { \
  |  |  304|  48.4k|  if (setjmp(this2->jerr.setjmp_buffer)) { \
  |  |  305|  27.0k|    memcpy(this->errStr, this2->errStr, JMSG_LENGTH_MAX); \
  |  |  ------------------
  |  |  |  |  792|  27.0k|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  306|  27.0k|    this->jerr.warning = this2->jerr.warning; \
  |  |  307|  27.0k|    this->isInstanceError = this2->isInstanceError; \
  |  |  308|  27.0k|    retval = -1;  goto bailout; \
  |  |  309|  27.0k|  } \
  |  |  310|  48.4k|}
  ------------------
  |  Branch (373:3): [True: 27.0k, False: 21.4k]
  ------------------
  374|       |
  375|  21.4k|  cinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
  376|       |
  377|  21.4k|  src->input_file = file;
  378|       |  /* Refuse to load images larger than the specified size. */
  379|  21.4k|  src->max_pixels = this->maxPixels;
  380|  21.4k|  (*src->start_input) (cinfo, src);
  381|  21.4k|  if (tempc == 'B') {
  ------------------
  |  Branch (381:7): [True: 0, False: 21.4k]
  ------------------
  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|  21.4k|  } else if (tempc == 0x89 && (this->init & COMPRESS) &&
  ------------------
  |  Branch (387:14): [True: 7.26k, False: 14.1k]
  |  Branch (387:31): [True: 7.26k, False: 0]
  ------------------
  388|  7.26k|             (this->saveMarkers == 2 || this->saveMarkers == 4)) {
  ------------------
  |  Branch (388:15): [True: 7.26k, False: 0]
  |  Branch (388:41): [True: 0, False: 0]
  ------------------
  389|  7.26k|    JOCTET *iccBuf = NULL;
  390|  7.26k|    unsigned int iccLen = 0;
  391|       |
  392|  7.26k|    if ((*src->read_icc_profile) (cinfo, src, &iccBuf, &iccLen) && iccBuf &&
  ------------------
  |  Branch (392:9): [True: 7, False: 7.25k]
  |  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.26k|  }
  396|  21.4k|  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
  397|       |
  398|  21.4k|  *width = cinfo->image_width;  *height = cinfo->image_height;
  399|  21.4k|  *pixelFormat = cs2pf[cinfo->in_color_space];
  400|       |
  401|  21.4k|  pitch = PAD((*width) * tjPixelSize[*pixelFormat], align);
  ------------------
  |  |   57|  21.4k|#define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
  ------------------
  402|       |
  403|  21.4k|  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|  21.4k|      (dstBuf = (_JSAMPLE *)malloc(pitch * (*height) *
  ------------------
  |  Branch (409:7): [True: 0, False: 21.4k]
  ------------------
  410|  21.4k|                                   sizeof(_JSAMPLE))) == NULL)
  411|  21.4k|    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|  21.4k|  CATCH_LIBJPEG2();
  ------------------
  |  |  303|  21.4k|#define CATCH_LIBJPEG2() { \
  |  |  304|  21.4k|  if (setjmp(this2->jerr.setjmp_buffer)) { \
  |  |  305|  9.21k|    memcpy(this->errStr, this2->errStr, JMSG_LENGTH_MAX); \
  |  |  ------------------
  |  |  |  |  792|  9.21k|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  ------------------
  |  |  306|  9.21k|    this->jerr.warning = this2->jerr.warning; \
  |  |  307|  9.21k|    this->isInstanceError = this2->isInstanceError; \
  |  |  308|  9.21k|    retval = -1;  goto bailout; \
  |  |  309|  9.21k|  } \
  |  |  310|  21.4k|}
  ------------------
  |  Branch (413:3): [True: 9.21k, False: 12.2k]
  ------------------
  414|       |
  415|  33.0M|  while (cinfo->next_scanline < cinfo->image_height) {
  ------------------
  |  Branch (415:10): [True: 32.9M, False: 12.2k]
  ------------------
  416|  32.9M|    int i, nlines = (*src->get_pixel_rows) (cinfo, src);
  417|       |
  418|  65.9M|    for (i = 0; i < nlines; i++) {
  ------------------
  |  Branch (418:17): [True: 32.9M, False: 32.9M]
  ------------------
  419|  32.9M|      _JSAMPLE *dstptr;
  ------------------
  |  |   45|  32.9M|#define _JSAMPLE  J12SAMPLE
  ------------------
  420|  32.9M|      int row;
  421|       |
  422|  32.9M|      row = cinfo->next_scanline + i;
  423|  32.9M|      if (invert) dstptr = &dstBuf[((*height) - row - 1) * pitch];
  ------------------
  |  Branch (423:11): [True: 4.87M, False: 28.1M]
  ------------------
  424|  28.1M|      else dstptr = &dstBuf[row * pitch];
  425|  32.9M|      memcpy(dstptr, src->_buffer[i],
  ------------------
  |  |   47|  32.9M|#define _buffer  buffer12
  ------------------
  426|  32.9M|             (*width) * tjPixelSize[*pixelFormat] * sizeof(_JSAMPLE));
  427|  32.9M|    }
  428|  32.9M|    cinfo->next_scanline += nlines;
  429|  32.9M|  }
  430|       |
  431|  49.2k|bailout:
  432|  49.2k|  if (src)
  ------------------
  |  Branch (432:7): [True: 48.4k, False: 749]
  ------------------
  433|  48.4k|    (*src->finish_input) (cinfo, src);
  434|  49.2k|  tj3Destroy(handle2);
  435|  49.2k|  if (retval < 0) { free(dstBuf);  dstBuf = NULL; }
  ------------------
  |  Branch (435:7): [True: 37.0k, False: 12.2k]
  ------------------
  436|  49.2k|  return dstBuf;
  437|  12.2k|}

tj3InitVersion:
  596|  56.2k|{
  597|  56.2k|  static const char FUNCTION_NAME[] = "tj3Init";
  598|  56.2k|  tjinstance *this = NULL;
  599|  56.2k|  tjhandle retval = NULL;
  600|       |
  601|  56.2k|  if (initType < 0 || initType >= TJ_NUMINIT || apiVersion < 1000000 ||
  ------------------
  |  |   86|   112k|#define TJ_NUMINIT  3
  ------------------
  |  Branch (601:7): [True: 0, False: 56.2k]
  |  Branch (601:23): [True: 0, False: 56.2k]
  |  Branch (601:49): [True: 0, False: 56.2k]
  ------------------
  602|  56.2k|      apiVersion > 999999999)
  ------------------
  |  Branch (602:7): [True: 0, False: 56.2k]
  ------------------
  603|  56.2k|    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|  56.2k|  if ((this = (tjinstance *)malloc(sizeof(tjinstance))) == NULL)
  ------------------
  |  Branch (605:7): [True: 0, False: 56.2k]
  ------------------
  606|  56.2k|    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|  56.2k|  memset(this, 0, sizeof(tjinstance));
  608|  56.2k|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
  ------------------
  |  |   42|  56.2k|#define SNPRINTF  snprintf
  ------------------
                SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
  ------------------
  |  |  792|  56.2k|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  ------------------
  609|       |
  610|  56.2k|  this->quality = -1;
  611|  56.2k|  this->subsamp = TJSAMP_UNKNOWN;
  612|  56.2k|  this->jpegWidth = -1;
  613|  56.2k|  this->jpegHeight = -1;
  614|  56.2k|  this->precision = 8;
  615|  56.2k|  this->colorspace = TJCS_DEFAULT;
  616|  56.2k|  this->losslessPSV = 1;
  617|  56.2k|  this->xDensity = 1;
  618|  56.2k|  this->yDensity = 1;
  619|  56.2k|  this->scalingFactor = TJUNSCALED;
  620|  56.2k|  this->saveMarkers = 2;
  621|       |
  622|  56.2k|  this->apiVersion = apiVersion;
  623|  56.2k|  this->numSamp = apiVersion >= 3002000 ? TJ_NUMSAMP : 7;
  ------------------
  |  |  111|  7.03k|#define TJ_NUMSAMP  9
  ------------------
  |  Branch (623:19): [True: 7.03k, False: 49.2k]
  ------------------
  624|       |
  625|  56.2k|  switch (initType) {
  ------------------
  |  Branch (625:11): [True: 56.2k, False: 0]
  ------------------
  626|  56.2k|  case TJINIT_COMPRESS:  return _tjInitCompress(this);
  ------------------
  |  Branch (626:3): [True: 56.2k, False: 0]
  ------------------
  627|      0|  case TJINIT_DECOMPRESS:  return _tjInitDecompress(this);
  ------------------
  |  Branch (627:3): [True: 0, False: 56.2k]
  ------------------
  628|      0|  case TJINIT_TRANSFORM:
  ------------------
  |  Branch (628:3): [True: 0, False: 56.2k]
  ------------------
  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|  56.2k|  }
  634|       |
  635|      0|bailout:
  636|      0|  return retval;
  637|  56.2k|}
tj3Init:
  641|  49.2k|{
  642|  49.2k|  return tj3InitVersion(initType, 3001000);
  643|  49.2k|}
tj3Destroy:
  648|  56.2k|{
  649|  56.2k|  tjinstance *this = (tjinstance *)handle;
  650|  56.2k|  j_compress_ptr cinfo = NULL;
  651|  56.2k|  j_decompress_ptr dinfo = NULL;
  652|       |
  653|  56.2k|  if (!this) return;
  ------------------
  |  Branch (653:7): [True: 0, False: 56.2k]
  ------------------
  654|       |
  655|  56.2k|  cinfo = &this->cinfo;  dinfo = &this->dinfo;
  656|  56.2k|  this->jerr.warning = FALSE;
  ------------------
  |  |  207|  56.2k|#define FALSE   0               /* values of boolean */
  ------------------
  657|  56.2k|  this->isInstanceError = FALSE;
  ------------------
  |  |  207|  56.2k|#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|  56.2k|  if (setjmp(this->jerr.setjmp_buffer)) goto destroy_decompress;
  ------------------
  |  Branch (661:7): [True: 0, False: 56.2k]
  ------------------
  662|  56.2k|  if (this->init & COMPRESS) jpeg_destroy_compress(cinfo);
  ------------------
  |  Branch (662:7): [True: 56.2k, False: 0]
  ------------------
  663|  56.2k|destroy_decompress:
  664|  56.2k|  if (setjmp(this->jerr.setjmp_buffer)) goto bailout;
  ------------------
  |  Branch (664:7): [True: 0, False: 56.2k]
  ------------------
  665|  56.2k|  if (this->init & DECOMPRESS) jpeg_destroy_decompress(dinfo);
  ------------------
  |  Branch (665:7): [True: 0, False: 56.2k]
  ------------------
  666|  56.2k|bailout:
  667|  56.2k|  free(this->iccBuf);
  668|  56.2k|  free(this->decompICCBuf);
  669|  56.2k|  free(this);
  670|  56.2k|}
tj3Set:
  744|   438k|{
  745|   438k|  static const char FUNCTION_NAME[] = "tj3Set";
  746|   438k|  int retval = 0;
  747|       |
  748|   438k|  GET_TJINSTANCE(handle, -1);
  ------------------
  |  |  350|   438k|  tjinstance *this = (tjinstance *)handle; \
  |  |  351|   438k|  \
  |  |  352|   438k|  if (!this) { \
  |  |  ------------------
  |  |  |  Branch (352:7): [True: 0, False: 438k]
  |  |  ------------------
  |  |  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|   438k|  this->jerr.warning = FALSE; \
  |  |  ------------------
  |  |  |  |  207|   438k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  357|   438k|  this->isInstanceError = FALSE;
  |  |  ------------------
  |  |  |  |  207|   438k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  ------------------
  749|       |
  750|   438k|  switch (param) {
  751|      0|  case TJPARAM_STOPONWARNING:
  ------------------
  |  Branch (751:3): [True: 0, False: 438k]
  ------------------
  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|  49.2k|  case TJPARAM_BOTTOMUP:
  ------------------
  |  Branch (754:3): [True: 49.2k, False: 389k]
  ------------------
  755|  49.2k|    SET_BOOL_PARAM(bottomUp);
  ------------------
  |  |  736|  49.2k|#define SET_BOOL_PARAM(field) { \
  |  |  737|  49.2k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (737:7): [True: 0, False: 49.2k]
  |  |  |  Branch (737:20): [True: 0, False: 49.2k]
  |  |  ------------------
  |  |  738|  49.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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  739|  49.2k|  this->field = (boolean)value; \
  |  |  740|  49.2k|}
  ------------------
  756|  49.2k|    break;
  757|  49.2k|  case TJPARAM_NOREALLOC:
  ------------------
  |  Branch (757:3): [True: 49.2k, False: 389k]
  ------------------
  758|  49.2k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (758:9): [True: 0, False: 49.2k]
  ------------------
  759|  49.2k|      THROW("TJPARAM_NOREALLOC is not applicable to decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  760|  49.2k|    SET_BOOL_PARAM(noRealloc);
  ------------------
  |  |  736|  49.2k|#define SET_BOOL_PARAM(field) { \
  |  |  737|  49.2k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (737:7): [True: 0, False: 49.2k]
  |  |  |  Branch (737:20): [True: 0, False: 49.2k]
  |  |  ------------------
  |  |  738|  49.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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  739|  49.2k|  this->field = (boolean)value; \
  |  |  740|  49.2k|}
  ------------------
  761|  49.2k|    break;
  762|  22.1k|  case TJPARAM_QUALITY:
  ------------------
  |  Branch (762:3): [True: 22.1k, False: 416k]
  ------------------
  763|  22.1k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (763:9): [True: 0, False: 22.1k]
  ------------------
  764|  22.1k|      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|  22.1k|    SET_PARAM(quality, 1, 100);
  ------------------
  |  |  730|  22.1k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|  22.1k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 22.1k]
  |  |  |  Branch (731:28): [True: 22.1k, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 22.1k]
  |  |  ------------------
  |  |  732|  22.1k|    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|  22.1k|  this->field = value; \
  |  |  734|  22.1k|}
  ------------------
  766|  22.1k|    break;
  767|  22.1k|  case TJPARAM_SUBSAMP:
  ------------------
  |  Branch (767:3): [True: 22.1k, False: 416k]
  ------------------
  768|  22.1k|    SET_PARAM(subsamp, 0, this->numSamp - 1);
  ------------------
  |  |  730|  22.1k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|  22.1k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 22.1k]
  |  |  |  Branch (731:28): [True: 22.1k, False: 0]
  |  |  |  Branch (731:44): [True: 0, False: 22.1k]
  |  |  ------------------
  |  |  732|  22.1k|    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|  22.1k|  this->field = value; \
  |  |  734|  22.1k|}
  ------------------
  769|  22.1k|    break;
  770|      0|  case TJPARAM_JPEGWIDTH:
  ------------------
  |  Branch (770:3): [True: 0, False: 438k]
  ------------------
  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: 438k]
  ------------------
  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: 438k]
  ------------------
  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|  49.2k|  case TJPARAM_COLORSPACE:
  ------------------
  |  Branch (783:3): [True: 49.2k, False: 389k]
  ------------------
  784|  49.2k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (784:9): [True: 0, False: 49.2k]
  ------------------
  785|  49.2k|      THROW("TJPARAM_COLORSPACE is read-only in decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  786|  49.2k|    SET_PARAM(colorspace, TJCS_DEFAULT, TJ_NUMCS - 1);
  ------------------
  |  |  730|  49.2k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|  49.2k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 49.2k]
  |  |  |  Branch (731:28): [True: 49.2k, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 49.2k]
  |  |  ------------------
  |  |  732|  49.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|  49.2k|  this->field = value; \
  |  |  734|  49.2k|}
  ------------------
  787|  49.2k|    break;
  788|      0|  case TJPARAM_FASTUPSAMPLE:
  ------------------
  |  Branch (788:3): [True: 0, False: 438k]
  ------------------
  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|  49.2k|  case TJPARAM_FASTDCT:
  ------------------
  |  Branch (793:3): [True: 49.2k, False: 389k]
  ------------------
  794|  49.2k|    SET_BOOL_PARAM(fastDCT);
  ------------------
  |  |  736|  49.2k|#define SET_BOOL_PARAM(field) { \
  |  |  737|  49.2k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (737:7): [True: 0, False: 49.2k]
  |  |  |  Branch (737:20): [True: 0, False: 49.2k]
  |  |  ------------------
  |  |  738|  49.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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  739|  49.2k|  this->field = (boolean)value; \
  |  |  740|  49.2k|}
  ------------------
  795|  49.2k|    break;
  796|      0|  case TJPARAM_OPTIMIZE:
  ------------------
  |  Branch (796:3): [True: 0, False: 438k]
  ------------------
  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|  49.2k|  case TJPARAM_PROGRESSIVE:
  ------------------
  |  Branch (801:3): [True: 49.2k, False: 389k]
  ------------------
  802|  49.2k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (802:9): [True: 0, False: 49.2k]
  ------------------
  803|  49.2k|      THROW("TJPARAM_PROGRESSIVE is read-only in decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  804|  49.2k|    SET_BOOL_PARAM(progressive);
  ------------------
  |  |  736|  49.2k|#define SET_BOOL_PARAM(field) { \
  |  |  737|  49.2k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (737:7): [True: 0, False: 49.2k]
  |  |  |  Branch (737:20): [True: 0, False: 49.2k]
  |  |  ------------------
  |  |  738|  49.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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  739|  49.2k|  this->field = (boolean)value; \
  |  |  740|  49.2k|}
  ------------------
  805|  49.2k|    break;
  806|      0|  case TJPARAM_SCANLIMIT:
  ------------------
  |  Branch (806:3): [True: 0, False: 438k]
  ------------------
  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|  49.2k|  case TJPARAM_ARITHMETIC:
  ------------------
  |  Branch (811:3): [True: 49.2k, False: 389k]
  ------------------
  812|  49.2k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (812:9): [True: 0, False: 49.2k]
  ------------------
  813|  49.2k|      THROW("TJPARAM_ARITHMETIC is read-only in decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  814|  49.2k|    SET_BOOL_PARAM(arithmetic);
  ------------------
  |  |  736|  49.2k|#define SET_BOOL_PARAM(field) { \
  |  |  737|  49.2k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (737:7): [True: 0, False: 49.2k]
  |  |  |  Branch (737:20): [True: 0, False: 49.2k]
  |  |  ------------------
  |  |  738|  49.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|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  739|  49.2k|  this->field = (boolean)value; \
  |  |  740|  49.2k|}
  ------------------
  815|  49.2k|    break;
  816|      0|  case TJPARAM_LOSSLESS:
  ------------------
  |  Branch (816:3): [True: 0, False: 438k]
  ------------------
  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: 438k]
  ------------------
  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: 438k]
  ------------------
  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: 438k]
  ------------------
  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|  49.2k|  case TJPARAM_RESTARTROWS:
  ------------------
  |  Branch (837:3): [True: 49.2k, False: 389k]
  ------------------
  838|  49.2k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (838:9): [True: 0, False: 49.2k]
  ------------------
  839|  49.2k|      THROW("TJPARAM_RESTARTROWS is not applicable to decompression instances.");
  ------------------
  |  |  283|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  279|      0|#define THROWRV(m, rv) { \
  |  |  |  |  280|      0|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  ------------------
  |  |  |  |                 SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  ------------------
  |  |  |  |  281|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  254|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  255|      0|  SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define SNPRINTF  snprintf
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  792|      0|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  257|      0|}
  |  |  |  |  ------------------
  |  |  |  |  282|      0|}
  |  |  ------------------
  ------------------
  840|  49.2k|    SET_PARAM(restartIntervalRows, 0, 65535);
  ------------------
  |  |  730|  49.2k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|  49.2k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 49.2k]
  |  |  |  Branch (731:28): [True: 49.2k, Folded]
  |  |  |  Branch (731:44): [True: 0, False: 49.2k]
  |  |  ------------------
  |  |  732|  49.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|  49.2k|  this->field = value; \
  |  |  734|  49.2k|}
  ------------------
  841|  49.2k|    if (value != 0) this->restartIntervalBlocks = 0;
  ------------------
  |  Branch (841:9): [True: 14.0k, False: 35.1k]
  ------------------
  842|  49.2k|    break;
  843|      0|  case TJPARAM_XDENSITY:
  ------------------
  |  Branch (843:3): [True: 0, False: 438k]
  ------------------
  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: 438k]
  ------------------
  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: 438k]
  ------------------
  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: 438k]
  ------------------
  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|  49.2k|  case TJPARAM_MAXPIXELS:
  ------------------
  |  Branch (861:3): [True: 49.2k, False: 389k]
  ------------------
  862|  49.2k|    SET_PARAM(maxPixels, 0, -1);
  ------------------
  |  |  730|  49.2k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  731|  49.2k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (731:7): [True: 0, False: 49.2k]
  |  |  |  Branch (731:28): [Folded, False: 49.2k]
  |  |  |  Branch (731:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  732|  49.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|  49.2k|  this->field = value; \
  |  |  734|  49.2k|}
  ------------------
  863|  49.2k|    break;
  864|      0|  case TJPARAM_SAVEMARKERS:
  ------------------
  |  Branch (864:3): [True: 0, False: 438k]
  ------------------
  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: 438k]
  ------------------
  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|   438k|  }
  870|       |
  871|   438k|bailout:
  872|   438k|  return retval;
  873|   438k|}
tj3Get:
  878|  22.1k|{
  879|  22.1k|  tjinstance *this = (tjinstance *)handle;
  880|  22.1k|  if (!this) return -1;
  ------------------
  |  Branch (880:7): [True: 0, False: 22.1k]
  ------------------
  881|       |
  882|  22.1k|  switch (param) {
  ------------------
  |  Branch (882:11): [True: 22.1k, False: 0]
  ------------------
  883|      0|  case TJPARAM_STOPONWARNING:
  ------------------
  |  Branch (883:3): [True: 0, False: 22.1k]
  ------------------
  884|      0|    return this->jerr.stopOnWarning;
  885|      0|  case TJPARAM_BOTTOMUP:
  ------------------
  |  Branch (885:3): [True: 0, False: 22.1k]
  ------------------
  886|      0|    return this->bottomUp;
  887|  22.1k|  case TJPARAM_NOREALLOC:
  ------------------
  |  Branch (887:3): [True: 22.1k, False: 0]
  ------------------
  888|  22.1k|    return this->noRealloc;
  889|      0|  case TJPARAM_QUALITY:
  ------------------
  |  Branch (889:3): [True: 0, False: 22.1k]
  ------------------
  890|      0|    return this->quality;
  891|      0|  case TJPARAM_SUBSAMP:
  ------------------
  |  Branch (891:3): [True: 0, False: 22.1k]
  ------------------
  892|      0|    return this->subsamp;
  893|      0|  case TJPARAM_JPEGWIDTH:
  ------------------
  |  Branch (893:3): [True: 0, False: 22.1k]
  ------------------
  894|      0|    return this->jpegWidth;
  895|      0|  case TJPARAM_JPEGHEIGHT:
  ------------------
  |  Branch (895:3): [True: 0, False: 22.1k]
  ------------------
  896|      0|    return this->jpegHeight;
  897|      0|  case TJPARAM_PRECISION:
  ------------------
  |  Branch (897:3): [True: 0, False: 22.1k]
  ------------------
  898|      0|    return this->precision;
  899|      0|  case TJPARAM_COLORSPACE:
  ------------------
  |  Branch (899:3): [True: 0, False: 22.1k]
  ------------------
  900|      0|    return this->colorspace;
  901|      0|  case TJPARAM_FASTUPSAMPLE:
  ------------------
  |  Branch (901:3): [True: 0, False: 22.1k]
  ------------------
  902|      0|    return this->fastUpsample;
  903|      0|  case TJPARAM_FASTDCT:
  ------------------
  |  Branch (903:3): [True: 0, False: 22.1k]
  ------------------
  904|      0|    return this->fastDCT;
  905|      0|  case TJPARAM_OPTIMIZE:
  ------------------
  |  Branch (905:3): [True: 0, False: 22.1k]
  ------------------
  906|      0|    return this->optimize;
  907|      0|  case TJPARAM_PROGRESSIVE:
  ------------------
  |  Branch (907:3): [True: 0, False: 22.1k]
  ------------------
  908|      0|    return this->progressive;
  909|      0|  case TJPARAM_SCANLIMIT:
  ------------------
  |  Branch (909:3): [True: 0, False: 22.1k]
  ------------------
  910|      0|    return this->scanLimit;
  911|      0|  case TJPARAM_ARITHMETIC:
  ------------------
  |  Branch (911:3): [True: 0, False: 22.1k]
  ------------------
  912|      0|    return this->arithmetic;
  913|      0|  case TJPARAM_LOSSLESS:
  ------------------
  |  Branch (913:3): [True: 0, False: 22.1k]
  ------------------
  914|      0|    return this->lossless;
  915|      0|  case TJPARAM_LOSSLESSPSV:
  ------------------
  |  Branch (915:3): [True: 0, False: 22.1k]
  ------------------
  916|      0|    return this->losslessPSV;
  917|      0|  case TJPARAM_LOSSLESSPT:
  ------------------
  |  Branch (917:3): [True: 0, False: 22.1k]
  ------------------
  918|      0|    return this->losslessPt;
  919|      0|  case TJPARAM_RESTARTBLOCKS:
  ------------------
  |  Branch (919:3): [True: 0, False: 22.1k]
  ------------------
  920|      0|    return this->restartIntervalBlocks;
  921|      0|  case TJPARAM_RESTARTROWS:
  ------------------
  |  Branch (921:3): [True: 0, False: 22.1k]
  ------------------
  922|      0|    return this->restartIntervalRows;
  923|      0|  case TJPARAM_XDENSITY:
  ------------------
  |  Branch (923:3): [True: 0, False: 22.1k]
  ------------------
  924|      0|    return this->xDensity;
  925|      0|  case TJPARAM_YDENSITY:
  ------------------
  |  Branch (925:3): [True: 0, False: 22.1k]
  ------------------
  926|      0|    return this->yDensity;
  927|      0|  case TJPARAM_DENSITYUNITS:
  ------------------
  |  Branch (927:3): [True: 0, False: 22.1k]
  ------------------
  928|      0|    return this->densityUnits;
  929|      0|  case TJPARAM_MAXMEMORY:
  ------------------
  |  Branch (929:3): [True: 0, False: 22.1k]
  ------------------
  930|      0|    return this->maxMemory;
  931|      0|  case TJPARAM_MAXPIXELS:
  ------------------
  |  Branch (931:3): [True: 0, False: 22.1k]
  ------------------
  932|      0|    return this->maxPixels;
  933|      0|  case TJPARAM_SAVEMARKERS:
  ------------------
  |  Branch (933:3): [True: 0, False: 22.1k]
  ------------------
  934|      0|    return this->saveMarkers;
  935|  22.1k|  }
  936|       |
  937|      0|  return -1;
  938|  22.1k|}
tj3Alloc:
  948|  3.13k|{
  949|  3.13k|  return MALLOC(bytes);
  ------------------
  |  |  520|  3.13k|#define MALLOC(size)  malloc(size)
  ------------------
  950|  3.13k|}
tj3Free:
  961|  58.4k|{
  962|  58.4k|  free(buf);
  963|  58.4k|}
tj3JPEGBufSize:
  974|  22.1k|{
  975|  22.1k|  static const char FUNCTION_NAME[] = "tj3JPEGBufSize";
  976|  22.1k|  unsigned long long retval = 0;
  977|  22.1k|  int mcuw, mcuh, chromasf;
  978|       |
  979|  22.1k|  if (width < 1 || height < 1 || jpegSubsamp < TJSAMP_UNKNOWN ||
  ------------------
  |  Branch (979:7): [True: 0, False: 22.1k]
  |  Branch (979:20): [True: 0, False: 22.1k]
  |  Branch (979:34): [True: 0, False: 22.1k]
  ------------------
  980|  22.1k|      jpegSubsamp >= TJ_NUMSAMP)
  ------------------
  |  |  111|  22.1k|#define TJ_NUMSAMP  9
  ------------------
  |  Branch (980:7): [True: 0, False: 22.1k]
  ------------------
  981|  22.1k|    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|  22.1k|  if (jpegSubsamp == TJSAMP_UNKNOWN)
  ------------------
  |  Branch (983:7): [True: 0, False: 22.1k]
  ------------------
  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|  22.1k|  mcuw = tjMCUWidth[jpegSubsamp];
  990|  22.1k|  mcuh = tjMCUHeight[jpegSubsamp];
  991|  22.1k|  chromasf = jpegSubsamp == TJSAMP_GRAY ? 0 : 4 * 64 / (mcuw * mcuh);
  ------------------
  |  Branch (991:14): [True: 6.76k, False: 15.4k]
  ------------------
  992|  22.1k|  retval = (unsigned long long)PAD(width, mcuw) * PAD(height, mcuh) *
  ------------------
  |  |   57|  22.1k|#define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
  ------------------
                retval = (unsigned long long)PAD(width, mcuw) * PAD(height, mcuh) *
  ------------------
  |  |   57|  22.1k|#define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
  ------------------
  993|  22.1k|           (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|  22.1k|bailout:
 1000|  22.1k|  return (size_t)retval;
 1001|  22.1k|}
tj3SetICCProfile:
 1240|  18.6k|{
 1241|  18.6k|  static const char FUNCTION_NAME[] = "tj3SetICCProfile";
 1242|  18.6k|  int retval = 0;
 1243|       |
 1244|  18.6k|  GET_TJINSTANCE(handle, -1)
  ------------------
  |  |  350|  18.6k|  tjinstance *this = (tjinstance *)handle; \
  |  |  351|  18.6k|  \
  |  |  352|  18.6k|  if (!this) { \
  |  |  ------------------
  |  |  |  Branch (352:7): [True: 0, False: 18.6k]
  |  |  ------------------
  |  |  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|  18.6k|  this->jerr.warning = FALSE; \
  |  |  ------------------
  |  |  |  |  207|  18.6k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  357|  18.6k|  this->isInstanceError = FALSE;
  |  |  ------------------
  |  |  |  |  207|  18.6k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  ------------------
 1245|  18.6k|  if ((this->init & COMPRESS) == 0)
  ------------------
  |  Branch (1245:7): [True: 0, False: 18.6k]
  ------------------
 1246|  18.6k|    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|  18.6k|  if (iccBuf == this->iccBuf && iccSize == this->iccSize)
  ------------------
  |  Branch (1248:7): [True: 0, False: 18.6k]
  |  Branch (1248:33): [True: 0, False: 0]
  ------------------
 1249|      0|    return 0;
 1250|       |
 1251|  18.6k|  free(this->iccBuf);
 1252|  18.6k|  this->iccBuf = NULL;
 1253|  18.6k|  this->iccSize = 0;
 1254|  18.6k|  if (iccBuf && iccSize) {
  ------------------
  |  Branch (1254:7): [True: 18.6k, False: 0]
  |  Branch (1254:17): [True: 18.6k, False: 0]
  ------------------
 1255|  18.6k|    if ((this->iccBuf = (unsigned char *)malloc(iccSize)) == NULL)
  ------------------
  |  Branch (1255:9): [True: 0, False: 18.6k]
  ------------------
 1256|  18.6k|      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|  18.6k|    memcpy(this->iccBuf, iccBuf, iccSize);
 1258|  18.6k|    this->iccSize = iccSize;
 1259|  18.6k|  }
 1260|       |
 1261|  18.6k|bailout:
 1262|  18.6k|  return retval;
 1263|  18.6k|}
turbojpeg.c:_tjInitCompress:
 1200|  56.2k|{
 1201|  56.2k|  static unsigned char buffer[1];
 1202|  56.2k|  unsigned char *buf = buffer;
 1203|  56.2k|  size_t size = 1;
 1204|       |
 1205|       |  /* This is also straight out of example.c */
 1206|  56.2k|  this->cinfo.err = jpeg_std_error(&this->jerr.pub);
 1207|  56.2k|  this->jerr.pub.error_exit = my_error_exit;
 1208|  56.2k|  this->jerr.pub.output_message = my_output_message;
 1209|  56.2k|  this->jerr.emit_message = this->jerr.pub.emit_message;
 1210|  56.2k|  this->jerr.pub.emit_message = my_emit_message;
 1211|  56.2k|  this->jerr.pub.addon_message_table = turbojpeg_message_table;
 1212|  56.2k|  this->jerr.pub.first_addon_message = JMSG_FIRSTADDONCODE;
 1213|  56.2k|  this->jerr.pub.last_addon_message = JMSG_LASTADDONCODE;
 1214|  56.2k|  this->jerr.tjHandle = (tjhandle)this;
 1215|       |
 1216|  56.2k|  if (setjmp(this->jerr.setjmp_buffer)) {
  ------------------
  |  Branch (1216:7): [True: 0, False: 56.2k]
  ------------------
 1217|       |    /* If we get here, the JPEG code has signaled an error. */
 1218|      0|    free(this);
 1219|      0|    return NULL;
 1220|      0|  }
 1221|       |
 1222|  56.2k|  jpeg_create_compress(&this->cinfo);
  ------------------
  |  |  969|  56.2k|  jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
  |  |  ------------------
  |  |  |  |    4|  56.2k|#define JPEG_LIB_VERSION  62
  |  |  ------------------
  |  |  970|  56.2k|                      (size_t)sizeof(struct jpeg_compress_struct))
  ------------------
 1223|       |  /* Make an initial call so it will create the destination manager */
 1224|  56.2k|  jpeg_mem_dest_tj(&this->cinfo, &buf, &size, 0);
 1225|       |
 1226|  56.2k|  this->init |= COMPRESS;
 1227|  56.2k|  return (tjhandle)this;
 1228|  56.2k|}
turbojpeg.c:my_error_exit:
   81|  36.2k|{
   82|  36.2k|  my_error_ptr myerr = (my_error_ptr)cinfo->err;
   83|       |
   84|  36.2k|  (*cinfo->err->output_message) (cinfo);
   85|  36.2k|  longjmp(myerr->setjmp_buffer, 1);
   86|  36.2k|}
turbojpeg.c:my_output_message:
  149|  36.2k|{
  150|  36.2k|  my_error_ptr myerr = (my_error_ptr)cinfo->err;
  151|  36.2k|  tjinstance *this = (tjinstance *)myerr->tjHandle;
  152|       |
  153|  36.2k|  if (this) {
  ------------------
  |  Branch (153:7): [True: 36.2k, False: 0]
  ------------------
  154|  36.2k|    this->isInstanceError = TRUE;
  ------------------
  |  |  210|  36.2k|#define TRUE    1
  ------------------
  155|  36.2k|    (*cinfo->err->format_message) (cinfo, this->errStr);
  156|  36.2k|  } else
  157|      0|    (*cinfo->err->format_message) (cinfo, errStr);
  158|  36.2k|}
turbojpeg.c:my_emit_message:
   89|  35.0k|{
   90|  35.0k|  my_error_ptr myerr = (my_error_ptr)cinfo->err;
   91|       |
   92|  35.0k|  myerr->emit_message(cinfo, msg_level);
   93|  35.0k|  if (msg_level < 0) {
  ------------------
  |  Branch (93:7): [True: 0, False: 35.0k]
  ------------------
   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|  35.0k|}
turbojpeg.c:setCompDefaults:
  379|  22.1k|{
  380|  22.1k|  int colorspace = yuv ? TJCS_DEFAULT : this->colorspace;
  ------------------
  |  Branch (380:20): [True: 0, False: 22.1k]
  ------------------
  381|       |
  382|  22.1k|  this->cinfo.in_color_space = pf2cs[pixelFormat];
  383|  22.1k|  this->cinfo.input_components = tjPixelSize[pixelFormat];
  384|  22.1k|  jpeg_set_defaults(&this->cinfo);
  385|       |
  386|  22.1k|  this->cinfo.restart_interval = this->restartIntervalBlocks;
  387|  22.1k|  this->cinfo.restart_in_rows = this->restartIntervalRows;
  388|  22.1k|  this->cinfo.X_density = (UINT16)this->xDensity;
  389|  22.1k|  this->cinfo.Y_density = (UINT16)this->yDensity;
  390|  22.1k|  this->cinfo.density_unit = (UINT8)this->densityUnits;
  391|  22.1k|  this->cinfo.mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
  392|       |
  393|  22.1k|  if (this->lossless && !yuv) {
  ------------------
  |  Branch (393:7): [True: 0, False: 22.1k]
  |  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|  22.1k|  jpeg_set_quality(&this->cinfo, this->quality, TRUE);
  ------------------
  |  |  210|  22.1k|#define TRUE    1
  ------------------
  401|  22.1k|  this->cinfo.dct_method = this->fastDCT ? JDCT_FASTEST : JDCT_ISLOW;
  ------------------
  |  |  304|  3.13k|#define JDCT_FASTEST  JDCT_IFAST
  ------------------
  |  Branch (401:28): [True: 3.13k, False: 19.0k]
  ------------------
  402|       |
  403|  22.1k|  switch (colorspace) {
  404|  3.05k|  case TJCS_RGB:
  ------------------
  |  Branch (404:3): [True: 3.05k, False: 19.1k]
  ------------------
  405|  3.05k|    jpeg_set_colorspace(&this->cinfo, JCS_RGB);  break;
  406|  3.13k|  case TJCS_YCbCr:
  ------------------
  |  Branch (406:3): [True: 3.13k, False: 19.0k]
  ------------------
  407|  3.13k|    jpeg_set_colorspace(&this->cinfo, JCS_YCbCr);  break;
  408|  3.05k|  case TJCS_GRAY:
  ------------------
  |  Branch (408:3): [True: 3.05k, False: 19.1k]
  ------------------
  409|  3.05k|    jpeg_set_colorspace(&this->cinfo, JCS_GRAYSCALE);  break;
  410|      0|  case TJCS_CMYK:
  ------------------
  |  Branch (410:3): [True: 0, False: 22.1k]
  ------------------
  411|      0|    jpeg_set_colorspace(&this->cinfo, JCS_CMYK);  break;
  412|  3.05k|  case TJCS_YCCK:
  ------------------
  |  Branch (412:3): [True: 3.05k, False: 19.1k]
  ------------------
  413|  3.05k|    jpeg_set_colorspace(&this->cinfo, JCS_YCCK);  break;
  414|  9.90k|  default:
  ------------------
  |  Branch (414:3): [True: 9.90k, False: 12.2k]
  ------------------
  415|  9.90k|    if (this->subsamp == TJSAMP_GRAY)
  ------------------
  |  Branch (415:9): [True: 3.71k, False: 6.18k]
  ------------------
  416|  3.71k|      jpeg_set_colorspace(&this->cinfo, JCS_GRAYSCALE);
  417|  6.18k|    else if (pixelFormat == TJPF_CMYK)
  ------------------
  |  Branch (417:14): [True: 0, False: 6.18k]
  ------------------
  418|      0|      jpeg_set_colorspace(&this->cinfo, JCS_YCCK);
  419|  6.18k|    else
  420|  6.18k|      jpeg_set_colorspace(&this->cinfo, JCS_YCbCr);
  421|  22.1k|  }
  422|       |
  423|  22.1k|  if (this->cinfo.data_precision == 8)
  ------------------
  |  Branch (423:7): [True: 0, False: 22.1k]
  ------------------
  424|      0|    this->cinfo.optimize_coding = this->optimize;
  425|  22.1k|#ifdef C_PROGRESSIVE_SUPPORTED
  426|  22.1k|  if (this->progressive) jpeg_simple_progression(&this->cinfo);
  ------------------
  |  Branch (426:7): [True: 6.76k, False: 15.4k]
  ------------------
  427|  22.1k|#endif
  428|  22.1k|  this->cinfo.arith_code = this->arithmetic;
  429|       |
  430|  22.1k|  this->cinfo.comp_info[0].h_samp_factor = tjMCUWidth[this->subsamp] / 8;
  431|  22.1k|  this->cinfo.comp_info[1].h_samp_factor = 1;
  432|  22.1k|  this->cinfo.comp_info[2].h_samp_factor = 1;
  433|  22.1k|  if (this->cinfo.num_components > 3)
  ------------------
  |  Branch (433:7): [True: 3.05k, False: 19.1k]
  ------------------
  434|  3.05k|    this->cinfo.comp_info[3].h_samp_factor = tjMCUWidth[this->subsamp] / 8;
  435|  22.1k|  this->cinfo.comp_info[0].v_samp_factor = tjMCUHeight[this->subsamp] / 8;
  436|  22.1k|  this->cinfo.comp_info[1].v_samp_factor = 1;
  437|  22.1k|  this->cinfo.comp_info[2].v_samp_factor = 1;
  438|  22.1k|  if (this->cinfo.num_components > 3)
  ------------------
  |  Branch (438:7): [True: 3.05k, False: 19.1k]
  ------------------
  439|  3.05k|    this->cinfo.comp_info[3].v_samp_factor = tjMCUHeight[this->subsamp] / 8;
  440|  22.1k|}

