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

jsimd_set_rgb_ycc:
  113|  10.8k|{
  114|  10.8k|  init_simd((j_common_ptr)cinfo);
  115|       |
  116|  10.8k|  if (BITS_IN_JSAMPLE != 8)
  ------------------
  |  |   34|  10.8k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (116:7): [Folded, False: 10.8k]
  ------------------
  117|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  118|  10.8k|  if (sizeof(JDIMENSION) != 4)
  ------------------
  |  Branch (118:7): [Folded, False: 10.8k]
  ------------------
  119|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  120|  10.8k|  if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
  ------------------
  |  |  302|  10.8k|#define RGB_PIXELSIZE   3       /* JSAMPLEs per RGB scanline element */
  ------------------
                if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
  ------------------
  |  |  302|      0|#define RGB_PIXELSIZE   3       /* JSAMPLEs per RGB scanline element */
  ------------------
  |  Branch (120:7): [Folded, False: 10.8k]
  |  Branch (120:31): [True: 0, Folded]
  ------------------
  121|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  122|  10.8k|  if (!cinfo->cconvert)
  ------------------
  |  Branch (122:7): [True: 0, False: 10.8k]
  ------------------
  123|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  124|       |
  125|  10.8k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
  126|  10.8k|  if ((cinfo->master->simd_support & JSIMD_AVX2) &&
  ------------------
  |  |   46|  10.8k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (126:7): [True: 10.8k, False: 0]
  ------------------
  127|  10.8k|      IS_ALIGNED_AVX(jconst_rgb_ycc_convert_avx2)) {
  ------------------
  |  |   46|  10.8k|#define IS_ALIGNED_AVX(ptr)  (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
  |  |  ------------------
  |  |  |  |   43|  10.8k|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (46:30): [True: 10.8k, False: 0]
  |  |  ------------------
  ------------------
  128|  10.8k|    SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, avx2);
  ------------------
  |  |   41|  10.8k|#define SET_SIMD_EXTRGB_COLOR_CONVERTER(cs, instrset) { \
  |  |   42|  10.8k|  switch (cinfo->in_color_space) { \
  |  |   43|      0|    case JCS_EXT_RGB: \
  |  |  ------------------
  |  |  |  Branch (43:5): [True: 0, False: 10.8k]
  |  |  ------------------
  |  |   44|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   45|      0|        jsimd_extrgb_##cs##_convert_##instrset; \
  |  |   46|      0|      break; \
  |  |   47|  3.56k|    case JCS_EXT_RGBX: \
  |  |  ------------------
  |  |  |  Branch (47:5): [True: 3.56k, False: 7.32k]
  |  |  ------------------
  |  |   48|  3.56k|    case JCS_EXT_RGBA: \
  |  |  ------------------
  |  |  |  Branch (48:5): [True: 0, False: 10.8k]
  |  |  ------------------
  |  |   49|  3.56k|      cinfo->cconvert->color_convert_simd = \
  |  |   50|  3.56k|        jsimd_extrgbx_##cs##_convert_##instrset; \
  |  |   51|  3.56k|      break; \
  |  |   52|  3.76k|    case JCS_EXT_BGR: \
  |  |  ------------------
  |  |  |  Branch (52:5): [True: 3.76k, False: 7.12k]
  |  |  ------------------
  |  |   53|  3.76k|      cinfo->cconvert->color_convert_simd = \
  |  |   54|  3.76k|        jsimd_extbgr_##cs##_convert_##instrset; \
  |  |   55|  3.76k|      break; \
  |  |   56|  3.56k|    case JCS_EXT_BGRX: \
  |  |  ------------------
  |  |  |  Branch (56:5): [True: 0, False: 10.8k]
  |  |  ------------------
  |  |   57|  3.56k|    case JCS_EXT_BGRA: \
  |  |  ------------------
  |  |  |  Branch (57:5): [True: 3.56k, False: 7.32k]
  |  |  ------------------
  |  |   58|  3.56k|      cinfo->cconvert->color_convert_simd = \
  |  |   59|  3.56k|        jsimd_extbgrx_##cs##_convert_##instrset; \
  |  |   60|  3.56k|      break; \
  |  |   61|      0|    case JCS_EXT_XBGR: \
  |  |  ------------------
  |  |  |  Branch (61:5): [True: 0, False: 10.8k]
  |  |  ------------------
  |  |   62|      0|    case JCS_EXT_ABGR: \
  |  |  ------------------
  |  |  |  Branch (62:5): [True: 0, False: 10.8k]
  |  |  ------------------
  |  |   63|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   64|      0|        jsimd_extxbgr_##cs##_convert_##instrset; \
  |  |   65|      0|      break; \
  |  |   66|      0|    case JCS_EXT_XRGB: \
  |  |  ------------------
  |  |  |  Branch (66:5): [True: 0, False: 10.8k]
  |  |  ------------------
  |  |   67|      0|    case JCS_EXT_ARGB: \
  |  |  ------------------
  |  |  |  Branch (67:5): [True: 0, False: 10.8k]
  |  |  ------------------
  |  |   68|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   69|      0|        jsimd_extxrgb_##cs##_convert_##instrset; \
  |  |   70|      0|      break; \
  |  |   71|      0|    default: \
  |  |  ------------------
  |  |  |  Branch (71:5): [True: 0, False: 10.8k]
  |  |  ------------------
  |  |   72|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   73|      0|        jsimd_rgb_##cs##_convert_##instrset; \
  |  |   74|  10.8k|  } \
  |  |   75|  10.8k|}
  ------------------
  129|  10.8k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  10.8k|#define JSIMD_AVX2       0x80
  ------------------
  130|  10.8k|  }
  131|      0|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (131:7): [True: 0, False: 0]
  ------------------
  132|      0|      IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) {
  ------------------
  |  |   45|      0|#define IS_ALIGNED_SSE(ptr)  (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
  |  |  ------------------
  |  |  |  |   43|      0|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (45:30): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  133|      0|    SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, sse2);
  ------------------
  |  |   41|      0|#define SET_SIMD_EXTRGB_COLOR_CONVERTER(cs, instrset) { \
  |  |   42|      0|  switch (cinfo->in_color_space) { \
  |  |   43|      0|    case JCS_EXT_RGB: \
  |  |  ------------------
  |  |  |  Branch (43:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   44|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   45|      0|        jsimd_extrgb_##cs##_convert_##instrset; \
  |  |   46|      0|      break; \
  |  |   47|      0|    case JCS_EXT_RGBX: \
  |  |  ------------------
  |  |  |  Branch (47:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   48|      0|    case JCS_EXT_RGBA: \
  |  |  ------------------
  |  |  |  Branch (48:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   50|      0|        jsimd_extrgbx_##cs##_convert_##instrset; \
  |  |   51|      0|      break; \
  |  |   52|      0|    case JCS_EXT_BGR: \
  |  |  ------------------
  |  |  |  Branch (52:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   53|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   54|      0|        jsimd_extbgr_##cs##_convert_##instrset; \
  |  |   55|      0|      break; \
  |  |   56|      0|    case JCS_EXT_BGRX: \
  |  |  ------------------
  |  |  |  Branch (56:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|    case JCS_EXT_BGRA: \
  |  |  ------------------
  |  |  |  Branch (57:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   58|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   59|      0|        jsimd_extbgrx_##cs##_convert_##instrset; \
  |  |   60|      0|      break; \
  |  |   61|      0|    case JCS_EXT_XBGR: \
  |  |  ------------------
  |  |  |  Branch (61:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   62|      0|    case JCS_EXT_ABGR: \
  |  |  ------------------
  |  |  |  Branch (62:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   63|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   64|      0|        jsimd_extxbgr_##cs##_convert_##instrset; \
  |  |   65|      0|      break; \
  |  |   66|      0|    case JCS_EXT_XRGB: \
  |  |  ------------------
  |  |  |  Branch (66:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   67|      0|    case JCS_EXT_ARGB: \
  |  |  ------------------
  |  |  |  Branch (67:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   68|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   69|      0|        jsimd_extxrgb_##cs##_convert_##instrset; \
  |  |   70|      0|      break; \
  |  |   71|      0|    default: \
  |  |  ------------------
  |  |  |  Branch (71:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   72|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   73|      0|        jsimd_rgb_##cs##_convert_##instrset; \
  |  |   74|      0|  } \
  |  |   75|      0|}
  ------------------
  134|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  135|      0|  }
  136|       |#if SIMD_ARCHITECTURE == I386
  137|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
  138|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, mmx);
  139|       |    return JSIMD_MMX;
  140|       |  }
  141|       |#endif
  142|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
  143|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
  144|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, neon);
  145|       |    return JSIMD_NEON;
  146|       |  }
  147|       |#elif SIMD_ARCHITECTURE == POWERPC
  148|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
  149|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, altivec);
  150|       |    return JSIMD_ALTIVEC;
  151|       |  }
  152|       |#elif SIMD_ARCHITECTURE == RISCV64
  153|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
  154|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, rvv);
  155|       |    return JSIMD_RVV;
  156|       |  }
  157|       |#elif SIMD_ARCHITECTURE == MIPS64
  158|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
  159|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, mmi);
  160|       |    return JSIMD_MMI;
  161|       |  }
  162|       |#endif
  163|       |
  164|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  165|      0|}
jsimd_set_rgb_gray:
  170|  3.56k|{
  171|  3.56k|  init_simd((j_common_ptr)cinfo);
  172|       |
  173|  3.56k|  if (BITS_IN_JSAMPLE != 8)
  ------------------
  |  |   34|  3.56k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (173:7): [Folded, False: 3.56k]
  ------------------
  174|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  175|  3.56k|  if (sizeof(JDIMENSION) != 4)
  ------------------
  |  Branch (175:7): [Folded, False: 3.56k]
  ------------------
  176|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  177|  3.56k|  if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
  ------------------
  |  |  302|  3.56k|#define RGB_PIXELSIZE   3       /* JSAMPLEs per RGB scanline element */
  ------------------
                if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
  ------------------
  |  |  302|      0|#define RGB_PIXELSIZE   3       /* JSAMPLEs per RGB scanline element */
  ------------------
  |  Branch (177:7): [Folded, False: 3.56k]
  |  Branch (177:31): [True: 0, Folded]
  ------------------
  178|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  179|  3.56k|  if (!cinfo->cconvert)
  ------------------
  |  Branch (179:7): [True: 0, False: 3.56k]
  ------------------
  180|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  181|       |
  182|  3.56k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
  183|  3.56k|  if ((cinfo->master->simd_support & JSIMD_AVX2) &&
  ------------------
  |  |   46|  3.56k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (183:7): [True: 3.56k, False: 0]
  ------------------
  184|  3.56k|      IS_ALIGNED_AVX(jconst_rgb_gray_convert_avx2)) {
  ------------------
  |  |   46|  3.56k|#define IS_ALIGNED_AVX(ptr)  (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
  |  |  ------------------
  |  |  |  |   43|  3.56k|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (46:30): [True: 3.56k, False: 0]
  |  |  ------------------
  ------------------
  185|  3.56k|    SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, avx2);
  ------------------
  |  |   41|  3.56k|#define SET_SIMD_EXTRGB_COLOR_CONVERTER(cs, instrset) { \
  |  |   42|  3.56k|  switch (cinfo->in_color_space) { \
  |  |   43|      0|    case JCS_EXT_RGB: \
  |  |  ------------------
  |  |  |  Branch (43:5): [True: 0, False: 3.56k]
  |  |  ------------------
  |  |   44|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   45|      0|        jsimd_extrgb_##cs##_convert_##instrset; \
  |  |   46|      0|      break; \
  |  |   47|      0|    case JCS_EXT_RGBX: \
  |  |  ------------------
  |  |  |  Branch (47:5): [True: 0, False: 3.56k]
  |  |  ------------------
  |  |   48|      0|    case JCS_EXT_RGBA: \
  |  |  ------------------
  |  |  |  Branch (48:5): [True: 0, False: 3.56k]
  |  |  ------------------
  |  |   49|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   50|      0|        jsimd_extrgbx_##cs##_convert_##instrset; \
  |  |   51|      0|      break; \
  |  |   52|      0|    case JCS_EXT_BGR: \
  |  |  ------------------
  |  |  |  Branch (52:5): [True: 0, False: 3.56k]
  |  |  ------------------
  |  |   53|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   54|      0|        jsimd_extbgr_##cs##_convert_##instrset; \
  |  |   55|      0|      break; \
  |  |   56|      0|    case JCS_EXT_BGRX: \
  |  |  ------------------
  |  |  |  Branch (56:5): [True: 0, False: 3.56k]
  |  |  ------------------
  |  |   57|      0|    case JCS_EXT_BGRA: \
  |  |  ------------------
  |  |  |  Branch (57:5): [True: 0, False: 3.56k]
  |  |  ------------------
  |  |   58|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   59|      0|        jsimd_extbgrx_##cs##_convert_##instrset; \
  |  |   60|      0|      break; \
  |  |   61|      0|    case JCS_EXT_XBGR: \
  |  |  ------------------
  |  |  |  Branch (61:5): [True: 0, False: 3.56k]
  |  |  ------------------
  |  |   62|      0|    case JCS_EXT_ABGR: \
  |  |  ------------------
  |  |  |  Branch (62:5): [True: 0, False: 3.56k]
  |  |  ------------------
  |  |   63|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   64|      0|        jsimd_extxbgr_##cs##_convert_##instrset; \
  |  |   65|      0|      break; \
  |  |   66|  3.56k|    case JCS_EXT_XRGB: \
  |  |  ------------------
  |  |  |  Branch (66:5): [True: 3.56k, False: 0]
  |  |  ------------------
  |  |   67|  3.56k|    case JCS_EXT_ARGB: \
  |  |  ------------------
  |  |  |  Branch (67:5): [True: 0, False: 3.56k]
  |  |  ------------------
  |  |   68|  3.56k|      cinfo->cconvert->color_convert_simd = \
  |  |   69|  3.56k|        jsimd_extxrgb_##cs##_convert_##instrset; \
  |  |   70|  3.56k|      break; \
  |  |   71|  3.56k|    default: \
  |  |  ------------------
  |  |  |  Branch (71:5): [True: 0, False: 3.56k]
  |  |  ------------------
  |  |   72|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   73|      0|        jsimd_rgb_##cs##_convert_##instrset; \
  |  |   74|  3.56k|  } \
  |  |   75|  3.56k|}
  ------------------
  186|  3.56k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  3.56k|#define JSIMD_AVX2       0x80
  ------------------
  187|  3.56k|  }
  188|      0|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (188:7): [True: 0, False: 0]
  ------------------
  189|      0|      IS_ALIGNED_SSE(jconst_rgb_gray_convert_sse2)) {
  ------------------
  |  |   45|      0|#define IS_ALIGNED_SSE(ptr)  (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
  |  |  ------------------
  |  |  |  |   43|      0|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (45:30): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  190|      0|    SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, sse2);
  ------------------
  |  |   41|      0|#define SET_SIMD_EXTRGB_COLOR_CONVERTER(cs, instrset) { \
  |  |   42|      0|  switch (cinfo->in_color_space) { \
  |  |   43|      0|    case JCS_EXT_RGB: \
  |  |  ------------------
  |  |  |  Branch (43:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   44|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   45|      0|        jsimd_extrgb_##cs##_convert_##instrset; \
  |  |   46|      0|      break; \
  |  |   47|      0|    case JCS_EXT_RGBX: \
  |  |  ------------------
  |  |  |  Branch (47:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   48|      0|    case JCS_EXT_RGBA: \
  |  |  ------------------
  |  |  |  Branch (48:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   50|      0|        jsimd_extrgbx_##cs##_convert_##instrset; \
  |  |   51|      0|      break; \
  |  |   52|      0|    case JCS_EXT_BGR: \
  |  |  ------------------
  |  |  |  Branch (52:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   53|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   54|      0|        jsimd_extbgr_##cs##_convert_##instrset; \
  |  |   55|      0|      break; \
  |  |   56|      0|    case JCS_EXT_BGRX: \
  |  |  ------------------
  |  |  |  Branch (56:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|    case JCS_EXT_BGRA: \
  |  |  ------------------
  |  |  |  Branch (57:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   58|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   59|      0|        jsimd_extbgrx_##cs##_convert_##instrset; \
  |  |   60|      0|      break; \
  |  |   61|      0|    case JCS_EXT_XBGR: \
  |  |  ------------------
  |  |  |  Branch (61:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   62|      0|    case JCS_EXT_ABGR: \
  |  |  ------------------
  |  |  |  Branch (62:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   63|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   64|      0|        jsimd_extxbgr_##cs##_convert_##instrset; \
  |  |   65|      0|      break; \
  |  |   66|      0|    case JCS_EXT_XRGB: \
  |  |  ------------------
  |  |  |  Branch (66:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   67|      0|    case JCS_EXT_ARGB: \
  |  |  ------------------
  |  |  |  Branch (67:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   68|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   69|      0|        jsimd_extxrgb_##cs##_convert_##instrset; \
  |  |   70|      0|      break; \
  |  |   71|      0|    default: \
  |  |  ------------------
  |  |  |  Branch (71:5): [True: 0, False: 0]
  |  |  ------------------
  |  |   72|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   73|      0|        jsimd_rgb_##cs##_convert_##instrset; \
  |  |   74|      0|  } \
  |  |   75|      0|}
  ------------------
  191|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  192|      0|  }
  193|       |#if SIMD_ARCHITECTURE == I386
  194|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
  195|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, mmx);
  196|       |    return JSIMD_MMX;
  197|       |  }
  198|       |#endif
  199|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
  200|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
  201|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, neon);
  202|       |    return JSIMD_NEON;
  203|       |  }
  204|       |#elif SIMD_ARCHITECTURE == POWERPC
  205|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
  206|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, altivec);
  207|       |    return JSIMD_ALTIVEC;
  208|       |  }
  209|       |#elif SIMD_ARCHITECTURE == RISCV64
  210|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
  211|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, rvv);
  212|       |    return JSIMD_RVV;
  213|       |  }
  214|       |#elif SIMD_ARCHITECTURE == MIPS64
  215|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
  216|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, mmi);
  217|       |    return JSIMD_MMI;
  218|       |  }
  219|       |#endif
  220|       |
  221|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  222|      0|}
jsimd_color_convert:
  228|  19.3M|{
  229|  19.3M|  cinfo->cconvert->color_convert_simd(cinfo->image_width, input_buf,
  230|  19.3M|                                      output_buf, output_row, num_rows);
  231|  19.3M|}
jsimd_set_h2v1_downsample:
  326|  7.52k|{
  327|  7.52k|  init_simd((j_common_ptr)cinfo);
  328|       |
  329|  7.52k|  if (BITS_IN_JSAMPLE != 8)
  ------------------
  |  |   34|  7.52k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (329:7): [Folded, False: 7.52k]
  ------------------
  330|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  331|  7.52k|  if (sizeof(JDIMENSION) != 4)
  ------------------
  |  Branch (331:7): [Folded, False: 7.52k]
  ------------------
  332|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  333|  7.52k|  if (!cinfo->downsample)
  ------------------
  |  Branch (333:7): [True: 0, False: 7.52k]
  ------------------
  334|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  335|       |
  336|  7.52k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
  337|  7.52k|  if (cinfo->master->simd_support & JSIMD_AVX2) {
  ------------------
  |  |   46|  7.52k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (337:7): [True: 7.52k, False: 0]
  ------------------
  338|  7.52k|    cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_avx2;
  339|  7.52k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  7.52k|#define JSIMD_AVX2       0x80
  ------------------
  340|  7.52k|  }
  341|      0|  if (cinfo->master->simd_support & JSIMD_SSE2) {
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (341:7): [True: 0, False: 0]
  ------------------
  342|      0|    cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_sse2;
  343|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  344|      0|  }
  345|       |#if SIMD_ARCHITECTURE == I386
  346|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
  347|       |    cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_mmx;
  348|       |    return JSIMD_MMX;
  349|       |  }
  350|       |#endif
  351|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
  352|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
  353|       |    cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_neon;
  354|       |    return JSIMD_NEON;
  355|       |  }
  356|       |#elif SIMD_ARCHITECTURE == POWERPC
  357|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
  358|       |    cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_altivec;
  359|       |    return JSIMD_ALTIVEC;
  360|       |  }
  361|       |#elif SIMD_ARCHITECTURE == RISCV64
  362|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
  363|       |    cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_rvv;
  364|       |    return JSIMD_RVV;
  365|       |  }
  366|       |#endif
  367|       |
  368|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  369|      0|}
jsimd_h2v1_downsample:
  375|  11.0M|{
  376|  11.0M|  cinfo->downsample->h2v1_downsample_simd(cinfo->image_width,
  377|  11.0M|                                          cinfo->max_v_samp_factor,
  378|  11.0M|                                          compptr->v_samp_factor,
  379|  11.0M|                                          compptr->width_in_blocks, input_data,
  380|  11.0M|                                          output_data);
  381|  11.0M|}
jsimd_set_h2v2_downsample:
  386|  7.12k|{
  387|  7.12k|  init_simd((j_common_ptr)cinfo);
  388|       |
  389|  7.12k|  if (BITS_IN_JSAMPLE != 8)
  ------------------
  |  |   34|  7.12k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (389:7): [Folded, False: 7.12k]
  ------------------
  390|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  391|  7.12k|  if (sizeof(JDIMENSION) != 4)
  ------------------
  |  Branch (391:7): [Folded, False: 7.12k]
  ------------------
  392|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  393|  7.12k|  if (!cinfo->downsample)
  ------------------
  |  Branch (393:7): [True: 0, False: 7.12k]
  ------------------
  394|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  395|       |
  396|  7.12k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
  397|  7.12k|  if (cinfo->master->simd_support & JSIMD_AVX2) {
  ------------------
  |  |   46|  7.12k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (397:7): [True: 7.12k, False: 0]
  ------------------
  398|  7.12k|    cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_avx2;
  399|  7.12k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  7.12k|#define JSIMD_AVX2       0x80
  ------------------
  400|  7.12k|  }
  401|      0|  if (cinfo->master->simd_support & JSIMD_SSE2) {
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (401:7): [True: 0, False: 0]
  ------------------
  402|      0|    cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_sse2;
  403|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  404|      0|  }
  405|       |#if SIMD_ARCHITECTURE == I386
  406|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
  407|       |    cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_mmx;
  408|       |    return JSIMD_MMX;
  409|       |  }
  410|       |#endif
  411|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
  412|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
  413|       |    cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_neon;
  414|       |    return JSIMD_NEON;
  415|       |  }
  416|       |#elif SIMD_ARCHITECTURE == POWERPC
  417|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
  418|       |    cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_altivec;
  419|       |    return JSIMD_ALTIVEC;
  420|       |  }
  421|       |#elif SIMD_ARCHITECTURE == RISCV64
  422|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
  423|       |    cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_rvv;
  424|       |    return JSIMD_RVV;
  425|       |  }
  426|       |#elif SIMD_ARCHITECTURE == MIPS64
  427|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
  428|       |    cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_mmi;
  429|       |    return JSIMD_MMI;
  430|       |  }
  431|       |#endif
  432|       |
  433|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  434|      0|}
jsimd_h2v2_downsample:
  440|  5.51M|{
  441|  5.51M|  cinfo->downsample->h2v2_downsample_simd(cinfo->image_width,
  442|  5.51M|                                          cinfo->max_v_samp_factor,
  443|  5.51M|                                          compptr->v_samp_factor,
  444|  5.51M|                                          compptr->width_in_blocks, input_data,
  445|  5.51M|                                          output_data);
  446|  5.51M|}
jsimd_set_convsamp:
  860|  26.5k|{
  861|  26.5k|  init_simd((j_common_ptr)cinfo);
  862|       |
  863|  26.5k|  if (BITS_IN_JSAMPLE != 8)
  ------------------
  |  |   34|  26.5k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (863:7): [Folded, False: 26.5k]
  ------------------
  864|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  865|  26.5k|  if (sizeof(JDIMENSION) != 4)
  ------------------
  |  Branch (865:7): [Folded, False: 26.5k]
  ------------------
  866|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  867|  26.5k|  if (sizeof(DCTELEM) != 2)
  ------------------
  |  Branch (867:7): [Folded, False: 26.5k]
  ------------------
  868|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  869|       |
  870|  26.5k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
  871|  26.5k|  if (cinfo->master->simd_support & JSIMD_AVX2) {
  ------------------
  |  |   46|  26.5k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (871:7): [True: 26.5k, False: 0]
  ------------------
  872|  26.5k|    *method = jsimd_convsamp_avx2;
  873|  26.5k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  26.5k|#define JSIMD_AVX2       0x80
  ------------------
  874|  26.5k|  }
  875|      0|  if (cinfo->master->simd_support & JSIMD_SSE2) {
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (875:7): [True: 0, False: 0]
  ------------------
  876|      0|    *method = jsimd_convsamp_sse2;
  877|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  878|      0|  }
  879|       |#if SIMD_ARCHITECTURE == I386
  880|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
  881|       |    *method = jsimd_convsamp_mmx;
  882|       |    return JSIMD_MMX;
  883|       |  }
  884|       |#endif
  885|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
  886|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
  887|       |    *method = jsimd_convsamp_neon;
  888|       |    return JSIMD_NEON;
  889|       |  }
  890|       |#elif SIMD_ARCHITECTURE == POWERPC
  891|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
  892|       |    *method = jsimd_convsamp_altivec;
  893|       |    return JSIMD_ALTIVEC;
  894|       |  }
  895|       |#elif SIMD_ARCHITECTURE == RISCV64
  896|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
  897|       |    *method = jsimd_convsamp_rvv;
  898|       |    return JSIMD_RVV;
  899|       |  }
  900|       |#endif
  901|       |
  902|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  903|      0|}
jsimd_set_fdct_islow:
  942|  22.9k|{
  943|  22.9k|  init_simd((j_common_ptr)cinfo);
  944|       |
  945|  22.9k|  if (sizeof(DCTELEM) != 2)
  ------------------
  |  Branch (945:7): [Folded, False: 22.9k]
  ------------------
  946|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  947|       |
  948|  22.9k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
  949|  22.9k|  if ((cinfo->master->simd_support & JSIMD_AVX2) &&
  ------------------
  |  |   46|  22.9k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (949:7): [True: 22.9k, False: 0]
  ------------------
  950|  22.9k|      IS_ALIGNED_AVX(jconst_fdct_islow_avx2)) {
  ------------------
  |  |   46|  22.9k|#define IS_ALIGNED_AVX(ptr)  (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
  |  |  ------------------
  |  |  |  |   43|  22.9k|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (46:30): [True: 22.9k, False: 0]
  |  |  ------------------
  ------------------
  951|  22.9k|    *method = jsimd_fdct_islow_avx2;
  952|  22.9k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  22.9k|#define JSIMD_AVX2       0x80
  ------------------
  953|  22.9k|  }
  954|      0|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (954:7): [True: 0, False: 0]
  ------------------
  955|      0|      IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) {
  ------------------
  |  |   45|      0|#define IS_ALIGNED_SSE(ptr)  (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
  |  |  ------------------
  |  |  |  |   43|      0|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (45:30): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  956|      0|    *method = jsimd_fdct_islow_sse2;
  957|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  958|      0|  }
  959|       |#if SIMD_ARCHITECTURE == I386
  960|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
  961|       |    *method = jsimd_fdct_islow_mmx;
  962|       |    return JSIMD_MMX;
  963|       |  }
  964|       |#endif
  965|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
  966|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
  967|       |    *method = jsimd_fdct_islow_neon;
  968|       |    return JSIMD_NEON;
  969|       |  }
  970|       |#elif SIMD_ARCHITECTURE == POWERPC
  971|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
  972|       |    *method = jsimd_fdct_islow_altivec;
  973|       |    return JSIMD_ALTIVEC;
  974|       |  }
  975|       |#elif SIMD_ARCHITECTURE == RISCV64
  976|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
  977|       |    *method = jsimd_fdct_islow_rvv;
  978|       |    return JSIMD_RVV;
  979|       |  }
  980|       |#elif SIMD_ARCHITECTURE == MIPS64
  981|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
  982|       |    *method = jsimd_fdct_islow_mmi;
  983|       |    return JSIMD_MMI;
  984|       |  }
  985|       |#endif
  986|       |
  987|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  988|      0|}
jsimd_set_fdct_ifast:
  993|  3.56k|{
  994|  3.56k|  init_simd((j_common_ptr)cinfo);
  995|       |
  996|  3.56k|  if (sizeof(DCTELEM) != 2)
  ------------------
  |  Branch (996:7): [Folded, False: 3.56k]
  ------------------
  997|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  998|       |
  999|  3.56k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1000|  3.56k|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|  3.56k|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (1000:7): [True: 3.56k, False: 0]
  ------------------
 1001|  3.56k|      IS_ALIGNED_SSE(jconst_fdct_ifast_sse2)) {
  ------------------
  |  |   45|  3.56k|#define IS_ALIGNED_SSE(ptr)  (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
  |  |  ------------------
  |  |  |  |   43|  3.56k|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (45:30): [True: 3.56k, False: 0]
  |  |  ------------------
  ------------------
 1002|  3.56k|    *method = jsimd_fdct_ifast_sse2;
 1003|  3.56k|    return JSIMD_SSE2;
  ------------------
  |  |   42|  3.56k|#define JSIMD_SSE2       0x08
  ------------------
 1004|  3.56k|  }
 1005|       |#if SIMD_ARCHITECTURE == I386
 1006|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
 1007|       |    *method = jsimd_fdct_ifast_mmx;
 1008|       |    return JSIMD_MMX;
 1009|       |  }
 1010|       |#endif
 1011|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
 1012|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
 1013|       |    *method = jsimd_fdct_ifast_neon;
 1014|       |    return JSIMD_NEON;
 1015|       |  }
 1016|       |#elif SIMD_ARCHITECTURE == POWERPC
 1017|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
 1018|       |    *method = jsimd_fdct_ifast_altivec;
 1019|       |    return JSIMD_ALTIVEC;
 1020|       |  }
 1021|       |#elif SIMD_ARCHITECTURE == RISCV64
 1022|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
 1023|       |    *method = jsimd_fdct_ifast_rvv;
 1024|       |    return JSIMD_RVV;
 1025|       |  }
 1026|       |#elif SIMD_ARCHITECTURE == MIPS64
 1027|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
 1028|       |    *method = jsimd_fdct_ifast_mmi;
 1029|       |    return JSIMD_MMI;
 1030|       |  }
 1031|       |#endif
 1032|       |
 1033|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1034|  3.56k|}
jsimd_set_quantize:
 1065|  26.5k|{
 1066|  26.5k|  init_simd((j_common_ptr)cinfo);
 1067|       |
 1068|  26.5k|  if (sizeof(JCOEF) != 2)
  ------------------
  |  Branch (1068:7): [Folded, False: 26.5k]
  ------------------
 1069|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1070|  26.5k|  if (sizeof(DCTELEM) != 2)
  ------------------
  |  Branch (1070:7): [Folded, False: 26.5k]
  ------------------
 1071|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1072|       |
 1073|  26.5k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1074|  26.5k|  if (cinfo->master->simd_support & JSIMD_AVX2) {
  ------------------
  |  |   46|  26.5k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (1074:7): [True: 26.5k, False: 0]
  ------------------
 1075|  26.5k|    *method = jsimd_quantize_avx2;
 1076|  26.5k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  26.5k|#define JSIMD_AVX2       0x80
  ------------------
 1077|  26.5k|  }
 1078|      0|  if (cinfo->master->simd_support & JSIMD_SSE2) {
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (1078:7): [True: 0, False: 0]
  ------------------
 1079|      0|    *method = jsimd_quantize_sse2;
 1080|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
 1081|      0|  }
 1082|       |#if SIMD_ARCHITECTURE == I386
 1083|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
 1084|       |    *method = jsimd_quantize_mmx;
 1085|       |    return JSIMD_MMX;
 1086|       |  }
 1087|       |#endif
 1088|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
 1089|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
 1090|       |    *method = jsimd_quantize_neon;
 1091|       |    return JSIMD_NEON;
 1092|       |  }
 1093|       |#elif SIMD_ARCHITECTURE == POWERPC
 1094|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
 1095|       |    *method = jsimd_quantize_altivec;
 1096|       |    return JSIMD_ALTIVEC;
 1097|       |  }
 1098|       |#elif SIMD_ARCHITECTURE == RISCV64
 1099|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
 1100|       |    *method = jsimd_quantize_rvv;
 1101|       |    return JSIMD_RVV;
 1102|       |  }
 1103|       |#elif SIMD_ARCHITECTURE == MIPS64
 1104|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
 1105|       |    *method = jsimd_quantize_mmi;
 1106|       |    return JSIMD_MMI;
 1107|       |  }
 1108|       |#endif
 1109|       |
 1110|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1111|      0|}
jsimd_set_huff_encode_one_block:
 1432|  19.2k|{
 1433|  19.2k|  init_simd((j_common_ptr)cinfo);
 1434|       |
 1435|  19.2k|  if (sizeof(JCOEF) != 2)
  ------------------
  |  Branch (1435:7): [Folded, False: 19.2k]
  ------------------
 1436|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1437|  19.2k|  if (!cinfo->entropy)
  ------------------
  |  Branch (1437:7): [True: 0, False: 19.2k]
  ------------------
 1438|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1439|       |
 1440|  19.2k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1441|  19.2k|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|  19.2k|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (1441:7): [True: 19.2k, False: 0]
  ------------------
 1442|  19.2k|      cinfo->master->simd_huffman &&
  ------------------
  |  Branch (1442:7): [True: 19.2k, False: 0]
  ------------------
 1443|  19.2k|      IS_ALIGNED_SSE(jconst_huff_encode_one_block)) {
  ------------------
  |  |   45|  19.2k|#define IS_ALIGNED_SSE(ptr)  (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
  |  |  ------------------
  |  |  |  |   43|  19.2k|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (45:30): [True: 19.2k, False: 0]
  |  |  ------------------
  ------------------
 1444|  19.2k|    cinfo->entropy->huff_encode_one_block_simd =
 1445|  19.2k|      jsimd_huff_encode_one_block_sse2;
 1446|  19.2k|    return JSIMD_SSE2;
  ------------------
  |  |   42|  19.2k|#define JSIMD_SSE2       0x08
  ------------------
 1447|  19.2k|  }
 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|  19.2k|}
jsimd_set_encode_mcu_AC_first_prepare:
 1464|  37.6k|{
 1465|  37.6k|  init_simd((j_common_ptr)cinfo);
 1466|       |
 1467|  37.6k|  if (sizeof(JCOEF) != 2)
  ------------------
  |  Branch (1467:7): [Folded, False: 37.6k]
  ------------------
 1468|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1469|       |
 1470|  37.6k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1471|  37.6k|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|  37.6k|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (1471:7): [True: 37.6k, False: 0]
  ------------------
 1472|  37.6k|      cinfo->master->simd_huffman) {
  ------------------
  |  Branch (1472:7): [True: 37.6k, False: 0]
  ------------------
 1473|  37.6k|    *method = jsimd_encode_mcu_AC_first_prepare_sse2;
 1474|  37.6k|    return JSIMD_SSE2;
  ------------------
  |  |   42|  37.6k|#define JSIMD_SSE2       0x08
  ------------------
 1475|  37.6k|  }
 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|  37.6k|}
jsimd_set_encode_mcu_AC_refine_prepare:
 1491|  30.0k|{
 1492|  30.0k|  init_simd((j_common_ptr)cinfo);
 1493|       |
 1494|  30.0k|  if (sizeof(JCOEF) != 2)
  ------------------
  |  Branch (1494:7): [Folded, False: 30.0k]
  ------------------
 1495|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1496|       |
 1497|  30.0k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1498|  30.0k|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|  30.0k|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (1498:7): [True: 30.0k, False: 0]
  ------------------
 1499|  30.0k|      cinfo->master->simd_huffman) {
  ------------------
  |  Branch (1499:7): [True: 30.0k, False: 0]
  ------------------
 1500|  30.0k|    *method = jsimd_encode_mcu_AC_refine_prepare_sse2;
 1501|  30.0k|    return JSIMD_SSE2;
  ------------------
  |  |   42|  30.0k|#define JSIMD_SSE2       0x08
  ------------------
 1502|  30.0k|  }
 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|  30.0k|}
jsimd.c:init_simd:
   56|   195k|{
   57|   195k|#ifndef NO_GETENV
   58|   195k|  char env[2] = { 0 };
   59|   195k|#endif
   60|   195k|  unsigned int simd_support = cinfo->is_decompressor ?
  ------------------
  |  Branch (60:31): [True: 0, False: 195k]
  ------------------
   61|      0|                              ((j_decompress_ptr)cinfo)->master->simd_support :
   62|   195k|                              ((j_compress_ptr)cinfo)->master->simd_support;
   63|   195k|  unsigned int simd_huffman = cinfo->is_decompressor ?
  ------------------
  |  Branch (63:31): [True: 0, False: 195k]
  ------------------
   64|      0|                              ((j_decompress_ptr)cinfo)->master->simd_huffman :
   65|   195k|                              ((j_compress_ptr)cinfo)->master->simd_huffman;
   66|       |
   67|   195k|  if (simd_support != JSIMD_UNDEFINED)
  ------------------
  |  |   49|   195k|#define JSIMD_UNDEFINED  ~(JSIMD_MAX * 2U - 1U)
  |  |  ------------------
  |  |  |  |   48|   195k|#define JSIMD_MAX        0x100
  |  |  ------------------
  ------------------
  |  Branch (67:7): [True: 190k, False: 4.94k]
  ------------------
   68|   190k|    return;
   69|       |
   70|  4.94k|  simd_support = jpeg_simd_cpu_support();
   71|       |
   72|  4.94k|#ifndef NO_GETENV
   73|       |  /* Force different settings through environment variables */
   74|  4.94k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
   75|  4.94k|  if (!GETENV_S(env, 2, "JSIMD_FORCESSE2") && !strcmp(env, "1"))
  ------------------
  |  Branch (75:7): [True: 4.94k, False: 0]
  |  Branch (75:47): [True: 0, False: 4.94k]
  ------------------
   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|  4.94k|  if (!GETENV_S(env, 2, "JSIMD_FORCENONE") && !strcmp(env, "1"))
  ------------------
  |  Branch (95:7): [True: 4.94k, False: 0]
  |  Branch (95:47): [True: 0, False: 4.94k]
  ------------------
   96|      0|    simd_support = 0;
   97|  4.94k|  if (!GETENV_S(env, 2, "JSIMD_NOHUFFENC") && !strcmp(env, "1"))
  ------------------
  |  Branch (97:7): [True: 4.94k, False: 0]
  |  Branch (97:47): [True: 0, False: 4.94k]
  ------------------
   98|      0|    simd_huffman = 0;
   99|  4.94k|#endif
  100|       |
  101|  4.94k|  if (cinfo->is_decompressor) {
  ------------------
  |  Branch (101:7): [True: 0, False: 4.94k]
  ------------------
  102|      0|    ((j_decompress_ptr)cinfo)->master->simd_support = simd_support;
  103|      0|    ((j_decompress_ptr)cinfo)->master->simd_huffman = simd_huffman;
  104|  4.94k|  } else {
  105|  4.94k|    ((j_compress_ptr)cinfo)->master->simd_support = simd_support;
  106|  4.94k|    ((j_compress_ptr)cinfo)->master->simd_huffman = simd_huffman;
  107|  4.94k|  }
  108|  4.94k|}

rdbmp.c:rgb_to_cmyk:
   29|  16.6M|{
   30|  16.6M|  double ctmp = 1.0 - ((double)r / (double)maxval);
   31|  16.6M|  double mtmp = 1.0 - ((double)g / (double)maxval);
   32|  16.6M|  double ytmp = 1.0 - ((double)b / (double)maxval);
   33|  16.6M|  double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
  ------------------
  |  |  515|  33.2M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 5.73M, False: 10.8M]
  |  |  |  Branch (515:27): [True: 2.54M, False: 14.0M]
  |  |  |  Branch (515:39): [True: 2.08M, False: 3.65M]
  |  |  ------------------
  ------------------
   34|       |
   35|  16.6M|  if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
  ------------------
  |  Branch (35:7): [True: 3.99M, False: 12.6M]
  ------------------
   36|  12.6M|  else {
   37|  12.6M|    ctmp = (ctmp - ktmp) / (1.0 - ktmp);
   38|  12.6M|    mtmp = (mtmp - ktmp) / (1.0 - ktmp);
   39|  12.6M|    ytmp = (ytmp - ktmp) / (1.0 - ktmp);
   40|  12.6M|  }
   41|  16.6M|  *c = (_JSAMPLE)((double)maxval - ctmp * (double)maxval + 0.5);
   42|  16.6M|  *m = (_JSAMPLE)((double)maxval - mtmp * (double)maxval + 0.5);
   43|  16.6M|  *y = (_JSAMPLE)((double)maxval - ytmp * (double)maxval + 0.5);
   44|  16.6M|  *k = (_JSAMPLE)((double)maxval - ktmp * (double)maxval + 0.5);
   45|  16.6M|}
rdpng-8.c:rgb_to_cmyk:
   29|   809k|{
   30|   809k|  double ctmp = 1.0 - ((double)r / (double)maxval);
   31|   809k|  double mtmp = 1.0 - ((double)g / (double)maxval);
   32|   809k|  double ytmp = 1.0 - ((double)b / (double)maxval);
   33|   809k|  double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
  ------------------
  |  |  515|  1.61M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 201k, False: 607k]
  |  |  |  Branch (515:27): [True: 135k, False: 673k]
  |  |  |  Branch (515:39): [True: 89.6k, False: 111k]
  |  |  ------------------
  ------------------
   34|       |
   35|   809k|  if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
  ------------------
  |  Branch (35:7): [True: 207k, False: 601k]
  ------------------
   36|   601k|  else {
   37|   601k|    ctmp = (ctmp - ktmp) / (1.0 - ktmp);
   38|   601k|    mtmp = (mtmp - ktmp) / (1.0 - ktmp);
   39|   601k|    ytmp = (ytmp - ktmp) / (1.0 - ktmp);
   40|   601k|  }
   41|   809k|  *c = (_JSAMPLE)((double)maxval - ctmp * (double)maxval + 0.5);
   42|   809k|  *m = (_JSAMPLE)((double)maxval - mtmp * (double)maxval + 0.5);
   43|   809k|  *y = (_JSAMPLE)((double)maxval - ytmp * (double)maxval + 0.5);
   44|   809k|  *k = (_JSAMPLE)((double)maxval - ktmp * (double)maxval + 0.5);
   45|   809k|}
rdppm-8.c:rgb_to_cmyk:
   29|  14.3M|{
   30|  14.3M|  double ctmp = 1.0 - ((double)r / (double)maxval);
   31|  14.3M|  double mtmp = 1.0 - ((double)g / (double)maxval);
   32|  14.3M|  double ytmp = 1.0 - ((double)b / (double)maxval);
   33|  14.3M|  double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
  ------------------
  |  |  515|  28.6M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 9.71k, False: 14.2M]
  |  |  |  Branch (515:27): [True: 6.80k, False: 14.2M]
  |  |  |  Branch (515:39): [True: 4.55k, False: 5.16k]
  |  |  ------------------
  ------------------
   34|       |
   35|  14.3M|  if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
  ------------------
  |  Branch (35:7): [True: 9.02M, False: 5.28M]
  ------------------
   36|  5.28M|  else {
   37|  5.28M|    ctmp = (ctmp - ktmp) / (1.0 - ktmp);
   38|  5.28M|    mtmp = (mtmp - ktmp) / (1.0 - ktmp);
   39|  5.28M|    ytmp = (ytmp - ktmp) / (1.0 - ktmp);
   40|  5.28M|  }
   41|  14.3M|  *c = (_JSAMPLE)((double)maxval - ctmp * (double)maxval + 0.5);
   42|  14.3M|  *m = (_JSAMPLE)((double)maxval - mtmp * (double)maxval + 0.5);
   43|  14.3M|  *y = (_JSAMPLE)((double)maxval - ytmp * (double)maxval + 0.5);
   44|  14.3M|  *k = (_JSAMPLE)((double)maxval - ktmp * (double)maxval + 0.5);
   45|  14.3M|}

jpeg_CreateCompress:
   39|  59.6k|{
   40|  59.6k|  int i;
   41|       |
   42|       |  /* Guard against version mismatches between library and caller. */
   43|  59.6k|  cinfo->mem = NULL;            /* so jpeg_destroy knows mem mgr not called */
   44|  59.6k|  if (version != JPEG_LIB_VERSION)
  ------------------
  |  |    4|  59.6k|#define JPEG_LIB_VERSION  62
  ------------------
  |  Branch (44:7): [True: 0, False: 59.6k]
  ------------------
   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|  59.6k|  if (structsize != sizeof(struct jpeg_compress_struct))
  ------------------
  |  Branch (46:7): [True: 0, False: 59.6k]
  ------------------
   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|  59.6k|             (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|  59.6k|  {
   57|  59.6k|    struct jpeg_error_mgr *err = cinfo->err;
   58|  59.6k|    void *client_data = cinfo->client_data; /* ignore Purify complaint here */
   59|  59.6k|    memset(cinfo, 0, sizeof(struct jpeg_compress_struct));
   60|  59.6k|    cinfo->err = err;
   61|  59.6k|    cinfo->client_data = client_data;
   62|  59.6k|  }
   63|  59.6k|  cinfo->is_decompressor = FALSE;
  ------------------
  |  |  207|  59.6k|#define FALSE   0               /* values of boolean */
  ------------------
   64|       |
   65|       |  /* Initialize a memory manager instance for this object */
   66|  59.6k|  jinit_memory_mgr((j_common_ptr)cinfo);
   67|       |
   68|       |  /* Zero out pointers to permanent structures. */
   69|  59.6k|  cinfo->progress = NULL;
   70|  59.6k|  cinfo->dest = NULL;
   71|       |
   72|  59.6k|  cinfo->comp_info = NULL;
   73|       |
   74|   298k|  for (i = 0; i < NUM_QUANT_TBLS; i++) {
  ------------------
  |  |   68|   298k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (74:15): [True: 238k, False: 59.6k]
  ------------------
   75|   238k|    cinfo->quant_tbl_ptrs[i] = NULL;
   76|       |#if JPEG_LIB_VERSION >= 70
   77|       |    cinfo->q_scale_factor[i] = 100;
   78|       |#endif
   79|   238k|  }
   80|       |
   81|   298k|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|   298k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (81:15): [True: 238k, False: 59.6k]
  ------------------
   82|   238k|    cinfo->dc_huff_tbl_ptrs[i] = NULL;
   83|   238k|    cinfo->ac_huff_tbl_ptrs[i] = NULL;
   84|   238k|  }
   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|  59.6k|  cinfo->script_space = NULL;
   94|       |
   95|  59.6k|  cinfo->input_gamma = 1.0;     /* in case application forgets */
   96|       |
   97|  59.6k|  cinfo->data_precision = BITS_IN_JSAMPLE;
  ------------------
  |  |   34|  59.6k|#define BITS_IN_JSAMPLE  8
  ------------------
   98|       |
   99|       |  /* OK, I'm ready */
  100|  59.6k|  cinfo->global_state = CSTATE_START;
  ------------------
  |  |   44|  59.6k|#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|  59.6k|  cinfo->master = (struct jpeg_comp_master *)
  106|  59.6k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
  ------------------
  |  |  888|  59.6k|#define JPOOL_PERMANENT  0      /* lasts until master record is destroyed */
  ------------------
  107|  59.6k|                                  sizeof(my_comp_master));
  108|  59.6k|  memset(cinfo->master, 0, sizeof(my_comp_master));
  109|  59.6k|#ifdef WITH_SIMD
  110|  59.6k|  cinfo->master->simd_support = JSIMD_UNDEFINED;
  ------------------
  |  |   49|  59.6k|#define JSIMD_UNDEFINED  ~(JSIMD_MAX * 2U - 1U)
  |  |  ------------------
  |  |  |  |   48|  59.6k|#define JSIMD_MAX        0x100
  |  |  ------------------
  ------------------
  111|  59.6k|  cinfo->master->simd_huffman = 1;
  112|  59.6k|#endif
  113|  59.6k|}
jpeg_destroy_compress:
  122|  59.6k|{
  123|  59.6k|  jpeg_destroy((j_common_ptr)cinfo); /* use common routine */
  124|  59.6k|}
jpeg_suppress_tables:
  153|  26.5k|{
  154|  26.5k|  int i;
  155|  26.5k|  JQUANT_TBL *qtbl;
  156|  26.5k|  JHUFF_TBL *htbl;
  157|       |
  158|   132k|  for (i = 0; i < NUM_QUANT_TBLS; i++) {
  ------------------
  |  |   68|   132k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (158:15): [True: 106k, False: 26.5k]
  ------------------
  159|   106k|    if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL)
  ------------------
  |  Branch (159:9): [True: 53.0k, False: 53.0k]
  ------------------
  160|  53.0k|      qtbl->sent_table = suppress;
  161|   106k|  }
  162|       |
  163|   132k|  for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|   132k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (163:15): [True: 106k, False: 26.5k]
  ------------------
  164|   106k|    if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL)
  ------------------
  |  Branch (164:9): [True: 53.0k, False: 53.0k]
  ------------------
  165|  53.0k|      htbl->sent_table = suppress;
  166|   106k|    if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL)
  ------------------
  |  Branch (166:9): [True: 53.0k, False: 53.0k]
  ------------------
  167|  53.0k|      htbl->sent_table = suppress;
  168|   106k|  }
  169|  26.5k|}
jpeg_finish_compress:
  181|  26.5k|{
  182|  26.5k|  JDIMENSION iMCU_row;
  183|       |
  184|  26.5k|  if (cinfo->global_state == CSTATE_SCANNING ||
  ------------------
  |  |   45|  53.0k|#define CSTATE_SCANNING  101    /* start_compress done, write_scanlines OK */
  ------------------
  |  Branch (184:7): [True: 26.5k, False: 0]
  ------------------
  185|  26.5k|      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|  26.5k|    if (cinfo->next_scanline < cinfo->image_height)
  ------------------
  |  Branch (187:9): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|    (*cinfo->master->finish_pass) (cinfo);
  190|  26.5k|  } 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|   129k|  while (!cinfo->master->is_last_pass) {
  ------------------
  |  Branch (193:10): [True: 103k, False: 26.5k]
  ------------------
  194|   103k|    (*cinfo->master->prepare_for_pass) (cinfo);
  195|  19.1M|    for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) {
  ------------------
  |  Branch (195:24): [True: 19.0M, False: 103k]
  ------------------
  196|  19.0M|      if (cinfo->progress != NULL) {
  ------------------
  |  Branch (196:11): [True: 0, False: 19.0M]
  ------------------
  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|  19.0M|      if (cinfo->data_precision <= 8) {
  ------------------
  |  Branch (204:11): [True: 19.0M, False: 0]
  ------------------
  205|  19.0M|        if (cinfo->coef->compress_data == NULL)
  ------------------
  |  Branch (205:13): [True: 0, False: 19.0M]
  ------------------
  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|  19.0M|        if (!(*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE)NULL))
  ------------------
  |  Branch (207:13): [True: 0, False: 19.0M]
  ------------------
  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|  19.0M|      } else if (cinfo->data_precision <= 12) {
  ------------------
  |  Branch (209:18): [True: 0, False: 0]
  ------------------
  210|      0|        if (cinfo->coef->compress_data_12 == NULL)
  ------------------
  |  Branch (210:13): [True: 0, False: 0]
  ------------------
  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|      0|        if (!(*cinfo->coef->compress_data_12) (cinfo, (J12SAMPIMAGE)NULL))
  ------------------
  |  Branch (212:13): [True: 0, False: 0]
  ------------------
  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|      0|      } 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|  19.0M|    }
  225|   103k|    (*cinfo->master->finish_pass) (cinfo);
  226|   103k|  }
  227|       |  /* Write EOI, do final cleanup */
  228|  26.5k|  (*cinfo->marker->write_file_trailer) (cinfo);
  229|  26.5k|  (*cinfo->dest->term_destination) (cinfo);
  230|       |  /* We can use jpeg_abort to release memory and reset global_state */
  231|  26.5k|  jpeg_abort((j_common_ptr)cinfo);
  232|  26.5k|}
jpeg_write_m_header:
  266|  23.6k|{
  267|  23.6k|  if (cinfo->next_scanline != 0 ||
  ------------------
  |  Branch (267:7): [True: 0, False: 23.6k]
  ------------------
  268|  23.6k|      (cinfo->global_state != CSTATE_SCANNING &&
  ------------------
  |  |   45|  47.2k|#define CSTATE_SCANNING  101    /* start_compress done, write_scanlines OK */
  ------------------
  |  Branch (268:8): [True: 0, False: 23.6k]
  ------------------
  269|      0|       cinfo->global_state != CSTATE_RAW_OK &&
  ------------------
  |  |   46|  23.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|  23.6k|  (*cinfo->marker->write_marker_header) (cinfo, marker, datalen);
  274|  23.6k|}
jpeg_write_m_byte:
  278|  1.08M|{
  279|  1.08M|  (*cinfo->marker->write_marker_byte) (cinfo, val);
  280|  1.08M|}

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

jinit_arith_encoder:
  913|  7.12k|{
  914|  7.12k|  arith_entropy_ptr entropy;
  915|  7.12k|  int i;
  916|       |
  917|  7.12k|  entropy = (arith_entropy_ptr)
  918|  7.12k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  7.12k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  919|  7.12k|                                sizeof(arith_entropy_encoder));
  920|  7.12k|  cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
  921|  7.12k|  entropy->pub.start_pass = start_pass;
  922|  7.12k|  entropy->pub.finish_pass = finish_pass;
  923|       |
  924|       |  /* Mark tables unallocated */
  925|   121k|  for (i = 0; i < NUM_ARITH_TBLS; i++) {
  ------------------
  |  |   70|   121k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (925:15): [True: 114k, False: 7.12k]
  ------------------
  926|   114k|    entropy->dc_stats[i] = NULL;
  927|   114k|    entropy->ac_stats[i] = NULL;
  928|   114k|  }
  929|       |
  930|       |  /* Initialize index for fixed probability estimation */
  931|  7.12k|  entropy->fixed_bin[0] = 113;
  932|  7.12k|}
jcarith.c:start_pass:
  829|  39.2k|{
  830|  39.2k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  831|  39.2k|  int ci, tbl;
  832|  39.2k|  jpeg_component_info *compptr;
  833|       |
  834|  39.2k|  if (gather_statistics)
  ------------------
  |  Branch (834:7): [True: 0, False: 39.2k]
  ------------------
  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|  39.2k|  if (cinfo->progressive_mode) {
  ------------------
  |  Branch (844:7): [True: 35.6k, False: 3.56k]
  ------------------
  845|  35.6k|    if (cinfo->Ah == 0) {
  ------------------
  |  Branch (845:9): [True: 17.8k, False: 17.8k]
  ------------------
  846|  17.8k|      if (cinfo->Ss == 0)
  ------------------
  |  Branch (846:11): [True: 3.56k, False: 14.2k]
  ------------------
  847|  3.56k|        entropy->pub.encode_mcu = encode_mcu_DC_first;
  848|  14.2k|      else
  849|  14.2k|        entropy->pub.encode_mcu = encode_mcu_AC_first;
  850|  17.8k|    } else {
  851|  17.8k|      if (cinfo->Ss == 0)
  ------------------
  |  Branch (851:11): [True: 3.56k, False: 14.2k]
  ------------------
  852|  3.56k|        entropy->pub.encode_mcu = encode_mcu_DC_refine;
  853|  14.2k|      else
  854|  14.2k|        entropy->pub.encode_mcu = encode_mcu_AC_refine;
  855|  17.8k|    }
  856|  35.6k|  } else
  857|  3.56k|    entropy->pub.encode_mcu = encode_mcu;
  858|       |
  859|       |  /* Allocate & initialize requested statistics areas */
  860|  99.7k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (860:16): [True: 60.5k, False: 39.2k]
  ------------------
  861|  60.5k|    compptr = cinfo->cur_comp_info[ci];
  862|       |    /* DC needs no table for refinement scan */
  863|  60.5k|    if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
  ------------------
  |  Branch (863:9): [True: 10.6k, False: 49.8k]
  |  Branch (863:42): [True: 21.3k, False: 28.5k]
  |  Branch (863:60): [True: 10.6k, False: 10.6k]
  ------------------
  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: 14.2k, False: 7.12k]
  ------------------
  868|  14.2k|        entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
  869|  14.2k|          ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
  ------------------
  |  |  889|  14.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                        ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
  ------------------
  |  |   69|  14.2k|#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|  60.5k|    if (cinfo->progressive_mode == 0 || cinfo->Se) {
  ------------------
  |  Branch (876:9): [True: 10.6k, False: 49.8k]
  |  Branch (876:41): [True: 28.5k, False: 21.3k]
  ------------------
  877|  39.2k|      tbl = compptr->ac_tbl_no;
  878|  39.2k|      if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
  ------------------
  |  |   70|  39.2k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (878:11): [True: 0, False: 39.2k]
  |  Branch (878:22): [True: 0, False: 39.2k]
  ------------------
  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|  39.2k|      if (entropy->ac_stats[tbl] == NULL)
  ------------------
  |  Branch (880:11): [True: 14.2k, False: 24.9k]
  ------------------
  881|  14.2k|        entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
  882|  14.2k|          ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
  ------------------
  |  |  889|  14.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                        ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
  ------------------
  |  |   70|  14.2k|#define AC_STAT_BINS  256
  ------------------
  883|  39.2k|      memset(entropy->ac_stats[tbl], 0, AC_STAT_BINS);
  ------------------
  |  |   70|  39.2k|#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|  39.2k|    }
  891|  60.5k|  }
  892|       |
  893|       |  /* Initialize arithmetic encoding variables */
  894|  39.2k|  entropy->c = 0;
  895|  39.2k|  entropy->a = 0x10000L;
  896|  39.2k|  entropy->sc = 0;
  897|  39.2k|  entropy->zc = 0;
  898|  39.2k|  entropy->ct = 11;
  899|  39.2k|  entropy->buffer = -1;  /* empty */
  900|       |
  901|       |  /* Initialize restart stuff */
  902|  39.2k|  entropy->restarts_to_go = cinfo->restart_interval;
  903|  39.2k|  entropy->next_restart_num = 0;
  904|  39.2k|}
jcarith.c:encode_mcu_DC_first:
  369|   866k|{
  370|   866k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  371|   866k|  JBLOCKROW block;
  372|   866k|  unsigned char *st;
  373|   866k|  int blkn, ci, tbl;
  374|   866k|  int v, v2, m;
  375|   866k|  ISHIFT_TEMPS
  376|       |
  377|       |  /* Emit restart marker if needed */
  378|   866k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (378:7): [True: 0, False: 866k]
  ------------------
  379|      0|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (379:9): [True: 0, False: 0]
  ------------------
  380|      0|      emit_restart(cinfo, entropy->next_restart_num);
  381|      0|      entropy->restarts_to_go = cinfo->restart_interval;
  382|      0|      entropy->next_restart_num++;
  383|      0|      entropy->next_restart_num &= 7;
  384|      0|    }
  385|      0|    entropy->restarts_to_go--;
  386|      0|  }
  387|       |
  388|       |  /* Encode the MCU data blocks */
  389|  6.06M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (389:18): [True: 5.20M, False: 866k]
  ------------------
  390|  5.20M|    block = MCU_data[blkn];
  391|  5.20M|    ci = cinfo->MCU_membership[blkn];
  392|  5.20M|    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.20M|    m = IRIGHT_SHIFT((int)((*block)[0]), cinfo->Al);
  ------------------
  |  |  117|  5.20M|#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.20M|    st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
  403|       |
  404|       |    /* Figure F.4: Encode_DC_DIFF */
  405|  5.20M|    if ((v = m - entropy->last_dc_val[ci]) == 0) {
  ------------------
  |  Branch (405:9): [True: 4.03M, False: 1.16M]
  ------------------
  406|  4.03M|      arith_encode(cinfo, st, 0);
  407|  4.03M|      entropy->dc_context[ci] = 0;      /* zero diff category */
  408|  4.03M|    } else {
  409|  1.16M|      entropy->last_dc_val[ci] = m;
  410|  1.16M|      arith_encode(cinfo, st, 1);
  411|       |      /* Figure F.6: Encoding nonzero value v */
  412|       |      /* Figure F.7: Encoding the sign of v */
  413|  1.16M|      if (v > 0) {
  ------------------
  |  Branch (413:11): [True: 583k, False: 578k]
  ------------------
  414|   583k|        arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
  415|   583k|        st += 2;                        /* Table F.4: SP = S0 + 2 */
  416|   583k|        entropy->dc_context[ci] = 4;    /* small positive diff category */
  417|   583k|      } else {
  418|   578k|        v = -v;
  419|   578k|        arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
  420|   578k|        st += 3;                        /* Table F.4: SN = S0 + 3 */
  421|   578k|        entropy->dc_context[ci] = 8;    /* small negative diff category */
  422|   578k|      }
  423|       |      /* Figure F.8: Encoding the magnitude category of v */
  424|  1.16M|      m = 0;
  425|  1.16M|      if (v -= 1) {
  ------------------
  |  Branch (425:11): [True: 925k, False: 237k]
  ------------------
  426|   925k|        arith_encode(cinfo, st, 1);
  427|   925k|        m = 1;
  428|   925k|        v2 = v;
  429|   925k|        st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
  430|  2.49M|        while (v2 >>= 1) {
  ------------------
  |  Branch (430:16): [True: 1.57M, False: 925k]
  ------------------
  431|  1.57M|          arith_encode(cinfo, st, 1);
  432|  1.57M|          m <<= 1;
  433|  1.57M|          st += 1;
  434|  1.57M|        }
  435|   925k|      }
  436|  1.16M|      arith_encode(cinfo, st, 0);
  437|       |      /* Section F.1.4.4.1.2: Establish dc_context conditioning category */
  438|  1.16M|      if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
  ------------------
  |  Branch (438:11): [True: 0, False: 1.16M]
  ------------------
  439|      0|        entropy->dc_context[ci] = 0;    /* zero diff category */
  440|  1.16M|      else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
  ------------------
  |  Branch (440:16): [True: 752k, False: 409k]
  ------------------
  441|   752k|        entropy->dc_context[ci] += 8;   /* large diff category */
  442|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  443|  1.16M|      st += 14;
  444|  2.73M|      while (m >>= 1)
  ------------------
  |  Branch (444:14): [True: 1.57M, False: 1.16M]
  ------------------
  445|  1.57M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (445:33): [True: 710k, False: 860k]
  ------------------
  446|  1.16M|    }
  447|  5.20M|  }
  448|       |
  449|   866k|  return TRUE;
  ------------------
  |  |  210|   866k|#define TRUE    1
  ------------------
  450|   866k|}
jcarith.c:emit_byte:
  124|  41.6M|{
  125|  41.6M|  struct jpeg_destination_mgr *dest = cinfo->dest;
  126|       |
  127|  41.6M|  *dest->next_output_byte++ = (JOCTET)val;
  128|  41.6M|  if (--dest->free_in_buffer == 0)
  ------------------
  |  Branch (128:7): [True: 3.76k, False: 41.6M]
  ------------------
  129|  3.76k|    if (!(*dest->empty_output_buffer) (cinfo))
  ------------------
  |  Branch (129:9): [True: 0, False: 3.76k]
  ------------------
  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|  41.6M|}
jcarith.c:arith_encode:
  226|   480M|{
  227|   480M|  register arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
  228|   480M|  register unsigned char nl, nm;
  229|   480M|  register JLONG qe, temp;
  230|   480M|  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|   480M|  sv = *st;
  236|   480M|  qe = jpeg_aritab[sv & 0x7F];  /* => Qe_Value */
  237|   480M|  nl = qe & 0xFF;  qe >>= 8;    /* Next_Index_LPS + Switch_MPS */
  238|   480M|  nm = qe & 0xFF;  qe >>= 8;    /* Next_Index_MPS */
  239|       |
  240|       |  /* Encode & estimation procedures per sections D.1.4 & D.1.5 */
  241|   480M|  e->a -= qe;
  242|   480M|  if (val != (sv >> 7)) {
  ------------------
  |  Branch (242:7): [True: 128M, False: 351M]
  ------------------
  243|       |    /* Encode the less probable symbol */
  244|   128M|    if (e->a >= qe) {
  ------------------
  |  Branch (244:9): [True: 94.4M, False: 34.3M]
  ------------------
  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|  94.4M|      e->c += e->a;
  250|  94.4M|      e->a = qe;
  251|  94.4M|    }
  252|   128M|    *st = (sv & 0x80) ^ nl;     /* Estimate_after_LPS */
  253|   351M|  } else {
  254|       |    /* Encode the more probable symbol */
  255|   351M|    if (e->a >= 0x8000L)
  ------------------
  |  Branch (255:9): [True: 223M, False: 128M]
  ------------------
  256|   223M|      return;  /* A >= 0x8000 -> ready, no renormalization required */
  257|   128M|    if (e->a < qe) {
  ------------------
  |  Branch (257:9): [True: 37.4M, False: 90.8M]
  ------------------
  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|  37.4M|      e->c += e->a;
  262|  37.4M|      e->a = qe;
  263|  37.4M|    }
  264|   128M|    *st = (sv & 0x80) ^ nm;     /* Estimate_after_MPS */
  265|   128M|  }
  266|       |
  267|       |  /* Renormalization & data output per section D.1.6 */
  268|   331M|  do {
  269|   331M|    e->a <<= 1;
  270|   331M|    e->c <<= 1;
  271|   331M|    if (--e->ct == 0) {
  ------------------
  |  Branch (271:9): [True: 41.4M, False: 290M]
  ------------------
  272|       |      /* Another byte is ready for output */
  273|  41.4M|      temp = e->c >> 19;
  274|  41.4M|      if (temp > 0xFF) {
  ------------------
  |  Branch (274:11): [True: 1.74M, False: 39.6M]
  ------------------
  275|       |        /* Handle overflow over all stacked 0xFF bytes */
  276|  1.74M|        if (e->buffer >= 0) {
  ------------------
  |  Branch (276:13): [True: 1.74M, False: 0]
  ------------------
  277|  1.74M|          if (e->zc)
  ------------------
  |  Branch (277:15): [True: 7.21k, False: 1.73M]
  ------------------
  278|  11.8k|            do emit_byte(0x00, cinfo);
  279|  11.8k|            while (--e->zc);
  ------------------
  |  Branch (279:20): [True: 4.59k, False: 7.21k]
  ------------------
  280|  1.74M|          emit_byte(e->buffer + 1, cinfo);
  281|  1.74M|          if (e->buffer + 1 == 0xFF)
  ------------------
  |  Branch (281:15): [True: 7.53k, False: 1.73M]
  ------------------
  282|  7.53k|            emit_byte(0x00, cinfo);
  283|  1.74M|        }
  284|  1.74M|        e->zc += e->sc;  /* carry-over converts stacked 0xFF bytes to 0x00 */
  285|  1.74M|        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|  1.74M|        e->buffer = temp & 0xFF;  /* new output byte, might overflow later */
  290|  39.6M|      } else if (temp == 0xFF) {
  ------------------
  |  Branch (290:18): [True: 224k, False: 39.4M]
  ------------------
  291|   224k|        ++e->sc;  /* stack 0xFF byte (which might overflow later) */
  292|  39.4M|      } else {
  293|       |        /* Output all stacked 0xFF bytes, they will not overflow any more */
  294|  39.4M|        if (e->buffer == 0)
  ------------------
  |  Branch (294:13): [True: 435k, False: 39.0M]
  ------------------
  295|   435k|          ++e->zc;
  296|  39.0M|        else if (e->buffer >= 0) {
  ------------------
  |  Branch (296:18): [True: 39.0M, False: 28.3k]
  ------------------
  297|  39.0M|          if (e->zc)
  ------------------
  |  Branch (297:15): [True: 163k, False: 38.8M]
  ------------------
  298|   335k|            do emit_byte(0x00, cinfo);
  299|   335k|            while (--e->zc);
  ------------------
  |  Branch (299:20): [True: 171k, False: 163k]
  ------------------
  300|  39.0M|          emit_byte(e->buffer, cinfo);
  301|  39.0M|        }
  302|  39.4M|        if (e->sc) {
  ------------------
  |  Branch (302:13): [True: 162k, False: 39.3M]
  ------------------
  303|   162k|          if (e->zc)
  ------------------
  |  Branch (303:15): [True: 870, False: 161k]
  ------------------
  304|  1.13k|            do emit_byte(0x00, cinfo);
  305|  1.13k|            while (--e->zc);
  ------------------
  |  Branch (305:20): [True: 262, False: 870]
  ------------------
  306|   194k|          do {
  307|   194k|            emit_byte(0xFF, cinfo);
  308|   194k|            emit_byte(0x00, cinfo);
  309|   194k|          } while (--e->sc);
  ------------------
  |  Branch (309:20): [True: 32.4k, False: 162k]
  ------------------
  310|   162k|        }
  311|  39.4M|        e->buffer = temp & 0xFF;  /* new output byte (can still overflow) */
  312|  39.4M|      }
  313|  41.4M|      e->c &= 0x7FFFFL;
  314|  41.4M|      e->ct += 8;
  315|  41.4M|    }
  316|   331M|  } while (e->a < 0x8000L);
  ------------------
  |  Branch (316:12): [True: 74.5M, False: 257M]
  ------------------
  317|   257M|}
jcarith.c:encode_mcu_AC_first:
  460|  4.71M|{
  461|  4.71M|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  462|  4.71M|  JBLOCKROW block;
  463|  4.71M|  unsigned char *st;
  464|  4.71M|  int tbl, k, ke;
  465|  4.71M|  int v, v2, m;
  466|       |
  467|       |  /* Emit restart marker if needed */
  468|  4.71M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (468:7): [True: 0, False: 4.71M]
  ------------------
  469|      0|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (469:9): [True: 0, False: 0]
  ------------------
  470|      0|      emit_restart(cinfo, entropy->next_restart_num);
  471|      0|      entropy->restarts_to_go = cinfo->restart_interval;
  472|      0|      entropy->next_restart_num++;
  473|      0|      entropy->next_restart_num &= 7;
  474|      0|    }
  475|      0|    entropy->restarts_to_go--;
  476|      0|  }
  477|       |
  478|       |  /* Encode the MCU data block */
  479|  4.71M|  block = MCU_data[0];
  480|  4.71M|  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|   187M|  for (ke = cinfo->Se; ke > 0; ke--)
  ------------------
  |  Branch (485:24): [True: 185M, False: 2.57M]
  ------------------
  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|   185M|    if ((v = (*block)[jpeg_natural_order[ke]]) >= 0) {
  ------------------
  |  Branch (490:9): [True: 177M, False: 7.69M]
  ------------------
  491|   177M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (491:11): [True: 1.07M, False: 176M]
  ------------------
  492|   177M|    } else {
  493|  7.69M|      v = -v;
  494|  7.69M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (494:11): [True: 1.07M, False: 6.62M]
  ------------------
  495|  7.69M|    }
  496|       |
  497|       |  /* Figure F.5: Encode_AC_Coefficients */
  498|  13.1M|  for (k = cinfo->Ss; k <= ke; k++) {
  ------------------
  |  Branch (498:23): [True: 8.40M, False: 4.71M]
  ------------------
  499|  8.40M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  500|  8.40M|    arith_encode(cinfo, st, 0);         /* EOB decision */
  501|  23.0M|    for (;;) {
  502|  23.0M|      if ((v = (*block)[jpeg_natural_order[k]]) >= 0) {
  ------------------
  |  Branch (502:11): [True: 15.2M, False: 7.85M]
  ------------------
  503|  15.2M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (503:13): [True: 4.19M, False: 11.0M]
  ------------------
  504|  4.19M|          arith_encode(cinfo, st + 1, 1);
  505|  4.19M|          arith_encode(cinfo, entropy->fixed_bin, 0);
  506|  4.19M|          break;
  507|  4.19M|        }
  508|  15.2M|      } else {
  509|  7.85M|        v = -v;
  510|  7.85M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (510:13): [True: 4.20M, False: 3.64M]
  ------------------
  511|  4.20M|          arith_encode(cinfo, st + 1, 1);
  512|  4.20M|          arith_encode(cinfo, entropy->fixed_bin, 1);
  513|  4.20M|          break;
  514|  4.20M|        }
  515|  7.85M|      }
  516|  14.6M|      arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  517|  14.6M|    }
  518|  8.40M|    st += 2;
  519|       |    /* Figure F.8: Encoding the magnitude category of v */
  520|  8.40M|    m = 0;
  521|  8.40M|    if (v -= 1) {
  ------------------
  |  Branch (521:9): [True: 3.45M, False: 4.94M]
  ------------------
  522|  3.45M|      arith_encode(cinfo, st, 1);
  523|  3.45M|      m = 1;
  524|  3.45M|      v2 = v;
  525|  3.45M|      if (v2 >>= 1) {
  ------------------
  |  Branch (525:11): [True: 1.74M, False: 1.70M]
  ------------------
  526|  1.74M|        arith_encode(cinfo, st, 1);
  527|  1.74M|        m <<= 1;
  528|  1.74M|        st = entropy->ac_stats[tbl] +
  529|  1.74M|             (k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
  ------------------
  |  Branch (529:15): [True: 1.11M, False: 627k]
  ------------------
  530|  2.41M|        while (v2 >>= 1) {
  ------------------
  |  Branch (530:16): [True: 671k, False: 1.74M]
  ------------------
  531|   671k|          arith_encode(cinfo, st, 1);
  532|   671k|          m <<= 1;
  533|   671k|          st += 1;
  534|   671k|        }
  535|  1.74M|      }
  536|  3.45M|    }
  537|  8.40M|    arith_encode(cinfo, st, 0);
  538|       |    /* Figure F.9: Encoding the magnitude bit pattern of v */
  539|  8.40M|    st += 14;
  540|  10.8M|    while (m >>= 1)
  ------------------
  |  Branch (540:12): [True: 2.41M, False: 8.40M]
  ------------------
  541|  2.41M|      arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (541:31): [True: 796k, False: 1.62M]
  ------------------
  542|  8.40M|  }
  543|       |  /* Encode EOB decision only if k <= cinfo->Se */
  544|  4.71M|  if (k <= cinfo->Se) {
  ------------------
  |  Branch (544:7): [True: 4.21M, False: 504k]
  ------------------
  545|  4.21M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  546|  4.21M|    arith_encode(cinfo, st, 1);
  547|  4.21M|  }
  548|       |
  549|  4.71M|  return TRUE;
  ------------------
  |  |  210|  4.71M|#define TRUE    1
  ------------------
  550|  4.71M|}
jcarith.c:encode_mcu_DC_refine:
  559|   866k|{
  560|   866k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  561|   866k|  unsigned char *st;
  562|   866k|  int Al, blkn;
  563|       |
  564|       |  /* Emit restart marker if needed */
  565|   866k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (565:7): [True: 0, False: 866k]
  ------------------
  566|      0|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (566:9): [True: 0, False: 0]
  ------------------
  567|      0|      emit_restart(cinfo, entropy->next_restart_num);
  568|      0|      entropy->restarts_to_go = cinfo->restart_interval;
  569|      0|      entropy->next_restart_num++;
  570|      0|      entropy->next_restart_num &= 7;
  571|      0|    }
  572|      0|    entropy->restarts_to_go--;
  573|      0|  }
  574|       |
  575|   866k|  st = entropy->fixed_bin;      /* use fixed probability estimation */
  576|   866k|  Al = cinfo->Al;
  577|       |
  578|       |  /* Encode the MCU data blocks */
  579|  6.06M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (579:18): [True: 5.20M, False: 866k]
  ------------------
  580|       |    /* We simply emit the Al'th bit of the DC coefficient value. */
  581|  5.20M|    arith_encode(cinfo, st, (MCU_data[blkn][0][0] >> Al) & 1);
  582|  5.20M|  }
  583|       |
  584|   866k|  return TRUE;
  ------------------
  |  |  210|   866k|#define TRUE    1
  ------------------
  585|   866k|}
jcarith.c:encode_mcu_AC_refine:
  594|  4.71M|{
  595|  4.71M|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  596|  4.71M|  JBLOCKROW block;
  597|  4.71M|  unsigned char *st;
  598|  4.71M|  int tbl, k, ke, kex;
  599|  4.71M|  int v;
  600|       |
  601|       |  /* Emit restart marker if needed */
  602|  4.71M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (602:7): [True: 0, False: 4.71M]
  ------------------
  603|      0|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (603:9): [True: 0, False: 0]
  ------------------
  604|      0|      emit_restart(cinfo, entropy->next_restart_num);
  605|      0|      entropy->restarts_to_go = cinfo->restart_interval;
  606|      0|      entropy->next_restart_num++;
  607|      0|      entropy->next_restart_num &= 7;
  608|      0|    }
  609|      0|    entropy->restarts_to_go--;
  610|      0|  }
  611|       |
  612|       |  /* Encode the MCU data block */
  613|  4.71M|  block = MCU_data[0];
  614|  4.71M|  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|   215M|  for (ke = cinfo->Se; ke > 0; ke--)
  ------------------
  |  Branch (619:24): [True: 213M, False: 2.45M]
  ------------------
  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|   213M|    if ((v = (*block)[jpeg_natural_order[ke]]) >= 0) {
  ------------------
  |  Branch (624:9): [True: 210M, False: 3.44M]
  ------------------
  625|   210M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (625:11): [True: 1.13M, False: 208M]
  ------------------
  626|   210M|    } else {
  627|  3.44M|      v = -v;
  628|  3.44M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (628:11): [True: 1.13M, False: 2.30M]
  ------------------
  629|  3.44M|    }
  630|       |
  631|       |  /* Establish EOBx (previous stage end-of-block) index */
  632|  34.9M|  for (kex = ke; kex > 0; kex--)
  ------------------
  |  Branch (632:18): [True: 32.3M, False: 2.52M]
  ------------------
  633|  32.3M|    if ((v = (*block)[jpeg_natural_order[kex]]) >= 0) {
  ------------------
  |  Branch (633:9): [True: 24.8M, False: 7.49M]
  ------------------
  634|  24.8M|      if (v >>= cinfo->Ah) break;
  ------------------
  |  Branch (634:11): [True: 1.09M, False: 23.7M]
  ------------------
  635|  24.8M|    } else {
  636|  7.49M|      v = -v;
  637|  7.49M|      if (v >>= cinfo->Ah) break;
  ------------------
  |  Branch (637:11): [True: 1.09M, False: 6.39M]
  ------------------
  638|  7.49M|    }
  639|       |
  640|       |  /* Figure G.10: Encode_AC_Coefficients_SA */
  641|  47.4M|  for (k = cinfo->Ss; k <= ke; k++) {
  ------------------
  |  Branch (641:23): [True: 42.7M, False: 4.71M]
  ------------------
  642|  42.7M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  643|  42.7M|    if (k > kex)
  ------------------
  |  Branch (643:9): [True: 8.84M, False: 33.8M]
  ------------------
  644|  8.84M|      arith_encode(cinfo, st, 0);       /* EOB decision */
  645|  85.9M|    for (;;) {
  646|  85.9M|      if ((v = (*block)[jpeg_natural_order[k]]) >= 0) {
  ------------------
  |  Branch (646:11): [True: 61.0M, False: 24.8M]
  ------------------
  647|  61.0M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (647:13): [True: 21.4M, False: 39.6M]
  ------------------
  648|  21.4M|          if (v >> 1)                   /* previously nonzero coef */
  ------------------
  |  Branch (648:15): [True: 11.1M, False: 10.3M]
  ------------------
  649|  11.1M|            arith_encode(cinfo, st + 2, (v & 1));
  650|  10.3M|          else {                        /* newly nonzero coef */
  651|  10.3M|            arith_encode(cinfo, st + 1, 1);
  652|  10.3M|            arith_encode(cinfo, entropy->fixed_bin, 0);
  653|  10.3M|          }
  654|  21.4M|          break;
  655|  21.4M|        }
  656|  61.0M|      } else {
  657|  24.8M|        v = -v;
  658|  24.8M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (658:13): [True: 21.2M, False: 3.54M]
  ------------------
  659|  21.2M|          if (v >> 1)                   /* previously nonzero coef */
  ------------------
  |  Branch (659:15): [True: 11.0M, False: 10.2M]
  ------------------
  660|  11.0M|            arith_encode(cinfo, st + 2, (v & 1));
  661|  10.2M|          else {                        /* newly nonzero coef */
  662|  10.2M|            arith_encode(cinfo, st + 1, 1);
  663|  10.2M|            arith_encode(cinfo, entropy->fixed_bin, 1);
  664|  10.2M|          }
  665|  21.2M|          break;
  666|  21.2M|        }
  667|  24.8M|      }
  668|  43.1M|      arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  669|  43.1M|    }
  670|  42.7M|  }
  671|       |  /* Encode EOB decision only if k <= cinfo->Se */
  672|  4.71M|  if (k <= cinfo->Se) {
  ------------------
  |  Branch (672:7): [True: 4.58M, False: 134k]
  ------------------
  673|  4.58M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  674|  4.58M|    arith_encode(cinfo, st, 1);
  675|  4.58M|  }
  676|       |
  677|  4.71M|  return TRUE;
  ------------------
  |  |  210|  4.71M|#define TRUE    1
  ------------------
  678|  4.71M|}
jcarith.c:encode_mcu:
  687|   642k|{
  688|   642k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  689|   642k|  jpeg_component_info *compptr;
  690|   642k|  JBLOCKROW block;
  691|   642k|  unsigned char *st;
  692|   642k|  int blkn, ci, tbl, k, ke;
  693|   642k|  int v, v2, m;
  694|       |
  695|       |  /* Emit restart marker if needed */
  696|   642k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (696:7): [True: 0, False: 642k]
  ------------------
  697|      0|    if (entropy->restarts_to_go == 0) {
  ------------------
  |  Branch (697:9): [True: 0, False: 0]
  ------------------
  698|      0|      emit_restart(cinfo, entropy->next_restart_num);
  699|      0|      entropy->restarts_to_go = cinfo->restart_interval;
  700|      0|      entropy->next_restart_num++;
  701|      0|      entropy->next_restart_num &= 7;
  702|      0|    }
  703|      0|    entropy->restarts_to_go--;
  704|      0|  }
  705|       |
  706|       |  /* Encode the MCU data blocks */
  707|  4.49M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (707:18): [True: 3.85M, False: 642k]
  ------------------
  708|  3.85M|    block = MCU_data[blkn];
  709|  3.85M|    ci = cinfo->MCU_membership[blkn];
  710|  3.85M|    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.85M|    tbl = compptr->dc_tbl_no;
  715|       |
  716|       |    /* Table F.4: Point to statistics bin S0 for DC coefficient coding */
  717|  3.85M|    st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
  718|       |
  719|       |    /* Figure F.4: Encode_DC_DIFF */
  720|  3.85M|    if ((v = (*block)[0] - entropy->last_dc_val[ci]) == 0) {
  ------------------
  |  Branch (720:9): [True: 2.56M, False: 1.29M]
  ------------------
  721|  2.56M|      arith_encode(cinfo, st, 0);
  722|  2.56M|      entropy->dc_context[ci] = 0;      /* zero diff category */
  723|  2.56M|    } else {
  724|  1.29M|      entropy->last_dc_val[ci] = (*block)[0];
  725|  1.29M|      arith_encode(cinfo, st, 1);
  726|       |      /* Figure F.6: Encoding nonzero value v */
  727|       |      /* Figure F.7: Encoding the sign of v */
  728|  1.29M|      if (v > 0) {
  ------------------
  |  Branch (728:11): [True: 647k, False: 643k]
  ------------------
  729|   647k|        arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
  730|   647k|        st += 2;                        /* Table F.4: SP = S0 + 2 */
  731|   647k|        entropy->dc_context[ci] = 4;    /* small positive diff category */
  732|   647k|      } else {
  733|   643k|        v = -v;
  734|   643k|        arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
  735|   643k|        st += 3;                        /* Table F.4: SN = S0 + 3 */
  736|   643k|        entropy->dc_context[ci] = 8;    /* small negative diff category */
  737|   643k|      }
  738|       |      /* Figure F.8: Encoding the magnitude category of v */
  739|  1.29M|      m = 0;
  740|  1.29M|      if (v -= 1) {
  ------------------
  |  Branch (740:11): [True: 1.20M, False: 82.5k]
  ------------------
  741|  1.20M|        arith_encode(cinfo, st, 1);
  742|  1.20M|        m = 1;
  743|  1.20M|        v2 = v;
  744|  1.20M|        st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
  745|  5.05M|        while (v2 >>= 1) {
  ------------------
  |  Branch (745:16): [True: 3.84M, False: 1.20M]
  ------------------
  746|  3.84M|          arith_encode(cinfo, st, 1);
  747|  3.84M|          m <<= 1;
  748|  3.84M|          st += 1;
  749|  3.84M|        }
  750|  1.20M|      }
  751|  1.29M|      arith_encode(cinfo, st, 0);
  752|       |      /* Section F.1.4.4.1.2: Establish dc_context conditioning category */
  753|  1.29M|      if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
  ------------------
  |  Branch (753:11): [True: 0, False: 1.29M]
  ------------------
  754|      0|        entropy->dc_context[ci] = 0;    /* zero diff category */
  755|  1.29M|      else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
  ------------------
  |  Branch (755:16): [True: 1.13M, False: 152k]
  ------------------
  756|  1.13M|        entropy->dc_context[ci] += 8;   /* large diff category */
  757|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  758|  1.29M|      st += 14;
  759|  5.14M|      while (m >>= 1)
  ------------------
  |  Branch (759:14): [True: 3.84M, False: 1.29M]
  ------------------
  760|  3.84M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (760:33): [True: 1.85M, False: 1.99M]
  ------------------
  761|  1.29M|    }
  762|       |
  763|       |    /* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */
  764|       |
  765|  3.85M|    tbl = compptr->ac_tbl_no;
  766|       |
  767|       |    /* Establish EOB (end-of-block) index */
  768|   185M|    for (ke = DCTSIZE2 - 1; ke > 0; ke--)
  ------------------
  |  |   67|  3.85M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (768:29): [True: 183M, False: 2.52M]
  ------------------
  769|   183M|      if ((*block)[jpeg_natural_order[ke]]) break;
  ------------------
  |  Branch (769:11): [True: 1.33M, False: 182M]
  ------------------
  770|       |
  771|       |    /* Figure F.5: Encode_AC_Coefficients */
  772|  39.9M|    for (k = 1; k <= ke; k++) {
  ------------------
  |  Branch (772:17): [True: 36.0M, False: 3.85M]
  ------------------
  773|  36.0M|      st = entropy->ac_stats[tbl] + 3 * (k - 1);
  774|  36.0M|      arith_encode(cinfo, st, 0);       /* EOB decision */
  775|  60.7M|      while ((v = (*block)[jpeg_natural_order[k]]) == 0) {
  ------------------
  |  Branch (775:14): [True: 24.7M, False: 36.0M]
  ------------------
  776|  24.7M|        arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  777|  24.7M|      }
  778|  36.0M|      arith_encode(cinfo, st + 1, 1);
  779|       |      /* Figure F.6: Encoding nonzero value v */
  780|       |      /* Figure F.7: Encoding the sign of v */
  781|  36.0M|      if (v > 0) {
  ------------------
  |  Branch (781:11): [True: 18.0M, False: 17.9M]
  ------------------
  782|  18.0M|        arith_encode(cinfo, entropy->fixed_bin, 0);
  783|  18.0M|      } else {
  784|  17.9M|        v = -v;
  785|  17.9M|        arith_encode(cinfo, entropy->fixed_bin, 1);
  786|  17.9M|      }
  787|  36.0M|      st += 2;
  788|       |      /* Figure F.8: Encoding the magnitude category of v */
  789|  36.0M|      m = 0;
  790|  36.0M|      if (v -= 1) {
  ------------------
  |  Branch (790:11): [True: 22.4M, False: 13.6M]
  ------------------
  791|  22.4M|        arith_encode(cinfo, st, 1);
  792|  22.4M|        m = 1;
  793|  22.4M|        v2 = v;
  794|  22.4M|        if (v2 >>= 1) {
  ------------------
  |  Branch (794:13): [True: 16.2M, False: 6.14M]
  ------------------
  795|  16.2M|          arith_encode(cinfo, st, 1);
  796|  16.2M|          m <<= 1;
  797|  16.2M|          st = entropy->ac_stats[tbl] +
  798|  16.2M|               (k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
  ------------------
  |  Branch (798:17): [True: 3.96M, False: 12.3M]
  ------------------
  799|  36.2M|          while (v2 >>= 1) {
  ------------------
  |  Branch (799:18): [True: 19.9M, False: 16.2M]
  ------------------
  800|  19.9M|            arith_encode(cinfo, st, 1);
  801|  19.9M|            m <<= 1;
  802|  19.9M|            st += 1;
  803|  19.9M|          }
  804|  16.2M|        }
  805|  22.4M|      }
  806|  36.0M|      arith_encode(cinfo, st, 0);
  807|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  808|  36.0M|      st += 14;
  809|  72.3M|      while (m >>= 1)
  ------------------
  |  Branch (809:14): [True: 36.2M, False: 36.0M]
  ------------------
  810|  36.2M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (810:33): [True: 14.8M, False: 21.4M]
  ------------------
  811|  36.0M|    }
  812|       |    /* Encode EOB decision only if k <= DCTSIZE2 - 1 */
  813|  3.85M|    if (k <= DCTSIZE2 - 1) {
  ------------------
  |  |   67|  3.85M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (813:9): [True: 3.60M, False: 246k]
  ------------------
  814|  3.60M|      st = entropy->ac_stats[tbl] + 3 * (k - 1);
  815|  3.60M|      arith_encode(cinfo, st, 1);
  816|  3.60M|    }
  817|  3.85M|  }
  818|       |
  819|   642k|  return TRUE;
  ------------------
  |  |  210|   642k|#define TRUE    1
  ------------------
  820|   642k|}
jcarith.c:finish_pass:
  140|  39.2k|{
  141|  39.2k|  arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
  142|  39.2k|  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|  39.2k|  if ((temp = (e->a - 1 + e->c) & 0xFFFF0000UL) < e->c)
  ------------------
  |  Branch (148:7): [True: 13.6k, False: 25.5k]
  ------------------
  149|  13.6k|    e->c = temp + 0x8000L;
  150|  25.5k|  else
  151|  25.5k|    e->c = temp;
  152|       |  /* Send remaining bytes to output */
  153|  39.2k|  e->c <<= e->ct;
  154|  39.2k|  if (e->c & 0xF8000000UL) {
  ------------------
  |  Branch (154:7): [True: 1.61k, False: 37.5k]
  ------------------
  155|       |    /* One final overflow has to be handled */
  156|  1.61k|    if (e->buffer >= 0) {
  ------------------
  |  Branch (156:9): [True: 1.61k, False: 0]
  ------------------
  157|  1.61k|      if (e->zc)
  ------------------
  |  Branch (157:11): [True: 33, False: 1.58k]
  ------------------
  158|  5.62k|        do emit_byte(0x00, cinfo);
  159|  5.62k|        while (--e->zc);
  ------------------
  |  Branch (159:16): [True: 5.58k, False: 33]
  ------------------
  160|  1.61k|      emit_byte(e->buffer + 1, cinfo);
  161|  1.61k|      if (e->buffer + 1 == 0xFF)
  ------------------
  |  Branch (161:11): [True: 177, False: 1.43k]
  ------------------
  162|    177|        emit_byte(0x00, cinfo);
  163|  1.61k|    }
  164|  1.61k|    e->zc += e->sc;  /* carry-over converts stacked 0xFF bytes to 0x00 */
  165|  1.61k|    e->sc = 0;
  166|  37.5k|  } else {
  167|  37.5k|    if (e->buffer == 0)
  ------------------
  |  Branch (167:9): [True: 761, False: 36.8k]
  ------------------
  168|    761|      ++e->zc;
  169|  36.8k|    else if (e->buffer >= 0) {
  ------------------
  |  Branch (169:14): [True: 25.9k, False: 10.8k]
  ------------------
  170|  25.9k|      if (e->zc)
  ------------------
  |  Branch (170:11): [True: 200, False: 25.7k]
  ------------------
  171|  7.73k|        do emit_byte(0x00, cinfo);
  172|  7.73k|        while (--e->zc);
  ------------------
  |  Branch (172:16): [True: 7.53k, False: 200]
  ------------------
  173|  25.9k|      emit_byte(e->buffer, cinfo);
  174|  25.9k|    }
  175|  37.5k|    if (e->sc) {
  ------------------
  |  Branch (175:9): [True: 189, False: 37.3k]
  ------------------
  176|    189|      if (e->zc)
  ------------------
  |  Branch (176:11): [True: 14, False: 175]
  ------------------
  177|    328|        do emit_byte(0x00, cinfo);
  178|    328|        while (--e->zc);
  ------------------
  |  Branch (178:16): [True: 314, False: 14]
  ------------------
  179|  21.7k|      do {
  180|  21.7k|        emit_byte(0xFF, cinfo);
  181|  21.7k|        emit_byte(0x00, cinfo);
  182|  21.7k|      } while (--e->sc);
  ------------------
  |  Branch (182:16): [True: 21.5k, False: 189]
  ------------------
  183|    189|    }
  184|  37.5k|  }
  185|       |  /* Output final bytes only if they are not 0x00 */
  186|  39.2k|  if (e->c & 0x7FFF800L) {
  ------------------
  |  Branch (186:7): [True: 38.0k, False: 1.19k]
  ------------------
  187|  38.0k|    if (e->zc)  /* output final pending zero bytes */
  ------------------
  |  Branch (187:9): [True: 393, False: 37.6k]
  ------------------
  188|  10.4k|      do emit_byte(0x00, cinfo);
  189|  10.4k|      while (--e->zc);
  ------------------
  |  Branch (189:14): [True: 10.0k, False: 393]
  ------------------
  190|  38.0k|    emit_byte((e->c >> 19) & 0xFF, cinfo);
  191|  38.0k|    if (((e->c >> 19) & 0xFF) == 0xFF)
  ------------------
  |  Branch (191:9): [True: 94, False: 37.9k]
  ------------------
  192|     94|      emit_byte(0x00, cinfo);
  193|  38.0k|    if (e->c & 0x7F800L) {
  ------------------
  |  Branch (193:9): [True: 6.63k, False: 31.3k]
  ------------------
  194|  6.63k|      emit_byte((e->c >> 11) & 0xFF, cinfo);
  195|  6.63k|      if (((e->c >> 11) & 0xFF) == 0xFF)
  ------------------
  |  Branch (195:11): [True: 0, False: 6.63k]
  ------------------
  196|      0|        emit_byte(0x00, cinfo);
  197|  6.63k|    }
  198|  38.0k|  }
  199|  39.2k|}

jinit_c_coef_controller:
  437|  26.5k|{
  438|  26.5k|  my_coef_ptr coef;
  439|       |
  440|  26.5k|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  26.5k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (440:7): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|  coef = (my_coef_ptr)
  444|  26.5k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  26.5k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  445|  26.5k|                                sizeof(my_coef_controller));
  446|  26.5k|  memset(coef, 0, sizeof(my_coef_controller));
  447|  26.5k|  cinfo->coef = (struct jpeg_c_coef_controller *)coef;
  448|  26.5k|  coef->pub.start_pass = start_pass_coef;
  449|       |
  450|       |  /* Create the coefficient buffer. */
  451|  26.5k|  if (need_full_buffer) {
  ------------------
  |  Branch (451:7): [True: 10.8k, False: 15.6k]
  ------------------
  452|  10.8k|#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|  10.8k|    int ci;
  456|  10.8k|    jpeg_component_info *compptr;
  457|       |
  458|  47.1k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (458:46): [True: 36.2k, False: 10.8k]
  ------------------
  459|  36.2k|         ci++, compptr++) {
  460|  36.2k|      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
  461|  36.2k|        ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
  ------------------
  |  |  889|  36.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                      ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
  ------------------
  |  |  207|  36.2k|#define FALSE   0               /* values of boolean */
  ------------------
  462|  36.2k|         (JDIMENSION)jround_up((long)compptr->width_in_blocks,
  463|  36.2k|                               (long)compptr->h_samp_factor),
  464|  36.2k|         (JDIMENSION)jround_up((long)compptr->height_in_blocks,
  465|  36.2k|                               (long)compptr->v_samp_factor),
  466|  36.2k|         (JDIMENSION)compptr->v_samp_factor);
  467|  36.2k|    }
  468|       |#else
  469|       |    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  470|       |#endif
  471|  15.6k|  } else {
  472|       |    /* We only need a single-MCU buffer. */
  473|  15.6k|    JBLOCKROW buffer;
  474|  15.6k|    int i;
  475|       |
  476|  15.6k|    buffer = (JBLOCKROW)
  477|  15.6k|      (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  15.6k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  478|  15.6k|                                  C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
  ------------------
  |  |   80|  15.6k|#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on data units/MCU */
  ------------------
  479|   172k|    for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
  ------------------
  |  |   80|   172k|#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on data units/MCU */
  ------------------
  |  Branch (479:17): [True: 156k, False: 15.6k]
  ------------------
  480|   156k|      coef->MCU_buffer[i] = buffer + i;
  481|   156k|    }
  482|       |    coef->whole_image[0] = NULL; /* flag for no virtual arrays */
  483|  15.6k|  }
  484|  26.5k|}
jccoefct-8.c:start_pass_coef:
  104|   129k|{
  105|   129k|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  106|       |
  107|   129k|  coef->iMCU_row_num = 0;
  108|   129k|  start_iMCU_row(cinfo);
  109|       |
  110|   129k|  switch (pass_mode) {
  111|  15.6k|  case JBUF_PASS_THRU:
  ------------------
  |  Branch (111:3): [True: 15.6k, False: 114k]
  ------------------
  112|  15.6k|    if (coef->whole_image[0] != NULL)
  ------------------
  |  Branch (112:9): [True: 0, False: 15.6k]
  ------------------
  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|  15.6k|    coef->pub._compress_data = compress_data;
  ------------------
  |  |  248|  15.6k|#define _compress_data  compress_data
  ------------------
  115|  15.6k|    break;
  116|      0|#ifdef FULL_COEF_BUFFER_SUPPORTED
  117|  10.8k|  case JBUF_SAVE_AND_PASS:
  ------------------
  |  Branch (117:3): [True: 10.8k, False: 118k]
  ------------------
  118|  10.8k|    if (coef->whole_image[0] == NULL)
  ------------------
  |  Branch (118:9): [True: 0, False: 10.8k]
  ------------------
  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|  10.8k|    coef->pub._compress_data = compress_first_pass;
  ------------------
  |  |  248|  10.8k|#define _compress_data  compress_data
  ------------------
  121|  10.8k|    break;
  122|   103k|  case JBUF_CRANK_DEST:
  ------------------
  |  Branch (122:3): [True: 103k, False: 26.5k]
  ------------------
  123|   103k|    if (coef->whole_image[0] == NULL)
  ------------------
  |  Branch (123:9): [True: 0, False: 103k]
  ------------------
  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|   103k|    coef->pub._compress_data = compress_output;
  ------------------
  |  |  248|   103k|#define _compress_data  compress_data
  ------------------
  126|   103k|    break;
  127|      0|#endif
  128|      0|  default:
  ------------------
  |  Branch (128:3): [True: 0, False: 129k]
  ------------------
  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|   129k|  }
  132|   129k|}
jccoefct-8.c:start_iMCU_row:
   77|  23.0M|{
   78|  23.0M|  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|  23.0M|  if (cinfo->comps_in_scan > 1) {
  ------------------
  |  Branch (84:7): [True: 5.22M, False: 17.8M]
  ------------------
   85|  5.22M|    coef->MCU_rows_per_iMCU_row = 1;
   86|  17.8M|  } else {
   87|  17.8M|    if (coef->iMCU_row_num < (cinfo->total_iMCU_rows - 1))
  ------------------
  |  Branch (87:9): [True: 17.6M, False: 193k]
  ------------------
   88|  17.6M|      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
   89|   193k|    else
   90|   193k|      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
   91|  17.8M|  }
   92|       |
   93|  23.0M|  coef->mcu_ctr = 0;
   94|  23.0M|  coef->MCU_vert_offset = 0;
   95|  23.0M|}
jccoefct-8.c:compress_data:
  147|  2.18M|{
  148|  2.18M|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  149|  2.18M|  JDIMENSION MCU_col_num;       /* index of current MCU within row */
  150|  2.18M|  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
  151|  2.18M|  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
  152|  2.18M|  int blkn, bi, ci, yindex, yoffset, blockcnt;
  153|  2.18M|  JDIMENSION ypos, xpos;
  154|  2.18M|  jpeg_component_info *compptr;
  155|       |
  156|       |  /* Loop to write as much as one whole iMCU row */
  157|  4.36M|  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
  ------------------
  |  Branch (157:41): [True: 2.18M, False: 2.18M]
  ------------------
  158|  2.18M|       yoffset++) {
  159|  6.64M|    for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col;
  ------------------
  |  Branch (159:39): [True: 4.45M, False: 2.18M]
  ------------------
  160|  4.45M|         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|  4.45M|      blkn = 0;
  171|  13.1M|      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (171:20): [True: 8.72M, False: 4.45M]
  ------------------
  172|  8.72M|        compptr = cinfo->cur_comp_info[ci];
  173|  8.72M|        blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width :
  ------------------
  |  Branch (173:20): [True: 4.46M, False: 4.26M]
  ------------------
  174|  8.72M|                                                  compptr->last_col_width;
  175|  8.72M|        xpos = MCU_col_num * compptr->MCU_sample_width;
  176|  8.72M|        ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */
  ------------------
  |  |   66|  8.72M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  177|  18.0M|        for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
  ------------------
  |  Branch (177:26): [True: 9.37M, False: 8.72M]
  ------------------
  178|  9.37M|          if (coef->iMCU_row_num < last_iMCU_row ||
  ------------------
  |  Branch (178:15): [True: 5.54M, False: 3.82M]
  ------------------
  179|  9.13M|              yoffset + yindex < compptr->last_row_height) {
  ------------------
  |  Branch (179:15): [True: 3.58M, False: 239k]
  ------------------
  180|  9.13M|            (*cinfo->fdct->_forward_DCT) (cinfo, compptr,
  ------------------
  |  |  254|  9.13M|#define _forward_DCT  forward_DCT
  ------------------
  181|  9.13M|                                          input_buf[compptr->component_index],
  182|  9.13M|                                          coef->MCU_buffer[blkn],
  183|  9.13M|                                          ypos, xpos, (JDIMENSION)blockcnt);
  184|  9.13M|            if (blockcnt < compptr->MCU_width) {
  ------------------
  |  Branch (184:17): [True: 598k, False: 8.53M]
  ------------------
  185|       |              /* Create some dummy blocks at the right edge of the image. */
  186|   598k|              jzero_far((void *)coef->MCU_buffer[blkn + blockcnt],
  187|   598k|                        (compptr->MCU_width - blockcnt) * sizeof(JBLOCK));
  188|  1.19M|              for (bi = blockcnt; bi < compptr->MCU_width; bi++) {
  ------------------
  |  Branch (188:35): [True: 598k, False: 598k]
  ------------------
  189|   598k|                coef->MCU_buffer[blkn + bi][0][0] =
  190|   598k|                  coef->MCU_buffer[blkn + bi - 1][0][0];
  191|   598k|              }
  192|   598k|            }
  193|  9.13M|          } else {
  194|       |            /* Create a row of dummy blocks at the bottom of the image. */
  195|   239k|            jzero_far((void *)coef->MCU_buffer[blkn],
  196|   239k|                      compptr->MCU_width * sizeof(JBLOCK));
  197|   719k|            for (bi = 0; bi < compptr->MCU_width; bi++) {
  ------------------
  |  Branch (197:26): [True: 479k, False: 239k]
  ------------------
  198|   479k|              coef->MCU_buffer[blkn + bi][0][0] =
  199|   479k|                coef->MCU_buffer[blkn - 1][0][0];
  200|   479k|            }
  201|   239k|          }
  202|  9.37M|          blkn += compptr->MCU_width;
  203|  9.37M|          ypos += DCTSIZE;
  ------------------
  |  |   66|  9.37M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  204|  9.37M|        }
  205|  8.72M|      }
  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|  4.45M|      if (!(*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
  ------------------
  |  Branch (212:11): [True: 0, False: 4.45M]
  ------------------
  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|  4.45M|    }
  229|       |    /* Completed an MCU row, but perhaps not an iMCU row */
  230|  2.18M|    coef->mcu_ctr = 0;
  231|  2.18M|  }
  232|       |  /* Completed the iMCU row, advance counters for next one */
  233|  2.18M|  coef->iMCU_row_num++;
  234|  2.18M|  start_iMCU_row(cinfo);
  235|  2.18M|  return TRUE;
  ------------------
  |  |  210|  2.18M|#define TRUE    1
  ------------------
  236|  2.18M|}
jccoefct-8.c:compress_first_pass:
  264|  1.72M|{
  265|  1.72M|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  266|  1.72M|  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
  267|  1.72M|  JDIMENSION blocks_across, MCUs_across, MCUindex;
  268|  1.72M|  int bi, ci, h_samp_factor, block_row, block_rows, ndummy;
  269|  1.72M|  JCOEF lastDC;
  270|  1.72M|  jpeg_component_info *compptr;
  271|  1.72M|  JBLOCKARRAY buffer;
  272|  1.72M|  JBLOCKROW thisblockrow, lastblockrow;
  273|       |
  274|  7.26M|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (274:44): [True: 5.53M, False: 1.72M]
  ------------------
  275|  5.53M|       ci++, compptr++) {
  276|       |    /* Align the virtual buffer for this component. */
  277|  5.53M|    buffer = (*cinfo->mem->access_virt_barray)
  278|  5.53M|      ((j_common_ptr)cinfo, coef->whole_image[ci],
  279|  5.53M|       coef->iMCU_row_num * compptr->v_samp_factor,
  280|  5.53M|       (JDIMENSION)compptr->v_samp_factor, TRUE);
  ------------------
  |  |  210|  5.53M|#define TRUE    1
  ------------------
  281|       |    /* Count non-dummy DCT block rows in this iMCU row. */
  282|  5.53M|    if (coef->iMCU_row_num < last_iMCU_row)
  ------------------
  |  Branch (282:9): [True: 5.49M, False: 36.2k]
  ------------------
  283|  5.49M|      block_rows = compptr->v_samp_factor;
  284|  36.2k|    else {
  285|       |      /* NB: can't use last_row_height here, since may not be set! */
  286|  36.2k|      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
  287|  36.2k|      if (block_rows == 0) block_rows = compptr->v_samp_factor;
  ------------------
  |  Branch (287:11): [True: 30.1k, False: 6.05k]
  ------------------
  288|  36.2k|    }
  289|  5.53M|    blocks_across = compptr->width_in_blocks;
  290|  5.53M|    h_samp_factor = compptr->h_samp_factor;
  291|       |    /* Count number of dummy blocks to be added at the right margin. */
  292|  5.53M|    ndummy = (int)(blocks_across % h_samp_factor);
  293|  5.53M|    if (ndummy > 0)
  ------------------
  |  Branch (293:9): [True: 1.28M, False: 4.24M]
  ------------------
  294|  1.28M|      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|  11.7M|    for (block_row = 0; block_row < block_rows; block_row++) {
  ------------------
  |  Branch (298:25): [True: 6.22M, False: 5.53M]
  ------------------
  299|  6.22M|      thisblockrow = buffer[block_row];
  300|  6.22M|      (*cinfo->fdct->_forward_DCT) (cinfo, compptr,
  ------------------
  |  |  254|  6.22M|#define _forward_DCT  forward_DCT
  ------------------
  301|  6.22M|                                    input_buf[ci], thisblockrow,
  302|  6.22M|                                    (JDIMENSION)(block_row * DCTSIZE),
  ------------------
  |  |   66|  6.22M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  303|  6.22M|                                    (JDIMENSION)0, blocks_across);
  304|  6.22M|      if (ndummy > 0) {
  ------------------
  |  Branch (304:11): [True: 1.28M, False: 4.93M]
  ------------------
  305|       |        /* Create dummy blocks at the right edge of the image. */
  306|  1.28M|        thisblockrow += blocks_across; /* => first dummy block */
  307|  1.28M|        jzero_far((void *)thisblockrow, ndummy * sizeof(JBLOCK));
  308|  1.28M|        lastDC = thisblockrow[-1][0];
  309|  3.86M|        for (bi = 0; bi < ndummy; bi++) {
  ------------------
  |  Branch (309:22): [True: 2.57M, False: 1.28M]
  ------------------
  310|  2.57M|          thisblockrow[bi][0] = lastDC;
  311|  2.57M|        }
  312|  1.28M|      }
  313|  6.22M|    }
  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|  5.53M|    if (coef->iMCU_row_num == last_iMCU_row) {
  ------------------
  |  Branch (319:9): [True: 36.2k, False: 5.49M]
  ------------------
  320|  36.2k|      blocks_across += ndummy;  /* include lower right corner */
  321|  36.2k|      MCUs_across = blocks_across / h_samp_factor;
  322|  42.2k|      for (block_row = block_rows; block_row < compptr->v_samp_factor;
  ------------------
  |  Branch (322:36): [True: 6.05k, False: 36.2k]
  ------------------
  323|  36.2k|           block_row++) {
  324|  6.05k|        thisblockrow = buffer[block_row];
  325|  6.05k|        lastblockrow = buffer[block_row - 1];
  326|  6.05k|        jzero_far((void *)thisblockrow,
  327|  6.05k|                  (size_t)(blocks_across * sizeof(JBLOCK)));
  328|   960k|        for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
  ------------------
  |  Branch (328:28): [True: 954k, False: 6.05k]
  ------------------
  329|   954k|          lastDC = lastblockrow[h_samp_factor - 1][0];
  330|  1.90M|          for (bi = 0; bi < h_samp_factor; bi++) {
  ------------------
  |  Branch (330:24): [True: 954k, False: 954k]
  ------------------
  331|   954k|            thisblockrow[bi][0] = lastDC;
  332|   954k|          }
  333|   954k|          thisblockrow += h_samp_factor; /* advance to next MCU in row */
  334|   954k|          lastblockrow += h_samp_factor;
  335|   954k|        }
  336|  6.05k|      }
  337|  36.2k|    }
  338|  5.53M|  }
  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|  1.72M|  return compress_output(cinfo, input_buf);
  345|  1.72M|}
jccoefct-8.c:compress_output:
  360|  20.7M|{
  361|  20.7M|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  362|  20.7M|  JDIMENSION MCU_col_num;       /* index of current MCU within row */
  363|  20.7M|  int blkn, ci, xindex, yindex, yoffset;
  364|  20.7M|  JDIMENSION start_col;
  365|  20.7M|  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
  366|  20.7M|  JBLOCKROW buffer_ptr;
  367|  20.7M|  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|  50.4M|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (373:16): [True: 29.7M, False: 20.7M]
  ------------------
  374|  29.7M|    compptr = cinfo->cur_comp_info[ci];
  375|  29.7M|    buffer[ci] = (*cinfo->mem->access_virt_barray)
  376|  29.7M|      ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
  377|  29.7M|       coef->iMCU_row_num * compptr->v_samp_factor,
  378|  29.7M|       (JDIMENSION)compptr->v_samp_factor, FALSE);
  ------------------
  |  |  207|  29.7M|#define FALSE   0               /* values of boolean */
  ------------------
  379|  29.7M|  }
  380|       |
  381|       |  /* Loop to process one whole iMCU row */
  382|  41.4M|  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
  ------------------
  |  Branch (382:41): [True: 20.7M, False: 20.7M]
  ------------------
  383|  20.7M|       yoffset++) {
  384|  57.3M|    for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row;
  ------------------
  |  Branch (384:39): [True: 36.5M, False: 20.7M]
  ------------------
  385|  36.5M|         MCU_col_num++) {
  386|       |      /* Construct list of pointers to DCT blocks belonging to this MCU */
  387|  36.5M|      blkn = 0;                 /* index of current DCT block within MCU */
  388|  88.7M|      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (388:20): [True: 52.2M, False: 36.5M]
  ------------------
  389|  52.2M|        compptr = cinfo->cur_comp_info[ci];
  390|  52.2M|        start_col = MCU_col_num * compptr->MCU_width;
  391|   108M|        for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
  ------------------
  |  Branch (391:26): [True: 56.1M, False: 52.2M]
  ------------------
  392|  56.1M|          buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
  393|   120M|          for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
  ------------------
  |  Branch (393:28): [True: 64.4M, False: 56.1M]
  ------------------
  394|  64.4M|            coef->MCU_buffer[blkn++] = buffer_ptr++;
  395|  64.4M|          }
  396|  56.1M|        }
  397|  52.2M|      }
  398|       |      /* Try to write the MCU. */
  399|       |#ifdef WITH_PROFILE
  400|       |      cinfo->master->start = getTime();
  401|       |#endif
  402|  36.5M|      if (!(*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
  ------------------
  |  Branch (402:11): [True: 0, False: 36.5M]
  ------------------
  403|       |        /* Suspension forced; update state counters and exit */
  404|      0|        coef->MCU_vert_offset = yoffset;
  405|      0|        coef->mcu_ctr = MCU_col_num;
  406|       |#ifdef WITH_PROFILE
  407|       |        cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
  408|       |        cinfo->master->entropy_mcoeffs +=
  409|       |          (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
  410|       |#endif
  411|      0|        return FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  412|      0|      }
  413|       |#ifdef WITH_PROFILE
  414|       |      cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
  415|       |      cinfo->master->entropy_mcoeffs +=
  416|       |        (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
  417|       |#endif
  418|  36.5M|    }
  419|       |    /* Completed an MCU row, but perhaps not an iMCU row */
  420|  20.7M|    coef->mcu_ctr = 0;
  421|  20.7M|  }
  422|       |  /* Completed the iMCU row, advance counters for next one */
  423|  20.7M|  coef->iMCU_row_num++;
  424|  20.7M|  start_iMCU_row(cinfo);
  425|  20.7M|  return TRUE;
  ------------------
  |  |  210|  20.7M|#define TRUE    1
  ------------------
  426|  20.7M|}

jinit_color_converter:
  418|  26.5k|{
  419|  26.5k|  my_cconvert_ptr cconvert;
  420|       |
  421|  26.5k|#ifdef C_LOSSLESS_SUPPORTED
  422|  26.5k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (422:7): [True: 0, False: 26.5k]
  ------------------
  423|      0|#if BITS_IN_JSAMPLE == 8
  424|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (424:9): [True: 0, False: 0]
  |  Branch (424:52): [True: 0, False: 0]
  ------------------
  425|       |#else
  426|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  427|       |        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  428|       |#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|  26.5k|#endif
  432|  26.5k|  {
  433|  26.5k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  26.5k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (433:9): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|  }
  436|       |
  437|  26.5k|  cconvert = (my_cconvert_ptr)
  438|  26.5k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  26.5k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  439|  26.5k|                                sizeof(my_color_converter));
  440|  26.5k|  cinfo->cconvert = (struct jpeg_color_converter *)cconvert;
  441|       |  /* set start_pass to null method until we find out differently */
  442|  26.5k|  cconvert->pub.start_pass = null_method;
  443|       |
  444|       |  /* Make sure input_components agrees with in_color_space */
  445|  26.5k|  switch (cinfo->in_color_space) {
  446|  4.76k|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (446:3): [True: 4.76k, False: 21.7k]
  ------------------
  447|  4.76k|    if (cinfo->input_components != 1)
  ------------------
  |  Branch (447:9): [True: 0, False: 4.76k]
  ------------------
  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|  4.76k|    break;
  450|       |
  451|      0|  case JCS_RGB:
  ------------------
  |  Branch (451:3): [True: 0, False: 26.5k]
  ------------------
  452|  3.76k|  case JCS_EXT_RGB:
  ------------------
  |  Branch (452:3): [True: 3.76k, False: 22.7k]
  ------------------
  453|  7.32k|  case JCS_EXT_RGBX:
  ------------------
  |  Branch (453:3): [True: 3.56k, False: 22.9k]
  ------------------
  454|  11.0k|  case JCS_EXT_BGR:
  ------------------
  |  Branch (454:3): [True: 3.76k, False: 22.7k]
  ------------------
  455|  11.0k|  case JCS_EXT_BGRX:
  ------------------
  |  Branch (455:3): [True: 0, False: 26.5k]
  ------------------
  456|  11.0k|  case JCS_EXT_XBGR:
  ------------------
  |  Branch (456:3): [True: 0, False: 26.5k]
  ------------------
  457|  14.6k|  case JCS_EXT_XRGB:
  ------------------
  |  Branch (457:3): [True: 3.56k, False: 22.9k]
  ------------------
  458|  14.6k|  case JCS_EXT_RGBA:
  ------------------
  |  Branch (458:3): [True: 0, False: 26.5k]
  ------------------
  459|  18.2k|  case JCS_EXT_BGRA:
  ------------------
  |  Branch (459:3): [True: 3.56k, False: 22.9k]
  ------------------
  460|  18.2k|  case JCS_EXT_ABGR:
  ------------------
  |  Branch (460:3): [True: 0, False: 26.5k]
  ------------------
  461|  18.2k|  case JCS_EXT_ARGB:
  ------------------
  |  Branch (461:3): [True: 0, False: 26.5k]
  ------------------
  462|  18.2k|    if (cinfo->input_components != rgb_pixelsize[cinfo->in_color_space])
  ------------------
  |  Branch (462:9): [True: 0, False: 18.2k]
  ------------------
  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|  18.2k|    break;
  465|       |
  466|      0|  case JCS_YCbCr:
  ------------------
  |  Branch (466:3): [True: 0, False: 26.5k]
  ------------------
  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.56k|  case JCS_CMYK:
  ------------------
  |  Branch (471:3): [True: 3.56k, False: 22.9k]
  ------------------
  472|  3.56k|  case JCS_YCCK:
  ------------------
  |  Branch (472:3): [True: 0, False: 26.5k]
  ------------------
  473|  3.56k|    if (cinfo->input_components != 4)
  ------------------
  |  Branch (473:9): [True: 0, False: 3.56k]
  ------------------
  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.56k|    break;
  476|       |
  477|      0|  default:                      /* JCS_UNKNOWN can be anything */
  ------------------
  |  Branch (477:3): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|  }
  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|  26.5k|  switch (cinfo->jpeg_color_space) {
  488|  8.32k|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (488:3): [True: 8.32k, False: 18.2k]
  ------------------
  489|  8.32k|#ifdef C_LOSSLESS_SUPPORTED
  490|  8.32k|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (490:9): [True: 0, False: 8.32k]
  ------------------
  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|  8.32k|#endif
  494|  8.32k|    if (cinfo->num_components != 1)
  ------------------
  |  Branch (494:9): [True: 0, False: 8.32k]
  ------------------
  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|  8.32k|    if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (496:9): [True: 4.76k, False: 3.56k]
  ------------------
  497|  4.76k|      cconvert->pub._color_convert = grayscale_convert;
  ------------------
  |  |  267|  4.76k|#define _color_convert  color_convert
  ------------------
  498|  3.56k|    else if (IsExtRGB(cinfo->in_color_space)) {
  ------------------
  |  |   78|  3.56k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 3.56k]
  |  |  |  Branch (78:22): [True: 3.56k, False: 0]
  |  |  |  Branch (78:43): [True: 3.56k, False: 0]
  |  |  ------------------
  ------------------
  499|  3.56k|#ifdef WITH_SIMD
  500|  3.56k|      if (jsimd_set_rgb_gray(cinfo))
  ------------------
  |  Branch (500:11): [True: 3.56k, False: 0]
  ------------------
  501|  3.56k|        cconvert->pub._color_convert = jsimd_color_convert;
  ------------------
  |  |  267|  3.56k|#define _color_convert  color_convert
  ------------------
  502|      0|      else
  503|      0|#endif
  504|      0|      {
  505|      0|        cconvert->pub.start_pass = rgb_ycc_start;
  506|      0|        switch (cinfo->in_color_space) {
  507|      0|        case JCS_EXT_RGB:
  ------------------
  |  Branch (507:9): [True: 0, False: 0]
  ------------------
  508|      0|          cconvert->pub._color_convert = extrgb_gray_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  509|      0|          break;
  510|      0|        case JCS_EXT_RGBX:
  ------------------
  |  Branch (510:9): [True: 0, False: 0]
  ------------------
  511|      0|        case JCS_EXT_RGBA:
  ------------------
  |  Branch (511:9): [True: 0, False: 0]
  ------------------
  512|      0|          cconvert->pub._color_convert = extrgbx_gray_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  513|      0|          break;
  514|      0|        case JCS_EXT_BGR:
  ------------------
  |  Branch (514:9): [True: 0, False: 0]
  ------------------
  515|      0|          cconvert->pub._color_convert = extbgr_gray_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  516|      0|          break;
  517|      0|        case JCS_EXT_BGRX:
  ------------------
  |  Branch (517:9): [True: 0, False: 0]
  ------------------
  518|      0|        case JCS_EXT_BGRA:
  ------------------
  |  Branch (518:9): [True: 0, False: 0]
  ------------------
  519|      0|          cconvert->pub._color_convert = extbgrx_gray_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  520|      0|          break;
  521|      0|        case JCS_EXT_XBGR:
  ------------------
  |  Branch (521:9): [True: 0, False: 0]
  ------------------
  522|      0|        case JCS_EXT_ABGR:
  ------------------
  |  Branch (522:9): [True: 0, False: 0]
  ------------------
  523|      0|          cconvert->pub._color_convert = extxbgr_gray_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  524|      0|          break;
  525|      0|        case JCS_EXT_XRGB:
  ------------------
  |  Branch (525:9): [True: 0, False: 0]
  ------------------
  526|      0|        case JCS_EXT_ARGB:
  ------------------
  |  Branch (526:9): [True: 0, False: 0]
  ------------------
  527|      0|          cconvert->pub._color_convert = extxrgb_gray_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  528|      0|          break;
  529|      0|        default:
  ------------------
  |  Branch (529:9): [True: 0, False: 0]
  ------------------
  530|      0|          cconvert->pub._color_convert = rgb_gray_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  531|      0|        }
  532|      0|      }
  533|  3.56k|    } else if (cinfo->in_color_space == JCS_YCbCr)
  ------------------
  |  Branch (533:16): [True: 0, False: 0]
  ------------------
  534|      0|      cconvert->pub._color_convert = grayscale_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  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|  8.32k|    break;
  538|       |
  539|  8.32k|  case JCS_RGB:
  ------------------
  |  Branch (539:3): [True: 3.76k, False: 22.7k]
  ------------------
  540|  3.76k|#ifdef C_LOSSLESS_SUPPORTED
  541|  3.76k|    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.76k]
  ------------------
  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.76k|#endif
  544|  3.76k|    if (cinfo->num_components != 3)
  ------------------
  |  Branch (544:9): [True: 0, False: 3.76k]
  ------------------
  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.76k|    if (rgb_red[cinfo->in_color_space] == 0 &&
  ------------------
  |  Branch (546:9): [True: 3.76k, False: 0]
  ------------------
  547|  3.76k|        rgb_green[cinfo->in_color_space] == 1 &&
  ------------------
  |  Branch (547:9): [True: 3.76k, False: 0]
  ------------------
  548|  3.76k|        rgb_blue[cinfo->in_color_space] == 2 &&
  ------------------
  |  Branch (548:9): [True: 3.76k, False: 0]
  ------------------
  549|  3.76k|        rgb_pixelsize[cinfo->in_color_space] == 3) {
  ------------------
  |  Branch (549:9): [True: 3.76k, False: 0]
  ------------------
  550|  3.76k|      cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  267|  3.76k|#define _color_convert  color_convert
  ------------------
  551|  3.76k|    } else if (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]
  |  |  ------------------
  ------------------
  552|      0|      switch (cinfo->in_color_space) {
  553|      0|      case JCS_EXT_RGB:
  ------------------
  |  Branch (553:7): [True: 0, False: 0]
  ------------------
  554|      0|        cconvert->pub._color_convert = extrgb_rgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  555|      0|        break;
  556|      0|      case JCS_EXT_RGBX:
  ------------------
  |  Branch (556:7): [True: 0, False: 0]
  ------------------
  557|      0|      case JCS_EXT_RGBA:
  ------------------
  |  Branch (557:7): [True: 0, False: 0]
  ------------------
  558|      0|        cconvert->pub._color_convert = extrgbx_rgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  559|      0|        break;
  560|      0|      case JCS_EXT_BGR:
  ------------------
  |  Branch (560:7): [True: 0, False: 0]
  ------------------
  561|      0|        cconvert->pub._color_convert = extbgr_rgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  562|      0|        break;
  563|      0|      case JCS_EXT_BGRX:
  ------------------
  |  Branch (563:7): [True: 0, False: 0]
  ------------------
  564|      0|      case JCS_EXT_BGRA:
  ------------------
  |  Branch (564:7): [True: 0, False: 0]
  ------------------
  565|      0|        cconvert->pub._color_convert = extbgrx_rgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  566|      0|        break;
  567|      0|      case JCS_EXT_XBGR:
  ------------------
  |  Branch (567:7): [True: 0, False: 0]
  ------------------
  568|      0|      case JCS_EXT_ABGR:
  ------------------
  |  Branch (568:7): [True: 0, False: 0]
  ------------------
  569|      0|        cconvert->pub._color_convert = extxbgr_rgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  570|      0|        break;
  571|      0|      case JCS_EXT_XRGB:
  ------------------
  |  Branch (571:7): [True: 0, False: 0]
  ------------------
  572|      0|      case JCS_EXT_ARGB:
  ------------------
  |  Branch (572:7): [True: 0, False: 0]
  ------------------
  573|      0|        cconvert->pub._color_convert = extxrgb_rgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  574|      0|        break;
  575|      0|      default:
  ------------------
  |  Branch (575:7): [True: 0, False: 0]
  ------------------
  576|      0|        cconvert->pub._color_convert = rgb_rgb_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  577|      0|      }
  578|      0|    } 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.76k|    break;
  581|       |
  582|  10.8k|  case JCS_YCbCr:
  ------------------
  |  Branch (582:3): [True: 10.8k, False: 15.6k]
  ------------------
  583|  10.8k|#ifdef C_LOSSLESS_SUPPORTED
  584|  10.8k|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (584:9): [True: 0, False: 10.8k]
  ------------------
  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|  10.8k|#endif
  588|  10.8k|    if (cinfo->num_components != 3)
  ------------------
  |  Branch (588:9): [True: 0, False: 10.8k]
  ------------------
  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|  10.8k|    if (IsExtRGB(cinfo->in_color_space)) {
  ------------------
  |  |   78|  10.8k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 10.8k]
  |  |  |  Branch (78:22): [True: 10.8k, False: 0]
  |  |  |  Branch (78:43): [True: 10.8k, False: 0]
  |  |  ------------------
  ------------------
  591|  10.8k|#ifdef WITH_SIMD
  592|  10.8k|      if (jsimd_set_rgb_ycc(cinfo))
  ------------------
  |  Branch (592:11): [True: 10.8k, False: 0]
  ------------------
  593|  10.8k|        cconvert->pub._color_convert = jsimd_color_convert;
  ------------------
  |  |  267|  10.8k|#define _color_convert  color_convert
  ------------------
  594|      0|      else
  595|      0|#endif
  596|      0|      {
  597|      0|        cconvert->pub.start_pass = rgb_ycc_start;
  598|      0|        switch (cinfo->in_color_space) {
  599|      0|        case JCS_EXT_RGB:
  ------------------
  |  Branch (599:9): [True: 0, False: 0]
  ------------------
  600|      0|          cconvert->pub._color_convert = extrgb_ycc_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  601|      0|          break;
  602|      0|        case JCS_EXT_RGBX:
  ------------------
  |  Branch (602:9): [True: 0, False: 0]
  ------------------
  603|      0|        case JCS_EXT_RGBA:
  ------------------
  |  Branch (603:9): [True: 0, False: 0]
  ------------------
  604|      0|          cconvert->pub._color_convert = extrgbx_ycc_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  605|      0|          break;
  606|      0|        case JCS_EXT_BGR:
  ------------------
  |  Branch (606:9): [True: 0, False: 0]
  ------------------
  607|      0|          cconvert->pub._color_convert = extbgr_ycc_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  608|      0|          break;
  609|      0|        case JCS_EXT_BGRX:
  ------------------
  |  Branch (609:9): [True: 0, False: 0]
  ------------------
  610|      0|        case JCS_EXT_BGRA:
  ------------------
  |  Branch (610:9): [True: 0, False: 0]
  ------------------
  611|      0|          cconvert->pub._color_convert = extbgrx_ycc_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  612|      0|          break;
  613|      0|        case JCS_EXT_XBGR:
  ------------------
  |  Branch (613:9): [True: 0, False: 0]
  ------------------
  614|      0|        case JCS_EXT_ABGR:
  ------------------
  |  Branch (614:9): [True: 0, False: 0]
  ------------------
  615|      0|          cconvert->pub._color_convert = extxbgr_ycc_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  616|      0|          break;
  617|      0|        case JCS_EXT_XRGB:
  ------------------
  |  Branch (617:9): [True: 0, False: 0]
  ------------------
  618|      0|        case JCS_EXT_ARGB:
  ------------------
  |  Branch (618:9): [True: 0, False: 0]
  ------------------
  619|      0|          cconvert->pub._color_convert = extxrgb_ycc_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  620|      0|          break;
  621|      0|        default:
  ------------------
  |  Branch (621:9): [True: 0, False: 0]
  ------------------
  622|      0|          cconvert->pub._color_convert = rgb_ycc_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  623|      0|        }
  624|      0|      }
  625|  10.8k|    } else if (cinfo->in_color_space == JCS_YCbCr) {
  ------------------
  |  Branch (625:16): [True: 0, False: 0]
  ------------------
  626|      0|      cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  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|  10.8k|    break;
  630|       |
  631|  10.8k|  case JCS_CMYK:
  ------------------
  |  Branch (631:3): [True: 0, False: 26.5k]
  ------------------
  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;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  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.56k|  case JCS_YCCK:
  ------------------
  |  Branch (645:3): [True: 3.56k, False: 22.9k]
  ------------------
  646|  3.56k|#ifdef C_LOSSLESS_SUPPORTED
  647|  3.56k|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (647:9): [True: 0, False: 3.56k]
  ------------------
  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.56k|#endif
  651|  3.56k|    if (cinfo->num_components != 4)
  ------------------
  |  Branch (651:9): [True: 0, False: 3.56k]
  ------------------
  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.56k|    if (cinfo->in_color_space == JCS_CMYK) {
  ------------------
  |  Branch (653:9): [True: 3.56k, False: 0]
  ------------------
  654|  3.56k|      cconvert->pub.start_pass = rgb_ycc_start;
  655|  3.56k|      cconvert->pub._color_convert = cmyk_ycck_convert;
  ------------------
  |  |  267|  3.56k|#define _color_convert  color_convert
  ------------------
  656|  3.56k|    } else if (cinfo->in_color_space == JCS_YCCK) {
  ------------------
  |  Branch (656:16): [True: 0, False: 0]
  ------------------
  657|      0|      cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  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.56k|    break;
  661|       |
  662|      0|  default:                      /* allow null conversion of JCS_UNKNOWN */
  ------------------
  |  Branch (662:3): [True: 0, False: 26.5k]
  ------------------
  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;
  ------------------
  |  |  267|      0|#define _color_convert  color_convert
  ------------------
  667|      0|    break;
  668|  26.5k|  }
  669|  26.5k|}
jccolor-8.c:null_method:
  407|  22.9k|{
  408|       |  /* no work needed */
  409|  22.9k|}
jccolor-8.c:grayscale_convert:
  319|  3.63M|{
  320|  3.63M|  register _JSAMPROW inptr;
  321|  3.63M|  register _JSAMPROW outptr;
  322|  3.63M|  register JDIMENSION col;
  323|  3.63M|  JDIMENSION num_cols = cinfo->image_width;
  324|  3.63M|  int instride = cinfo->input_components;
  325|       |
  326|  7.26M|  while (--num_rows >= 0) {
  ------------------
  |  Branch (326:10): [True: 3.63M, False: 3.63M]
  ------------------
  327|  3.63M|    inptr = *input_buf++;
  328|  3.63M|    outptr = output_buf[0][output_row];
  329|  3.63M|    output_row++;
  330|  18.6M|    for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (330:19): [True: 15.0M, False: 3.63M]
  ------------------
  331|  15.0M|      outptr[col] = inptr[0];
  332|  15.0M|      inptr += instride;
  333|  15.0M|    }
  334|  3.63M|  }
  335|  3.63M|}
jccolor-8.c:rgb_ycc_start:
  216|  3.56k|{
  217|  3.56k|#if BITS_IN_JSAMPLE != 16
  218|  3.56k|  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
  219|  3.56k|  JLONG *rgb_ycc_tab;
  220|  3.56k|  JLONG i;
  221|       |
  222|       |  /* Allocate and fill in the conversion tables. */
  223|  3.56k|  cconvert->rgb_ycc_tab = rgb_ycc_tab = (JLONG *)
  224|  3.56k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  3.56k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  225|  3.56k|                                (TABLE_SIZE * sizeof(JLONG)));
  ------------------
  |  |   90|  3.56k|#define TABLE_SIZE      (8 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|  3.56k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  3.56k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  226|       |
  227|   915k|  for (i = 0; i <= _MAXJSAMPLE; i++) {
  ------------------
  |  |  226|   915k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|   915k|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
  |  Branch (227:15): [True: 912k, False: 3.56k]
  ------------------
  228|   912k|    rgb_ycc_tab[i + R_Y_OFF] = FIX(0.29900) * i;
  ------------------
  |  |   81|   912k|#define R_Y_OFF         0                       /* offset to R => Y section */
  ------------------
                  rgb_ycc_tab[i + R_Y_OFF] = FIX(0.29900) * i;
  ------------------
  |  |   73|   912k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   912k|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  229|   912k|    rgb_ycc_tab[i + G_Y_OFF] = FIX(0.58700) * i;
  ------------------
  |  |   82|   912k|#define G_Y_OFF         (1 * (_MAXJSAMPLE + 1)) /* offset to G => Y section */
  |  |  ------------------
  |  |  |  |  226|   912k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|   912k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + G_Y_OFF] = FIX(0.58700) * i;
  ------------------
  |  |   73|   912k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   912k|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  230|   912k|    rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i   + ONE_HALF;
  ------------------
  |  |   83|   912k|#define B_Y_OFF         (2 * (_MAXJSAMPLE + 1)) /* etc. */
  |  |  ------------------
  |  |  |  |  226|   912k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|   912k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i   + ONE_HALF;
  ------------------
  |  |   73|   912k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   912k|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i   + ONE_HALF;
  ------------------
  |  |   72|   912k|#define ONE_HALF        ((JLONG)1 << (SCALEBITS - 1))
  |  |  ------------------
  |  |  |  |   70|   912k|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  231|   912k|    rgb_ycc_tab[i + R_CB_OFF] = (-FIX(0.16874)) * i;
  ------------------
  |  |   84|   912k|#define R_CB_OFF        (3 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|   912k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|   912k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + R_CB_OFF] = (-FIX(0.16874)) * i;
  ------------------
  |  |   73|   912k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   912k|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  232|   912k|    rgb_ycc_tab[i + G_CB_OFF] = (-FIX(0.33126)) * i;
  ------------------
  |  |   85|   912k|#define G_CB_OFF        (4 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|   912k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|   912k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + G_CB_OFF] = (-FIX(0.33126)) * i;
  ------------------
  |  |   73|   912k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   912k|#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|   912k|    rgb_ycc_tab[i + B_CB_OFF] = FIX(0.50000) * i  + CBCR_OFFSET + ONE_HALF - 1;
  ------------------
  |  |   86|   912k|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|   912k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|   912k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_CB_OFF] = FIX(0.50000) * i  + CBCR_OFFSET + ONE_HALF - 1;
  ------------------
  |  |   73|   912k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   912k|#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|   912k|#define CBCR_OFFSET     ((JLONG)_CENTERJSAMPLE << SCALEBITS)
  |  |  ------------------
  |  |  |  |  227|   912k|#define _CENTERJSAMPLE   CENTERJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   53|   912k|#define CENTERJSAMPLE    128
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define CBCR_OFFSET     ((JLONG)_CENTERJSAMPLE << SCALEBITS)
  |  |  ------------------
  |  |  |  |   70|   912k|#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|   912k|#define ONE_HALF        ((JLONG)1 << (SCALEBITS - 1))
  |  |  ------------------
  |  |  |  |   70|   912k|#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|   912k|    rgb_ycc_tab[i + G_CR_OFF] = (-FIX(0.41869)) * i;
  ------------------
  |  |   88|   912k|#define G_CR_OFF        (6 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|   912k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|   912k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + G_CR_OFF] = (-FIX(0.41869)) * i;
  ------------------
  |  |   73|   912k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   912k|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  242|   912k|    rgb_ycc_tab[i + B_CR_OFF] = (-FIX(0.08131)) * i;
  ------------------
  |  |   89|   912k|#define B_CR_OFF        (7 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|   912k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|   912k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_CR_OFF] = (-FIX(0.08131)) * i;
  ------------------
  |  |   73|   912k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   912k|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  243|   912k|  }
  244|       |#else
  245|       |  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  246|       |#endif
  247|  3.56k|}
jccolor-8.c:null_convert:
  347|  5.51M|{
  348|  5.51M|  register _JSAMPROW inptr;
  349|  5.51M|  register _JSAMPROW outptr, outptr0, outptr1, outptr2, outptr3;
  350|  5.51M|  register JDIMENSION col;
  351|  5.51M|  register int ci;
  352|  5.51M|  int nc = cinfo->num_components;
  353|  5.51M|  JDIMENSION num_cols = cinfo->image_width;
  354|       |
  355|  5.51M|  if (nc == 3) {
  ------------------
  |  Branch (355:7): [True: 5.51M, False: 0]
  ------------------
  356|  11.0M|    while (--num_rows >= 0) {
  ------------------
  |  Branch (356:12): [True: 5.51M, False: 5.51M]
  ------------------
  357|  5.51M|      inptr = *input_buf++;
  358|  5.51M|      outptr0 = output_buf[0][output_row];
  359|  5.51M|      outptr1 = output_buf[1][output_row];
  360|  5.51M|      outptr2 = output_buf[2][output_row];
  361|  5.51M|      output_row++;
  362|  36.6M|      for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (362:21): [True: 31.1M, False: 5.51M]
  ------------------
  363|  31.1M|        outptr0[col] = *inptr++;
  364|  31.1M|        outptr1[col] = *inptr++;
  365|  31.1M|        outptr2[col] = *inptr++;
  366|  31.1M|      }
  367|  5.51M|    }
  368|  5.51M|  } else if (nc == 4) {
  ------------------
  |  Branch (368:14): [True: 0, False: 0]
  ------------------
  369|      0|    while (--num_rows >= 0) {
  ------------------
  |  Branch (369:12): [True: 0, False: 0]
  ------------------
  370|      0|      inptr = *input_buf++;
  371|      0|      outptr0 = output_buf[0][output_row];
  372|      0|      outptr1 = output_buf[1][output_row];
  373|      0|      outptr2 = output_buf[2][output_row];
  374|      0|      outptr3 = output_buf[3][output_row];
  375|      0|      output_row++;
  376|      0|      for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (376:21): [True: 0, False: 0]
  ------------------
  377|      0|        outptr0[col] = *inptr++;
  378|      0|        outptr1[col] = *inptr++;
  379|      0|        outptr2[col] = *inptr++;
  380|      0|        outptr3[col] = *inptr++;
  381|      0|      }
  382|      0|    }
  383|      0|  } else {
  384|      0|    while (--num_rows >= 0) {
  ------------------
  |  Branch (384:12): [True: 0, False: 0]
  ------------------
  385|       |      /* It seems fastest to make a separate pass for each component. */
  386|      0|      for (ci = 0; ci < nc; ci++) {
  ------------------
  |  Branch (386:20): [True: 0, False: 0]
  ------------------
  387|      0|        inptr = *input_buf;
  388|      0|        outptr = output_buf[ci][output_row];
  389|      0|        for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (389:23): [True: 0, False: 0]
  ------------------
  390|      0|          outptr[col] = inptr[ci];
  391|      0|          inptr += nc;
  392|      0|        }
  393|      0|      }
  394|      0|      input_buf++;
  395|      0|      output_row++;
  396|      0|    }
  397|      0|  }
  398|  5.51M|}
jccolor-8.c:cmyk_ycck_convert:
  264|  2.75M|{
  265|  2.75M|#if BITS_IN_JSAMPLE != 16
  266|  2.75M|  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
  267|  2.75M|  register int r, g, b;
  268|  2.75M|  register JLONG *ctab = cconvert->rgb_ycc_tab;
  269|  2.75M|  register _JSAMPROW inptr;
  270|  2.75M|  register _JSAMPROW outptr0, outptr1, outptr2, outptr3;
  271|  2.75M|  register JDIMENSION col;
  272|  2.75M|  JDIMENSION num_cols = cinfo->image_width;
  273|       |
  274|  8.27M|  while (--num_rows >= 0) {
  ------------------
  |  Branch (274:10): [True: 5.51M, False: 2.75M]
  ------------------
  275|  5.51M|    inptr = *input_buf++;
  276|  5.51M|    outptr0 = output_buf[0][output_row];
  277|  5.51M|    outptr1 = output_buf[1][output_row];
  278|  5.51M|    outptr2 = output_buf[2][output_row];
  279|  5.51M|    outptr3 = output_buf[3][output_row];
  280|  5.51M|    output_row++;
  281|  36.5M|    for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (281:19): [True: 31.0M, False: 5.51M]
  ------------------
  282|  31.0M|      r = _MAXJSAMPLE - RANGE_LIMIT(inptr[0]);
  ------------------
  |  |  226|  31.0M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|  31.0M|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
                    r = _MAXJSAMPLE - RANGE_LIMIT(inptr[0]);
  ------------------
  |  |  101|  31.0M|#define RANGE_LIMIT(value)  (value)
  ------------------
  283|  31.0M|      g = _MAXJSAMPLE - RANGE_LIMIT(inptr[1]);
  ------------------
  |  |  226|  31.0M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|  31.0M|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
                    g = _MAXJSAMPLE - RANGE_LIMIT(inptr[1]);
  ------------------
  |  |  101|  31.0M|#define RANGE_LIMIT(value)  (value)
  ------------------
  284|  31.0M|      b = _MAXJSAMPLE - RANGE_LIMIT(inptr[2]);
  ------------------
  |  |  226|  31.0M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|  31.0M|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
                    b = _MAXJSAMPLE - RANGE_LIMIT(inptr[2]);
  ------------------
  |  |  101|  31.0M|#define RANGE_LIMIT(value)  (value)
  ------------------
  285|       |      /* K passes through as-is */
  286|  31.0M|      outptr3[col] = inptr[3];
  287|  31.0M|      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|  31.0M|      outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   81|  31.0M|#define R_Y_OFF         0                       /* offset to R => Y section */
  ------------------
                    outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   82|  31.0M|#define G_Y_OFF         (1 * (_MAXJSAMPLE + 1)) /* offset to G => Y section */
  |  |  ------------------
  |  |  |  |  226|  31.0M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  31.0M|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  295|  31.0M|                                 ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   83|  31.0M|#define B_Y_OFF         (2 * (_MAXJSAMPLE + 1)) /* etc. */
  |  |  ------------------
  |  |  |  |  226|  31.0M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  31.0M|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  31.0M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
  296|       |      /* Cb */
  297|  31.0M|      outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
  ------------------
  |  |   84|  31.0M|#define R_CB_OFF        (3 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|  31.0M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  31.0M|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
  ------------------
  |  |   85|  31.0M|#define G_CB_OFF        (4 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|  31.0M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  31.0M|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  298|  31.0M|                                 ctab[b + B_CB_OFF]) >> SCALEBITS);
  ------------------
  |  |   86|  31.0M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|  31.0M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  31.0M|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_CB_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  31.0M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
  299|       |      /* Cr */
  300|  31.0M|      outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
  ------------------
  |  |   87|  31.0M|#define R_CR_OFF        B_CB_OFF                /* B=>Cb, R=>Cr are the same */
  |  |  ------------------
  |  |  |  |   86|  31.0M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |  226|  31.0M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   52|  31.0M|#define MAXJSAMPLE       255
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
  ------------------
  |  |   88|  31.0M|#define G_CR_OFF        (6 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|  31.0M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  31.0M|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  301|  31.0M|                                 ctab[b + B_CR_OFF]) >> SCALEBITS);
  ------------------
  |  |   89|  31.0M|#define B_CR_OFF        (7 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|  31.0M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  31.0M|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_CR_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  31.0M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
  302|  31.0M|    }
  303|  5.51M|  }
  304|       |#else
  305|       |  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  306|       |#endif
  307|  2.75M|}

jinit_forward_dct:
  672|  26.5k|{
  673|  26.5k|  my_fdct_ptr fdct;
  674|  26.5k|  int i;
  675|       |
  676|  26.5k|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  26.5k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (676:7): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|  fdct = (my_fdct_ptr)
  680|  26.5k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  26.5k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  681|  26.5k|                                sizeof(my_fdct_controller));
  682|  26.5k|  cinfo->fdct = (struct jpeg_forward_dct *)fdct;
  683|  26.5k|  fdct->pub.start_pass = start_pass_fdctmgr;
  684|       |
  685|       |  /* First determine the DCT... */
  686|  26.5k|  switch (cinfo->dct_method) {
  687|      0|#ifdef DCT_ISLOW_SUPPORTED
  688|  22.9k|  case JDCT_ISLOW:
  ------------------
  |  Branch (688:3): [True: 22.9k, False: 3.56k]
  ------------------
  689|  22.9k|    fdct->pub._forward_DCT = forward_DCT;
  ------------------
  |  |  254|  22.9k|#define _forward_DCT  forward_DCT
  ------------------
  690|  22.9k|#ifdef WITH_SIMD
  691|  22.9k|    if (!jsimd_set_fdct_islow(cinfo, &fdct->dct))
  ------------------
  |  Branch (691:9): [True: 0, False: 22.9k]
  ------------------
  692|      0|#endif
  693|      0|      fdct->dct = _jpeg_fdct_islow;
  ------------------
  |  |  300|      0|#define _jpeg_fdct_islow  jpeg_fdct_islow
  ------------------
  694|  22.9k|    break;
  695|      0|#endif
  696|      0|#ifdef DCT_IFAST_SUPPORTED
  697|  3.56k|  case JDCT_IFAST:
  ------------------
  |  Branch (697:3): [True: 3.56k, False: 22.9k]
  ------------------
  698|  3.56k|    fdct->pub._forward_DCT = forward_DCT;
  ------------------
  |  |  254|  3.56k|#define _forward_DCT  forward_DCT
  ------------------
  699|  3.56k|#ifdef WITH_SIMD
  700|  3.56k|    if (!jsimd_set_fdct_ifast(cinfo, &fdct->dct))
  ------------------
  |  Branch (700:9): [True: 0, False: 3.56k]
  ------------------
  701|      0|#endif
  702|      0|      fdct->dct = _jpeg_fdct_ifast;
  ------------------
  |  |  301|      0|#define _jpeg_fdct_ifast  jpeg_fdct_ifast
  ------------------
  703|  3.56k|    break;
  704|      0|#endif
  705|      0|#ifdef DCT_FLOAT_SUPPORTED
  706|      0|  case JDCT_FLOAT:
  ------------------
  |  Branch (706:3): [True: 0, False: 26.5k]
  ------------------
  707|      0|    fdct->pub._forward_DCT = forward_DCT_float;
  ------------------
  |  |  254|      0|#define _forward_DCT  forward_DCT
  ------------------
  708|      0|#ifdef WITH_SIMD
  709|      0|    if (!jsimd_set_fdct_float(cinfo, &fdct->float_dct))
  ------------------
  |  Branch (709:9): [True: 0, False: 0]
  ------------------
  710|      0|#endif
  711|      0|      fdct->float_dct = jpeg_fdct_float;
  712|      0|    break;
  713|      0|#endif
  714|      0|  default:
  ------------------
  |  Branch (714:3): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|  }
  718|       |
  719|       |  /* ...then the supporting stages. */
  720|  26.5k|  switch (cinfo->dct_method) {
  721|      0|#ifdef DCT_ISLOW_SUPPORTED
  722|  22.9k|  case JDCT_ISLOW:
  ------------------
  |  Branch (722:3): [True: 22.9k, False: 3.56k]
  ------------------
  723|  22.9k|#endif
  724|  22.9k|#ifdef DCT_IFAST_SUPPORTED
  725|  26.5k|  case JDCT_IFAST:
  ------------------
  |  Branch (725:3): [True: 3.56k, False: 22.9k]
  ------------------
  726|  26.5k|#endif
  727|  26.5k|#if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED)
  728|  26.5k|#ifdef WITH_SIMD
  729|  26.5k|    if (!jsimd_set_convsamp(cinfo, &fdct->convsamp))
  ------------------
  |  Branch (729:9): [True: 0, False: 26.5k]
  ------------------
  730|      0|#endif
  731|      0|      fdct->convsamp = convsamp;
  732|  26.5k|#ifdef WITH_SIMD
  733|  26.5k|    if (!jsimd_set_quantize(cinfo, &fdct->quantize))
  ------------------
  |  Branch (733:9): [True: 0, False: 26.5k]
  ------------------
  734|      0|#endif
  735|      0|      fdct->quantize = quantize;
  736|  26.5k|    break;
  737|      0|#endif
  738|      0|#ifdef DCT_FLOAT_SUPPORTED
  739|      0|  case JDCT_FLOAT:
  ------------------
  |  Branch (739:3): [True: 0, False: 26.5k]
  ------------------
  740|      0|#ifdef WITH_SIMD
  741|      0|    if (!jsimd_set_convsamp_float(cinfo, &fdct->float_convsamp))
  ------------------
  |  Branch (741:9): [True: 0, False: 0]
  ------------------
  742|      0|#endif
  743|      0|      fdct->float_convsamp = convsamp_float;
  744|      0|#ifdef WITH_SIMD
  745|      0|    if (!jsimd_set_quantize_float(cinfo, &fdct->float_quantize))
  ------------------
  |  Branch (745:9): [True: 0, False: 0]
  ------------------
  746|      0|#endif
  747|      0|      fdct->float_quantize = quantize_float;
  748|      0|    break;
  749|      0|#endif
  750|      0|  default:
  ------------------
  |  Branch (750:3): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|  }
  754|       |
  755|       |  /* Allocate workspace memory */
  756|  26.5k|#ifdef DCT_FLOAT_SUPPORTED
  757|  26.5k|  if (cinfo->dct_method == JDCT_FLOAT)
  ------------------
  |  Branch (757:7): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|  else
  762|  26.5k|#endif
  763|  26.5k|    fdct->workspace = (DCTELEM *)
  764|  26.5k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  26.5k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  765|  26.5k|                                  sizeof(DCTELEM) * DCTSIZE2);
  ------------------
  |  |   67|  26.5k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  766|       |
  767|       |  /* Mark divisor tables unallocated */
  768|   132k|  for (i = 0; i < NUM_QUANT_TBLS; i++) {
  ------------------
  |  |   68|   132k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (768:15): [True: 106k, False: 26.5k]
  ------------------
  769|   106k|    fdct->divisors[i] = NULL;
  770|   106k|#ifdef DCT_FLOAT_SUPPORTED
  771|       |    fdct->float_divisors[i] = NULL;
  772|   106k|#endif
  773|   106k|  }
  774|  26.5k|}
jcdctmgr-8.c:start_pass_fdctmgr:
  235|  26.5k|{
  236|  26.5k|  my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
  237|  26.5k|  int ci, qtblno, i;
  238|  26.5k|  jpeg_component_info *compptr;
  239|  26.5k|  JQUANT_TBL *qtbl;
  240|  26.5k|  DCTELEM *dtbl;
  241|       |
  242|  93.0k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (242:44): [True: 66.5k, False: 26.5k]
  ------------------
  243|  66.5k|       ci++, compptr++) {
  244|  66.5k|    qtblno = compptr->quant_tbl_no;
  245|       |    /* Make sure specified quantization table is present */
  246|  66.5k|    if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
  ------------------
  |  |   68|   133k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (246:9): [True: 0, False: 66.5k]
  |  Branch (246:23): [True: 0, False: 66.5k]
  ------------------
  247|  66.5k|        cinfo->quant_tbl_ptrs[qtblno] == NULL)
  ------------------
  |  Branch (247:9): [True: 0, False: 66.5k]
  ------------------
  248|      0|      ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  249|  66.5k|    qtbl = cinfo->quant_tbl_ptrs[qtblno];
  250|       |    /* Compute divisors for this quant table */
  251|       |    /* We may do this more than once for same table, but it's not a big deal */
  252|  66.5k|    switch (cinfo->dct_method) {
  253|      0|#ifdef DCT_ISLOW_SUPPORTED
  254|  55.8k|    case JDCT_ISLOW:
  ------------------
  |  Branch (254:5): [True: 55.8k, False: 10.6k]
  ------------------
  255|       |      /* For LL&M IDCT method, divisors are equal to raw quantization
  256|       |       * coefficients multiplied by 8 (to counteract scaling).
  257|       |       */
  258|  55.8k|      if (fdct->divisors[qtblno] == NULL) {
  ------------------
  |  Branch (258:11): [True: 33.8k, False: 21.9k]
  ------------------
  259|  33.8k|        fdct->divisors[qtblno] = (DCTELEM *)
  260|  33.8k|          (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  33.8k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  261|  33.8k|                                      (DCTSIZE2 * 4) * sizeof(DCTELEM));
  ------------------
  |  |   67|  33.8k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  262|  33.8k|      }
  263|  55.8k|      dtbl = fdct->divisors[qtblno];
  264|  3.62M|      for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  3.62M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (264:19): [True: 3.57M, False: 55.8k]
  ------------------
  265|  3.57M|#if BITS_IN_JSAMPLE == 8
  266|  3.57M|#ifdef WITH_SIMD
  267|  3.57M|        if (!compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]) &&
  ------------------
  |  Branch (267:13): [True: 0, False: 3.57M]
  ------------------
  268|      0|            fdct->quantize != quantize)
  ------------------
  |  Branch (268:13): [True: 0, False: 0]
  ------------------
  269|      0|          fdct->quantize = quantize;
  270|       |#else
  271|       |        compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]);
  272|       |#endif
  273|       |#else
  274|       |        dtbl[i] = ((DCTELEM)qtbl->quantval[i]) << 3;
  275|       |#endif
  276|  3.57M|      }
  277|  55.8k|      break;
  278|      0|#endif
  279|      0|#ifdef DCT_IFAST_SUPPORTED
  280|  10.6k|    case JDCT_IFAST:
  ------------------
  |  Branch (280:5): [True: 10.6k, False: 55.8k]
  ------------------
  281|  10.6k|      {
  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|  10.6k|#define CONST_BITS  14
  289|  10.6k|        static const INT16 aanscales[DCTSIZE2] = {
  290|       |          /* precomputed values scaled up by 14 bits */
  291|  10.6k|          16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
  292|  10.6k|          22725, 31521, 29692, 26722, 22725, 17855, 12299,  6270,
  293|  10.6k|          21407, 29692, 27969, 25172, 21407, 16819, 11585,  5906,
  294|  10.6k|          19266, 26722, 25172, 22654, 19266, 15137, 10426,  5315,
  295|  10.6k|          16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
  296|  10.6k|          12873, 17855, 16819, 15137, 12873, 10114,  6967,  3552,
  297|  10.6k|           8867, 12299, 11585, 10426,  8867,  6967,  4799,  2446,
  298|  10.6k|           4520,  6270,  5906,  5315,  4520,  3552,  2446,  1247
  299|  10.6k|        };
  300|  10.6k|        SHIFT_TEMPS
  301|       |
  302|  10.6k|        if (fdct->divisors[qtblno] == NULL) {
  ------------------
  |  Branch (302:13): [True: 7.12k, False: 3.56k]
  ------------------
  303|  7.12k|          fdct->divisors[qtblno] = (DCTELEM *)
  304|  7.12k|            (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  7.12k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  305|  7.12k|                                        (DCTSIZE2 * 4) * sizeof(DCTELEM));
  ------------------
  |  |   67|  7.12k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  306|  7.12k|        }
  307|  10.6k|        dtbl = fdct->divisors[qtblno];
  308|   694k|        for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|   694k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (308:21): [True: 684k, False: 10.6k]
  ------------------
  309|   684k|#if BITS_IN_JSAMPLE == 8
  310|   684k|#ifdef WITH_SIMD
  311|   684k|          if (!compute_reciprocal(
  ------------------
  |  Branch (311:15): [True: 0, False: 684k]
  ------------------
  312|   684k|                DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
  ------------------
  |  |  216|   684k|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   684k|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  313|   684k|                                      (JLONG)aanscales[i]),
  314|   684k|                        CONST_BITS - 3), &dtbl[i]) &&
  315|      0|              fdct->quantize != quantize)
  ------------------
  |  Branch (315:15): [True: 0, False: 0]
  ------------------
  316|      0|            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|       |          dtbl[i] = (DCTELEM)
  325|       |            DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
  326|       |                                  (JLONG)aanscales[i]),
  327|       |                    CONST_BITS - 3);
  328|       |#endif
  329|   684k|        }
  330|  10.6k|      }
  331|  10.6k|      break;
  332|      0|#endif
  333|      0|#ifdef DCT_FLOAT_SUPPORTED
  334|      0|    case JDCT_FLOAT:
  ------------------
  |  Branch (334:5): [True: 0, False: 66.5k]
  ------------------
  335|      0|      {
  336|       |        /* For float AA&N IDCT method, divisors are equal to quantization
  337|       |         * coefficients scaled by scalefactor[row]*scalefactor[col], where
  338|       |         *   scalefactor[0] = 1
  339|       |         *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
  340|       |         * We apply a further scale factor of 8.
  341|       |         * What's actually stored is 1/divisor so that the inner loop can
  342|       |         * use a multiplication rather than a division.
  343|       |         */
  344|      0|        FAST_FLOAT *fdtbl;
  ------------------
  |  |  386|      0|#define FAST_FLOAT  float
  ------------------
  345|      0|        int row, col;
  346|      0|        static const double aanscalefactor[DCTSIZE] = {
  347|      0|          1.0, 1.387039845, 1.306562965, 1.175875602,
  348|      0|          1.0, 0.785694958, 0.541196100, 0.275899379
  349|      0|        };
  350|       |
  351|      0|        if (fdct->float_divisors[qtblno] == NULL) {
  ------------------
  |  Branch (351:13): [True: 0, False: 0]
  ------------------
  352|      0|          fdct->float_divisors[qtblno] = (FAST_FLOAT *)
  353|      0|            (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      0|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  354|      0|                                        DCTSIZE2 * sizeof(FAST_FLOAT));
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  355|      0|        }
  356|      0|        fdtbl = fdct->float_divisors[qtblno];
  357|      0|        i = 0;
  358|      0|        for (row = 0; row < DCTSIZE; row++) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (358:23): [True: 0, False: 0]
  ------------------
  359|      0|          for (col = 0; col < DCTSIZE; col++) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (359:25): [True: 0, False: 0]
  ------------------
  360|      0|            fdtbl[i] = (FAST_FLOAT)
  361|      0|              (1.0 / (((double)qtbl->quantval[i] *
  362|      0|                       aanscalefactor[row] * aanscalefactor[col] * 8.0)));
  363|      0|            i++;
  364|      0|          }
  365|      0|        }
  366|      0|      }
  367|      0|      break;
  368|      0|#endif
  369|      0|    default:
  ------------------
  |  Branch (369:5): [True: 0, False: 66.5k]
  ------------------
  370|      0|      ERREXIT(cinfo, JERR_NOT_COMPILED);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  371|      0|      break;
  372|  66.5k|    }
  373|  66.5k|  }
  374|  26.5k|}
jcdctmgr-8.c:compute_reciprocal:
  166|  4.25M|{
  167|  4.25M|  UDCTELEM2 fq, fr;
  168|  4.25M|  UDCTELEM c;
  169|  4.25M|  int b, r;
  170|       |
  171|  4.25M|  if (divisor <= 1) {
  ------------------
  |  Branch (171:7): [True: 0, False: 4.25M]
  ------------------
  172|       |    /* divisor == 1 means unquantized, so these reciprocal/correction/shift
  173|       |     * values will cause the C quantization algorithm to act like the
  174|       |     * identity function.  Since only the C quantization algorithm is used in
  175|       |     * these cases, the scale value is irrelevant.
  176|       |     *
  177|       |     * divisor == 0 can never happen in a normal program, because
  178|       |     * jpeg_add_quant_table() clamps values < 1.  However, a program could
  179|       |     * abuse the API by manually modifying the exposed quantization table just
  180|       |     * before calling jpeg_start_compress().  Thus, we effectively clamp
  181|       |     * values < 1 here as well, to avoid dividing by 0.
  182|       |     */
  183|      0|    dtbl[DCTSIZE2 * 0] = (DCTELEM)1;                        /* reciprocal */
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  184|      0|    dtbl[DCTSIZE2 * 1] = (DCTELEM)0;                        /* correction */
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  185|      0|    dtbl[DCTSIZE2 * 2] = (DCTELEM)1;                        /* scale */
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  186|      0|    dtbl[DCTSIZE2 * 3] = -(DCTELEM)(sizeof(DCTELEM) * 8);   /* shift */
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  187|      0|    return 0;
  188|      0|  }
  189|       |
  190|  4.25M|  b = flss(divisor) - 1;
  191|  4.25M|  r  = sizeof(DCTELEM) * 8 + b;
  192|       |
  193|  4.25M|  fq = ((UDCTELEM2)1 << r) / divisor;
  194|  4.25M|  fr = ((UDCTELEM2)1 << r) % divisor;
  195|       |
  196|  4.25M|  c = divisor / 2;                      /* for rounding */
  197|       |
  198|  4.25M|  if (fr == 0) {                        /* divisor is power of two */
  ------------------
  |  Branch (198:7): [True: 832k, False: 3.42M]
  ------------------
  199|       |    /* fq will be one bit too large to fit in DCTELEM, so adjust */
  200|   832k|    fq >>= 1;
  201|   832k|    r--;
  202|  3.42M|  } else if (fr <= (divisor / 2U)) {    /* fractional part is < 0.5 */
  ------------------
  |  Branch (202:14): [True: 705k, False: 2.71M]
  ------------------
  203|   705k|    c++;
  204|  2.71M|  } else {                              /* fractional part is > 0.5 */
  205|  2.71M|    fq++;
  206|  2.71M|  }
  207|       |
  208|  4.25M|  dtbl[DCTSIZE2 * 0] = (DCTELEM)fq;     /* reciprocal */
  ------------------
  |  |   67|  4.25M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  209|  4.25M|  dtbl[DCTSIZE2 * 1] = (DCTELEM)c;      /* correction + roundfactor */
  ------------------
  |  |   67|  4.25M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  210|  4.25M|#ifdef WITH_SIMD
  211|  4.25M|  dtbl[DCTSIZE2 * 2] = (DCTELEM)(1 << (sizeof(DCTELEM) * 8 * 2 - r)); /* scale */
  ------------------
  |  |   67|  4.25M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  212|       |#else
  213|       |  dtbl[DCTSIZE2 * 2] = 1;
  214|       |#endif
  215|  4.25M|  dtbl[DCTSIZE2 * 3] = (DCTELEM)r - sizeof(DCTELEM) * 8; /* shift */
  ------------------
  |  |   67|  4.25M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  216|       |
  217|  4.25M|  if (r <= 16) return 0;
  ------------------
  |  Branch (217:7): [True: 0, False: 4.25M]
  ------------------
  218|  4.25M|  else return 1;
  219|  4.25M|}
jcdctmgr-8.c:flss:
   76|  4.25M|{
   77|  4.25M|  int bit;
   78|       |
   79|  4.25M|  bit = 16;
   80|       |
   81|  4.25M|  if (!val)
  ------------------
  |  Branch (81:7): [True: 0, False: 4.25M]
  ------------------
   82|      0|    return 0;
   83|       |
   84|  4.25M|  if (!(val & 0xff00)) {
  ------------------
  |  Branch (84:7): [True: 2.06M, False: 2.19M]
  ------------------
   85|  2.06M|    bit -= 8;
   86|  2.06M|    val <<= 8;
   87|  2.06M|  }
   88|  4.25M|  if (!(val & 0xf000)) {
  ------------------
  |  Branch (88:7): [True: 2.91M, False: 1.33M]
  ------------------
   89|  2.91M|    bit -= 4;
   90|  2.91M|    val <<= 4;
   91|  2.91M|  }
   92|  4.25M|  if (!(val & 0xc000)) {
  ------------------
  |  Branch (92:7): [True: 1.15M, False: 3.10M]
  ------------------
   93|  1.15M|    bit -= 2;
   94|  1.15M|    val <<= 2;
   95|  1.15M|  }
   96|  4.25M|  if (!(val & 0x8000)) {
  ------------------
  |  Branch (96:7): [True: 1.93M, False: 2.32M]
  ------------------
   97|  1.93M|    bit -= 1;
   98|  1.93M|    val <<= 1;
   99|  1.93M|  }
  100|       |
  101|  4.25M|  return bit;
  102|  4.25M|}
jcdctmgr-8.c:forward_DCT:
  503|  15.3M|{
  504|       |  /* This routine is heavily used, so it's worth coding it tightly. */
  505|  15.3M|  my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
  506|  15.3M|  DCTELEM *divisors = fdct->divisors[compptr->quant_tbl_no];
  507|  15.3M|  DCTELEM *workspace;
  508|  15.3M|  JDIMENSION bi;
  509|       |
  510|       |  /* Make sure the compiler doesn't look up these every pass */
  511|  15.3M|  forward_DCT_method_ptr do_dct = fdct->dct;
  512|  15.3M|  convsamp_method_ptr do_convsamp = fdct->convsamp;
  513|  15.3M|  quantize_method_ptr do_quantize = fdct->quantize;
  514|  15.3M|  workspace = fdct->workspace;
  515|       |
  516|  15.3M|  sample_data += start_row;     /* fold in the vertical offset once */
  517|       |
  518|  36.6M|  for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {
  ------------------
  |  |   66|  21.3M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (518:16): [True: 21.3M, False: 15.3M]
  ------------------
  519|       |    /* Load data into workspace, applying unsigned->signed conversion */
  520|       |#ifdef WITH_PROFILE
  521|       |    cinfo->master->start = getTime();
  522|       |#endif
  523|  21.3M|    (*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.3M|    (*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.3M|    (*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.3M|  }
  549|  15.3M|}

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

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

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

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

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

jinit_c_master_control:
  722|  26.5k|{
  723|  26.5k|  my_master_ptr master = (my_master_ptr)cinfo->master;
  724|  26.5k|  boolean empty_huff_tables = TRUE;
  ------------------
  |  |  210|  26.5k|#define TRUE    1
  ------------------
  725|  26.5k|  int i;
  726|       |
  727|       |#ifdef WITH_PROFILE
  728|       |  master->pub.total_start = getTime();
  729|       |#endif
  730|       |
  731|  26.5k|  master->pub.prepare_for_pass = prepare_for_pass;
  732|  26.5k|  master->pub.pass_startup = pass_startup;
  733|  26.5k|  master->pub.finish_pass = finish_pass_master;
  734|  26.5k|  master->pub.is_last_pass = FALSE;
  ------------------
  |  |  207|  26.5k|#define FALSE   0               /* values of boolean */
  ------------------
  735|       |
  736|  26.5k|  if (cinfo->scan_info != NULL) {
  ------------------
  |  Branch (736:7): [True: 7.32k, False: 19.2k]
  ------------------
  737|  7.32k|#ifdef NEED_SCAN_SCRIPT
  738|  7.32k|    validate_script(cinfo);
  739|       |#else
  740|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  741|       |#endif
  742|  19.2k|  } else {
  743|  19.2k|    cinfo->progressive_mode = FALSE;
  ------------------
  |  |  207|  19.2k|#define FALSE   0               /* values of boolean */
  ------------------
  744|  19.2k|    cinfo->num_scans = 1;
  745|  19.2k|  }
  746|       |
  747|  26.5k|#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|  26.5k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (753:7): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|#endif
  765|       |
  766|       |  /* Validate parameters, determine derived values */
  767|  26.5k|  initial_setup(cinfo, transcode_only);
  768|       |
  769|  26.5k|  if (cinfo->arith_code)
  ------------------
  |  Branch (769:7): [True: 7.12k, False: 19.4k]
  ------------------
  770|  7.12k|    cinfo->optimize_coding = FALSE;
  ------------------
  |  |  207|  7.12k|#define FALSE   0               /* values of boolean */
  ------------------
  771|  19.4k|  else {
  772|  19.4k|    if (cinfo->master->lossless ||      /*  TEMPORARY HACK ??? */
  ------------------
  |  Branch (772:9): [True: 0, False: 19.4k]
  ------------------
  773|  19.4k|        cinfo->progressive_mode)
  ------------------
  |  Branch (773:9): [True: 3.76k, False: 15.6k]
  ------------------
  774|  3.76k|      cinfo->optimize_coding = TRUE; /* assume default tables no good for
  ------------------
  |  |  210|  3.76k|#define TRUE    1
  ------------------
  775|       |                                        progressive mode or lossless mode */
  776|  19.4k|    for (i = 0; i < NUM_HUFF_TBLS; i++) {
  ------------------
  |  |   69|  19.4k|#define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  ------------------
  |  Branch (776:17): [True: 19.4k, False: 0]
  ------------------
  777|  19.4k|      if (cinfo->dc_huff_tbl_ptrs[i] != NULL ||
  ------------------
  |  Branch (777:11): [True: 19.4k, False: 0]
  ------------------
  778|  19.4k|          cinfo->ac_huff_tbl_ptrs[i] != NULL) {
  ------------------
  |  Branch (778:11): [True: 0, False: 0]
  ------------------
  779|  19.4k|        empty_huff_tables = FALSE;
  ------------------
  |  |  207|  19.4k|#define FALSE   0               /* values of boolean */
  ------------------
  780|  19.4k|        break;
  781|  19.4k|      }
  782|  19.4k|    }
  783|  19.4k|    if (cinfo->data_precision == 12 && !cinfo->optimize_coding &&
  ------------------
  |  Branch (783:9): [True: 0, False: 19.4k]
  |  Branch (783:40): [True: 0, False: 0]
  ------------------
  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|  19.4k|  }
  788|       |
  789|       |  /* Initialize my private state */
  790|  26.5k|  if (transcode_only) {
  ------------------
  |  Branch (790:7): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|  } else {
  797|       |    /* for normal compression, first pass is always this type: */
  798|  26.5k|    master->pass_type = main_pass;
  799|  26.5k|  }
  800|  26.5k|  master->scan_number = 0;
  801|  26.5k|  master->pass_number = 0;
  802|  26.5k|  if (cinfo->optimize_coding)
  ------------------
  |  Branch (802:7): [True: 7.32k, False: 19.2k]
  ------------------
  803|  7.32k|    master->total_passes = cinfo->num_scans * 2;
  804|  19.2k|  else
  805|  19.2k|    master->total_passes = cinfo->num_scans;
  806|       |
  807|  26.5k|  master->jpeg_version = PACKAGE_NAME " version " VERSION " (build " BUILD ")";
  ------------------
  |  |   17|  26.5k|#define PACKAGE_NAME  "libjpeg-turbo"
  ------------------
  808|  26.5k|}
jcmaster.c:prepare_for_pass:
  579|   129k|{
  580|   129k|  my_master_ptr master = (my_master_ptr)cinfo->master;
  581|       |
  582|   129k|  switch (master->pass_type) {
  583|  26.5k|  case main_pass:
  ------------------
  |  Branch (583:3): [True: 26.5k, False: 103k]
  ------------------
  584|       |    /* Initial pass: will collect input data, and do either Huffman
  585|       |     * optimization or data output for the first scan.
  586|       |     */
  587|  26.5k|    select_scan_parameters(cinfo);
  588|  26.5k|    per_scan_setup(cinfo);
  589|  26.5k|    if (!cinfo->raw_data_in) {
  ------------------
  |  Branch (589:9): [True: 26.5k, False: 0]
  ------------------
  590|  26.5k|      (*cinfo->cconvert->start_pass) (cinfo);
  591|  26.5k|      (*cinfo->downsample->start_pass) (cinfo);
  592|  26.5k|      (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU);
  593|  26.5k|    }
  594|  26.5k|    (*cinfo->fdct->start_pass) (cinfo);
  595|  26.5k|    (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding);
  596|  26.5k|    (*cinfo->coef->start_pass) (cinfo,
  597|  26.5k|                                (master->total_passes > 1 ?
  ------------------
  |  Branch (597:34): [True: 10.8k, False: 15.6k]
  ------------------
  598|  15.6k|                                 JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
  599|  26.5k|    (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
  600|  26.5k|    if (cinfo->optimize_coding) {
  ------------------
  |  Branch (600:9): [True: 7.32k, False: 19.2k]
  ------------------
  601|       |      /* No immediate data output; postpone writing frame/scan headers */
  602|  7.32k|      master->pub.call_pass_startup = FALSE;
  ------------------
  |  |  207|  7.32k|#define FALSE   0               /* values of boolean */
  ------------------
  603|  19.2k|    } else {
  604|       |      /* Will write frame/scan headers at first jpeg_write_scanlines call */
  605|  19.2k|      master->pub.call_pass_startup = TRUE;
  ------------------
  |  |  210|  19.2k|#define TRUE    1
  ------------------
  606|  19.2k|    }
  607|  26.5k|    break;
  608|      0|#ifdef ENTROPY_OPT_SUPPORTED
  609|  33.8k|  case huff_opt_pass:
  ------------------
  |  Branch (609:3): [True: 33.8k, False: 96.0k]
  ------------------
  610|       |    /* Do Huffman optimization for a scan after the first one. */
  611|  33.8k|    select_scan_parameters(cinfo);
  612|  33.8k|    per_scan_setup(cinfo);
  613|  33.8k|    if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code ||
  ------------------
  |  Branch (613:9): [True: 30.0k, False: 3.76k]
  |  Branch (613:27): [True: 0, False: 3.76k]
  |  Branch (613:45): [True: 0, False: 3.76k]
  ------------------
  614|  30.0k|        cinfo->master->lossless) {
  ------------------
  |  Branch (614:9): [True: 0, False: 3.76k]
  ------------------
  615|  30.0k|      (*cinfo->entropy->start_pass) (cinfo, TRUE);
  ------------------
  |  |  210|  30.0k|#define TRUE    1
  ------------------
  616|  30.0k|      (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
  617|  30.0k|      master->pub.call_pass_startup = FALSE;
  ------------------
  |  |  207|  30.0k|#define FALSE   0               /* values of boolean */
  ------------------
  618|  30.0k|      break;
  619|  30.0k|    }
  620|       |    /* Special case: Huffman DC refinement scans need no Huffman table
  621|       |     * and therefore we can skip the optimization pass for them.
  622|       |     */
  623|  3.76k|    master->pass_type = output_pass;
  624|  3.76k|    master->pass_number++;
  625|  3.76k|    FALLTHROUGH                 /*FALLTHROUGH*/
  ------------------
  |  |   41|  3.76k|#define FALLTHROUGH  __attribute__((fallthrough));
  ------------------
  626|  3.76k|#endif
  627|  73.2k|  case output_pass:
  ------------------
  |  Branch (627:3): [True: 69.4k, False: 60.3k]
  ------------------
  628|       |    /* Do a data-output pass. */
  629|       |    /* We need not repeat per-scan setup if prior optimization pass did it. */
  630|  73.2k|    if (!cinfo->optimize_coding) {
  ------------------
  |  Branch (630:9): [True: 32.0k, False: 41.1k]
  ------------------
  631|  32.0k|      select_scan_parameters(cinfo);
  632|  32.0k|      per_scan_setup(cinfo);
  633|  32.0k|    }
  634|  73.2k|    (*cinfo->entropy->start_pass) (cinfo, FALSE);
  ------------------
  |  |  207|  73.2k|#define FALSE   0               /* values of boolean */
  ------------------
  635|  73.2k|    (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
  636|       |    /* We emit frame/scan headers now */
  637|  73.2k|    if (master->scan_number == 0)
  ------------------
  |  Branch (637:9): [True: 7.32k, False: 65.9k]
  ------------------
  638|  7.32k|      (*cinfo->marker->write_frame_header) (cinfo);
  639|  73.2k|    (*cinfo->marker->write_scan_header) (cinfo);
  640|  73.2k|    master->pub.call_pass_startup = FALSE;
  ------------------
  |  |  207|  73.2k|#define FALSE   0               /* values of boolean */
  ------------------
  641|  73.2k|    break;
  642|      0|  default:
  ------------------
  |  Branch (642:3): [True: 0, False: 129k]
  ------------------
  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|   129k|  }
  645|       |
  646|   129k|  master->pub.is_last_pass = (master->pass_number == master->total_passes - 1);
  647|       |
  648|       |  /* Set up progress monitor's pass info if present */
  649|   129k|  if (cinfo->progress != NULL) {
  ------------------
  |  Branch (649:7): [True: 0, False: 129k]
  ------------------
  650|      0|    cinfo->progress->completed_passes = master->pass_number;
  651|      0|    cinfo->progress->total_passes = master->total_passes;
  652|      0|  }
  653|   129k|}
jcmaster.c:select_scan_parameters:
  444|  92.4k|{
  445|  92.4k|  int ci;
  446|       |
  447|  92.4k|#ifdef NEED_SCAN_SCRIPT
  448|  92.4k|  if (cinfo->scan_info != NULL) {
  ------------------
  |  Branch (448:7): [True: 73.2k, False: 19.2k]
  ------------------
  449|       |    /* Prepare for current scan --- the script is already validated */
  450|  73.2k|    my_master_ptr master = (my_master_ptr)cinfo->master;
  451|  73.2k|    const jpeg_scan_info *scanptr = cinfo->scan_info + master->scan_number;
  452|       |
  453|  73.2k|    cinfo->comps_in_scan = scanptr->comps_in_scan;
  454|   175k|    for (ci = 0; ci < scanptr->comps_in_scan; ci++) {
  ------------------
  |  Branch (454:18): [True: 102k, False: 73.2k]
  ------------------
  455|   102k|      cinfo->cur_comp_info[ci] =
  456|   102k|        &cinfo->comp_info[scanptr->component_index[ci]];
  457|   102k|    }
  458|  73.2k|    cinfo->Ss = scanptr->Ss;
  459|  73.2k|    cinfo->Se = scanptr->Se;
  460|  73.2k|    cinfo->Ah = scanptr->Ah;
  461|  73.2k|    cinfo->Al = scanptr->Al;
  462|  73.2k|  } else
  463|  19.2k|#endif
  464|  19.2k|  {
  465|       |    /* Prepare for single sequential-JPEG scan containing all components */
  466|  19.2k|    if (cinfo->num_components > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  19.2k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (466:9): [True: 0, False: 19.2k]
  ------------------
  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|  19.2k|               MAX_COMPS_IN_SCAN);
  469|  19.2k|    cinfo->comps_in_scan = cinfo->num_components;
  470|  63.7k|    for (ci = 0; ci < cinfo->num_components; ci++) {
  ------------------
  |  Branch (470:18): [True: 44.5k, False: 19.2k]
  ------------------
  471|  44.5k|      cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
  472|  44.5k|    }
  473|  19.2k|    if (!cinfo->master->lossless) {
  ------------------
  |  Branch (473:9): [True: 19.2k, False: 0]
  ------------------
  474|  19.2k|      cinfo->Ss = 0;
  475|  19.2k|      cinfo->Se = DCTSIZE2 - 1;
  ------------------
  |  |   67|  19.2k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  476|  19.2k|      cinfo->Ah = 0;
  477|  19.2k|      cinfo->Al = 0;
  478|  19.2k|    }
  479|  19.2k|  }
  480|  92.4k|}
jcmaster.c:per_scan_setup:
  487|  92.4k|{
  488|  92.4k|  int ci, mcublks, tmp;
  489|  92.4k|  jpeg_component_info *compptr;
  490|  92.4k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  92.4k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (490:19): [True: 0, False: 92.4k]
  ------------------
  491|       |
  492|  92.4k|  if (cinfo->comps_in_scan == 1) {
  ------------------
  |  Branch (492:7): [True: 66.9k, False: 25.5k]
  ------------------
  493|       |
  494|       |    /* Noninterleaved (single-component) scan */
  495|  66.9k|    compptr = cinfo->cur_comp_info[0];
  496|       |
  497|       |    /* Overall image size in MCUs */
  498|  66.9k|    cinfo->MCUs_per_row = compptr->width_in_blocks;
  499|  66.9k|    cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
  500|       |
  501|       |    /* For noninterleaved scan, always one block per MCU */
  502|  66.9k|    compptr->MCU_width = 1;
  503|  66.9k|    compptr->MCU_height = 1;
  504|  66.9k|    compptr->MCU_blocks = 1;
  505|  66.9k|    compptr->MCU_sample_width = data_unit;
  506|  66.9k|    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|  66.9k|    tmp = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
  511|  66.9k|    if (tmp == 0) tmp = compptr->v_samp_factor;
  ------------------
  |  Branch (511:9): [True: 66.9k, False: 0]
  ------------------
  512|  66.9k|    compptr->last_row_height = tmp;
  513|       |
  514|       |    /* Prepare array describing MCU composition */
  515|  66.9k|    cinfo->blocks_in_MCU = 1;
  516|  66.9k|    cinfo->MCU_membership[0] = 0;
  517|       |
  518|  66.9k|  } else {
  519|       |
  520|       |    /* Interleaved (multi-component) scan */
  521|  25.5k|    if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  25.5k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (521:9): [True: 0, False: 25.5k]
  |  Branch (521:38): [True: 0, False: 25.5k]
  ------------------
  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|  25.5k|               MAX_COMPS_IN_SCAN);
  524|       |
  525|       |    /* Overall image size in MCUs */
  526|  25.5k|    cinfo->MCUs_per_row = (JDIMENSION)
  527|  25.5k|      jdiv_round_up((long)cinfo->_jpeg_width,
  ------------------
  |  |   30|  25.5k|#define _jpeg_width  image_width
  ------------------
  528|  25.5k|                    (long)(cinfo->max_h_samp_factor * data_unit));
  529|  25.5k|    cinfo->MCU_rows_in_scan = (JDIMENSION)
  530|  25.5k|      jdiv_round_up((long)cinfo->_jpeg_height,
  ------------------
  |  |   31|  25.5k|#define _jpeg_height  image_height
  ------------------
  531|  25.5k|                    (long)(cinfo->max_v_samp_factor * data_unit));
  532|       |
  533|  25.5k|    cinfo->blocks_in_MCU = 0;
  534|       |
  535|   105k|    for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (535:18): [True: 80.1k, False: 25.5k]
  ------------------
  536|  80.1k|      compptr = cinfo->cur_comp_info[ci];
  537|       |      /* Sampling factors give # of blocks of component in each MCU */
  538|  80.1k|      compptr->MCU_width = compptr->h_samp_factor;
  539|  80.1k|      compptr->MCU_height = compptr->v_samp_factor;
  540|  80.1k|      compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
  541|  80.1k|      compptr->MCU_sample_width = compptr->MCU_width * data_unit;
  542|       |      /* Figure number of non-dummy blocks in last MCU column & row */
  543|  80.1k|      tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
  544|  80.1k|      if (tmp == 0) tmp = compptr->MCU_width;
  ------------------
  |  Branch (544:11): [True: 63.5k, False: 16.6k]
  ------------------
  545|  80.1k|      compptr->last_col_width = tmp;
  546|  80.1k|      tmp = (int)(compptr->height_in_blocks % compptr->MCU_height);
  547|  80.1k|      if (tmp == 0) tmp = compptr->MCU_height;
  ------------------
  |  Branch (547:11): [True: 71.0k, False: 9.08k]
  ------------------
  548|  80.1k|      compptr->last_row_height = tmp;
  549|       |      /* Prepare array describing MCU composition */
  550|  80.1k|      mcublks = compptr->MCU_blocks;
  551|  80.1k|      if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU)
  ------------------
  |  |   80|  80.1k|#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on data units/MCU */
  ------------------
  |  Branch (551:11): [True: 0, False: 80.1k]
  ------------------
  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|   207k|      while (mcublks-- > 0) {
  ------------------
  |  Branch (553:14): [True: 126k, False: 80.1k]
  ------------------
  554|   126k|        cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
  555|   126k|      }
  556|  80.1k|    }
  557|       |
  558|  25.5k|  }
  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.4k|  if (cinfo->restart_in_rows > 0) {
  ------------------
  |  Branch (562:7): [True: 7.32k, False: 85.1k]
  ------------------
  563|  7.32k|    long nominal = (long)cinfo->restart_in_rows * (long)cinfo->MCUs_per_row;
  564|  7.32k|    cinfo->restart_interval = (unsigned int)MIN(nominal, 65535L);
  ------------------
  |  |  515|  7.32k|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 7.32k, False: 0]
  |  |  ------------------
  ------------------
  565|  7.32k|  }
  566|  92.4k|}
jcmaster.c:pass_startup:
  668|  19.2k|{
  669|  19.2k|  cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */
  ------------------
  |  |  207|  19.2k|#define FALSE   0               /* values of boolean */
  ------------------
  670|       |
  671|  19.2k|  (*cinfo->marker->write_frame_header) (cinfo);
  672|  19.2k|  (*cinfo->marker->write_scan_header) (cinfo);
  673|  19.2k|}
jcmaster.c:finish_pass_master:
  682|   129k|{
  683|   129k|  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|   129k|  (*cinfo->entropy->finish_pass) (cinfo);
  689|       |
  690|       |  /* Update state for next pass */
  691|   129k|  switch (master->pass_type) {
  ------------------
  |  Branch (691:11): [True: 129k, False: 0]
  ------------------
  692|  26.5k|  case main_pass:
  ------------------
  |  Branch (692:3): [True: 26.5k, False: 103k]
  ------------------
  693|       |    /* next pass is either output of scan 0 (after optimization)
  694|       |     * or output of scan 1 (if no optimization).
  695|       |     */
  696|  26.5k|    master->pass_type = output_pass;
  697|  26.5k|    if (!cinfo->optimize_coding)
  ------------------
  |  Branch (697:9): [True: 19.2k, False: 7.32k]
  ------------------
  698|  19.2k|      master->scan_number++;
  699|  26.5k|    break;
  700|  30.0k|  case huff_opt_pass:
  ------------------
  |  Branch (700:3): [True: 30.0k, False: 99.7k]
  ------------------
  701|       |    /* next pass is always output of current scan */
  702|  30.0k|    master->pass_type = output_pass;
  703|  30.0k|    break;
  704|  73.2k|  case output_pass:
  ------------------
  |  Branch (704:3): [True: 73.2k, False: 56.6k]
  ------------------
  705|       |    /* next pass is either optimization or output of next scan */
  706|  73.2k|    if (cinfo->optimize_coding)
  ------------------
  |  Branch (706:9): [True: 41.1k, False: 32.0k]
  ------------------
  707|  41.1k|      master->pass_type = huff_opt_pass;
  708|  73.2k|    master->scan_number++;
  709|  73.2k|    break;
  710|   129k|  }
  711|       |
  712|   129k|  master->pass_number++;
  713|   129k|}
jcmaster.c:validate_script:
  280|  7.32k|{
  281|  7.32k|  const jpeg_scan_info *scanptr;
  282|  7.32k|  int scanno, ncomps, ci, thisi;
  283|  7.32k|  int Ss, Se, Ah, Al;
  284|  7.32k|  boolean component_sent[MAX_COMPONENTS];
  285|  7.32k|#ifdef C_PROGRESSIVE_SUPPORTED
  286|  7.32k|  int coefi, *last_bitpos_ptr;
  287|  7.32k|  int last_bitpos[MAX_COMPONENTS][DCTSIZE2];
  288|       |  /* -1 until that coefficient has been seen; then last Al for it */
  289|  7.32k|#endif
  290|       |
  291|  7.32k|  if (cinfo->num_scans <= 0)
  ------------------
  |  Branch (291:7): [True: 0, False: 7.32k]
  ------------------
  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|  7.32k|  scanptr = cinfo->scan_info;
  300|  7.32k|  if (scanptr->Ss != 0 && scanptr->Se == 0) {
  ------------------
  |  Branch (300:7): [True: 0, False: 7.32k]
  |  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|  7.32k|  else if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2 - 1) {
  ------------------
  |  |   67|  7.32k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (313:12): [True: 0, False: 7.32k]
  |  Branch (313:32): [True: 7.32k, False: 0]
  ------------------
  314|  7.32k|#ifdef C_PROGRESSIVE_SUPPORTED
  315|  7.32k|    cinfo->progressive_mode = TRUE;
  ------------------
  |  |  210|  7.32k|#define TRUE    1
  ------------------
  316|  7.32k|    cinfo->master->lossless = FALSE;
  ------------------
  |  |  207|  7.32k|#define FALSE   0               /* values of boolean */
  ------------------
  317|  7.32k|    last_bitpos_ptr = &last_bitpos[0][0];
  318|  29.2k|    for (ci = 0; ci < cinfo->num_components; ci++)
  ------------------
  |  Branch (318:18): [True: 21.9k, False: 7.32k]
  ------------------
  319|  1.42M|      for (coefi = 0; coefi < DCTSIZE2; coefi++)
  ------------------
  |  |   67|  1.42M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (319:23): [True: 1.40M, False: 21.9k]
  ------------------
  320|  1.40M|        *last_bitpos_ptr++ = -1;
  321|       |#else
  322|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  323|       |#endif
  324|  7.32k|  } else {
  325|      0|    cinfo->progressive_mode = cinfo->master->lossless = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  326|      0|    for (ci = 0; ci < cinfo->num_components; ci++)
  ------------------
  |  Branch (326:18): [True: 0, False: 0]
  ------------------
  327|      0|      component_sent[ci] = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  328|      0|  }
  329|       |
  330|  80.5k|  for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) {
  ------------------
  |  Branch (330:20): [True: 73.2k, False: 7.32k]
  ------------------
  331|       |    /* Validate component indexes */
  332|  73.2k|    ncomps = scanptr->comps_in_scan;
  333|  73.2k|    if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN)
  ------------------
  |  |   71|  73.2k|#define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  ------------------
  |  Branch (333:9): [True: 0, False: 73.2k]
  |  Branch (333:24): [True: 0, False: 73.2k]
  ------------------
  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|   175k|    for (ci = 0; ci < ncomps; ci++) {
  ------------------
  |  Branch (335:18): [True: 102k, False: 73.2k]
  ------------------
  336|   102k|      thisi = scanptr->component_index[ci];
  337|   102k|      if (thisi < 0 || thisi >= cinfo->num_components)
  ------------------
  |  Branch (337:11): [True: 0, False: 102k]
  |  Branch (337:24): [True: 0, False: 102k]
  ------------------
  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|   102k|      if (ci > 0 && thisi <= scanptr->component_index[ci - 1])
  ------------------
  |  Branch (340:11): [True: 29.2k, False: 73.2k]
  |  Branch (340:21): [True: 0, False: 29.2k]
  ------------------
  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|   102k|    }
  343|       |    /* Validate progression parameters */
  344|  73.2k|    Ss = scanptr->Ss;
  345|  73.2k|    Se = scanptr->Se;
  346|  73.2k|    Ah = scanptr->Ah;
  347|  73.2k|    Al = scanptr->Al;
  348|  73.2k|    if (cinfo->progressive_mode) {
  ------------------
  |  Branch (348:9): [True: 73.2k, False: 0]
  ------------------
  349|  73.2k|#ifdef C_PROGRESSIVE_SUPPORTED
  350|       |      /* Rec. ITU-T T.81 | ISO/IEC 10918-1 simply gives the ranges 0..13 for Ah
  351|       |       * and Al, but that seems wrong: the upper bound ought to depend on data
  352|       |       * precision.  Perhaps they really meant 0..N+1 for N-bit precision.
  353|       |       * Here we allow 0..10 for 8-bit data; Al larger than 10 results in
  354|       |       * out-of-range reconstructed DC values during the first DC scan,
  355|       |       * which might cause problems for some decoders.
  356|       |       */
  357|  73.2k|      int max_Ah_Al = cinfo->data_precision == 12 ? 13 : 10;
  ------------------
  |  Branch (357:23): [True: 0, False: 73.2k]
  ------------------
  358|       |
  359|  73.2k|      if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
  ------------------
  |  |   67|   146k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
                    if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
  ------------------
  |  |   67|   146k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (359:11): [True: 0, False: 73.2k]
  |  Branch (359:21): [True: 0, False: 73.2k]
  |  Branch (359:39): [True: 0, False: 73.2k]
  |  Branch (359:50): [True: 0, False: 73.2k]
  ------------------
  360|  73.2k|          Ah < 0 || Ah > max_Ah_Al || Al < 0 || Al > max_Ah_Al)
  ------------------
  |  Branch (360:11): [True: 0, False: 73.2k]
  |  Branch (360:21): [True: 0, False: 73.2k]
  |  Branch (360:39): [True: 0, False: 73.2k]
  |  Branch (360:49): [True: 0, False: 73.2k]
  ------------------
  361|      0|        ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  362|  73.2k|      if (Ss == 0) {
  ------------------
  |  Branch (362:11): [True: 14.6k, False: 58.5k]
  ------------------
  363|  14.6k|        if (Se != 0)            /* DC and AC together not OK */
  ------------------
  |  Branch (363:13): [True: 0, False: 14.6k]
  ------------------
  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|  58.5k|      } else {
  366|  58.5k|        if (ncomps != 1)        /* AC scans must be for only one component */
  ------------------
  |  Branch (366:13): [True: 0, False: 58.5k]
  ------------------
  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|  58.5k|      }
  369|   175k|      for (ci = 0; ci < ncomps; ci++) {
  ------------------
  |  Branch (369:20): [True: 102k, False: 73.2k]
  ------------------
  370|   102k|        last_bitpos_ptr = &last_bitpos[scanptr->component_index[ci]][0];
  371|   102k|        if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */
  ------------------
  |  Branch (371:13): [True: 58.5k, False: 43.9k]
  |  Branch (371:24): [True: 0, False: 58.5k]
  ------------------
  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.37M|        for (coefi = Ss; coefi <= Se; coefi++) {
  ------------------
  |  Branch (373:26): [True: 3.27M, False: 102k]
  ------------------
  374|  3.27M|          if (last_bitpos_ptr[coefi] < 0) {
  ------------------
  |  Branch (374:15): [True: 1.40M, False: 1.86M]
  ------------------
  375|       |            /* first scan of this coefficient */
  376|  1.40M|            if (Ah != 0)
  ------------------
  |  Branch (376:17): [True: 0, False: 1.40M]
  ------------------
  377|      0|              ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  378|  1.86M|          } else {
  379|       |            /* not first scan */
  380|  1.86M|            if (Ah != last_bitpos_ptr[coefi] || Al != Ah - 1)
  ------------------
  |  Branch (380:17): [True: 0, False: 1.86M]
  |  Branch (380:49): [True: 0, False: 1.86M]
  ------------------
  381|      0|              ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  382|  1.86M|          }
  383|  3.27M|          last_bitpos_ptr[coefi] = Al;
  384|  3.27M|        }
  385|   102k|      }
  386|  73.2k|#endif
  387|  73.2k|    } else {
  388|      0|#ifdef C_LOSSLESS_SUPPORTED
  389|      0|      if (cinfo->master->lossless) {
  ------------------
  |  Branch (389:11): [True: 0, False: 0]
  ------------------
  390|       |        /* The JPEG spec simply gives the range 0..15 for Al (Pt), but that
  391|       |         * seems wrong: the upper bound ought to depend on data precision.
  392|       |         * Perhaps they really meant 0..N-1 for N-bit precision, which is what
  393|       |         * we allow here.  Values greater than or equal to the data precision
  394|       |         * will result in a blank image.
  395|       |         */
  396|      0|        if (Ss < 1 || Ss > 7 ||         /* predictor selection value */
  ------------------
  |  Branch (396:13): [True: 0, False: 0]
  |  Branch (396:23): [True: 0, False: 0]
  ------------------
  397|      0|            Se != 0 || Ah != 0 ||
  ------------------
  |  Branch (397:13): [True: 0, False: 0]
  |  Branch (397:24): [True: 0, False: 0]
  ------------------
  398|      0|            Al < 0 || Al >= cinfo->data_precision) /* point transform */
  ------------------
  |  Branch (398:13): [True: 0, False: 0]
  |  Branch (398:23): [True: 0, False: 0]
  ------------------
  399|      0|          ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  400|      0|      } else
  401|      0|#endif
  402|      0|      {
  403|       |        /* For sequential JPEG, all progression parameters must be these: */
  404|      0|        if (Ss != 0 || Se != DCTSIZE2 - 1 || Ah != 0 || Al != 0)
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (404:13): [True: 0, False: 0]
  |  Branch (404:24): [True: 0, False: 0]
  |  Branch (404:46): [True: 0, False: 0]
  |  Branch (404:57): [True: 0, False: 0]
  ------------------
  405|      0|          ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  406|      0|      }
  407|       |      /* Make sure components are not sent twice */
  408|      0|      for (ci = 0; ci < ncomps; ci++) {
  ------------------
  |  Branch (408:20): [True: 0, False: 0]
  ------------------
  409|      0|        thisi = scanptr->component_index[ci];
  410|      0|        if (component_sent[thisi])
  ------------------
  |  Branch (410:13): [True: 0, False: 0]
  ------------------
  411|      0|          ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  412|      0|        component_sent[thisi] = TRUE;
  ------------------
  |  |  210|      0|#define TRUE    1
  ------------------
  413|      0|      }
  414|      0|    }
  415|  73.2k|  }
  416|       |
  417|       |  /* Now verify that everything got sent. */
  418|  7.32k|  if (cinfo->progressive_mode) {
  ------------------
  |  Branch (418:7): [True: 7.32k, False: 0]
  ------------------
  419|  7.32k|#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|  29.2k|    for (ci = 0; ci < cinfo->num_components; ci++) {
  ------------------
  |  Branch (425:18): [True: 21.9k, False: 7.32k]
  ------------------
  426|  21.9k|      if (last_bitpos[ci][0] < 0)
  ------------------
  |  Branch (426:11): [True: 0, False: 21.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|  21.9k|    }
  429|  7.32k|#endif
  430|  7.32k|  } 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|  7.32k|}
jcmaster.c:initial_setup:
  166|  26.5k|{
  167|  26.5k|  int ci;
  168|  26.5k|  jpeg_component_info *compptr;
  169|  26.5k|  long samplesperrow;
  170|  26.5k|  JDIMENSION jd_samplesperrow;
  171|  26.5k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  26.5k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (171:19): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|  if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0 ||
  ------------------
  |  |   31|  26.5k|#define _jpeg_height  image_height
  ------------------
                if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0 ||
  ------------------
  |  |   30|  26.5k|#define _jpeg_width  image_width
  ------------------
  |  Branch (181:7): [True: 0, False: 26.5k]
  |  Branch (181:35): [True: 0, False: 26.5k]
  ------------------
  182|  26.5k|      cinfo->num_components <= 0 || cinfo->input_components <= 0)
  ------------------
  |  Branch (182:7): [True: 0, False: 26.5k]
  |  Branch (182:37): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|  if ((long)cinfo->_jpeg_height > (long)JPEG_MAX_DIMENSION ||
  ------------------
  |  |   31|  26.5k|#define _jpeg_height  image_height
  ------------------
                if ((long)cinfo->_jpeg_height > (long)JPEG_MAX_DIMENSION ||
  ------------------
  |  |  158|  53.0k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (186:7): [True: 0, False: 26.5k]
  ------------------
  187|  26.5k|      (long)cinfo->_jpeg_width > (long)JPEG_MAX_DIMENSION)
  ------------------
  |  |   30|  26.5k|#define _jpeg_width  image_width
  ------------------
                    (long)cinfo->_jpeg_width > (long)JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  26.5k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (187:7): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|  samplesperrow = (long)cinfo->image_width * (long)cinfo->input_components;
  192|  26.5k|  jd_samplesperrow = (JDIMENSION)samplesperrow;
  193|  26.5k|  if ((long)jd_samplesperrow != samplesperrow)
  ------------------
  |  Branch (193:7): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|#ifdef C_LOSSLESS_SUPPORTED
  200|  26.5k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (200:7): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|#endif
  205|  26.5k|  {
  206|  26.5k|    if (cinfo->data_precision != 8 && cinfo->data_precision != 12)
  ------------------
  |  Branch (206:9): [True: 0, False: 26.5k]
  |  Branch (206:39): [True: 0, False: 0]
  ------------------
  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|  26.5k|  }
  209|       |
  210|       |  /* Check that number of components won't exceed internal array sizes */
  211|  26.5k|  if (cinfo->num_components > MAX_COMPONENTS)
  ------------------
  |  |   30|  26.5k|#define MAX_COMPONENTS  10      /* maximum number of image components */
  ------------------
  |  Branch (211:7): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|             MAX_COMPONENTS);
  214|       |
  215|       |  /* Compute maximum sampling factors; check factor validity */
  216|  26.5k|  cinfo->max_h_samp_factor = 1;
  217|  26.5k|  cinfo->max_v_samp_factor = 1;
  218|  93.0k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (218:44): [True: 66.5k, False: 26.5k]
  ------------------
  219|  66.5k|       ci++, compptr++) {
  220|  66.5k|    if (compptr->h_samp_factor <= 0 ||
  ------------------
  |  Branch (220:9): [True: 0, False: 66.5k]
  ------------------
  221|  66.5k|        compptr->h_samp_factor > MAX_SAMP_FACTOR ||
  ------------------
  |  |   72|   133k|#define MAX_SAMP_FACTOR     4   /* JPEG limit on sampling factors */
  ------------------
  |  Branch (221:9): [True: 0, False: 66.5k]
  ------------------
  222|  66.5k|        compptr->v_samp_factor <= 0 ||
  ------------------
  |  Branch (222:9): [True: 0, False: 66.5k]
  ------------------
  223|  66.5k|        compptr->v_samp_factor > MAX_SAMP_FACTOR)
  ------------------
  |  |   72|  66.5k|#define MAX_SAMP_FACTOR     4   /* JPEG limit on sampling factors */
  ------------------
  |  Branch (223:9): [True: 0, False: 66.5k]
  ------------------
  224|      0|      ERREXIT(cinfo, JERR_BAD_SAMPLING);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  225|  66.5k|    cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
  ------------------
  |  |  513|  66.5k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 21.7k, False: 44.7k]
  |  |  ------------------
  ------------------
  226|  66.5k|                                   compptr->h_samp_factor);
  227|  66.5k|    cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
  ------------------
  |  |  513|  66.5k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 14.2k, False: 52.2k]
  |  |  ------------------
  ------------------
  228|  66.5k|                                   compptr->v_samp_factor);
  229|  66.5k|  }
  230|       |
  231|       |  /* Compute dimensions of components */
  232|  93.0k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (232:44): [True: 66.5k, False: 26.5k]
  ------------------
  233|  66.5k|       ci++, compptr++) {
  234|       |    /* Fill in the correct component_index value; don't rely on application */
  235|  66.5k|    compptr->component_index = ci;
  236|       |    /* For compression, we never do DCT scaling. */
  237|       |#if JPEG_LIB_VERSION >= 70
  238|       |    compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = data_unit;
  239|       |#else
  240|  66.5k|    compptr->DCT_scaled_size = data_unit;
  241|  66.5k|#endif
  242|       |    /* Size in data units */
  243|  66.5k|    compptr->width_in_blocks = (JDIMENSION)
  244|  66.5k|      jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
  ------------------
  |  |   30|  66.5k|#define _jpeg_width  image_width
  ------------------
  245|  66.5k|                    (long)(cinfo->max_h_samp_factor * data_unit));
  246|  66.5k|    compptr->height_in_blocks = (JDIMENSION)
  247|  66.5k|      jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
  ------------------
  |  |   31|  66.5k|#define _jpeg_height  image_height
  ------------------
  248|  66.5k|                    (long)(cinfo->max_v_samp_factor * data_unit));
  249|       |    /* Size in samples */
  250|  66.5k|    compptr->downsampled_width = (JDIMENSION)
  251|  66.5k|      jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
  ------------------
  |  |   30|  66.5k|#define _jpeg_width  image_width
  ------------------
  252|  66.5k|                    (long)cinfo->max_h_samp_factor);
  253|  66.5k|    compptr->downsampled_height = (JDIMENSION)
  254|  66.5k|      jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
  ------------------
  |  |   31|  66.5k|#define _jpeg_height  image_height
  ------------------
  255|  66.5k|                    (long)cinfo->max_v_samp_factor);
  256|       |    /* Mark component needed (this flag isn't actually used for compression) */
  257|  66.5k|    compptr->component_needed = TRUE;
  ------------------
  |  |  210|  66.5k|#define TRUE    1
  ------------------
  258|  66.5k|  }
  259|       |
  260|       |  /* Compute number of fully interleaved MCU rows (number of times that
  261|       |   * main controller will call coefficient or difference controller).
  262|       |   */
  263|  26.5k|  cinfo->total_iMCU_rows = (JDIMENSION)
  264|  26.5k|    jdiv_round_up((long)cinfo->_jpeg_height,
  ------------------
  |  |   31|  26.5k|#define _jpeg_height  image_height
  ------------------
  265|  26.5k|                  (long)(cinfo->max_v_samp_factor * data_unit));
  266|  26.5k|}

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

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

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

jinit_c_prep_controller:
  356|  26.5k|{
  357|  26.5k|  my_prep_ptr prep;
  358|  26.5k|  int ci;
  359|  26.5k|  jpeg_component_info *compptr;
  360|  26.5k|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  26.5k|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (360:19): [True: 0, False: 26.5k]
  ------------------
  361|       |
  362|  26.5k|#ifdef C_LOSSLESS_SUPPORTED
  363|  26.5k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (363:7): [True: 0, False: 26.5k]
  ------------------
  364|      0|#if BITS_IN_JSAMPLE == 8
  365|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (365:9): [True: 0, False: 0]
  |  Branch (365:52): [True: 0, False: 0]
  ------------------
  366|       |#else
  367|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  368|       |        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  369|       |#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|  26.5k|#endif
  373|  26.5k|  {
  374|  26.5k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  26.5k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (374:9): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|  }
  377|       |
  378|  26.5k|  if (need_full_buffer)         /* safety check */
  ------------------
  |  Branch (378:7): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|  prep = (my_prep_ptr)
  382|  26.5k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  26.5k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  383|  26.5k|                                sizeof(my_prep_controller));
  384|  26.5k|  cinfo->prep = (struct jpeg_c_prep_controller *)prep;
  385|  26.5k|  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|  26.5k|  if (cinfo->downsample->need_context_rows) {
  ------------------
  |  Branch (391:7): [True: 0, False: 26.5k]
  ------------------
  392|       |    /* Set up to provide context rows */
  393|      0|#ifdef CONTEXT_ROWS_SUPPORTED
  394|      0|    prep->pub._pre_process_data = pre_process_context;
  ------------------
  |  |  246|      0|#define _pre_process_data  pre_process_data
  ------------------
  395|      0|    create_context_buffer(cinfo);
  396|       |#else
  397|       |    ERREXIT(cinfo, JERR_NOT_COMPILED);
  398|       |#endif
  399|  26.5k|  } else {
  400|       |    /* No context, just make it tall enough for one row group */
  401|  26.5k|    prep->pub._pre_process_data = pre_process_data;
  ------------------
  |  |  246|  26.5k|#define _pre_process_data  pre_process_data
  ------------------
  402|  93.0k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (402:46): [True: 66.5k, False: 26.5k]
  ------------------
  403|  66.5k|         ci++, compptr++) {
  404|  66.5k|      prep->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  405|  66.5k|        ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  66.5k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  406|  66.5k|         (JDIMENSION)(((long)compptr->width_in_blocks * data_unit *
  407|  66.5k|                       cinfo->max_h_samp_factor) / compptr->h_samp_factor),
  408|  66.5k|         (JDIMENSION)cinfo->max_v_samp_factor);
  409|  66.5k|    }
  410|  26.5k|  }
  411|  26.5k|}
jcprepct-8.c:start_pass_prep:
   90|  26.5k|{
   91|  26.5k|  my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
   92|       |
   93|  26.5k|  if (pass_mode != JBUF_PASS_THRU)
  ------------------
  |  Branch (93:7): [True: 0, False: 26.5k]
  ------------------
   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|  26.5k|  prep->rows_to_go = cinfo->image_height;
   98|       |  /* Mark the conversion buffer empty */
   99|  26.5k|  prep->next_buf_row = 0;
  100|  26.5k|#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|  26.5k|  prep->this_row_group = 0;
  105|       |  /* Set next_buf_stop to stop after two row groups have been read in. */
  106|  26.5k|  prep->next_buf_stop = 2 * cinfo->max_v_samp_factor;
  107|  26.5k|#endif
  108|  26.5k|}
jcprepct-8.c:expand_bottom_edge:
  119|  52.4k|{
  120|  52.4k|  register int row;
  121|       |
  122|   342k|  for (row = input_rows; row < output_rows; row++) {
  ------------------
  |  Branch (122:26): [True: 289k, False: 52.4k]
  ------------------
  123|   289k|    _jcopy_sample_rows(image_data, input_rows - 1, image_data, row, 1,
  ------------------
  |  |  297|   289k|#define _jcopy_sample_rows  jcopy_sample_rows
  ------------------
  124|   289k|                       num_cols);
  125|   289k|  }
  126|  52.4k|}
jcprepct-8.c:pre_process_data:
  143|  3.91M|{
  144|  3.91M|  my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
  145|  3.91M|  int numrows, ci;
  146|  3.91M|  JDIMENSION inrows;
  147|  3.91M|  jpeg_component_info *compptr;
  148|  3.91M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  3.91M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (148:19): [True: 0, False: 3.91M]
  ------------------
  149|       |
  150|  35.1M|  while (*in_row_ctr < in_rows_avail &&
  ------------------
  |  Branch (150:10): [True: 35.1M, False: 10.4k]
  ------------------
  151|  35.1M|         *out_row_group_ctr < out_row_groups_avail) {
  ------------------
  |  Branch (151:10): [True: 31.2M, False: 3.88M]
  ------------------
  152|       |    /* Do color conversion to fill the conversion buffer. */
  153|  31.2M|    inrows = in_rows_avail - *in_row_ctr;
  154|  31.2M|    numrows = cinfo->max_v_samp_factor - prep->next_buf_row;
  155|  31.2M|    numrows = (int)MIN((JDIMENSION)numrows, inrows);
  ------------------
  |  |  515|  31.2M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 31.1M, False: 26.5k]
  |  |  ------------------
  ------------------
  156|       |#ifdef WITH_PROFILE
  157|       |    cinfo->master->start = getTime();
  158|       |#endif
  159|  31.2M|    (*cinfo->cconvert->_color_convert) (cinfo, input_buf + *in_row_ctr,
  ------------------
  |  |  267|  31.2M|#define _color_convert  color_convert
  ------------------
  160|  31.2M|                                        prep->color_buf,
  161|  31.2M|                                        (JDIMENSION)prep->next_buf_row,
  162|  31.2M|                                        numrows);
  163|       |#ifdef WITH_PROFILE
  164|       |    cinfo->master->cconvert_elapsed += getTime() - cinfo->master->start;
  165|       |    cinfo->master->cconvert_mpixels +=
  166|       |      (double)cinfo->image_width * numrows / 1000000.;
  167|       |#endif
  168|  31.2M|    *in_row_ctr += numrows;
  169|  31.2M|    prep->next_buf_row += numrows;
  170|  31.2M|    prep->rows_to_go -= numrows;
  171|       |    /* If at bottom of image, pad to fill the conversion buffer. */
  172|  31.2M|    if (prep->rows_to_go == 0 &&
  ------------------
  |  Branch (172:9): [True: 26.5k, False: 31.1M]
  ------------------
  173|  26.5k|        prep->next_buf_row < cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (173:9): [True: 2.21k, False: 24.3k]
  ------------------
  174|  9.95k|      for (ci = 0; ci < cinfo->num_components; ci++) {
  ------------------
  |  Branch (174:20): [True: 7.74k, False: 2.21k]
  ------------------
  175|  7.74k|        expand_bottom_edge(prep->color_buf[ci], cinfo->image_width,
  176|  7.74k|                           prep->next_buf_row, cinfo->max_v_samp_factor);
  177|  7.74k|      }
  178|  2.21k|      prep->next_buf_row = cinfo->max_v_samp_factor;
  179|  2.21k|    }
  180|       |    /* If we've filled the conversion buffer, empty it. */
  181|  31.2M|    if (prep->next_buf_row == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (181:9): [True: 31.2M, False: 0]
  ------------------
  182|       |#ifdef WITH_PROFILE
  183|       |      cinfo->master->start = getTime();
  184|       |#endif
  185|  31.2M|      (*cinfo->downsample->_downsample) (cinfo,
  ------------------
  |  |  252|  31.2M|#define _downsample  downsample
  ------------------
  186|  31.2M|                                         prep->color_buf, (JDIMENSION)0,
  187|  31.2M|                                         output_buf, *out_row_group_ctr);
  188|       |#ifdef WITH_PROFILE
  189|       |      cinfo->master->downsample_elapsed += getTime() - cinfo->master->start;
  190|       |      cinfo->master->downsample_msamples +=
  191|       |        (double)cinfo->image_width * cinfo->max_v_samp_factor / 1000000.;
  192|       |#endif
  193|  31.2M|      prep->next_buf_row = 0;
  194|  31.2M|      (*out_row_group_ctr)++;
  195|  31.2M|    }
  196|       |    /* If at bottom of image, pad the output to a full iMCU height.
  197|       |     * Note we assume the caller is providing a one-iMCU-height output buffer!
  198|       |     */
  199|  31.2M|    if (prep->rows_to_go == 0 && *out_row_group_ctr < out_row_groups_avail) {
  ------------------
  |  Branch (199:9): [True: 26.5k, False: 31.1M]
  |  Branch (199:34): [True: 16.0k, False: 10.4k]
  ------------------
  200|  60.7k|      for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (200:48): [True: 44.6k, False: 16.0k]
  ------------------
  201|  44.6k|           ci++, compptr++) {
  202|  44.6k|        expand_bottom_edge(output_buf[ci],
  203|  44.6k|                           compptr->width_in_blocks * data_unit,
  204|  44.6k|                           (int)(*out_row_group_ctr * compptr->v_samp_factor),
  205|  44.6k|                           (int)(out_row_groups_avail * compptr->v_samp_factor));
  206|  44.6k|      }
  207|  16.0k|      *out_row_group_ctr = out_row_groups_avail;
  208|  16.0k|      break;                    /* can exit outer loop without test */
  209|  16.0k|    }
  210|  31.2M|  }
  211|  3.91M|}

jinit_downsampler:
  468|  26.5k|{
  469|  26.5k|  my_downsample_ptr downsample;
  470|  26.5k|  int ci;
  471|  26.5k|  jpeg_component_info *compptr;
  472|  26.5k|#ifdef INPUT_SMOOTHING_SUPPORTED
  473|  26.5k|  boolean smoothok = TRUE;
  ------------------
  |  |  210|  26.5k|#define TRUE    1
  ------------------
  474|  26.5k|#endif
  475|       |
  476|  26.5k|#ifdef C_LOSSLESS_SUPPORTED
  477|  26.5k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (477:7): [True: 0, False: 26.5k]
  ------------------
  478|      0|#if BITS_IN_JSAMPLE == 8
  479|      0|    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|      0|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (479:9): [True: 0, False: 0]
  |  Branch (479:52): [True: 0, False: 0]
  ------------------
  480|       |#else
  481|       |    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  482|       |        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  483|       |#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|  26.5k|#endif
  487|  26.5k|  {
  488|  26.5k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  26.5k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (488:9): [True: 0, False: 26.5k]
  ------------------
  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|  26.5k|  }
  491|       |
  492|  26.5k|  downsample = (my_downsample_ptr)
  493|  26.5k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  26.5k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  494|  26.5k|                                sizeof(my_downsampler));
  495|  26.5k|  cinfo->downsample = (struct jpeg_downsampler *)downsample;
  496|  26.5k|  downsample->pub.start_pass = start_pass_downsample;
  497|  26.5k|  downsample->pub._downsample = sep_downsample;
  ------------------
  |  |  252|  26.5k|#define _downsample  downsample
  ------------------
  498|  26.5k|  downsample->pub.need_context_rows = FALSE;
  ------------------
  |  |  207|  26.5k|#define FALSE   0               /* values of boolean */
  ------------------
  499|       |
  500|  26.5k|  if (cinfo->CCIR601_sampling)
  ------------------
  |  Branch (500:7): [True: 0, False: 26.5k]
  ------------------
  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|  93.0k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (504:44): [True: 66.5k, False: 26.5k]
  ------------------
  505|  66.5k|       ci++, compptr++) {
  506|  66.5k|    if (compptr->h_samp_factor == cinfo->max_h_samp_factor &&
  ------------------
  |  Branch (506:9): [True: 44.7k, False: 21.7k]
  ------------------
  507|  44.7k|        compptr->v_samp_factor == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (507:9): [True: 37.6k, False: 7.12k]
  ------------------
  508|  37.6k|#ifdef INPUT_SMOOTHING_SUPPORTED
  509|  37.6k|      if (cinfo->smoothing_factor) {
  ------------------
  |  Branch (509:11): [True: 0, False: 37.6k]
  ------------------
  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|  37.6k|#endif
  514|  37.6k|        downsample->methods[ci] = fullsize_downsample;
  515|  37.6k|    } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
  ------------------
  |  Branch (515:16): [True: 14.6k, False: 14.2k]
  ------------------
  516|  14.6k|               compptr->v_samp_factor == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (516:16): [True: 7.52k, False: 7.12k]
  ------------------
  517|  7.52k|#ifdef INPUT_SMOOTHING_SUPPORTED
  518|  7.52k|      smoothok = FALSE;
  ------------------
  |  |  207|  7.52k|#define FALSE   0               /* values of boolean */
  ------------------
  519|  7.52k|#endif
  520|  7.52k|#ifdef WITH_SIMD
  521|  7.52k|      if (jsimd_set_h2v1_downsample(cinfo))
  ------------------
  |  Branch (521:11): [True: 7.52k, False: 0]
  ------------------
  522|  7.52k|        downsample->methods[ci] = jsimd_h2v1_downsample;
  523|      0|      else
  524|      0|#endif
  525|      0|        downsample->methods[ci] = h2v1_downsample;
  526|  21.3k|    } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
  ------------------
  |  Branch (526:16): [True: 7.12k, False: 14.2k]
  ------------------
  527|  7.12k|               compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) {
  ------------------
  |  Branch (527:16): [True: 7.12k, False: 0]
  ------------------
  528|  7.12k|#ifdef INPUT_SMOOTHING_SUPPORTED
  529|  7.12k|      if (cinfo->smoothing_factor) {
  ------------------
  |  Branch (529:11): [True: 0, False: 7.12k]
  ------------------
  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|  7.12k|#endif
  534|  7.12k|      {
  535|  7.12k|#ifdef WITH_SIMD
  536|  7.12k|        if (jsimd_set_h2v2_downsample(cinfo))
  ------------------
  |  Branch (536:13): [True: 7.12k, False: 0]
  ------------------
  537|  7.12k|          downsample->methods[ci] = jsimd_h2v2_downsample;
  538|      0|        else
  539|      0|#endif
  540|      0|          downsample->methods[ci] = h2v2_downsample;
  541|  7.12k|      }
  542|  14.2k|    } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 &&
  ------------------
  |  Branch (542:16): [True: 14.2k, False: 0]
  ------------------
  543|  14.2k|               (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) {
  ------------------
  |  Branch (543:16): [True: 14.2k, False: 0]
  ------------------
  544|  14.2k|#ifdef INPUT_SMOOTHING_SUPPORTED
  545|  14.2k|      smoothok = FALSE;
  ------------------
  |  |  207|  14.2k|#define FALSE   0               /* values of boolean */
  ------------------
  546|  14.2k|#endif
  547|  14.2k|      downsample->methods[ci] = int_downsample;
  548|  14.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|  66.5k|  }
  551|       |
  552|  26.5k|#ifdef INPUT_SMOOTHING_SUPPORTED
  553|  26.5k|  if (cinfo->smoothing_factor && !smoothok)
  ------------------
  |  Branch (553:7): [True: 0, False: 26.5k]
  |  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|  26.5k|#endif
  556|  26.5k|}
jcsample-8.c:start_pass_downsample:
   89|  26.5k|{
   90|       |  /* no work for now */
   91|  26.5k|}
jcsample-8.c:sep_downsample:
  130|  31.2M|{
  131|  31.2M|  my_downsample_ptr downsample = (my_downsample_ptr)cinfo->downsample;
  132|  31.2M|  int ci;
  133|  31.2M|  jpeg_component_info *compptr;
  134|  31.2M|  _JSAMPARRAY in_ptr, out_ptr;
  ------------------
  |  |  230|  31.2M|#define _JSAMPARRAY  JSAMPARRAY
  ------------------
  135|       |
  136|   109M|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (136:44): [True: 78.1M, False: 31.2M]
  ------------------
  137|  78.1M|       ci++, compptr++) {
  138|  78.1M|    in_ptr = input_buf[ci] + in_row_index;
  139|  78.1M|    out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor);
  140|  78.1M|    (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr);
  141|  78.1M|  }
  142|  31.2M|}
jcsample-8.c:expand_right_edge:
  102|  61.5M|{
  103|  61.5M|  register _JSAMPROW ptr;
  104|  61.5M|  register _JSAMPLE pixval;
  105|  61.5M|  register int count;
  106|  61.5M|  int row;
  107|  61.5M|  int numcols = (int)(output_cols - input_cols);
  108|       |
  109|  61.5M|  if (numcols > 0) {
  ------------------
  |  Branch (109:7): [True: 61.4M, False: 104k]
  ------------------
  110|   136M|    for (row = 0; row < num_rows; row++) {
  ------------------
  |  Branch (110:19): [True: 75.2M, False: 61.4M]
  ------------------
  111|  75.2M|      ptr = image_data[row] + input_cols;
  112|  75.2M|      pixval = ptr[-1];
  113|   798M|      for (count = numcols; count > 0; count--)
  ------------------
  |  Branch (113:29): [True: 723M, False: 75.2M]
  ------------------
  114|   723M|        *ptr++ = pixval;
  115|  75.2M|    }
  116|  61.4M|  }
  117|  61.5M|}
jcsample-8.c:fullsize_downsample:
  203|  45.0M|{
  204|  45.0M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  45.0M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (204:19): [True: 0, False: 45.0M]
  ------------------
  205|       |
  206|       |  /* Copy the data */
  207|  45.0M|  _jcopy_sample_rows(input_data, 0, output_data, 0, cinfo->max_v_samp_factor,
  ------------------
  |  |  297|  45.0M|#define _jcopy_sample_rows  jcopy_sample_rows
  ------------------
  208|  45.0M|                     cinfo->image_width);
  209|       |  /* Edge-expand */
  210|  45.0M|  expand_right_edge(output_data, cinfo->max_v_samp_factor, cinfo->image_width,
  211|  45.0M|                    compptr->width_in_blocks * data_unit);
  212|  45.0M|}
jcsample-8.c:int_downsample:
  155|  16.5M|{
  156|  16.5M|  int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v;
  157|  16.5M|  JDIMENSION outcol, outcol_h;  /* outcol_h == outcol*h_expand */
  158|  16.5M|  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
  ------------------
  |  |   66|  16.5M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (158:19): [True: 0, False: 16.5M]
  ------------------
  159|  16.5M|  JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
  160|  16.5M|  _JSAMPROW inptr, outptr;
  ------------------
  |  |  229|  16.5M|#define _JSAMPROW  JSAMPROW
  ------------------
  161|  16.5M|  JLONG outvalue;
  162|       |
  163|  16.5M|  h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor;
  164|  16.5M|  v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor;
  165|  16.5M|  numpix = h_expand * v_expand;
  166|  16.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|  16.5M|  expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
  173|  16.5M|                    output_cols * h_expand);
  174|       |
  175|  16.5M|  inrow = 0;
  176|  33.1M|  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  ------------------
  |  Branch (176:20): [True: 16.5M, False: 16.5M]
  ------------------
  177|  16.5M|    outptr = output_data[outrow];
  178|   179M|    for (outcol = 0, outcol_h = 0; outcol < output_cols;
  ------------------
  |  Branch (178:36): [True: 163M, False: 16.5M]
  ------------------
  179|   163M|         outcol++, outcol_h += h_expand) {
  180|   163M|      outvalue = 0;
  181|   393M|      for (v = 0; v < v_expand; v++) {
  ------------------
  |  Branch (181:19): [True: 230M, False: 163M]
  ------------------
  182|   230M|        inptr = input_data[inrow + v] + outcol_h;
  183|   748M|        for (h = 0; h < h_expand; h++) {
  ------------------
  |  Branch (183:21): [True: 517M, False: 230M]
  ------------------
  184|   517M|          outvalue += (JLONG)(*inptr++);
  185|   517M|        }
  186|   230M|      }
  187|   163M|      *outptr++ = (_JSAMPLE)((outvalue + numpix2) / numpix);
  188|   163M|    }
  189|  16.5M|    inrow += v_expand;
  190|  16.5M|  }
  191|  16.5M|}

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

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

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

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

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

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

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

jinit_read_bmp:
  662|  6.67k|{
  663|  6.67k|  bmp_source_ptr source;
  664|       |
  665|  6.67k|  if (cinfo->data_precision != 8)
  ------------------
  |  Branch (665:7): [True: 0, False: 6.67k]
  ------------------
  666|      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)))
  ------------------
  667|       |
  668|       |  /* Create module interface object */
  669|  6.67k|  source = (bmp_source_ptr)
  670|  6.67k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  6.67k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  671|  6.67k|                                sizeof(bmp_source_struct));
  672|  6.67k|  source->cinfo = cinfo;        /* make back link for subroutines */
  673|       |  /* Fill in method ptrs, except get_pixel_rows which start_input sets */
  674|  6.67k|  source->pub.start_input = start_input_bmp;
  675|  6.67k|  source->pub.read_icc_profile = read_icc_profile_bmp;
  676|  6.67k|  source->pub.finish_input = finish_input_bmp;
  677|  6.67k|  source->pub.max_pixels = 0;
  678|       |
  679|  6.67k|  source->use_inversion_array = use_inversion_array;
  680|       |
  681|  6.67k|  return (cjpeg_source_ptr)source;
  682|  6.67k|}
rdbmp.c:start_input_bmp:
  408|  6.67k|{
  409|  6.67k|  bmp_source_ptr source = (bmp_source_ptr)sinfo;
  410|  6.67k|  unsigned char bmpfileheader[14];
  411|  6.67k|  unsigned char bmpinfoheader[64];
  412|       |
  413|  6.67k|#define GET_2B(array, offset) \
  414|  6.67k|  ((unsigned short)array[offset] + \
  415|  6.67k|   (((unsigned short)array[offset + 1]) << 8))
  416|  6.67k|#define GET_4B(array, offset) \
  417|  6.67k|  ((unsigned int)array[offset] + \
  418|  6.67k|   (((unsigned int)array[offset + 1]) << 8) + \
  419|  6.67k|   (((unsigned int)array[offset + 2]) << 16) + \
  420|  6.67k|   (((unsigned int)array[offset + 3]) << 24))
  421|       |
  422|  6.67k|  int bfOffBits;
  423|  6.67k|  int headerSize;
  424|  6.67k|  int biWidth;
  425|  6.67k|  int biHeight;
  426|  6.67k|  unsigned short biPlanes;
  427|  6.67k|  unsigned int biCompression;
  428|  6.67k|  int biXPelsPerMeter, biYPelsPerMeter;
  429|  6.67k|  int biClrUsed = 0;
  430|  6.67k|  int mapentrysize = 0;         /* 0 indicates no colormap */
  431|  6.67k|  int bPad;
  432|  6.67k|  JDIMENSION row_width = 0;
  433|       |
  434|       |  /* Read and verify the bitmap file header */
  435|  6.67k|  if (!ReadOK(source->pub.input_file, bmpfileheader, 14))
  ------------------
  |  |   36|  6.67k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (435:7): [True: 49, False: 6.62k]
  ------------------
  436|     49|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     49|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     49|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  437|  6.67k|  if (GET_2B(bmpfileheader, 0) != 0x4D42) /* 'BM' */
  ------------------
  |  |  414|  6.67k|  ((unsigned short)array[offset] + \
  |  |  415|  6.67k|   (((unsigned short)array[offset + 1]) << 8))
  ------------------
  |  Branch (437:7): [True: 98, False: 6.57k]
  ------------------
  438|     98|    ERREXIT(cinfo, JERR_BMP_NOT);
  ------------------
  |  |  240|     98|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     98|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  439|  6.67k|  bfOffBits = GET_4B(bmpfileheader, 10);
  ------------------
  |  |  417|  6.67k|  ((unsigned int)array[offset] + \
  |  |  418|  6.67k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  6.67k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  6.67k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  440|       |  /* We ignore the remaining fileheader fields */
  441|       |
  442|       |  /* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows),
  443|       |   * or 64 bytes (OS/2 2.x).  Check the first 4 bytes to find out which.
  444|       |   */
  445|  6.67k|  if (!ReadOK(source->pub.input_file, bmpinfoheader, 4))
  ------------------
  |  |   36|  6.67k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (445:7): [True: 7, False: 6.66k]
  ------------------
  446|      7|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|      7|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      7|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  447|  6.67k|  headerSize = GET_4B(bmpinfoheader, 0);
  ------------------
  |  |  417|  6.67k|  ((unsigned int)array[offset] + \
  |  |  418|  6.67k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  6.67k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  6.67k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  448|  6.67k|  if (headerSize < 12 || headerSize > 64 || (headerSize + 14) > bfOffBits)
  ------------------
  |  Branch (448:7): [True: 371, False: 6.30k]
  |  Branch (448:26): [True: 210, False: 6.09k]
  |  Branch (448:45): [True: 182, False: 5.90k]
  ------------------
  449|    609|    ERREXIT(cinfo, JERR_BMP_BADHEADER);
  ------------------
  |  |  240|    609|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    609|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  450|  6.67k|  if (!ReadOK(source->pub.input_file, bmpinfoheader + 4, headerSize - 4))
  ------------------
  |  |   36|  6.67k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (450:7): [True: 35, False: 6.63k]
  ------------------
  451|     35|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     35|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     35|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  452|       |
  453|  6.67k|  switch (headerSize) {
  454|  3.01k|  case 12:
  ------------------
  |  Branch (454:3): [True: 3.01k, False: 3.66k]
  ------------------
  455|       |    /* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */
  456|  3.01k|    biWidth = (int)GET_2B(bmpinfoheader, 4);
  ------------------
  |  |  414|  3.01k|  ((unsigned short)array[offset] + \
  |  |  415|  3.01k|   (((unsigned short)array[offset + 1]) << 8))
  ------------------
  457|  3.01k|    biHeight = (int)GET_2B(bmpinfoheader, 6);
  ------------------
  |  |  414|  3.01k|  ((unsigned short)array[offset] + \
  |  |  415|  3.01k|   (((unsigned short)array[offset + 1]) << 8))
  ------------------
  458|  3.01k|    biPlanes = GET_2B(bmpinfoheader, 8);
  ------------------
  |  |  414|  3.01k|  ((unsigned short)array[offset] + \
  |  |  415|  3.01k|   (((unsigned short)array[offset + 1]) << 8))
  ------------------
  459|  3.01k|    source->bits_per_pixel = (int)GET_2B(bmpinfoheader, 10);
  ------------------
  |  |  414|  3.01k|  ((unsigned short)array[offset] + \
  |  |  415|  3.01k|   (((unsigned short)array[offset + 1]) << 8))
  ------------------
  460|       |
  461|  3.01k|    switch (source->bits_per_pixel) {
  462|  1.52k|    case 8:                     /* colormapped image */
  ------------------
  |  Branch (462:5): [True: 1.52k, False: 1.48k]
  ------------------
  463|  1.52k|      mapentrysize = 3;         /* OS/2 uses RGBTRIPLE colormap */
  464|  1.52k|      TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, biWidth, biHeight);
  ------------------
  |  |  304|  1.52k|  ((cinfo)->err->msg_code = (code), \
  |  |  305|  1.52k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  306|  1.52k|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  307|  1.52k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  465|  1.52k|      break;
  466|    931|    case 24:                    /* RGB image */
  ------------------
  |  Branch (466:5): [True: 931, False: 2.07k]
  ------------------
  467|  1.47k|    case 32:                    /* RGB image + Alpha channel */
  ------------------
  |  Branch (467:5): [True: 546, False: 2.46k]
  ------------------
  468|  1.47k|      TRACEMS3(cinfo, 1, JTRC_BMP_OS2, biWidth, biHeight,
  ------------------
  |  |  309|  1.47k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.47k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.47k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  1.47k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  1.47k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  1.47k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  469|  1.47k|               source->bits_per_pixel);
  470|  1.47k|      break;
  471|      7|    default:
  ------------------
  |  Branch (471:5): [True: 7, False: 3.00k]
  ------------------
  472|      7|      ERREXIT(cinfo, JERR_BMP_BADDEPTH);
  ------------------
  |  |  240|      7|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      7|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  473|      7|      break;
  474|  3.01k|    }
  475|  3.00k|    break;
  476|  3.00k|  case 40:
  ------------------
  |  Branch (476:3): [True: 2.84k, False: 3.82k]
  ------------------
  477|  2.85k|  case 64:
  ------------------
  |  Branch (477:3): [True: 7, False: 6.66k]
  ------------------
  478|       |    /* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */
  479|       |    /* or OS/2 2.x header, which has additional fields that we ignore */
  480|  2.85k|    biWidth = (int)GET_4B(bmpinfoheader, 4);
  ------------------
  |  |  417|  2.85k|  ((unsigned int)array[offset] + \
  |  |  418|  2.85k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  2.85k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  2.85k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  481|  2.85k|    biHeight = (int)GET_4B(bmpinfoheader, 8);
  ------------------
  |  |  417|  2.85k|  ((unsigned int)array[offset] + \
  |  |  418|  2.85k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  2.85k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  2.85k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  482|  2.85k|    biPlanes = GET_2B(bmpinfoheader, 12);
  ------------------
  |  |  414|  2.85k|  ((unsigned short)array[offset] + \
  |  |  415|  2.85k|   (((unsigned short)array[offset + 1]) << 8))
  ------------------
  483|  2.85k|    source->bits_per_pixel = (int)GET_2B(bmpinfoheader, 14);
  ------------------
  |  |  414|  2.85k|  ((unsigned short)array[offset] + \
  |  |  415|  2.85k|   (((unsigned short)array[offset + 1]) << 8))
  ------------------
  484|  2.85k|    biCompression = GET_4B(bmpinfoheader, 16);
  ------------------
  |  |  417|  2.85k|  ((unsigned int)array[offset] + \
  |  |  418|  2.85k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  2.85k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  2.85k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  485|  2.85k|    biXPelsPerMeter = (int)GET_4B(bmpinfoheader, 24);
  ------------------
  |  |  417|  2.85k|  ((unsigned int)array[offset] + \
  |  |  418|  2.85k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  2.85k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  2.85k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  486|  2.85k|    biYPelsPerMeter = (int)GET_4B(bmpinfoheader, 28);
  ------------------
  |  |  417|  2.85k|  ((unsigned int)array[offset] + \
  |  |  418|  2.85k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  2.85k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  2.85k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  487|  2.85k|    biClrUsed = GET_4B(bmpinfoheader, 32);
  ------------------
  |  |  417|  2.85k|  ((unsigned int)array[offset] + \
  |  |  418|  2.85k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  2.85k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  2.85k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  488|       |    /* biSizeImage, biClrImportant fields are ignored */
  489|       |
  490|  2.85k|    switch (source->bits_per_pixel) {
  491|  2.56k|    case 8:                     /* colormapped image */
  ------------------
  |  Branch (491:5): [True: 2.56k, False: 294]
  ------------------
  492|  2.56k|      mapentrysize = 4;         /* Windows uses RGBQUAD colormap */
  493|  2.56k|      TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, biWidth, biHeight);
  ------------------
  |  |  304|  2.56k|  ((cinfo)->err->msg_code = (code), \
  |  |  305|  2.56k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  306|  2.56k|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  307|  2.56k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  494|  2.56k|      break;
  495|     49|    case 24:                    /* RGB image */
  ------------------
  |  Branch (495:5): [True: 49, False: 2.80k]
  ------------------
  496|    280|    case 32:                    /* RGB image + Alpha channel */
  ------------------
  |  Branch (496:5): [True: 231, False: 2.62k]
  ------------------
  497|    280|      TRACEMS3(cinfo, 1, JTRC_BMP, biWidth, biHeight, source->bits_per_pixel);
  ------------------
  |  |  309|    280|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|    280|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 280]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|    280|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|    280|           (cinfo)->err->msg_code = (code); \
  |  |  312|    280|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  498|    280|      break;
  499|     14|    default:
  ------------------
  |  Branch (499:5): [True: 14, False: 2.84k]
  ------------------
  500|     14|      ERREXIT(cinfo, JERR_BMP_BADDEPTH);
  ------------------
  |  |  240|     14|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     14|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  501|     14|      break;
  502|  2.85k|    }
  503|  2.84k|    if (biCompression != 0)
  ------------------
  |  Branch (503:9): [True: 252, False: 2.59k]
  ------------------
  504|    252|      ERREXIT(cinfo, JERR_BMP_COMPRESSED);
  ------------------
  |  |  240|    252|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    252|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  505|       |
  506|  2.84k|    if (biXPelsPerMeter > 0 && biYPelsPerMeter > 0) {
  ------------------
  |  Branch (506:9): [True: 1.48k, False: 1.35k]
  |  Branch (506:32): [True: 847, False: 637]
  ------------------
  507|       |      /* Set JFIF density parameters from the BMP data */
  508|    847|      cinfo->X_density = (UINT16)(biXPelsPerMeter / 100); /* 100 cm per meter */
  509|    847|      cinfo->Y_density = (UINT16)(biYPelsPerMeter / 100);
  510|    847|      cinfo->density_unit = 2;  /* dots/cm */
  511|    847|    }
  512|  2.84k|    break;
  513|      7|  default:
  ------------------
  |  Branch (513:3): [True: 7, False: 6.66k]
  ------------------
  514|      7|    ERREXIT(cinfo, JERR_BMP_BADHEADER);
  ------------------
  |  |  240|      7|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      7|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  515|      7|    return;
  516|  6.67k|  }
  517|       |
  518|  5.59k|  if (biWidth <= 0 || biHeight <= 0)
  ------------------
  |  Branch (518:7): [True: 238, False: 5.35k]
  |  Branch (518:23): [True: 252, False: 5.10k]
  ------------------
  519|    490|    ERREXIT(cinfo, JERR_BMP_EMPTY);
  ------------------
  |  |  240|    490|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    490|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  520|  5.59k|  if (biWidth > JPEG_MAX_DIMENSION || biHeight > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  11.1k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
                if (biWidth > JPEG_MAX_DIMENSION || biHeight > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  5.00k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (520:7): [True: 588, False: 5.00k]
  |  Branch (520:39): [True: 119, False: 4.88k]
  ------------------
  521|    217|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, JPEG_MAX_DIMENSION);
  ------------------
  |  |  243|    217|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    217|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    217|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  522|  5.59k|  if (sinfo->max_pixels &&
  ------------------
  |  Branch (522:7): [True: 4.88k, False: 707]
  ------------------
  523|  4.88k|      (unsigned long long)biWidth * biHeight > sinfo->max_pixels)
  ------------------
  |  Branch (523:7): [True: 301, False: 4.58k]
  ------------------
  524|    301|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
  ------------------
  |  |  243|    301|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    301|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    301|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  525|  5.59k|  if (biPlanes != 1)
  ------------------
  |  Branch (525:7): [True: 84, False: 5.50k]
  ------------------
  526|     84|    ERREXIT(cinfo, JERR_BMP_BADPLANES);
  ------------------
  |  |  240|     84|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     84|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  527|       |
  528|       |  /* Compute distance to bitmap data --- will adjust for colormap below */
  529|  5.59k|  bPad = bfOffBits - (headerSize + 14);
  530|       |
  531|       |  /* Read the colormap, if any */
  532|  5.59k|  if (mapentrysize > 0) {
  ------------------
  |  Branch (532:7): [True: 3.21k, False: 2.38k]
  ------------------
  533|  3.21k|    if (biClrUsed <= 0)
  ------------------
  |  Branch (533:9): [True: 2.24k, False: 966]
  ------------------
  534|  2.24k|      biClrUsed = 256;          /* assume it's 256 */
  535|    966|    else if (biClrUsed > 256)
  ------------------
  |  Branch (535:14): [True: 196, False: 770]
  ------------------
  536|    196|      ERREXIT(cinfo, JERR_BMP_BADCMAP);
  ------------------
  |  |  240|    196|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    196|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  537|       |    /* Allocate space to store the colormap */
  538|  3.21k|    source->colormap = (*cinfo->mem->alloc_sarray)
  539|  3.21k|      ((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)biClrUsed, (JDIMENSION)3);
  ------------------
  |  |  889|  3.21k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  540|  3.21k|    source->cmap_length = (int)biClrUsed;
  541|       |    /* and read it from the file */
  542|  3.21k|    read_colormap(source, (int)biClrUsed, mapentrysize);
  543|       |    /* account for size of colormap */
  544|  3.21k|    bPad -= biClrUsed * mapentrysize;
  545|  3.21k|  }
  546|       |
  547|       |  /* Skip any remaining pad bytes */
  548|  5.59k|  if (bPad < 0)                 /* incorrect bfOffBits value? */
  ------------------
  |  Branch (548:7): [True: 68, False: 5.52k]
  ------------------
  549|     68|    ERREXIT(cinfo, JERR_BMP_BADHEADER);
  ------------------
  |  |  240|     68|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     68|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  550|  1.38M|  while (--bPad >= 0) {
  ------------------
  |  Branch (550:10): [True: 1.37M, False: 5.59k]
  ------------------
  551|  1.37M|    (void)read_byte(source);
  552|  1.37M|  }
  553|       |
  554|       |  /* Compute row width in file, including padding to 4-byte boundary */
  555|  5.59k|  switch (source->bits_per_pixel) {
  556|  1.52k|  case 8:
  ------------------
  |  Branch (556:3): [True: 1.52k, False: 4.06k]
  ------------------
  557|  1.52k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (557:9): [True: 0, False: 1.52k]
  ------------------
  558|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  559|  1.52k|    if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  1.52k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 1.52k]
  |  |  |  Branch (78:22): [True: 1.23k, False: 295]
  |  |  |  Branch (78:43): [True: 1.23k, False: 0]
  |  |  ------------------
  ------------------
  560|  1.23k|      cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
  561|    295|    else if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (561:14): [True: 49, False: 246]
  ------------------
  562|     49|      cinfo->input_components = 1;
  563|    246|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (563:14): [True: 246, False: 0]
  ------------------
  564|    246|      cinfo->input_components = 4;
  565|      0|    else
  566|      0|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  567|  1.52k|    row_width = (JDIMENSION)biWidth;
  568|  1.52k|    break;
  569|    511|  case 24:
  ------------------
  |  Branch (569:3): [True: 511, False: 5.08k]
  ------------------
  570|    511|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (570:9): [True: 0, False: 511]
  ------------------
  571|      0|      cinfo->in_color_space = JCS_EXT_BGR;
  572|    511|    if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|    511|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 511]
  |  |  |  Branch (78:22): [True: 365, False: 146]
  |  |  |  Branch (78:43): [True: 365, False: 0]
  |  |  ------------------
  ------------------
  573|    365|      cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
  574|    146|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (574:14): [True: 73, False: 73]
  ------------------
  575|     73|      cinfo->input_components = 4;
  576|     73|    else
  577|     73|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|     73|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     73|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  578|    511|    row_width = (JDIMENSION)biWidth * 3;
  579|    511|    break;
  580|    490|  case 32:
  ------------------
  |  Branch (580:3): [True: 490, False: 5.10k]
  ------------------
  581|    490|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (581:9): [True: 0, False: 490]
  ------------------
  582|      0|      cinfo->in_color_space = JCS_EXT_BGRA;
  583|    490|    if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|    490|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 490]
  |  |  |  Branch (78:22): [True: 350, False: 140]
  |  |  |  Branch (78:43): [True: 350, False: 0]
  |  |  ------------------
  ------------------
  584|    350|      cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
  585|    140|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (585:14): [True: 70, False: 70]
  ------------------
  586|     70|      cinfo->input_components = 4;
  587|     70|    else
  588|     70|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|     70|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     70|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  589|    490|    row_width = (JDIMENSION)biWidth * 4;
  590|    490|    break;
  591|      0|  default:
  ------------------
  |  Branch (591:3): [True: 0, False: 5.59k]
  ------------------
  592|      0|    ERREXIT(cinfo, JERR_BMP_BADDEPTH);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  593|  5.59k|  }
  594|  3.72k|  while ((row_width & 3) != 0) row_width++;
  ------------------
  |  Branch (594:10): [True: 1.33k, False: 2.38k]
  ------------------
  595|  2.38k|  source->row_width = row_width;
  596|       |
  597|  2.38k|  if (source->use_inversion_array) {
  ------------------
  |  Branch (597:7): [True: 0, False: 2.38k]
  ------------------
  598|       |    /* Allocate space for inversion array, prepare for preload pass */
  599|      0|    source->whole_image = (*cinfo->mem->request_virt_sarray)
  600|      0|      ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
  ------------------
  |  |  889|      0|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                    ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  601|      0|       row_width, (JDIMENSION)biHeight, (JDIMENSION)1);
  602|      0|    source->pub.get_pixel_rows = preload_image;
  603|      0|    if (cinfo->progress != NULL) {
  ------------------
  |  Branch (603:9): [True: 0, False: 0]
  ------------------
  604|      0|      cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
  605|      0|      progress->total_extra_passes++; /* count file input as separate pass */
  606|      0|    }
  607|  2.38k|  } else {
  608|  2.38k|    source->iobuffer = (unsigned char *)
  609|  2.38k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, row_width);
  ------------------
  |  |  889|  2.38k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  610|  2.38k|    switch (source->bits_per_pixel) {
  611|  1.52k|    case 8:
  ------------------
  |  Branch (611:5): [True: 1.52k, False: 858]
  ------------------
  612|  1.52k|      source->pub.get_pixel_rows = get_8bit_row;
  613|  1.52k|      break;
  614|    438|    case 24:
  ------------------
  |  Branch (614:5): [True: 438, False: 1.94k]
  ------------------
  615|    438|      source->pub.get_pixel_rows = get_24bit_row;
  616|    438|      break;
  617|    420|    case 32:
  ------------------
  |  Branch (617:5): [True: 420, False: 1.96k]
  ------------------
  618|    420|      source->pub.get_pixel_rows = get_32bit_row;
  619|    420|      break;
  620|      0|    default:
  ------------------
  |  Branch (620:5): [True: 0, False: 2.38k]
  ------------------
  621|      0|      ERREXIT(cinfo, JERR_BMP_BADDEPTH);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  622|  2.38k|    }
  623|  2.38k|  }
  624|       |
  625|       |  /* Allocate one-row buffer for returned data */
  626|  2.38k|  source->pub.buffer = (*cinfo->mem->alloc_sarray)
  627|  2.38k|    ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  2.38k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  628|  2.38k|     (JDIMENSION)biWidth * (JDIMENSION)cinfo->input_components, (JDIMENSION)1);
  629|  2.38k|  source->pub.buffer_height = 1;
  630|       |
  631|  2.38k|  cinfo->data_precision = 8;
  632|  2.38k|  cinfo->image_width = (JDIMENSION)biWidth;
  633|  2.38k|  cinfo->image_height = (JDIMENSION)biHeight;
  634|  2.38k|}
rdbmp.c:read_colormap:
   90|  3.01k|{
   91|  3.01k|  int i, gray = 1;
   92|       |
   93|  3.01k|  switch (mapentrysize) {
   94|  1.40k|  case 3:
  ------------------
  |  Branch (94:3): [True: 1.40k, False: 1.61k]
  ------------------
   95|       |    /* BGR format (occurs in OS/2 files) */
   96|   257k|    for (i = 0; i < cmaplen; i++) {
  ------------------
  |  Branch (96:17): [True: 256k, False: 1.40k]
  ------------------
   97|   256k|      sinfo->colormap[2][i] = (JSAMPLE)read_byte(sinfo);
   98|   256k|      sinfo->colormap[1][i] = (JSAMPLE)read_byte(sinfo);
   99|   256k|      sinfo->colormap[0][i] = (JSAMPLE)read_byte(sinfo);
  100|   256k|      if (sinfo->colormap[2][i] != sinfo->colormap[1][i] ||
  ------------------
  |  Branch (100:11): [True: 141k, False: 114k]
  ------------------
  101|   114k|          sinfo->colormap[1][i] != sinfo->colormap[0][i])
  ------------------
  |  Branch (101:11): [True: 20.6k, False: 94.2k]
  ------------------
  102|   161k|        gray = 0;
  103|   256k|    }
  104|  1.40k|    break;
  105|  1.61k|  case 4:
  ------------------
  |  Branch (105:3): [True: 1.61k, False: 1.40k]
  ------------------
  106|       |    /* BGR0 format (occurs in MS Windows files) */
  107|  85.3k|    for (i = 0; i < cmaplen; i++) {
  ------------------
  |  Branch (107:17): [True: 83.7k, False: 1.61k]
  ------------------
  108|  83.7k|      sinfo->colormap[2][i] = (JSAMPLE)read_byte(sinfo);
  109|  83.7k|      sinfo->colormap[1][i] = (JSAMPLE)read_byte(sinfo);
  110|  83.7k|      sinfo->colormap[0][i] = (JSAMPLE)read_byte(sinfo);
  111|  83.7k|      (void)read_byte(sinfo);
  112|  83.7k|      if (sinfo->colormap[2][i] != sinfo->colormap[1][i] ||
  ------------------
  |  Branch (112:11): [True: 30.6k, False: 53.0k]
  ------------------
  113|  53.0k|          sinfo->colormap[1][i] != sinfo->colormap[0][i])
  ------------------
  |  Branch (113:11): [True: 11.6k, False: 41.4k]
  ------------------
  114|  41.5k|        gray = 0;
  115|  83.7k|    }
  116|  1.61k|    break;
  117|      0|  default:
  ------------------
  |  Branch (117:3): [True: 0, False: 3.01k]
  ------------------
  118|      0|    ERREXIT(sinfo->cinfo, JERR_BMP_BADCMAP);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  119|      0|    break;
  120|  3.01k|  }
  121|       |
  122|  1.81k|  if ((sinfo->cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (122:8): [True: 0, False: 1.81k]
  ------------------
  123|  1.81k|       sinfo->cinfo->in_color_space == JCS_RGB) && gray)
  ------------------
  |  Branch (123:8): [True: 0, False: 1.81k]
  |  Branch (123:52): [True: 0, False: 0]
  ------------------
  124|      0|    sinfo->cinfo->in_color_space = JCS_GRAYSCALE;
  125|       |
  126|  1.81k|  if (sinfo->cinfo->in_color_space == JCS_GRAYSCALE && !gray)
  ------------------
  |  Branch (126:7): [True: 259, False: 1.55k]
  |  Branch (126:56): [True: 208, False: 51]
  ------------------
  127|    208|    ERREXIT(sinfo->cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    208|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    208|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  128|  1.81k|}
rdbmp.c:read_byte:
   77|  2.47M|{
   78|  2.47M|  register FILE *infile = sinfo->pub.input_file;
   79|  2.47M|  register int c;
   80|       |
   81|  2.47M|  if ((c = getc(infile)) == EOF)
  ------------------
  |  Branch (81:7): [True: 1.50k, False: 2.47M]
  ------------------
   82|  1.50k|    ERREXIT(sinfo->cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|  1.50k|  ((cinfo)->err->msg_code = (code), \
  |  |  241|  1.50k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   83|  2.47M|  return c;
   84|  2.47M|}
rdbmp.c:get_8bit_row:
  141|  9.43M|{
  142|  9.43M|  bmp_source_ptr source = (bmp_source_ptr)sinfo;
  143|  9.43M|  register JSAMPARRAY colormap = source->colormap;
  144|  9.43M|  int cmaplen = source->cmap_length;
  145|  9.43M|  JSAMPARRAY image_ptr;
  146|  9.43M|  register int t;
  147|  9.43M|  register JSAMPROW inptr, outptr;
  148|  9.43M|  register JDIMENSION col;
  149|       |
  150|  9.43M|  if (source->use_inversion_array) {
  ------------------
  |  Branch (150:7): [True: 0, False: 9.43M]
  ------------------
  151|       |    /* Fetch next row from virtual array */
  152|      0|    source->source_row--;
  153|      0|    image_ptr = (*cinfo->mem->access_virt_sarray)
  154|      0|      ((j_common_ptr)cinfo, source->whole_image,
  155|      0|       source->source_row, (JDIMENSION)1, FALSE);
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  156|      0|    inptr = image_ptr[0];
  157|  9.43M|  } else {
  158|  9.43M|    if (!ReadOK(source->pub.input_file, source->iobuffer, source->row_width))
  ------------------
  |  |   36|  9.43M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (158:9): [True: 410, False: 9.43M]
  ------------------
  159|    410|      ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    410|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    410|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  160|  9.43M|    inptr = source->iobuffer;
  161|  9.43M|  }
  162|       |
  163|       |  /* Expand the colormap indexes to real data */
  164|  9.43M|  outptr = source->pub.buffer[0];
  165|  9.43M|  if (cinfo->in_color_space == JCS_GRAYSCALE) {
  ------------------
  |  Branch (165:7): [True: 715, False: 9.43M]
  ------------------
  166|  9.69k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (166:36): [True: 8.97k, False: 715]
  ------------------
  167|  8.97k|      t = *inptr++;
  168|  8.97k|      if (t >= cmaplen)
  ------------------
  |  Branch (168:11): [True: 17, False: 8.96k]
  ------------------
  169|     17|        ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
  ------------------
  |  |  240|     17|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     17|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  170|  8.97k|      *outptr++ = colormap[0][t];
  171|  8.97k|    }
  172|  9.43M|  } else if (cinfo->in_color_space == JCS_CMYK) {
  ------------------
  |  Branch (172:14): [True: 1.57M, False: 7.86M]
  ------------------
  173|  17.3M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (173:36): [True: 15.7M, False: 1.57M]
  ------------------
  174|  15.7M|      t = *inptr++;
  175|  15.7M|      if (t >= cmaplen)
  ------------------
  |  Branch (175:11): [True: 24, False: 15.7M]
  ------------------
  176|     24|        ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
  ------------------
  |  |  240|     24|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     24|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  177|  15.7M|      rgb_to_cmyk(255, colormap[0][t], colormap[1][t], colormap[2][t], outptr,
  178|  15.7M|                  outptr + 1, outptr + 2, outptr + 3);
  179|  15.7M|      outptr += 4;
  180|  15.7M|    }
  181|  7.86M|  } else {
  182|  7.86M|    register int rindex = rgb_red[cinfo->in_color_space];
  183|  7.86M|    register int gindex = rgb_green[cinfo->in_color_space];
  184|  7.86M|    register int bindex = rgb_blue[cinfo->in_color_space];
  185|  7.86M|    register int aindex = alpha_index[cinfo->in_color_space];
  186|  7.86M|    register int ps = rgb_pixelsize[cinfo->in_color_space];
  187|       |
  188|  7.86M|    if (aindex >= 0) {
  ------------------
  |  Branch (188:9): [True: 1.57M, False: 6.28M]
  ------------------
  189|  17.3M|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (189:38): [True: 15.7M, False: 1.57M]
  ------------------
  190|  15.7M|        t = *inptr++;
  191|  15.7M|        if (t >= cmaplen)
  ------------------
  |  Branch (191:13): [True: 24, False: 15.7M]
  ------------------
  192|     24|          ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
  ------------------
  |  |  240|     24|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     24|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  193|  15.7M|        outptr[rindex] = colormap[0][t];
  194|  15.7M|        outptr[gindex] = colormap[1][t];
  195|  15.7M|        outptr[bindex] = colormap[2][t];
  196|  15.7M|        outptr[aindex] = 0xFF;
  197|  15.7M|        outptr += ps;
  198|  15.7M|      }
  199|  6.28M|    } else {
  200|  69.4M|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (200:38): [True: 63.1M, False: 6.28M]
  ------------------
  201|  63.1M|        t = *inptr++;
  202|  63.1M|        if (t >= cmaplen)
  ------------------
  |  Branch (202:13): [True: 96, False: 63.1M]
  ------------------
  203|     96|          ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
  ------------------
  |  |  240|     96|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     96|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  204|  63.1M|        outptr[rindex] = colormap[0][t];
  205|  63.1M|        outptr[gindex] = colormap[1][t];
  206|  63.1M|        outptr[bindex] = colormap[2][t];
  207|  63.1M|        outptr += ps;
  208|  63.1M|      }
  209|  6.28M|    }
  210|  7.86M|  }
  211|       |
  212|  9.43M|  return 1;
  213|  9.43M|}
rdbmp.c:get_24bit_row:
  219|   484k|{
  220|   484k|  bmp_source_ptr source = (bmp_source_ptr)sinfo;
  221|   484k|  JSAMPARRAY image_ptr;
  222|   484k|  register JSAMPROW inptr, outptr;
  223|   484k|  register JDIMENSION col;
  224|       |
  225|   484k|  if (source->use_inversion_array) {
  ------------------
  |  Branch (225:7): [True: 0, False: 484k]
  ------------------
  226|       |    /* Fetch next row from virtual array */
  227|      0|    source->source_row--;
  228|      0|    image_ptr = (*cinfo->mem->access_virt_sarray)
  229|      0|      ((j_common_ptr)cinfo, source->whole_image,
  230|      0|       source->source_row, (JDIMENSION)1, FALSE);
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  231|      0|    inptr = image_ptr[0];
  232|   484k|  } else {
  233|   484k|    if (!ReadOK(source->pub.input_file, source->iobuffer, source->row_width))
  ------------------
  |  |   36|   484k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (233:9): [True: 420, False: 484k]
  ------------------
  234|    420|      ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    420|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    420|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  235|   484k|    inptr = source->iobuffer;
  236|   484k|  }
  237|       |
  238|       |  /* Transfer data.  Note source values are in BGR order
  239|       |   * (even though Microsoft's own documents say the opposite).
  240|       |   */
  241|   484k|  outptr = source->pub.buffer[0];
  242|   484k|  if (cinfo->in_color_space == JCS_EXT_BGR) {
  ------------------
  |  Branch (242:7): [True: 80.6k, False: 403k]
  ------------------
  243|  80.6k|    memcpy(outptr, inptr, source->row_width);
  244|   403k|  } else if (cinfo->in_color_space == JCS_CMYK) {
  ------------------
  |  Branch (244:14): [True: 80.6k, False: 323k]
  ------------------
  245|   261k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (245:36): [True: 180k, False: 80.6k]
  ------------------
  246|   180k|      JSAMPLE b = *inptr++, g = *inptr++, r = *inptr++;
  247|   180k|      rgb_to_cmyk(255, r, g, b, outptr, outptr + 1, outptr + 2, outptr + 3);
  248|   180k|      outptr += 4;
  249|   180k|    }
  250|   323k|  } else {
  251|   323k|    register int rindex = rgb_red[cinfo->in_color_space];
  252|   323k|    register int gindex = rgb_green[cinfo->in_color_space];
  253|   323k|    register int bindex = rgb_blue[cinfo->in_color_space];
  254|   323k|    register int aindex = alpha_index[cinfo->in_color_space];
  255|   323k|    register int ps = rgb_pixelsize[cinfo->in_color_space];
  256|       |
  257|   323k|    if (aindex >= 0) {
  ------------------
  |  Branch (257:9): [True: 80.6k, False: 242k]
  ------------------
  258|   261k|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (258:38): [True: 180k, False: 80.6k]
  ------------------
  259|   180k|        outptr[bindex] = *inptr++;
  260|   180k|        outptr[gindex] = *inptr++;
  261|   180k|        outptr[rindex] = *inptr++;
  262|   180k|        outptr[aindex] = 0xFF;
  263|   180k|        outptr += ps;
  264|   180k|      }
  265|   242k|    } else {
  266|   784k|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (266:38): [True: 541k, False: 242k]
  ------------------
  267|   541k|        outptr[bindex] = *inptr++;
  268|   541k|        outptr[gindex] = *inptr++;
  269|   541k|        outptr[rindex] = *inptr++;
  270|   541k|        outptr += ps;
  271|   541k|      }
  272|   242k|    }
  273|   323k|  }
  274|       |
  275|   484k|  return 1;
  276|   484k|}
rdbmp.c:get_32bit_row:
  282|  1.48M|{
  283|  1.48M|  bmp_source_ptr source = (bmp_source_ptr)sinfo;
  284|  1.48M|  JSAMPARRAY image_ptr;
  285|  1.48M|  register JSAMPROW inptr, outptr;
  286|  1.48M|  register JDIMENSION col;
  287|       |
  288|  1.48M|  if (source->use_inversion_array) {
  ------------------
  |  Branch (288:7): [True: 0, False: 1.48M]
  ------------------
  289|       |    /* Fetch next row from virtual array */
  290|      0|    source->source_row--;
  291|      0|    image_ptr = (*cinfo->mem->access_virt_sarray)
  292|      0|      ((j_common_ptr)cinfo, source->whole_image,
  293|      0|       source->source_row, (JDIMENSION)1, FALSE);
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  294|      0|    inptr = image_ptr[0];
  295|  1.48M|  } else {
  296|  1.48M|    if (!ReadOK(source->pub.input_file, source->iobuffer, source->row_width))
  ------------------
  |  |   36|  1.48M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (296:9): [True: 330, False: 1.48M]
  ------------------
  297|    330|      ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    330|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    330|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  298|  1.48M|    inptr = source->iobuffer;
  299|  1.48M|  }
  300|       |
  301|       |  /* Transfer data.  Note source values are in BGR order
  302|       |   * (even though Microsoft's own documents say the opposite).
  303|       |   */
  304|  1.48M|  outptr = source->pub.buffer[0];
  305|  1.48M|  if (cinfo->in_color_space == JCS_EXT_BGRX ||
  ------------------
  |  Branch (305:7): [True: 330, False: 1.48M]
  ------------------
  306|  1.48M|      cinfo->in_color_space == JCS_EXT_BGRA) {
  ------------------
  |  Branch (306:7): [True: 247k, False: 1.23M]
  ------------------
  307|   247k|    memcpy(outptr, inptr, source->row_width);
  308|  1.23M|  } else if (cinfo->in_color_space == JCS_CMYK) {
  ------------------
  |  Branch (308:14): [True: 247k, False: 988k]
  ------------------
  309|   887k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (309:36): [True: 640k, False: 247k]
  ------------------
  310|   640k|      JSAMPLE b = *inptr++, g = *inptr++, r = *inptr++;
  311|   640k|      rgb_to_cmyk(255, r, g, b, outptr, outptr + 1, outptr + 2, outptr + 3);
  312|   640k|      inptr++;                          /* skip the 4th byte (Alpha channel) */
  313|   640k|      outptr += 4;
  314|   640k|    }
  315|   988k|  } else {
  316|   988k|    register int rindex = rgb_red[cinfo->in_color_space];
  317|   988k|    register int gindex = rgb_green[cinfo->in_color_space];
  318|   988k|    register int bindex = rgb_blue[cinfo->in_color_space];
  319|   988k|    register int aindex = alpha_index[cinfo->in_color_space];
  320|   988k|    register int ps = rgb_pixelsize[cinfo->in_color_space];
  321|       |
  322|   988k|    if (aindex >= 0) {
  ------------------
  |  Branch (322:9): [True: 0, False: 988k]
  ------------------
  323|      0|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (323:38): [True: 0, False: 0]
  ------------------
  324|      0|        outptr[bindex] = *inptr++;
  325|      0|        outptr[gindex] = *inptr++;
  326|      0|        outptr[rindex] = *inptr++;
  327|      0|        outptr[aindex] = *inptr++;
  328|      0|        outptr += ps;
  329|      0|      }
  330|   988k|    } else {
  331|  3.55M|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (331:38): [True: 2.56M, False: 988k]
  ------------------
  332|  2.56M|        outptr[bindex] = *inptr++;
  333|  2.56M|        outptr[gindex] = *inptr++;
  334|  2.56M|        outptr[rindex] = *inptr++;
  335|  2.56M|        inptr++;                        /* skip the 4th byte (Alpha channel) */
  336|  2.56M|        outptr += ps;
  337|  2.56M|      }
  338|   988k|    }
  339|   988k|  }
  340|       |
  341|  1.48M|  return 1;
  342|  1.48M|}
rdbmp.c:finish_input_bmp:
  651|  6.67k|{
  652|       |  /* no work */
  653|  6.67k|}

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

jinit_read_ppm:
  924|  17.9k|{
  925|  17.9k|  ppm_source_ptr source;
  926|       |
  927|  17.9k|#if BITS_IN_JSAMPLE == 8
  928|  17.9k|  if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|  35.8k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (928:7): [True: 0, False: 17.9k]
  |  Branch (928:50): [True: 0, False: 17.9k]
  ------------------
  929|       |#else
  930|       |  if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  931|       |      cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  932|       |#endif
  933|      0|    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  934|       |
  935|       |  /* Create module interface object */
  936|  17.9k|  source = (ppm_source_ptr)
  937|  17.9k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  17.9k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  938|  17.9k|                                sizeof(ppm_source_struct));
  939|       |  /* Fill in method ptrs, except get_pixel_rows which start_input sets */
  940|  17.9k|  source->pub.start_input = start_input_ppm;
  941|  17.9k|  source->pub.read_icc_profile = read_icc_profile_ppm;
  942|  17.9k|  source->pub.finish_input = finish_input_ppm;
  943|  17.9k|  source->pub.max_pixels = 0;
  944|       |
  945|  17.9k|  return (cjpeg_source_ptr)source;
  946|  17.9k|}
rdppm-8.c:start_input_ppm:
  703|  17.9k|{
  704|  17.9k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  705|  17.9k|  int c;
  706|  17.9k|  unsigned int w, h, maxval;
  707|  17.9k|  boolean need_iobuffer, use_raw_buffer, need_rescale;
  708|       |
  709|  17.9k|  if (getc(source->pub.input_file) != 'P')
  ------------------
  |  Branch (709:7): [True: 0, False: 17.9k]
  ------------------
  710|      0|    ERREXIT(cinfo, JERR_PPM_NOT);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  711|       |
  712|  17.9k|  c = getc(source->pub.input_file); /* subformat discriminator character */
  713|       |
  714|       |  /* detect unsupported variants (ie, PBM) before trying to read header */
  715|  17.9k|  switch (c) {
  716|  1.29k|  case '2':                     /* it's a text-format PGM file */
  ------------------
  |  Branch (716:3): [True: 1.29k, False: 16.6k]
  ------------------
  717|  2.87k|  case '3':                     /* it's a text-format PPM file */
  ------------------
  |  Branch (717:3): [True: 1.57k, False: 16.3k]
  ------------------
  718|  13.7k|  case '5':                     /* it's a raw-format PGM file */
  ------------------
  |  Branch (718:3): [True: 10.8k, False: 7.03k]
  ------------------
  719|  17.8k|  case '6':                     /* it's a raw-format PPM file */
  ------------------
  |  Branch (719:3): [True: 4.15k, False: 13.7k]
  ------------------
  720|  17.8k|    break;
  721|     14|  default:
  ------------------
  |  Branch (721:3): [True: 14, False: 17.8k]
  ------------------
  722|     14|    ERREXIT(cinfo, JERR_PPM_NOT);
  ------------------
  |  |  240|     14|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     14|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  723|     14|    break;
  724|  17.9k|  }
  725|       |
  726|       |  /* fetch the remaining header info */
  727|  17.8k|  w = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  728|  17.8k|  h = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  729|  17.8k|  maxval = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  730|       |
  731|  17.8k|  if (w <= 0 || h <= 0 || maxval <= 0) /* error check */
  ------------------
  |  Branch (731:7): [True: 1.17k, False: 16.7k]
  |  Branch (731:17): [True: 14, False: 16.7k]
  |  Branch (731:27): [True: 7, False: 16.7k]
  ------------------
  732|     42|    ERREXIT(cinfo, JERR_PPM_NOT);
  ------------------
  |  |  240|     42|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     42|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  733|  17.8k|  if (w > JPEG_MAX_DIMENSION || h > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  35.7k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
                if (w > JPEG_MAX_DIMENSION || h > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  16.6k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (733:7): [True: 1.20k, False: 16.6k]
  |  Branch (733:33): [True: 14, False: 16.6k]
  ------------------
  734|     21|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, JPEG_MAX_DIMENSION);
  ------------------
  |  |  243|     21|  ((cinfo)->err->msg_code = (code), \
  |  |  244|     21|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|     21|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  735|  17.8k|  if (sinfo->max_pixels && (unsigned long long)w * h > sinfo->max_pixels)
  ------------------
  |  Branch (735:7): [True: 16.6k, False: 1.21k]
  |  Branch (735:28): [True: 210, False: 16.4k]
  ------------------
  736|    210|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
  ------------------
  |  |  243|    210|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    210|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    210|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  737|       |
  738|  17.8k|  cinfo->image_width = (JDIMENSION)w;
  739|  17.8k|  cinfo->image_height = (JDIMENSION)h;
  740|  17.8k|  source->maxval = maxval;
  741|       |
  742|       |  /* initialize flags to most common settings */
  743|  17.8k|  need_iobuffer = TRUE;         /* do we need an I/O buffer? */
  ------------------
  |  |  210|  17.8k|#define TRUE    1
  ------------------
  744|  17.8k|  use_raw_buffer = FALSE;       /* do we map input buffer onto I/O buffer? */
  ------------------
  |  |  207|  17.8k|#define FALSE   0               /* values of boolean */
  ------------------
  745|  17.8k|  need_rescale = TRUE;          /* do we need a rescale array? */
  ------------------
  |  |  210|  17.8k|#define TRUE    1
  ------------------
  746|       |
  747|  17.8k|  switch (c) {
  ------------------
  |  Branch (747:11): [True: 16.4k, False: 1.42k]
  ------------------
  748|    959|  case '2':                     /* it's a text-format PGM file */
  ------------------
  |  Branch (748:3): [True: 959, False: 16.9k]
  ------------------
  749|    959|    if (cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (749:9): [True: 0, False: 959]
  ------------------
  750|    959|        cinfo->in_color_space == JCS_RGB)
  ------------------
  |  Branch (750:9): [True: 0, False: 959]
  ------------------
  751|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  752|    959|    TRACEMS3(cinfo, 1, JTRC_PGM_TEXT, w, h, maxval);
  ------------------
  |  |  309|    959|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|    959|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 959]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|    959|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|    959|           (cinfo)->err->msg_code = (code); \
  |  |  312|    959|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  753|    959|    if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (753:9): [True: 137, False: 822]
  ------------------
  754|    137|      source->pub.get_pixel_rows = get_text_gray_row;
  755|    822|    else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|    822|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 822]
  |  |  |  Branch (78:22): [True: 685, False: 137]
  |  |  |  Branch (78:43): [True: 685, False: 0]
  |  |  ------------------
  ------------------
  756|    685|      source->pub.get_pixel_rows = get_text_gray_rgb_row;
  757|    137|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (757:14): [True: 137, False: 0]
  ------------------
  758|    137|      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|    959|    need_iobuffer = FALSE;
  ------------------
  |  |  207|    959|#define FALSE   0               /* values of boolean */
  ------------------
  762|    959|    break;
  763|       |
  764|  1.25k|  case '3':                     /* it's a text-format PPM file */
  ------------------
  |  Branch (764:3): [True: 1.25k, False: 16.6k]
  ------------------
  765|  1.25k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (765:9): [True: 0, False: 1.25k]
  ------------------
  766|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  767|  1.25k|    TRACEMS3(cinfo, 1, JTRC_PPM_TEXT, w, h, maxval);
  ------------------
  |  |  309|  1.25k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.25k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.25k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  1.25k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  1.25k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  1.25k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  768|  1.25k|    if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  1.25k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 1.25k]
  |  |  |  Branch (78:22): [True: 895, False: 358]
  |  |  |  Branch (78:43): [True: 895, False: 0]
  |  |  ------------------
  ------------------
  769|    895|      source->pub.get_pixel_rows = get_text_rgb_row;
  770|    358|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (770:14): [True: 179, False: 179]
  ------------------
  771|    179|      source->pub.get_pixel_rows = get_text_rgb_cmyk_row;
  772|    179|    else
  773|    179|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    179|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    179|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  774|  1.25k|    need_iobuffer = FALSE;
  ------------------
  |  |  207|  1.25k|#define FALSE   0               /* values of boolean */
  ------------------
  775|  1.25k|    break;
  776|       |
  777|  10.4k|  case '5':                     /* it's a raw-format PGM file */
  ------------------
  |  Branch (777:3): [True: 10.4k, False: 7.41k]
  ------------------
  778|  10.4k|    if (cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (778:9): [True: 0, False: 10.4k]
  ------------------
  779|  10.4k|        cinfo->in_color_space == JCS_RGB)
  ------------------
  |  Branch (779:9): [True: 0, False: 10.4k]
  ------------------
  780|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  781|  10.4k|    TRACEMS3(cinfo, 1, JTRC_PGM, w, h, maxval);
  ------------------
  |  |  309|  10.4k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  10.4k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 10.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  10.4k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  10.4k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  10.4k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  782|  10.4k|    if (maxval > 255) {
  ------------------
  |  Branch (782:9): [True: 742, False: 9.74k]
  ------------------
  783|    742|      if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (783:11): [True: 106, False: 636]
  ------------------
  784|    106|        source->pub.get_pixel_rows = get_word_gray_row;
  785|    636|      else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|    636|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 636]
  |  |  |  Branch (78:22): [True: 530, False: 106]
  |  |  |  Branch (78:43): [True: 530, False: 0]
  |  |  ------------------
  ------------------
  786|    530|        source->pub.get_pixel_rows = get_word_gray_rgb_row;
  787|    106|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (787:16): [True: 106, False: 0]
  ------------------
  788|    106|        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|    742|#if BITS_IN_JSAMPLE == 8
  792|  9.74k|    } else if (maxval <= _MAXJSAMPLE &&
  ------------------
  |  |  226|  9.74k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|  19.4k|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
  |  Branch (792:16): [True: 9.74k, False: 0]
  ------------------
  793|  9.74k|               maxval == ((1U << cinfo->data_precision) - 1U) &&
  ------------------
  |  Branch (793:16): [True: 1.05k, False: 8.68k]
  ------------------
  794|  1.05k|               cinfo->in_color_space == JCS_GRAYSCALE) {
  ------------------
  |  Branch (794:16): [True: 151, False: 906]
  ------------------
  795|    151|      source->pub.get_pixel_rows = get_raw_row;
  796|    151|      use_raw_buffer = TRUE;
  ------------------
  |  |  210|    151|#define TRUE    1
  ------------------
  797|    151|      need_rescale = FALSE;
  ------------------
  |  |  207|    151|#define FALSE   0               /* values of boolean */
  ------------------
  798|    151|#endif
  799|  9.59k|    } else {
  800|  9.59k|      if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (800:11): [True: 1.24k, False: 8.35k]
  ------------------
  801|  1.24k|        source->pub.get_pixel_rows = get_scaled_gray_row;
  802|  8.35k|      else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  8.35k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 8.35k]
  |  |  |  Branch (78:22): [True: 6.96k, False: 1.39k]
  |  |  |  Branch (78:43): [True: 6.96k, False: 0]
  |  |  ------------------
  ------------------
  803|  6.96k|        source->pub.get_pixel_rows = get_gray_rgb_row;
  804|  1.39k|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (804:16): [True: 1.39k, False: 0]
  ------------------
  805|  1.39k|        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|  9.59k|    }
  809|  10.4k|    break;
  810|       |
  811|  3.77k|  case '6':                     /* it's a raw-format PPM file */
  ------------------
  |  Branch (811:3): [True: 3.77k, False: 14.1k]
  ------------------
  812|  3.77k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (812:9): [True: 0, False: 3.77k]
  ------------------
  813|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  814|  3.77k|    TRACEMS3(cinfo, 1, JTRC_PPM, w, h, maxval);
  ------------------
  |  |  309|  3.77k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  3.77k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 3.77k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  3.77k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  3.77k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  3.77k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  815|  3.77k|    if (maxval > 255) {
  ------------------
  |  Branch (815:9): [True: 1.09k, False: 2.68k]
  ------------------
  816|  1.09k|      if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  1.09k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 1.09k]
  |  |  |  Branch (78:22): [True: 780, False: 312]
  |  |  |  Branch (78:43): [True: 780, False: 0]
  |  |  ------------------
  ------------------
  817|    780|        source->pub.get_pixel_rows = get_word_rgb_row;
  818|    312|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (818:16): [True: 156, False: 156]
  ------------------
  819|    156|        source->pub.get_pixel_rows = get_word_rgb_cmyk_row;
  820|    156|      else
  821|    156|        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    156|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    156|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  822|  1.09k|#if BITS_IN_JSAMPLE == 8
  823|  2.68k|    } else if (maxval <= _MAXJSAMPLE &&
  ------------------
  |  |  226|  2.68k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|  5.36k|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
  |  Branch (823:16): [True: 2.68k, False: 0]
  ------------------
  824|  2.68k|               maxval == ((1U << cinfo->data_precision) - 1U) &&
  ------------------
  |  Branch (824:16): [True: 616, False: 2.06k]
  ------------------
  825|    616|#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3
  826|    616|               (cinfo->in_color_space == JCS_EXT_RGB ||
  ------------------
  |  Branch (826:17): [True: 88, False: 528]
  ------------------
  827|    528|                cinfo->in_color_space == JCS_RGB)) {
  ------------------
  |  Branch (827:17): [True: 0, False: 528]
  ------------------
  828|       |#else
  829|       |               cinfo->in_color_space == JCS_EXT_RGB) {
  830|       |#endif
  831|     88|      source->pub.get_pixel_rows = get_raw_row;
  832|     88|      use_raw_buffer = TRUE;
  ------------------
  |  |  210|     88|#define TRUE    1
  ------------------
  833|     88|      need_rescale = FALSE;
  ------------------
  |  |  207|     88|#define FALSE   0               /* values of boolean */
  ------------------
  834|     88|#endif
  835|  2.59k|    } else {
  836|  2.59k|      if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  2.59k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 2.59k]
  |  |  |  Branch (78:22): [True: 1.82k, False: 766]
  |  |  |  Branch (78:43): [True: 1.82k, False: 0]
  |  |  ------------------
  ------------------
  837|  1.82k|        source->pub.get_pixel_rows = get_rgb_row;
  838|    766|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (838:16): [True: 383, False: 383]
  ------------------
  839|    383|        source->pub.get_pixel_rows = get_rgb_cmyk_row;
  840|    383|      else
  841|    383|        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    383|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    383|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  842|  2.59k|    }
  843|  3.77k|    break;
  844|  17.8k|  }
  845|       |
  846|  15.7k|  if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  15.7k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 15.7k]
  |  |  |  Branch (78:22): [True: 11.7k, False: 3.98k]
  |  |  |  Branch (78:43): [True: 11.7k, False: 0]
  |  |  ------------------
  ------------------
  847|  11.7k|    cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
  848|  3.98k|  else if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (848:12): [True: 1.63k, False: 2.35k]
  ------------------
  849|  1.63k|    cinfo->input_components = 1;
  850|  2.35k|  else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (850:12): [True: 2.35k, False: 0]
  ------------------
  851|  2.35k|    cinfo->input_components = 4;
  852|       |
  853|       |  /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */
  854|  15.7k|  if (need_iobuffer) {
  ------------------
  |  Branch (854:7): [True: 13.7k, False: 2.03k]
  ------------------
  855|  13.7k|    if (c == '6')
  ------------------
  |  Branch (855:9): [True: 3.23k, False: 10.4k]
  ------------------
  856|  3.23k|      source->buffer_width = (size_t)w * 3 * (maxval <= 255 ? 1 : 2);
  ------------------
  |  Branch (856:47): [True: 2.29k, False: 936]
  ------------------
  857|  10.4k|    else
  858|  10.4k|      source->buffer_width = (size_t)w * (maxval <= 255 ? 1 : 2);
  ------------------
  |  Branch (858:43): [True: 9.74k, False: 742]
  ------------------
  859|  13.7k|    source->iobuffer = (unsigned char *)
  860|  13.7k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  13.7k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  861|  13.7k|                                  source->buffer_width);
  862|  13.7k|  }
  863|       |
  864|       |  /* Create compressor input buffer. */
  865|  15.7k|  if (use_raw_buffer) {
  ------------------
  |  Branch (865:7): [True: 239, False: 15.5k]
  ------------------
  866|       |    /* For unscaled raw-input case, we can just map it onto the I/O buffer. */
  867|       |    /* Synthesize a _JSAMPARRAY pointer structure */
  868|    239|    source->pixrow = (_JSAMPROW)source->iobuffer;
  869|    239|    source->pub._buffer = &source->pixrow;
  ------------------
  |  |  326|    239|#define _buffer  buffer
  ------------------
  870|    239|    source->pub.buffer_height = 1;
  871|  15.5k|  } else {
  872|       |    /* Need to translate anyway, so make a separate sample buffer. */
  873|  15.5k|    source->pub._buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  ------------------
  |  |  326|  15.5k|#define _buffer  buffer
  ------------------
  874|  15.5k|      ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  15.5k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  875|  15.5k|       (JDIMENSION)w * cinfo->input_components, (JDIMENSION)1);
  876|  15.5k|    source->pub.buffer_height = 1;
  877|  15.5k|  }
  878|       |
  879|       |  /* Compute the rescaling array if required. */
  880|  15.7k|  if (need_rescale) {
  ------------------
  |  Branch (880:7): [True: 15.5k, False: 239]
  ------------------
  881|  15.5k|    size_t val, half_maxval;
  882|       |
  883|       |    /* On 16-bit-int machines we have to be careful of maxval = 65535 */
  884|  15.5k|    source->rescale = (_JSAMPLE *)
  885|  15.5k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  15.5k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  886|  15.5k|                                  (MAX(maxval, 255) + 1L) * sizeof(_JSAMPLE));
  ------------------
  |  |  513|  15.5k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 1.90k, False: 13.6k]
  |  |  ------------------
  ------------------
  887|  15.5k|    memset(source->rescale, 0, (MAX(maxval, 255) + 1L) * sizeof(_JSAMPLE));
  ------------------
  |  |  513|  15.5k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 1.90k, False: 13.6k]
  |  |  ------------------
  ------------------
  888|  15.5k|    half_maxval = (size_t)maxval / 2;
  889|  22.0M|    for (val = 0; val <= (size_t)maxval; val++) {
  ------------------
  |  Branch (889:19): [True: 22.0M, False: 15.5k]
  ------------------
  890|       |      /* The multiplication here must be done in 32 bits to avoid overflow */
  891|  22.0M|      source->rescale[val] =
  892|  22.0M|        (_JSAMPLE)((val * ((1 << cinfo->data_precision) - 1) + half_maxval) /
  893|  22.0M|                   maxval);
  894|  22.0M|    }
  895|  15.5k|  }
  896|  15.7k|}
rdppm-8.c:read_pbm_integer:
   92|   120k|{
   93|   120k|  register int ch;
   94|   120k|  register unsigned int val;
   95|       |
   96|       |  /* Skip any leading whitespace */
   97|   127k|  do {
   98|   127k|    ch = pbm_getc(infile);
   99|   127k|    if (ch == EOF)
  ------------------
  |  Branch (99:9): [True: 2.65k, False: 125k]
  ------------------
  100|  2.65k|      ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|  2.65k|  ((cinfo)->err->msg_code = (code), \
  |  |  241|  2.65k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  101|   127k|  } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
  ------------------
  |  Branch (101:12): [True: 3.83k, False: 123k]
  |  Branch (101:25): [True: 1.62k, False: 122k]
  |  Branch (101:39): [True: 3.06k, False: 119k]
  |  Branch (101:53): [True: 930, False: 118k]
  ------------------
  102|       |
  103|   120k|  if (ch < '0' || ch > '9')
  ------------------
  |  Branch (103:7): [True: 2.77k, False: 118k]
  |  Branch (103:19): [True: 104, False: 118k]
  ------------------
  104|    226|    ERREXIT(cinfo, JERR_PPM_NONNUMERIC);
  ------------------
  |  |  240|    226|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    226|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  105|       |
  106|   120k|  val = ch - '0';
  107|   164k|  while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') {
  ------------------
  |  Branch (107:10): [True: 115k, False: 48.5k]
  |  Branch (107:44): [True: 43.1k, False: 72.4k]
  ------------------
  108|  43.1k|    val *= 10;
  109|  43.1k|    val += ch - '0';
  110|  43.1k|    if (val > maxval)
  ------------------
  |  Branch (110:9): [True: 132, False: 43.0k]
  ------------------
  111|    132|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    132|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    132|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  112|  43.1k|  }
  113|       |
  114|   120k|  return val;
  115|   120k|}
rdppm-8.c:pbm_getc:
   73|   288k|{
   74|   288k|  register int ch;
   75|       |
   76|   288k|  ch = getc(infile);
   77|   288k|  if (ch == '#') {
  ------------------
  |  Branch (77:7): [True: 3.70k, False: 285k]
  ------------------
   78|  29.8k|    do {
   79|  29.8k|      ch = getc(infile);
   80|  29.8k|    } while (ch != '\n' && ch != EOF);
  ------------------
  |  Branch (80:14): [True: 26.5k, False: 3.33k]
  |  Branch (80:28): [True: 26.1k, False: 375]
  ------------------
   81|  3.70k|  }
   82|   288k|  return ch;
   83|   288k|}
rdppm-8.c:get_text_gray_row:
  133|  1.27k|{
  134|  1.27k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  135|  1.27k|  FILE *infile = source->pub.input_file;
  136|  1.27k|  register _JSAMPROW ptr;
  137|  1.27k|  register _JSAMPLE *rescale = source->rescale;
  138|  1.27k|  JDIMENSION col;
  139|  1.27k|  unsigned int maxval = source->maxval;
  140|       |
  141|  1.27k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  1.27k|#define _buffer  buffer
  ------------------
  142|  3.79k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (142:34): [True: 2.51k, False: 1.27k]
  ------------------
  143|  2.51k|    *ptr++ = rescale[read_pbm_integer(cinfo, infile, maxval)];
  144|  2.51k|  }
  145|  1.27k|  return 1;
  146|  1.27k|}
rdppm-8.c:get_text_gray_rgb_row:
  161|  6.39k|{
  162|  6.39k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  163|  6.39k|  FILE *infile = source->pub.input_file;
  164|  6.39k|  register _JSAMPROW ptr;
  165|  6.39k|  register _JSAMPLE *rescale = source->rescale;
  166|  6.39k|  JDIMENSION col;
  167|  6.39k|  unsigned int maxval = source->maxval;
  168|  6.39k|  register int rindex = rgb_red[cinfo->in_color_space];
  169|  6.39k|  register int gindex = rgb_green[cinfo->in_color_space];
  170|  6.39k|  register int bindex = rgb_blue[cinfo->in_color_space];
  171|  6.39k|  register int aindex = alpha_index[cinfo->in_color_space];
  172|  6.39k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  173|       |
  174|  6.39k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  6.39k|#define _buffer  buffer
  ------------------
  175|  6.39k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (175:7): [True: 1.26k, False: 5.13k]
  ------------------
  176|  1.26k|    if (aindex >= 0)
  ------------------
  |  Branch (176:9): [True: 252, False: 1.00k]
  ------------------
  177|    252|      GRAY_RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
  ------------------
  |  |  149|    252|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|    902|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 650, False: 252]
  |  |  ------------------
  |  |  151|    650|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|    650|    alpha_set_op \
  |  |  153|    650|    ptr += ps; \
  |  |  154|    650|  } \
  |  |  155|    252|}
  ------------------
  178|  1.26k|                         ptr[aindex] = (_JSAMPLE)maxval;)
  179|  1.00k|    else
  180|  1.00k|      GRAY_RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
  ------------------
  |  |  149|  1.00k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  3.60k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 2.60k, False: 1.00k]
  |  |  ------------------
  |  |  151|  2.60k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  2.60k|    alpha_set_op \
  |  |  153|  2.60k|    ptr += ps; \
  |  |  154|  2.60k|  } \
  |  |  155|  1.00k|}
  ------------------
  181|  5.13k|  } else {
  182|  5.13k|    if (aindex >= 0)
  ------------------
  |  Branch (182:9): [True: 1.02k, False: 4.10k]
  ------------------
  183|  1.02k|      GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
  ------------------
  |  |  149|  1.02k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  2.88k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 1.86k, False: 1.02k]
  |  |  ------------------
  |  |  151|  1.86k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  1.86k|    alpha_set_op \
  |  |  153|  1.86k|    ptr += ps; \
  |  |  154|  1.86k|  } \
  |  |  155|  1.02k|}
  ------------------
  184|  5.13k|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  185|  4.10k|    else
  186|  4.10k|      GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
  ------------------
  |  |  149|  4.10k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  11.5k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 7.45k, False: 4.10k]
  |  |  ------------------
  |  |  151|  7.45k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  7.45k|    alpha_set_op \
  |  |  153|  7.45k|    ptr += ps; \
  |  |  154|  7.45k|  } \
  |  |  155|  4.10k|}
  ------------------
  187|  5.13k|  }
  188|  6.39k|  return 1;
  189|  6.39k|}
rdppm-8.c:get_text_gray_cmyk_row:
  196|  1.27k|{
  197|  1.27k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  198|  1.27k|  FILE *infile = source->pub.input_file;
  199|  1.27k|  register _JSAMPROW ptr;
  200|  1.27k|  register _JSAMPLE *rescale = source->rescale;
  201|  1.27k|  JDIMENSION col;
  202|  1.27k|  unsigned int maxval = source->maxval;
  203|       |
  204|  1.27k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  1.27k|#define _buffer  buffer
  ------------------
  205|  1.27k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (205:7): [True: 252, False: 1.02k]
  ------------------
  206|    902|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (206:36): [True: 650, False: 252]
  ------------------
  207|    650|      _JSAMPLE gray = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  224|    650|#define _JSAMPLE  JSAMPLE
  ------------------
  208|    650|      rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
  209|    650|      ptr += 4;
  210|    650|    }
  211|  1.02k|  } else {
  212|  2.88k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (212:36): [True: 1.86k, False: 1.02k]
  ------------------
  213|  1.86k|      _JSAMPLE gray = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  224|  1.86k|#define _JSAMPLE  JSAMPLE
  ------------------
  214|  1.86k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  215|  1.86k|                  ptr + 1, ptr + 2, ptr + 3);
  216|  1.86k|      ptr += 4;
  217|  1.86k|    }
  218|  1.02k|  }
  219|  1.27k|  return 1;
  220|  1.27k|}
rdppm-8.c:get_text_rgb_row:
  236|  8.79k|{
  237|  8.79k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  238|  8.79k|  FILE *infile = source->pub.input_file;
  239|  8.79k|  register _JSAMPROW ptr;
  240|  8.79k|  register _JSAMPLE *rescale = source->rescale;
  241|  8.79k|  JDIMENSION col;
  242|  8.79k|  unsigned int maxval = source->maxval;
  243|  8.79k|  register int rindex = rgb_red[cinfo->in_color_space];
  244|  8.79k|  register int gindex = rgb_green[cinfo->in_color_space];
  245|  8.79k|  register int bindex = rgb_blue[cinfo->in_color_space];
  246|  8.79k|  register int aindex = alpha_index[cinfo->in_color_space];
  247|  8.79k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  248|       |
  249|  8.79k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  8.79k|#define _buffer  buffer
  ------------------
  250|  8.79k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (250:7): [True: 2.64k, False: 6.15k]
  ------------------
  251|  2.64k|    if (aindex >= 0)
  ------------------
  |  Branch (251:9): [True: 528, False: 2.11k]
  ------------------
  252|    528|      RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
  ------------------
  |  |  223|    528|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  1.51k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 986, False: 528]
  |  |  ------------------
  |  |  225|    986|    ptr[rindex] = read_op; \
  |  |  226|    986|    ptr[gindex] = read_op; \
  |  |  227|    986|    ptr[bindex] = read_op; \
  |  |  228|    986|    alpha_set_op \
  |  |  229|    986|    ptr += ps; \
  |  |  230|    986|  } \
  |  |  231|    528|}
  ------------------
  253|  2.64k|                    ptr[aindex] = (_JSAMPLE)maxval;)
  254|  2.11k|    else
  255|  2.11k|      RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
  ------------------
  |  |  223|  2.11k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  6.05k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 3.94k, False: 2.11k]
  |  |  ------------------
  |  |  225|  3.94k|    ptr[rindex] = read_op; \
  |  |  226|  3.94k|    ptr[gindex] = read_op; \
  |  |  227|  3.94k|    ptr[bindex] = read_op; \
  |  |  228|  3.94k|    alpha_set_op \
  |  |  229|  3.94k|    ptr += ps; \
  |  |  230|  3.94k|  } \
  |  |  231|  2.11k|}
  ------------------
  256|  6.15k|  } else {
  257|  6.15k|    if (aindex >= 0)
  ------------------
  |  Branch (257:9): [True: 1.23k, False: 4.92k]
  ------------------
  258|  1.23k|      RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
  ------------------
  |  |  223|  1.23k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  3.22k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 1.99k, False: 1.23k]
  |  |  ------------------
  |  |  225|  1.99k|    ptr[rindex] = read_op; \
  |  |  226|  1.99k|    ptr[gindex] = read_op; \
  |  |  227|  1.99k|    ptr[bindex] = read_op; \
  |  |  228|  1.99k|    alpha_set_op \
  |  |  229|  1.99k|    ptr += ps; \
  |  |  230|  1.99k|  } \
  |  |  231|  1.23k|}
  ------------------
  259|  6.15k|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  260|  4.92k|    else
  261|  4.92k|      RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
  ------------------
  |  |  223|  4.92k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  12.8k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 7.96k, False: 4.92k]
  |  |  ------------------
  |  |  225|  7.96k|    ptr[rindex] = read_op; \
  |  |  226|  7.96k|    ptr[gindex] = read_op; \
  |  |  227|  7.96k|    ptr[bindex] = read_op; \
  |  |  228|  7.96k|    alpha_set_op \
  |  |  229|  7.96k|    ptr += ps; \
  |  |  230|  7.96k|  } \
  |  |  231|  4.92k|}
  ------------------
  262|  6.15k|  }
  263|  8.79k|  return 1;
  264|  8.79k|}
rdppm-8.c:get_text_rgb_cmyk_row:
  271|  1.75k|{
  272|  1.75k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  273|  1.75k|  FILE *infile = source->pub.input_file;
  274|  1.75k|  register _JSAMPROW ptr;
  275|  1.75k|  register _JSAMPLE *rescale = source->rescale;
  276|  1.75k|  JDIMENSION col;
  277|  1.75k|  unsigned int maxval = source->maxval;
  278|       |
  279|  1.75k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  1.75k|#define _buffer  buffer
  ------------------
  280|  1.75k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (280:7): [True: 528, False: 1.23k]
  ------------------
  281|  1.51k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (281:36): [True: 986, False: 528]
  ------------------
  282|    986|      _JSAMPLE r = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  224|    986|#define _JSAMPLE  JSAMPLE
  ------------------
  283|    986|      _JSAMPLE g = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  224|    986|#define _JSAMPLE  JSAMPLE
  ------------------
  284|    986|      _JSAMPLE b = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  224|    986|#define _JSAMPLE  JSAMPLE
  ------------------
  285|    986|      rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
  286|    986|      ptr += 4;
  287|    986|    }
  288|  1.23k|  } else {
  289|  3.22k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (289:36): [True: 1.99k, False: 1.23k]
  ------------------
  290|  1.99k|      _JSAMPLE r = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  224|  1.99k|#define _JSAMPLE  JSAMPLE
  ------------------
  291|  1.99k|      _JSAMPLE g = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  224|  1.99k|#define _JSAMPLE  JSAMPLE
  ------------------
  292|  1.99k|      _JSAMPLE b = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  224|  1.99k|#define _JSAMPLE  JSAMPLE
  ------------------
  293|  1.99k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  294|  1.99k|                  ptr + 2, ptr + 3);
  295|  1.99k|      ptr += 4;
  296|  1.99k|    }
  297|  1.23k|  }
  298|  1.75k|  return 1;
  299|  1.75k|}
rdppm-8.c:get_word_gray_row:
  491|  1.55k|{
  492|  1.55k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  493|  1.55k|  register _JSAMPROW ptr;
  494|  1.55k|  register unsigned char *bufferptr;
  495|  1.55k|  register _JSAMPLE *rescale = source->rescale;
  496|  1.55k|  JDIMENSION col;
  497|  1.55k|  unsigned int maxval = source->maxval;
  498|       |
  499|  1.55k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  1.55k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (499:7): [True: 64, False: 1.49k]
  ------------------
  500|     64|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     64|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     64|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  501|  1.55k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  1.55k|#define _buffer  buffer
  ------------------
  502|  1.55k|  bufferptr = source->iobuffer;
  503|  4.04k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (503:34): [True: 2.48k, False: 1.55k]
  ------------------
  504|  2.48k|    register unsigned int temp;
  505|  2.48k|    temp  = (*bufferptr++) << 8;
  506|  2.48k|    temp |= (*bufferptr++);
  507|  2.48k|    if (temp > maxval)
  ------------------
  |  Branch (507:9): [True: 29, False: 2.45k]
  ------------------
  508|     29|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     29|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     29|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  509|  2.48k|    *ptr++ = rescale[temp];
  510|  2.48k|  }
  511|  1.55k|  return 1;
  512|  1.55k|}
rdppm-8.c:get_word_gray_rgb_row:
  518|  7.79k|{
  519|  7.79k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  520|  7.79k|  register _JSAMPROW ptr;
  521|  7.79k|  register unsigned char *bufferptr;
  522|  7.79k|  register _JSAMPLE *rescale = source->rescale;
  523|  7.79k|  JDIMENSION col;
  524|  7.79k|  unsigned int maxval = source->maxval;
  525|  7.79k|  register int rindex = rgb_red[cinfo->in_color_space];
  526|  7.79k|  register int gindex = rgb_green[cinfo->in_color_space];
  527|  7.79k|  register int bindex = rgb_blue[cinfo->in_color_space];
  528|  7.79k|  register int aindex = alpha_index[cinfo->in_color_space];
  529|  7.79k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  530|       |
  531|  7.79k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  7.79k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (531:7): [True: 320, False: 7.47k]
  ------------------
  532|    320|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    320|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    320|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  533|  7.79k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  7.79k|#define _buffer  buffer
  ------------------
  534|  7.79k|  bufferptr = source->iobuffer;
  535|  20.2k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (535:34): [True: 12.4k, False: 7.79k]
  ------------------
  536|  12.4k|    register unsigned int temp;
  537|  12.4k|    temp  = (*bufferptr++) << 8;
  538|  12.4k|    temp |= (*bufferptr++);
  539|  12.4k|    if (temp > maxval)
  ------------------
  |  Branch (539:9): [True: 145, False: 12.2k]
  ------------------
  540|    145|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    145|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    145|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  541|  12.4k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = rescale[temp];
  542|  12.4k|    if (aindex >= 0)
  ------------------
  |  Branch (542:9): [True: 2.45k, False: 9.96k]
  ------------------
  543|  2.45k|      ptr[aindex] = (1 << cinfo->data_precision) - 1;
  544|  12.4k|    ptr += ps;
  545|  12.4k|  }
  546|  7.79k|  return 1;
  547|  7.79k|}
rdppm-8.c:get_word_gray_cmyk_row:
  553|  1.55k|{
  554|  1.55k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  555|  1.55k|  register _JSAMPROW ptr;
  556|  1.55k|  register unsigned char *bufferptr;
  557|  1.55k|  register _JSAMPLE *rescale = source->rescale;
  558|  1.55k|  JDIMENSION col;
  559|  1.55k|  unsigned int maxval = source->maxval;
  560|       |
  561|  1.55k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  1.55k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (561:7): [True: 64, False: 1.49k]
  ------------------
  562|     64|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     64|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     64|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  563|  1.55k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  1.55k|#define _buffer  buffer
  ------------------
  564|  1.55k|  bufferptr = source->iobuffer;
  565|  1.55k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (565:7): [True: 0, False: 1.55k]
  ------------------
  566|      0|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (566:36): [True: 0, False: 0]
  ------------------
  567|      0|      register unsigned int gray;
  568|      0|      gray  = (*bufferptr++) << 8;
  569|      0|      gray |= (*bufferptr++);
  570|      0|      if (gray > maxval)
  ------------------
  |  Branch (570:11): [True: 0, False: 0]
  ------------------
  571|      0|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  572|      0|      rgb_to_cmyk(maxval, (_JSAMPLE)gray, (_JSAMPLE)gray, (_JSAMPLE)gray, ptr,
  573|      0|                  ptr + 1, ptr + 2, ptr + 3);
  574|      0|      ptr += 4;
  575|      0|    }
  576|  1.55k|  } else {
  577|  4.04k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (577:36): [True: 2.48k, False: 1.55k]
  ------------------
  578|  2.48k|      register unsigned int temp;
  579|  2.48k|      _JSAMPLE gray;
  ------------------
  |  |  224|  2.48k|#define _JSAMPLE  JSAMPLE
  ------------------
  580|  2.48k|      temp  = (*bufferptr++) << 8;
  581|  2.48k|      temp |= (*bufferptr++);
  582|  2.48k|      if (temp > maxval)
  ------------------
  |  Branch (582:11): [True: 29, False: 2.45k]
  ------------------
  583|     29|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     29|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     29|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  584|  2.48k|      gray = rescale[temp];
  585|  2.48k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  586|  2.48k|                  ptr + 1, ptr + 2, ptr + 3);
  587|  2.48k|      ptr += 4;
  588|  2.48k|    }
  589|  1.55k|  }
  590|  1.55k|  return 1;
  591|  1.55k|}
rdppm-8.c:get_raw_row:
  477|   234k|{
  478|   234k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  479|       |
  480|   234k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|   234k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (480:7): [True: 76, False: 234k]
  ------------------
  481|     76|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     76|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     76|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  482|   234k|  return 1;
  483|   234k|}
rdppm-8.c:get_scaled_gray_row:
  305|  3.36M|{
  306|  3.36M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  307|  3.36M|  register _JSAMPROW ptr;
  308|  3.36M|  register unsigned char *bufferptr;
  309|  3.36M|  register _JSAMPLE *rescale = source->rescale;
  310|  3.36M|  JDIMENSION col;
  311|       |
  312|  3.36M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  3.36M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (312:7): [True: 75, False: 3.36M]
  ------------------
  313|     75|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     75|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     75|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  314|  3.36M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  3.36M|#define _buffer  buffer
  ------------------
  315|  3.36M|  bufferptr = source->iobuffer;
  316|  17.1M|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (316:34): [True: 13.7M, False: 3.36M]
  ------------------
  317|  13.7M|    *ptr++ = rescale[*bufferptr++];
  318|  13.7M|  }
  319|  3.36M|  return 1;
  320|  3.36M|}
rdppm-8.c:get_gray_rgb_row:
  327|  17.9M|{
  328|  17.9M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  329|  17.9M|  register _JSAMPROW ptr;
  330|  17.9M|  register unsigned char *bufferptr;
  331|  17.9M|  register _JSAMPLE *rescale = source->rescale;
  332|  17.9M|  JDIMENSION col;
  333|  17.9M|  unsigned int maxval = source->maxval;
  334|  17.9M|  register int rindex = rgb_red[cinfo->in_color_space];
  335|  17.9M|  register int gindex = rgb_green[cinfo->in_color_space];
  336|  17.9M|  register int bindex = rgb_blue[cinfo->in_color_space];
  337|  17.9M|  register int aindex = alpha_index[cinfo->in_color_space];
  338|  17.9M|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  339|       |
  340|  17.9M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  17.9M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (340:7): [True: 520, False: 17.9M]
  ------------------
  341|    520|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    520|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    520|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  342|  17.9M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  17.9M|#define _buffer  buffer
  ------------------
  343|  17.9M|  bufferptr = source->iobuffer;
  344|  17.9M|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (344:7): [True: 1.14M, False: 16.8M]
  ------------------
  345|  1.14M|    if (aindex >= 0)
  ------------------
  |  Branch (345:9): [True: 229k, False: 918k]
  ------------------
  346|   229k|      GRAY_RGB_READ_LOOP(*bufferptr++, ptr[aindex] = (_JSAMPLE)maxval;)
  ------------------
  |  |  149|   229k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|   731k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 501k, False: 229k]
  |  |  ------------------
  |  |  151|   501k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|   501k|    alpha_set_op \
  |  |  153|   501k|    ptr += ps; \
  |  |  154|   501k|  } \
  |  |  155|   229k|}
  ------------------
  347|   918k|    else
  348|   918k|      GRAY_RGB_READ_LOOP(*bufferptr++, {})
  ------------------
  |  |  149|   918k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  2.92M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 2.00M, False: 918k]
  |  |  ------------------
  |  |  151|  2.00M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  2.00M|    alpha_set_op \
  |  |  153|  2.00M|    ptr += ps; \
  |  |  154|  2.00M|  } \
  |  |  155|   918k|}
  ------------------
  349|  16.8M|  } else {
  350|  16.8M|    if (aindex >= 0)
  ------------------
  |  Branch (350:9): [True: 3.36M, False: 13.4M]
  ------------------
  351|  3.36M|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  149|  3.36M|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  17.1M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 13.7M, False: 3.36M]
  |  |  ------------------
  |  |  151|  13.7M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  13.7M|    alpha_set_op \
  |  |  153|  13.7M|    ptr += ps; \
  |  |  154|  13.7M|  } \
  |  |  155|  3.36M|}
  ------------------
  352|  16.8M|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  353|  13.4M|    else
  354|  13.4M|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++], {})
  ------------------
  |  |  149|  13.4M|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  68.5M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 55.0M, False: 13.4M]
  |  |  ------------------
  |  |  151|  55.0M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  55.0M|    alpha_set_op \
  |  |  153|  55.0M|    ptr += ps; \
  |  |  154|  55.0M|  } \
  |  |  155|  13.4M|}
  ------------------
  355|  16.8M|  }
  356|  17.9M|  return 1;
  357|  17.9M|}
rdppm-8.c:get_gray_cmyk_row:
  364|  3.59M|{
  365|  3.59M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  366|  3.59M|  register _JSAMPROW ptr;
  367|  3.59M|  register unsigned char *bufferptr;
  368|  3.59M|  register _JSAMPLE *rescale = source->rescale;
  369|  3.59M|  JDIMENSION col;
  370|  3.59M|  unsigned int maxval = source->maxval;
  371|       |
  372|  3.59M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  3.59M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (372:7): [True: 104, False: 3.59M]
  ------------------
  373|    104|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    104|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    104|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  374|  3.59M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  3.59M|#define _buffer  buffer
  ------------------
  375|  3.59M|  bufferptr = source->iobuffer;
  376|  3.59M|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (376:7): [True: 229k, False: 3.36M]
  ------------------
  377|   731k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (377:36): [True: 501k, False: 229k]
  ------------------
  378|   501k|      _JSAMPLE gray = *bufferptr++;
  ------------------
  |  |  224|   501k|#define _JSAMPLE  JSAMPLE
  ------------------
  379|   501k|      rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
  380|   501k|      ptr += 4;
  381|   501k|    }
  382|  3.36M|  } else {
  383|  17.1M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (383:36): [True: 13.7M, False: 3.36M]
  ------------------
  384|  13.7M|      _JSAMPLE gray = rescale[*bufferptr++];
  ------------------
  |  |  224|  13.7M|#define _JSAMPLE  JSAMPLE
  ------------------
  385|  13.7M|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  386|  13.7M|                  ptr + 1, ptr + 2, ptr + 3);
  387|  13.7M|      ptr += 4;
  388|  13.7M|    }
  389|  3.36M|  }
  390|  3.59M|  return 1;
  391|  3.59M|}
rdppm-8.c:get_word_rgb_row:
  597|  11.1k|{
  598|  11.1k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  599|  11.1k|  register _JSAMPROW ptr;
  600|  11.1k|  register unsigned char *bufferptr;
  601|  11.1k|  register _JSAMPLE *rescale = source->rescale;
  602|  11.1k|  JDIMENSION col;
  603|  11.1k|  unsigned int maxval = source->maxval;
  604|  11.1k|  register int rindex = rgb_red[cinfo->in_color_space];
  605|  11.1k|  register int gindex = rgb_green[cinfo->in_color_space];
  606|  11.1k|  register int bindex = rgb_blue[cinfo->in_color_space];
  607|  11.1k|  register int aindex = alpha_index[cinfo->in_color_space];
  608|  11.1k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  609|       |
  610|  11.1k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  11.1k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (610:7): [True: 395, False: 10.7k]
  ------------------
  611|    395|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    395|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    395|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  612|  11.1k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  11.1k|#define _buffer  buffer
  ------------------
  613|  11.1k|  bufferptr = source->iobuffer;
  614|  26.9k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (614:34): [True: 15.8k, False: 11.1k]
  ------------------
  615|  15.8k|    register unsigned int temp;
  616|  15.8k|    temp  = (*bufferptr++) << 8;
  617|  15.8k|    temp |= (*bufferptr++);
  618|  15.8k|    if (temp > maxval)
  ------------------
  |  Branch (618:9): [True: 145, False: 15.6k]
  ------------------
  619|    145|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    145|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    145|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  620|  15.8k|    ptr[rindex] = rescale[temp];
  621|  15.8k|    temp  = (*bufferptr++) << 8;
  622|  15.8k|    temp |= (*bufferptr++);
  623|  15.8k|    if (temp > maxval)
  ------------------
  |  Branch (623:9): [True: 110, False: 15.7k]
  ------------------
  624|    110|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    110|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    110|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  625|  15.8k|    ptr[gindex] = rescale[temp];
  626|  15.8k|    temp  = (*bufferptr++) << 8;
  627|  15.8k|    temp |= (*bufferptr++);
  628|  15.8k|    if (temp > maxval)
  ------------------
  |  Branch (628:9): [True: 100, False: 15.7k]
  ------------------
  629|    100|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    100|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    100|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  630|  15.8k|    ptr[bindex] = rescale[temp];
  631|  15.8k|    if (aindex >= 0)
  ------------------
  |  Branch (631:9): [True: 3.09k, False: 12.7k]
  ------------------
  632|  3.09k|      ptr[aindex] = (1 << cinfo->data_precision) - 1;
  633|  15.8k|    ptr += ps;
  634|  15.8k|  }
  635|  11.1k|  return 1;
  636|  11.1k|}
rdppm-8.c:get_word_rgb_cmyk_row:
  642|  2.22k|{
  643|  2.22k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  644|  2.22k|  register _JSAMPROW ptr;
  645|  2.22k|  register unsigned char *bufferptr;
  646|  2.22k|  register _JSAMPLE *rescale = source->rescale;
  647|  2.22k|  JDIMENSION col;
  648|  2.22k|  unsigned int maxval = source->maxval;
  649|       |
  650|  2.22k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  2.22k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (650:7): [True: 79, False: 2.14k]
  ------------------
  651|     79|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     79|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     79|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  652|  2.22k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  2.22k|#define _buffer  buffer
  ------------------
  653|  2.22k|  bufferptr = source->iobuffer;
  654|  2.22k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (654:7): [True: 0, False: 2.22k]
  ------------------
  655|      0|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (655:36): [True: 0, False: 0]
  ------------------
  656|      0|      register unsigned int r, g, b;
  657|      0|      r  = (*bufferptr++) << 8;
  658|      0|      r |= (*bufferptr++);
  659|      0|      if (r > maxval)
  ------------------
  |  Branch (659:11): [True: 0, False: 0]
  ------------------
  660|      0|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  661|      0|      g  = (*bufferptr++) << 8;
  662|      0|      g |= (*bufferptr++);
  663|      0|      if (g > maxval)
  ------------------
  |  Branch (663:11): [True: 0, False: 0]
  ------------------
  664|      0|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  665|      0|      b  = (*bufferptr++) << 8;
  666|      0|      b |= (*bufferptr++);
  667|      0|      if (b > maxval)
  ------------------
  |  Branch (667:11): [True: 0, False: 0]
  ------------------
  668|      0|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  669|      0|      rgb_to_cmyk(maxval, (_JSAMPLE)r, (_JSAMPLE)g, (_JSAMPLE)b, ptr, ptr + 1,
  670|      0|                  ptr + 2, ptr + 3);
  671|      0|      ptr += 4;
  672|      0|    }
  673|  2.22k|  } else {
  674|  5.38k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (674:36): [True: 3.16k, False: 2.22k]
  ------------------
  675|  3.16k|      register unsigned int r, g, b;
  676|  3.16k|      r  = (*bufferptr++) << 8;
  677|  3.16k|      r |= (*bufferptr++);
  678|  3.16k|      if (r > maxval)
  ------------------
  |  Branch (678:11): [True: 29, False: 3.13k]
  ------------------
  679|     29|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     29|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     29|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  680|  3.16k|      g  = (*bufferptr++) << 8;
  681|  3.16k|      g |= (*bufferptr++);
  682|  3.16k|      if (g > maxval)
  ------------------
  |  Branch (682:11): [True: 22, False: 3.14k]
  ------------------
  683|     22|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     22|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     22|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  684|  3.16k|      b  = (*bufferptr++) << 8;
  685|  3.16k|      b |= (*bufferptr++);
  686|  3.16k|      if (b > maxval)
  ------------------
  |  Branch (686:11): [True: 20, False: 3.14k]
  ------------------
  687|     20|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     20|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     20|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  688|  3.16k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, rescale[r], rescale[g],
  689|  3.16k|                  rescale[b], ptr, ptr + 1, ptr + 2, ptr + 3);
  690|  3.16k|      ptr += 4;
  691|  3.16k|    }
  692|  2.22k|  }
  693|  2.22k|  return 1;
  694|  2.22k|}
rdppm-8.c:get_rgb_row:
  397|  75.5k|{
  398|  75.5k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  399|  75.5k|  register _JSAMPROW ptr;
  400|  75.5k|  register unsigned char *bufferptr;
  401|  75.5k|  register _JSAMPLE *rescale = source->rescale;
  402|  75.5k|  JDIMENSION col;
  403|  75.5k|  unsigned int maxval = source->maxval;
  404|  75.5k|  register int rindex = rgb_red[cinfo->in_color_space];
  405|  75.5k|  register int gindex = rgb_green[cinfo->in_color_space];
  406|  75.5k|  register int bindex = rgb_blue[cinfo->in_color_space];
  407|  75.5k|  register int aindex = alpha_index[cinfo->in_color_space];
  408|  75.5k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  409|       |
  410|  75.5k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  75.5k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (410:7): [True: 693, False: 74.8k]
  ------------------
  411|    693|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    693|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    693|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  412|  75.5k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  75.5k|#define _buffer  buffer
  ------------------
  413|  75.5k|  bufferptr = source->iobuffer;
  414|  75.5k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (414:7): [True: 19.9k, False: 55.6k]
  ------------------
  415|  19.9k|    if (aindex >= 0)
  ------------------
  |  Branch (415:9): [True: 4.98k, False: 14.9k]
  ------------------
  416|  4.98k|      RGB_READ_LOOP(*bufferptr++, ptr[aindex] = (_JSAMPLE)maxval;)
  ------------------
  |  |  223|  4.98k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  11.9k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 7.01k, False: 4.98k]
  |  |  ------------------
  |  |  225|  7.01k|    ptr[rindex] = read_op; \
  |  |  226|  7.01k|    ptr[gindex] = read_op; \
  |  |  227|  7.01k|    ptr[bindex] = read_op; \
  |  |  228|  7.01k|    alpha_set_op \
  |  |  229|  7.01k|    ptr += ps; \
  |  |  230|  7.01k|  } \
  |  |  231|  4.98k|}
  ------------------
  417|  14.9k|    else
  418|  14.9k|      RGB_READ_LOOP(*bufferptr++, {})
  ------------------
  |  |  223|  14.9k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  35.9k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 21.0k, False: 14.9k]
  |  |  ------------------
  |  |  225|  21.0k|    ptr[rindex] = read_op; \
  |  |  226|  21.0k|    ptr[gindex] = read_op; \
  |  |  227|  21.0k|    ptr[bindex] = read_op; \
  |  |  228|  21.0k|    alpha_set_op \
  |  |  229|  21.0k|    ptr += ps; \
  |  |  230|  21.0k|  } \
  |  |  231|  14.9k|}
  ------------------
  419|  55.6k|  } else {
  420|  55.6k|    if (aindex >= 0)
  ------------------
  |  Branch (420:9): [True: 10.9k, False: 44.6k]
  ------------------
  421|  10.9k|      RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  223|  10.9k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  32.6k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 21.6k, False: 10.9k]
  |  |  ------------------
  |  |  225|  21.6k|    ptr[rindex] = read_op; \
  |  |  226|  21.6k|    ptr[gindex] = read_op; \
  |  |  227|  21.6k|    ptr[bindex] = read_op; \
  |  |  228|  21.6k|    alpha_set_op \
  |  |  229|  21.6k|    ptr += ps; \
  |  |  230|  21.6k|  } \
  |  |  231|  10.9k|}
  ------------------
  422|  55.6k|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  423|  44.6k|    else
  424|  44.6k|      RGB_READ_LOOP(rescale[*bufferptr++], {})
  ------------------
  |  |  223|  44.6k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|   131k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 86.5k, False: 44.6k]
  |  |  ------------------
  |  |  225|  86.5k|    ptr[rindex] = read_op; \
  |  |  226|  86.5k|    ptr[gindex] = read_op; \
  |  |  227|  86.5k|    ptr[bindex] = read_op; \
  |  |  228|  86.5k|    alpha_set_op \
  |  |  229|  86.5k|    ptr += ps; \
  |  |  230|  86.5k|  } \
  |  |  231|  44.6k|}
  ------------------
  425|  55.6k|  }
  426|  75.5k|  return 1;
  427|  75.5k|}
rdppm-8.c:get_rgb_cmyk_row:
  434|  16.1k|{
  435|  16.1k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  436|  16.1k|  register _JSAMPROW ptr;
  437|  16.1k|  register unsigned char *bufferptr;
  438|  16.1k|  register _JSAMPLE *rescale = source->rescale;
  439|  16.1k|  JDIMENSION col;
  440|  16.1k|  unsigned int maxval = source->maxval;
  441|       |
  442|  16.1k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  16.1k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (442:7): [True: 148, False: 15.9k]
  ------------------
  443|    148|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    148|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    148|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  444|  16.1k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  16.1k|#define _buffer  buffer
  ------------------
  445|  16.1k|  bufferptr = source->iobuffer;
  446|  16.1k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (446:7): [True: 4.98k, False: 11.1k]
  ------------------
  447|  11.9k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (447:36): [True: 7.01k, False: 4.98k]
  ------------------
  448|  7.01k|      _JSAMPLE r = *bufferptr++;
  ------------------
  |  |  224|  7.01k|#define _JSAMPLE  JSAMPLE
  ------------------
  449|  7.01k|      _JSAMPLE g = *bufferptr++;
  ------------------
  |  |  224|  7.01k|#define _JSAMPLE  JSAMPLE
  ------------------
  450|  7.01k|      _JSAMPLE b = *bufferptr++;
  ------------------
  |  |  224|  7.01k|#define _JSAMPLE  JSAMPLE
  ------------------
  451|  7.01k|      rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
  452|  7.01k|      ptr += 4;
  453|  7.01k|    }
  454|  11.1k|  } else {
  455|  32.7k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (455:36): [True: 21.6k, False: 11.1k]
  ------------------
  456|  21.6k|      _JSAMPLE r = rescale[*bufferptr++];
  ------------------
  |  |  224|  21.6k|#define _JSAMPLE  JSAMPLE
  ------------------
  457|  21.6k|      _JSAMPLE g = rescale[*bufferptr++];
  ------------------
  |  |  224|  21.6k|#define _JSAMPLE  JSAMPLE
  ------------------
  458|  21.6k|      _JSAMPLE b = rescale[*bufferptr++];
  ------------------
  |  |  224|  21.6k|#define _JSAMPLE  JSAMPLE
  ------------------
  459|  21.6k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  460|  21.6k|                  ptr + 2, ptr + 3);
  461|  21.6k|      ptr += 4;
  462|  21.6k|    }
  463|  11.1k|  }
  464|  16.1k|  return 1;
  465|  16.1k|}
rdppm-8.c:finish_input_ppm:
  913|  17.9k|{
  914|       |  /* no work */
  915|  17.9k|}

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

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

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

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

inflateResetKeep:
  100|   114k|int ZEXPORT inflateResetKeep(z_streamp strm) {
  101|   114k|    struct inflate_state FAR *state;
  102|       |
  103|   114k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (103:9): [True: 0, False: 114k]
  ------------------
  104|   114k|    state = (struct inflate_state FAR *)strm->state;
  105|   114k|    strm->total_in = strm->total_out = state->total = 0;
  106|   114k|    strm->msg = Z_NULL;
  ------------------
  |  |  216|   114k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  107|   114k|    strm->data_type = 0;
  108|   114k|    if (state->wrap)        /* to support ill-conceived Java test suite */
  ------------------
  |  Branch (108:9): [True: 114k, False: 0]
  ------------------
  109|   114k|        strm->adler = state->wrap & 1;
  110|   114k|    state->mode = HEAD;
  111|   114k|    state->last = 0;
  112|   114k|    state->havedict = 0;
  113|   114k|    state->flags = -1;
  114|   114k|    state->dmax = 32768U;
  115|   114k|    state->head = Z_NULL;
  ------------------
  |  |  216|   114k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  116|   114k|    state->hold = 0;
  117|   114k|    state->bits = 0;
  118|   114k|    state->lencode = state->distcode = state->next = state->codes;
  119|   114k|    state->sane = 1;
  120|   114k|    state->back = -1;
  121|   114k|    Tracev((stderr, "inflate: reset\n"));
  122|   114k|    return Z_OK;
  ------------------
  |  |  181|   114k|#define Z_OK            0
  ------------------
  123|   114k|}
inflateReset:
  125|   114k|int ZEXPORT inflateReset(z_streamp strm) {
  126|   114k|    struct inflate_state FAR *state;
  127|       |
  128|   114k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (128:9): [True: 0, False: 114k]
  ------------------
  129|   114k|    state = (struct inflate_state FAR *)strm->state;
  130|   114k|    state->wsize = 0;
  131|   114k|    state->whave = 0;
  132|   114k|    state->wnext = 0;
  133|   114k|    return inflateResetKeep(strm);
  134|   114k|}
inflateReset2:
  136|   114k|int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
  137|   114k|    int wrap;
  138|   114k|    struct inflate_state FAR *state;
  139|       |
  140|       |    /* get the state */
  141|   114k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (141:9): [True: 0, False: 114k]
  ------------------
  142|   114k|    state = (struct inflate_state FAR *)strm->state;
  143|       |
  144|       |    /* extract wrap request from windowBits parameter */
  145|   114k|    if (windowBits < 0) {
  ------------------
  |  Branch (145:9): [True: 0, False: 114k]
  ------------------
  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|   114k|    else {
  152|   114k|        wrap = (windowBits >> 4) + 5;
  153|       |#ifdef GUNZIP
  154|       |        if (windowBits < 48)
  155|       |            windowBits &= 15;
  156|       |#endif
  157|   114k|    }
  158|       |
  159|       |    /* set number of window bits, free window if different */
  160|   114k|    if (windowBits && (windowBits < 8 || windowBits > 15))
  ------------------
  |  Branch (160:9): [True: 114k, False: 0]
  |  Branch (160:24): [True: 0, False: 114k]
  |  Branch (160:42): [True: 0, False: 114k]
  ------------------
  161|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  162|   114k|    if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
  ------------------
  |  |  216|   228k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (162:9): [True: 0, False: 114k]
  |  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|   114k|    state->wrap = wrap;
  169|   114k|    state->wbits = (unsigned)windowBits;
  170|   114k|    return inflateReset(strm);
  171|   114k|}
inflateInit2_:
  174|   114k|                          const char *version, int stream_size) {
  175|   114k|    int ret;
  176|   114k|    struct inflate_state FAR *state;
  177|       |
  178|   114k|    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
  ------------------
  |  |  216|   228k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
                  if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
  ------------------
  |  |   44|   114k|#define ZLIB_VERSION "1.3.2"
  ------------------
  |  Branch (178:9): [True: 0, False: 114k]
  |  Branch (178:30): [True: 0, False: 114k]
  ------------------
  179|   114k|        stream_size != (int)(sizeof(z_stream)))
  ------------------
  |  Branch (179:9): [True: 0, False: 114k]
  ------------------
  180|      0|        return Z_VERSION_ERROR;
  ------------------
  |  |  189|      0|#define Z_VERSION_ERROR (-6)
  ------------------
  181|   114k|    if (strm == Z_NULL) return Z_STREAM_ERROR;
  ------------------
  |  |  216|   114k|#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: 114k]
  ------------------
  182|   114k|    strm->msg = Z_NULL;                 /* in case we return an error */
  ------------------
  |  |  216|   114k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  183|   114k|    if (strm->zalloc == (alloc_func)0) {
  ------------------
  |  Branch (183:9): [True: 0, False: 114k]
  ------------------
  184|       |#ifdef Z_SOLO
  185|       |        return Z_STREAM_ERROR;
  186|       |#else
  187|      0|        strm->zalloc = zcalloc;
  188|      0|        strm->opaque = (voidpf)0;
  189|      0|#endif
  190|      0|    }
  191|   114k|    if (strm->zfree == (free_func)0)
  ------------------
  |  Branch (191:9): [True: 0, False: 114k]
  ------------------
  192|       |#ifdef Z_SOLO
  193|       |        return Z_STREAM_ERROR;
  194|       |#else
  195|      0|        strm->zfree = zcfree;
  196|   114k|#endif
  197|   114k|    state = (struct inflate_state FAR *)
  198|   114k|            ZALLOC(strm, 1, sizeof(struct inflate_state));
  ------------------
  |  |  253|   114k|           (*((strm)->zalloc))((strm)->opaque, (items), (size))
  ------------------
  199|   114k|    if (state == Z_NULL) return Z_MEM_ERROR;
  ------------------
  |  |  216|   114k|#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: 114k]
  ------------------
  200|   114k|    zmemzero(state, sizeof(struct inflate_state));
  ------------------
  |  |  218|   114k|#    define zmemzero(dest, len) memset(dest, 0, len)
  ------------------
  201|   114k|    Tracev((stderr, "inflate: allocated\n"));
  202|   114k|    strm->state = (struct internal_state FAR *)state;
  203|   114k|    state->strm = strm;
  204|   114k|    state->window = Z_NULL;
  ------------------
  |  |  216|   114k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  205|   114k|    state->mode = HEAD;     /* to pass state test in inflateReset2() */
  206|   114k|    ret = inflateReset2(strm, windowBits);
  207|   114k|    if (ret != Z_OK) {
  ------------------
  |  |  181|   114k|#define Z_OK            0
  ------------------
  |  Branch (207:9): [True: 0, False: 114k]
  ------------------
  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|   114k|    return ret;
  212|   114k|}
inflate:
  474|   311k|int ZEXPORT inflate(z_streamp strm, int flush) {
  475|   311k|    struct inflate_state FAR *state;
  476|   311k|    z_const unsigned char FAR *next;    /* next input */
  477|   311k|    unsigned char FAR *put;     /* next output */
  478|   311k|    unsigned have, left;        /* available input and output */
  479|   311k|    unsigned long hold;         /* bit buffer */
  480|   311k|    unsigned bits;              /* bits in bit buffer */
  481|   311k|    unsigned in, out;           /* save starting available input and output */
  482|   311k|    unsigned copy;              /* number of stored or match bytes to copy */
  483|   311k|    unsigned char FAR *from;    /* where to copy match bytes from */
  484|   311k|    code here;                  /* current decoding table entry */
  485|   311k|    code last;                  /* parent table entry */
  486|   311k|    unsigned len;               /* length to copy for repeats, bits to drop */
  487|   311k|    int ret;                    /* return code */
  488|       |#ifdef GUNZIP
  489|       |    unsigned char hbuf[4];      /* buffer for gzip header crc calculation */
  490|       |#endif
  491|   311k|    static const unsigned short order[19] = /* permutation of code lengths */
  492|   311k|        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
  493|       |
  494|   311k|    if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
  ------------------
  |  |  216|   623k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (494:9): [True: 0, False: 311k]
  |  Branch (494:36): [True: 0, False: 311k]
  ------------------
  495|   311k|        (strm->next_in == Z_NULL && strm->avail_in != 0))
  ------------------
  |  |  216|   623k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (495:10): [True: 42, False: 311k]
  |  Branch (495:37): [True: 0, False: 42]
  ------------------
  496|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  497|       |
  498|   311k|    state = (struct inflate_state FAR *)strm->state;
  499|   311k|    if (state->mode == TYPE) state->mode = TYPEDO;      /* skip check */
  ------------------
  |  Branch (499:9): [True: 953, False: 310k]
  ------------------
  500|   311k|    LOAD();
  ------------------
  |  |  329|   311k|    do { \
  |  |  330|   311k|        put = strm->next_out; \
  |  |  331|   311k|        left = strm->avail_out; \
  |  |  332|   311k|        next = strm->next_in; \
  |  |  333|   311k|        have = strm->avail_in; \
  |  |  334|   311k|        hold = state->hold; \
  |  |  335|   311k|        bits = state->bits; \
  |  |  336|   311k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (336:14): [Folded, False: 311k]
  |  |  ------------------
  ------------------
  501|   311k|    in = have;
  502|   311k|    out = left;
  503|   311k|    ret = Z_OK;
  ------------------
  |  |  181|   311k|#define Z_OK            0
  ------------------
  504|   311k|    for (;;)
  505|  4.33M|        switch (state->mode) {
  506|   116k|        case HEAD:
  ------------------
  |  Branch (506:9): [True: 116k, False: 4.21M]
  ------------------
  507|   116k|            if (state->wrap == 0) {
  ------------------
  |  Branch (507:17): [True: 0, False: 116k]
  ------------------
  508|      0|                state->mode = TYPEDO;
  509|      0|                break;
  510|      0|            }
  511|   116k|            NEEDBITS(16);
  ------------------
  |  |  369|   116k|    do { \
  |  |  370|   343k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 230k, False: 113k]
  |  |  ------------------
  |  |  371|   230k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   230k|    do { \
  |  |  |  |  360|   230k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 2.53k, False: 227k]
  |  |  |  |  ------------------
  |  |  |  |  361|   230k|        have--; \
  |  |  |  |  362|   227k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   227k|        bits += 8; \
  |  |  |  |  364|   227k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 227k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   116k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 113k]
  |  |  ------------------
  ------------------
  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|   113k|            if (
  527|   113k|#endif
  528|   113k|                ((BITS(8) << 8) + (hold >> 8)) % 31) {
  ------------------
  |  |  376|   113k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  |  Branch (528:17): [True: 13.1k, False: 100k]
  ------------------
  529|  13.1k|                strm->msg = (z_const char *)"incorrect header check";
  530|  13.1k|                state->mode = BAD;
  531|  13.1k|                break;
  532|  13.1k|            }
  533|   100k|            if (BITS(4) != Z_DEFLATED) {
  ------------------
  |  |  376|   100k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
                          if (BITS(4) != Z_DEFLATED) {
  ------------------
  |  |  213|   100k|#define Z_DEFLATED   8
  ------------------
  |  Branch (533:17): [True: 1.67k, False: 98.7k]
  ------------------
  534|  1.67k|                strm->msg = (z_const char *)"unknown compression method";
  535|  1.67k|                state->mode = BAD;
  536|  1.67k|                break;
  537|  1.67k|            }
  538|  98.7k|            DROPBITS(4);
  ------------------
  |  |  380|  98.7k|    do { \
  |  |  381|  98.7k|        hold >>= (n); \
  |  |  382|  98.7k|        bits -= (unsigned)(n); \
  |  |  383|  98.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 98.7k]
  |  |  ------------------
  ------------------
  539|  98.7k|            len = BITS(4) + 8;
  ------------------
  |  |  376|  98.7k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  540|  98.7k|            if (state->wbits == 0)
  ------------------
  |  Branch (540:17): [True: 0, False: 98.7k]
  ------------------
  541|      0|                state->wbits = len;
  542|  98.7k|            if (len > 15 || len > state->wbits) {
  ------------------
  |  Branch (542:17): [True: 14, False: 98.7k]
  |  Branch (542:29): [True: 0, False: 98.7k]
  ------------------
  543|     14|                strm->msg = (z_const char *)"invalid window size";
  544|     14|                state->mode = BAD;
  545|     14|                break;
  546|     14|            }
  547|  98.7k|            state->dmax = 1U << len;
  548|  98.7k|            state->flags = 0;               /* indicate zlib header */
  549|  98.7k|            Tracev((stderr, "inflate:   zlib header ok\n"));
  550|  98.7k|            strm->adler = state->check = adler32(0L, Z_NULL, 0);
  ------------------
  |  |  216|  98.7k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  551|  98.7k|            state->mode = hold & 0x200 ? DICTID : TYPE;
  ------------------
  |  Branch (551:27): [True: 170, False: 98.5k]
  ------------------
  552|  98.7k|            INITBITS();
  ------------------
  |  |  351|  98.7k|    do { \
  |  |  352|  98.7k|        hold = 0; \
  |  |  353|  98.7k|        bits = 0; \
  |  |  354|  98.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 98.7k]
  |  |  ------------------
  ------------------
  553|  98.7k|            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|    266|        case DICTID:
  ------------------
  |  Branch (694:9): [True: 266, False: 4.33M]
  ------------------
  695|    266|            NEEDBITS(32);
  ------------------
  |  |  369|    266|    do { \
  |  |  370|    872|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 733, False: 139]
  |  |  ------------------
  |  |  371|    733|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|    733|    do { \
  |  |  |  |  360|    733|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 127, False: 606]
  |  |  |  |  ------------------
  |  |  |  |  361|    733|        have--; \
  |  |  |  |  362|    606|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|    606|        bits += 8; \
  |  |  |  |  364|    606|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 606]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|    266|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 139]
  |  |  ------------------
  ------------------
  696|    139|            strm->adler = state->check = ZSWAP32(hold);
  ------------------
  |  |  258|    139|#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
  |  |  259|    139|                    (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
  ------------------
  697|    139|            INITBITS();
  ------------------
  |  |  351|    139|    do { \
  |  |  352|    139|        hold = 0; \
  |  |  353|    139|        bits = 0; \
  |  |  354|    139|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 139]
  |  |  ------------------
  ------------------
  698|    139|            state->mode = DICT;
  699|       |                /* fallthrough */
  700|    139|        case DICT:
  ------------------
  |  Branch (700:9): [True: 0, False: 4.33M]
  ------------------
  701|    139|            if (state->havedict == 0) {
  ------------------
  |  Branch (701:17): [True: 139, False: 0]
  ------------------
  702|    139|                RESTORE();
  ------------------
  |  |  340|    139|    do { \
  |  |  341|    139|        strm->next_out = put; \
  |  |  342|    139|        strm->avail_out = left; \
  |  |  343|    139|        strm->next_in = next; \
  |  |  344|    139|        strm->avail_in = have; \
  |  |  345|    139|        state->hold = hold; \
  |  |  346|    139|        state->bits = bits; \
  |  |  347|    139|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 139]
  |  |  ------------------
  ------------------
  703|    139|                return Z_NEED_DICT;
  ------------------
  |  |  183|    139|#define Z_NEED_DICT     2
  ------------------
  704|    139|            }
  705|      0|            strm->adler = state->check = adler32(0L, Z_NULL, 0);
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  706|      0|            state->mode = TYPE;
  707|       |                /* fallthrough */
  708|   193k|        case TYPE:
  ------------------
  |  Branch (708:9): [True: 193k, False: 4.14M]
  ------------------
  709|   193k|            if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  177|   387k|#define Z_BLOCK         5
  ------------------
                          if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|   193k|#define Z_TREES         6
  ------------------
  |  Branch (709:17): [True: 0, False: 193k]
  |  Branch (709:37): [True: 0, False: 193k]
  ------------------
  710|       |                /* fallthrough */
  711|   195k|        case TYPEDO:
  ------------------
  |  Branch (711:9): [True: 1.86k, False: 4.33M]
  ------------------
  712|   195k|            if (state->last) {
  ------------------
  |  Branch (712:17): [True: 86.7k, False: 108k]
  ------------------
  713|  86.7k|                BYTEBITS();
  ------------------
  |  |  387|  86.7k|    do { \
  |  |  388|  86.7k|        hold >>= bits & 7; \
  |  |  389|  86.7k|        bits -= bits & 7; \
  |  |  390|  86.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (390:14): [Folded, False: 86.7k]
  |  |  ------------------
  ------------------
  714|  86.7k|                state->mode = CHECK;
  715|  86.7k|                break;
  716|  86.7k|            }
  717|   108k|            NEEDBITS(3);
  ------------------
  |  |  369|   108k|    do { \
  |  |  370|   214k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 108k, False: 106k]
  |  |  ------------------
  |  |  371|   108k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   108k|    do { \
  |  |  |  |  360|   108k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.90k, False: 106k]
  |  |  |  |  ------------------
  |  |  |  |  361|   108k|        have--; \
  |  |  |  |  362|   106k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   106k|        bits += 8; \
  |  |  |  |  364|   106k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 106k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   108k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 106k]
  |  |  ------------------
  ------------------
  718|   106k|            state->last = BITS(1);
  ------------------
  |  |  376|   106k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  719|   106k|            DROPBITS(1);
  ------------------
  |  |  380|   106k|    do { \
  |  |  381|   106k|        hold >>= (n); \
  |  |  382|   106k|        bits -= (unsigned)(n); \
  |  |  383|   106k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 106k]
  |  |  ------------------
  ------------------
  720|   106k|            switch (BITS(2)) {
  ------------------
  |  |  376|   106k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  721|  2.70k|            case 0:                             /* stored block */
  ------------------
  |  Branch (721:13): [True: 2.70k, False: 104k]
  ------------------
  722|  2.70k|                Tracev((stderr, "inflate:     stored block%s\n",
  723|  2.70k|                        state->last ? " (last)" : ""));
  724|  2.70k|                state->mode = STORED;
  725|  2.70k|                break;
  726|  89.0k|            case 1:                             /* fixed block */
  ------------------
  |  Branch (726:13): [True: 89.0k, False: 17.7k]
  ------------------
  727|  89.0k|                inflate_fixed(state);
  728|  89.0k|                Tracev((stderr, "inflate:     fixed codes block%s\n",
  729|  89.0k|                        state->last ? " (last)" : ""));
  730|  89.0k|                state->mode = LEN_;             /* decode codes */
  731|  89.0k|                if (flush == Z_TREES) {
  ------------------
  |  |  178|  89.0k|#define Z_TREES         6
  ------------------
  |  Branch (731:21): [True: 0, False: 89.0k]
  ------------------
  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|  89.0k|                break;
  736|  89.0k|            case 2:                             /* dynamic block */
  ------------------
  |  Branch (736:13): [True: 14.8k, False: 91.9k]
  ------------------
  737|  14.8k|                Tracev((stderr, "inflate:     dynamic codes block%s\n",
  738|  14.8k|                        state->last ? " (last)" : ""));
  739|  14.8k|                state->mode = TABLE;
  740|  14.8k|                break;
  741|    131|            default:
  ------------------
  |  Branch (741:13): [True: 131, False: 106k]
  ------------------
  742|    131|                strm->msg = (z_const char *)"invalid block type";
  743|    131|                state->mode = BAD;
  744|   106k|            }
  745|   106k|            DROPBITS(2);
  ------------------
  |  |  380|   106k|    do { \
  |  |  381|   106k|        hold >>= (n); \
  |  |  382|   106k|        bits -= (unsigned)(n); \
  |  |  383|   106k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 106k]
  |  |  ------------------
  ------------------
  746|   106k|            break;
  747|  2.83k|        case STORED:
  ------------------
  |  Branch (747:9): [True: 2.83k, False: 4.33M]
  ------------------
  748|  2.83k|            BYTEBITS();                         /* go to byte boundary */
  ------------------
  |  |  387|  2.83k|    do { \
  |  |  388|  2.83k|        hold >>= bits & 7; \
  |  |  389|  2.83k|        bits -= bits & 7; \
  |  |  390|  2.83k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (390:14): [Folded, False: 2.83k]
  |  |  ------------------
  ------------------
  749|  2.83k|            NEEDBITS(32);
  ------------------
  |  |  369|  2.83k|    do { \
  |  |  370|  13.3k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 10.7k, False: 2.57k]
  |  |  ------------------
  |  |  371|  10.7k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  10.7k|    do { \
  |  |  |  |  360|  10.7k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 256, False: 10.5k]
  |  |  |  |  ------------------
  |  |  |  |  361|  10.7k|        have--; \
  |  |  |  |  362|  10.5k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  10.5k|        bits += 8; \
  |  |  |  |  364|  10.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 10.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  2.83k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 2.57k]
  |  |  ------------------
  ------------------
  750|  2.57k|            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
  ------------------
  |  Branch (750:17): [True: 581, False: 1.99k]
  ------------------
  751|    581|                strm->msg = (z_const char *)"invalid stored block lengths";
  752|    581|                state->mode = BAD;
  753|    581|                break;
  754|    581|            }
  755|  1.99k|            state->length = (unsigned)hold & 0xffff;
  756|  1.99k|            Tracev((stderr, "inflate:       stored length %u\n",
  757|  1.99k|                    state->length));
  758|  1.99k|            INITBITS();
  ------------------
  |  |  351|  1.99k|    do { \
  |  |  352|  1.99k|        hold = 0; \
  |  |  353|  1.99k|        bits = 0; \
  |  |  354|  1.99k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 1.99k]
  |  |  ------------------
  ------------------
  759|  1.99k|            state->mode = COPY_;
  760|  1.99k|            if (flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|  1.99k|#define Z_TREES         6
  ------------------
  |  Branch (760:17): [True: 0, False: 1.99k]
  ------------------
  761|       |                /* fallthrough */
  762|  1.99k|        case COPY_:
  ------------------
  |  Branch (762:9): [True: 0, False: 4.33M]
  ------------------
  763|  1.99k|            state->mode = COPY;
  764|       |                /* fallthrough */
  765|  54.7k|        case COPY:
  ------------------
  |  Branch (765:9): [True: 52.7k, False: 4.28M]
  ------------------
  766|  54.7k|            copy = state->length;
  767|  54.7k|            if (copy) {
  ------------------
  |  Branch (767:17): [True: 53.6k, False: 1.11k]
  ------------------
  768|  53.6k|                if (copy > have) copy = have;
  ------------------
  |  Branch (768:21): [True: 50.7k, False: 2.92k]
  ------------------
  769|  53.6k|                if (copy > left) copy = left;
  ------------------
  |  Branch (769:21): [True: 48.8k, False: 4.82k]
  ------------------
  770|  53.6k|                if (copy == 0) goto inf_leave;
  ------------------
  |  Branch (770:21): [True: 26.5k, False: 27.1k]
  ------------------
  771|  27.1k|                zmemcpy(put, next, copy);
  ------------------
  |  |  216|  27.1k|#    define zmemcpy memcpy
  ------------------
  772|  27.1k|                have -= copy;
  773|  27.1k|                next += copy;
  774|  27.1k|                left -= copy;
  775|  27.1k|                put += copy;
  776|  27.1k|                state->length -= copy;
  777|  27.1k|                break;
  778|  53.6k|            }
  779|  1.11k|            Tracev((stderr, "inflate:       stored end\n"));
  780|  1.11k|            state->mode = TYPE;
  781|  1.11k|            break;
  782|  18.3k|        case TABLE:
  ------------------
  |  Branch (782:9): [True: 18.3k, False: 4.31M]
  ------------------
  783|  18.3k|            NEEDBITS(14);
  ------------------
  |  |  369|  18.3k|    do { \
  |  |  370|  47.8k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 33.0k, False: 14.8k]
  |  |  ------------------
  |  |  371|  33.0k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  33.0k|    do { \
  |  |  |  |  360|  33.0k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 3.49k, False: 29.5k]
  |  |  |  |  ------------------
  |  |  |  |  361|  33.0k|        have--; \
  |  |  |  |  362|  29.5k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  29.5k|        bits += 8; \
  |  |  |  |  364|  29.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 29.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  18.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 14.8k]
  |  |  ------------------
  ------------------
  784|  14.8k|            state->nlen = BITS(5) + 257;
  ------------------
  |  |  376|  14.8k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  785|  14.8k|            DROPBITS(5);
  ------------------
  |  |  380|  14.8k|    do { \
  |  |  381|  14.8k|        hold >>= (n); \
  |  |  382|  14.8k|        bits -= (unsigned)(n); \
  |  |  383|  14.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 14.8k]
  |  |  ------------------
  ------------------
  786|  14.8k|            state->ndist = BITS(5) + 1;
  ------------------
  |  |  376|  14.8k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  787|  14.8k|            DROPBITS(5);
  ------------------
  |  |  380|  14.8k|    do { \
  |  |  381|  14.8k|        hold >>= (n); \
  |  |  382|  14.8k|        bits -= (unsigned)(n); \
  |  |  383|  14.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 14.8k]
  |  |  ------------------
  ------------------
  788|  14.8k|            state->ncode = BITS(4) + 4;
  ------------------
  |  |  376|  14.8k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  789|  14.8k|            DROPBITS(4);
  ------------------
  |  |  380|  14.8k|    do { \
  |  |  381|  14.8k|        hold >>= (n); \
  |  |  382|  14.8k|        bits -= (unsigned)(n); \
  |  |  383|  14.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 14.8k]
  |  |  ------------------
  ------------------
  790|  14.8k|#ifndef PKZIP_BUG_WORKAROUND
  791|  14.8k|            if (state->nlen > 286 || state->ndist > 30) {
  ------------------
  |  Branch (791:17): [True: 34, False: 14.8k]
  |  Branch (791:38): [True: 273, False: 14.5k]
  ------------------
  792|    307|                strm->msg = (z_const char *)
  793|    307|                    "too many length or distance symbols";
  794|    307|                state->mode = BAD;
  795|    307|                break;
  796|    307|            }
  797|  14.5k|#endif
  798|  14.5k|            Tracev((stderr, "inflate:       table sizes ok\n"));
  799|  14.5k|            state->have = 0;
  800|  14.5k|            state->mode = LENLENS;
  801|       |                /* fallthrough */
  802|  23.1k|        case LENLENS:
  ------------------
  |  Branch (802:9): [True: 8.55k, False: 4.32M]
  ------------------
  803|   267k|            while (state->have < state->ncode) {
  ------------------
  |  Branch (803:20): [True: 252k, False: 14.4k]
  ------------------
  804|   252k|                NEEDBITS(3);
  ------------------
  |  |  369|   252k|    do { \
  |  |  370|   335k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 91.3k, False: 244k]
  |  |  ------------------
  |  |  371|   252k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  91.3k|    do { \
  |  |  |  |  360|  91.3k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 8.69k, False: 82.6k]
  |  |  |  |  ------------------
  |  |  |  |  361|  91.3k|        have--; \
  |  |  |  |  362|  82.6k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  82.6k|        bits += 8; \
  |  |  |  |  364|  82.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 82.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   252k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 244k]
  |  |  ------------------
  ------------------
  805|   244k|                state->lens[order[state->have++]] = (unsigned short)BITS(3);
  ------------------
  |  |  376|   244k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  806|   244k|                DROPBITS(3);
  ------------------
  |  |  380|   244k|    do { \
  |  |  381|   244k|        hold >>= (n); \
  |  |  382|   244k|        bits -= (unsigned)(n); \
  |  |  383|   244k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 244k]
  |  |  ------------------
  ------------------
  807|   244k|            }
  808|  45.0k|            while (state->have < 19)
  ------------------
  |  Branch (808:20): [True: 30.6k, False: 14.4k]
  ------------------
  809|  30.6k|                state->lens[order[state->have++]] = 0;
  810|  14.4k|            state->next = state->codes;
  811|  14.4k|            state->lencode = state->distcode = (const code FAR *)(state->next);
  812|  14.4k|            state->lenbits = 7;
  813|  14.4k|            ret = inflate_table(CODES, state->lens, 19, &(state->next),
  814|  14.4k|                                &(state->lenbits), state->work);
  815|  14.4k|            if (ret) {
  ------------------
  |  Branch (815:17): [True: 975, False: 13.4k]
  ------------------
  816|    975|                strm->msg = (z_const char *)"invalid code lengths set";
  817|    975|                state->mode = BAD;
  818|    975|                break;
  819|    975|            }
  820|  13.4k|            Tracev((stderr, "inflate:       code lengths ok\n"));
  821|  13.4k|            state->have = 0;
  822|  13.4k|            state->mode = CODELENS;
  823|       |                /* fallthrough */
  824|  46.4k|        case CODELENS:
  ------------------
  |  Branch (824:9): [True: 32.9k, False: 4.30M]
  ------------------
  825|  1.05M|            while (state->have < state->nlen + state->ndist) {
  ------------------
  |  Branch (825:20): [True: 1.04M, False: 12.4k]
  ------------------
  826|  1.38M|                for (;;) {
  827|  1.38M|                    here = state->lencode[BITS(state->lenbits)];
  ------------------
  |  |  376|  1.38M|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  828|  1.38M|                    if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (828:25): [True: 1.01M, False: 366k]
  ------------------
  829|   366k|                    PULLBYTE();
  ------------------
  |  |  359|   366k|    do { \
  |  |  360|   366k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 26.9k, False: 339k]
  |  |  ------------------
  |  |  361|   366k|        have--; \
  |  |  362|   339k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|   339k|        bits += 8; \
  |  |  364|   339k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 339k]
  |  |  ------------------
  ------------------
  830|   366k|                }
  831|  1.01M|                if (here.val < 16) {
  ------------------
  |  Branch (831:21): [True: 938k, False: 81.2k]
  ------------------
  832|   938k|                    DROPBITS(here.bits);
  ------------------
  |  |  380|   938k|    do { \
  |  |  381|   938k|        hold >>= (n); \
  |  |  382|   938k|        bits -= (unsigned)(n); \
  |  |  383|   938k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 938k]
  |  |  ------------------
  ------------------
  833|   938k|                    state->lens[state->have++] = here.val;
  834|   938k|                }
  835|  81.2k|                else {
  836|  81.2k|                    if (here.val == 16) {
  ------------------
  |  Branch (836:25): [True: 26.3k, False: 54.9k]
  ------------------
  837|  26.3k|                        NEEDBITS(here.bits + 2);
  ------------------
  |  |  369|  26.3k|    do { \
  |  |  370|  37.4k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 11.5k, False: 25.9k]
  |  |  ------------------
  |  |  371|  26.3k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  11.5k|    do { \
  |  |  |  |  360|  11.5k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 417, False: 11.1k]
  |  |  |  |  ------------------
  |  |  |  |  361|  11.5k|        have--; \
  |  |  |  |  362|  11.1k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  11.1k|        bits += 8; \
  |  |  |  |  364|  11.1k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 11.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  26.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 25.9k]
  |  |  ------------------
  ------------------
  838|  25.9k|                        DROPBITS(here.bits);
  ------------------
  |  |  380|  25.9k|    do { \
  |  |  381|  25.9k|        hold >>= (n); \
  |  |  382|  25.9k|        bits -= (unsigned)(n); \
  |  |  383|  25.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 25.9k]
  |  |  ------------------
  ------------------
  839|  25.9k|                        if (state->have == 0) {
  ------------------
  |  Branch (839:29): [True: 35, False: 25.8k]
  ------------------
  840|     35|                            strm->msg = (z_const char *)
  841|     35|                                "invalid bit length repeat";
  842|     35|                            state->mode = BAD;
  843|     35|                            break;
  844|     35|                        }
  845|  25.8k|                        len = state->lens[state->have - 1];
  846|  25.8k|                        copy = 3 + BITS(2);
  ------------------
  |  |  376|  25.8k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  847|  25.8k|                        DROPBITS(2);
  ------------------
  |  |  380|  25.8k|    do { \
  |  |  381|  25.8k|        hold >>= (n); \
  |  |  382|  25.8k|        bits -= (unsigned)(n); \
  |  |  383|  25.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 25.8k]
  |  |  ------------------
  ------------------
  848|  25.8k|                    }
  849|  54.9k|                    else if (here.val == 17) {
  ------------------
  |  Branch (849:30): [True: 11.7k, False: 43.1k]
  ------------------
  850|  11.7k|                        NEEDBITS(here.bits + 3);
  ------------------
  |  |  369|  11.7k|    do { \
  |  |  370|  16.3k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 7.10k, False: 9.23k]
  |  |  ------------------
  |  |  371|  11.7k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  7.10k|    do { \
  |  |  |  |  360|  7.10k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 2.54k, False: 4.56k]
  |  |  |  |  ------------------
  |  |  |  |  361|  7.10k|        have--; \
  |  |  |  |  362|  4.56k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  4.56k|        bits += 8; \
  |  |  |  |  364|  4.56k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 4.56k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  11.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 9.23k]
  |  |  ------------------
  ------------------
  851|  9.23k|                        DROPBITS(here.bits);
  ------------------
  |  |  380|  9.23k|    do { \
  |  |  381|  9.23k|        hold >>= (n); \
  |  |  382|  9.23k|        bits -= (unsigned)(n); \
  |  |  383|  9.23k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 9.23k]
  |  |  ------------------
  ------------------
  852|  9.23k|                        len = 0;
  853|  9.23k|                        copy = 3 + BITS(3);
  ------------------
  |  |  376|  9.23k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  854|  9.23k|                        DROPBITS(3);
  ------------------
  |  |  380|  9.23k|    do { \
  |  |  381|  9.23k|        hold >>= (n); \
  |  |  382|  9.23k|        bits -= (unsigned)(n); \
  |  |  383|  9.23k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 9.23k]
  |  |  ------------------
  ------------------
  855|  9.23k|                    }
  856|  43.1k|                    else {
  857|  43.1k|                        NEEDBITS(here.bits + 7);
  ------------------
  |  |  369|  43.1k|    do { \
  |  |  370|  72.1k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 32.7k, False: 39.4k]
  |  |  ------------------
  |  |  371|  43.1k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  32.7k|    do { \
  |  |  |  |  360|  32.7k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 3.71k, False: 28.9k]
  |  |  |  |  ------------------
  |  |  |  |  361|  32.7k|        have--; \
  |  |  |  |  362|  28.9k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  28.9k|        bits += 8; \
  |  |  |  |  364|  28.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 28.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  43.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 39.4k]
  |  |  ------------------
  ------------------
  858|  39.4k|                        DROPBITS(here.bits);
  ------------------
  |  |  380|  39.4k|    do { \
  |  |  381|  39.4k|        hold >>= (n); \
  |  |  382|  39.4k|        bits -= (unsigned)(n); \
  |  |  383|  39.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 39.4k]
  |  |  ------------------
  ------------------
  859|  39.4k|                        len = 0;
  860|  39.4k|                        copy = 11 + BITS(7);
  ------------------
  |  |  376|  39.4k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  861|  39.4k|                        DROPBITS(7);
  ------------------
  |  |  380|  39.4k|    do { \
  |  |  381|  39.4k|        hold >>= (n); \
  |  |  382|  39.4k|        bits -= (unsigned)(n); \
  |  |  383|  39.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 39.4k]
  |  |  ------------------
  ------------------
  862|  39.4k|                    }
  863|  74.5k|                    if (state->have + copy > state->nlen + state->ndist) {
  ------------------
  |  Branch (863:25): [True: 387, False: 74.1k]
  ------------------
  864|    387|                        strm->msg = (z_const char *)
  865|    387|                            "invalid bit length repeat";
  866|    387|                        state->mode = BAD;
  867|    387|                        break;
  868|    387|                    }
  869|  3.11M|                    while (copy--)
  ------------------
  |  Branch (869:28): [True: 3.03M, False: 74.1k]
  ------------------
  870|  3.03M|                        state->lens[state->have++] = (unsigned short)len;
  871|  74.1k|                }
  872|  1.01M|            }
  873|       |
  874|       |            /* handle error breaks in while */
  875|  12.8k|            if (state->mode == BAD) break;
  ------------------
  |  Branch (875:17): [True: 422, False: 12.4k]
  ------------------
  876|       |
  877|       |            /* check for end-of-block code (better have one) */
  878|  12.4k|            if (state->lens[256] == 0) {
  ------------------
  |  Branch (878:17): [True: 187, False: 12.2k]
  ------------------
  879|    187|                strm->msg = (z_const char *)
  880|    187|                    "invalid code -- missing end-of-block";
  881|    187|                state->mode = BAD;
  882|    187|                break;
  883|    187|            }
  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|  12.2k|            state->next = state->codes;
  889|  12.2k|            state->lencode = (const code FAR *)(state->next);
  890|  12.2k|            state->lenbits = 9;
  891|  12.2k|            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
  892|  12.2k|                                &(state->lenbits), state->work);
  893|  12.2k|            if (ret) {
  ------------------
  |  Branch (893:17): [True: 400, False: 11.8k]
  ------------------
  894|    400|                strm->msg = (z_const char *)"invalid literal/lengths set";
  895|    400|                state->mode = BAD;
  896|    400|                break;
  897|    400|            }
  898|  11.8k|            state->distcode = (const code FAR *)(state->next);
  899|  11.8k|            state->distbits = 6;
  900|  11.8k|            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
  901|  11.8k|                            &(state->next), &(state->distbits), state->work);
  902|  11.8k|            if (ret) {
  ------------------
  |  Branch (902:17): [True: 311, False: 11.5k]
  ------------------
  903|    311|                strm->msg = (z_const char *)"invalid distances set";
  904|    311|                state->mode = BAD;
  905|    311|                break;
  906|    311|            }
  907|  11.5k|            Tracev((stderr, "inflate:       codes ok\n"));
  908|  11.5k|            state->mode = LEN_;
  909|  11.5k|            if (flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|  11.5k|#define Z_TREES         6
  ------------------
  |  Branch (909:17): [True: 0, False: 11.5k]
  ------------------
  910|       |                /* fallthrough */
  911|   100k|        case LEN_:
  ------------------
  |  Branch (911:9): [True: 89.0k, False: 4.24M]
  ------------------
  912|   100k|            state->mode = LEN;
  913|       |                /* fallthrough */
  914|  2.20M|        case LEN:
  ------------------
  |  Branch (914:9): [True: 2.10M, False: 2.22M]
  ------------------
  915|  2.20M|            if (have >= 6 && left >= 258) {
  ------------------
  |  Branch (915:17): [True: 1.98M, False: 222k]
  |  Branch (915:30): [True: 237k, False: 1.74M]
  ------------------
  916|   237k|                RESTORE();
  ------------------
  |  |  340|   237k|    do { \
  |  |  341|   237k|        strm->next_out = put; \
  |  |  342|   237k|        strm->avail_out = left; \
  |  |  343|   237k|        strm->next_in = next; \
  |  |  344|   237k|        strm->avail_in = have; \
  |  |  345|   237k|        state->hold = hold; \
  |  |  346|   237k|        state->bits = bits; \
  |  |  347|   237k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 237k]
  |  |  ------------------
  ------------------
  917|   237k|                inflate_fast(strm, out);
  918|   237k|                LOAD();
  ------------------
  |  |  329|   237k|    do { \
  |  |  330|   237k|        put = strm->next_out; \
  |  |  331|   237k|        left = strm->avail_out; \
  |  |  332|   237k|        next = strm->next_in; \
  |  |  333|   237k|        have = strm->avail_in; \
  |  |  334|   237k|        hold = state->hold; \
  |  |  335|   237k|        bits = state->bits; \
  |  |  336|   237k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (336:14): [Folded, False: 237k]
  |  |  ------------------
  ------------------
  919|   237k|                if (state->mode == TYPE)
  ------------------
  |  Branch (919:21): [True: 85.6k, False: 152k]
  ------------------
  920|  85.6k|                    state->back = -1;
  921|   237k|                break;
  922|   237k|            }
  923|  1.97M|            state->back = 0;
  924|  2.89M|            for (;;) {
  925|  2.89M|                here = state->lencode[BITS(state->lenbits)];
  ------------------
  |  |  376|  2.89M|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  926|  2.89M|                if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (926:21): [True: 1.93M, False: 962k]
  ------------------
  927|   962k|                PULLBYTE();
  ------------------
  |  |  359|   962k|    do { \
  |  |  360|   962k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 39.3k, False: 923k]
  |  |  ------------------
  |  |  361|   962k|        have--; \
  |  |  362|   923k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|   923k|        bits += 8; \
  |  |  364|   923k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 923k]
  |  |  ------------------
  ------------------
  928|   962k|            }
  929|  1.93M|            if (here.op && (here.op & 0xf0) == 0) {
  ------------------
  |  Branch (929:17): [True: 499k, False: 1.43M]
  |  Branch (929:28): [True: 19.5k, False: 480k]
  ------------------
  930|  19.5k|                last = here;
  931|  25.8k|                for (;;) {
  932|  25.8k|                    here = state->lencode[last.val +
  933|  25.8k|                            (BITS(last.bits + last.op) >> last.bits)];
  ------------------
  |  |  376|  25.8k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  934|  25.8k|                    if ((unsigned)(last.bits + here.bits) <= bits) break;
  ------------------
  |  Branch (934:25): [True: 18.7k, False: 7.11k]
  ------------------
  935|  7.11k|                    PULLBYTE();
  ------------------
  |  |  359|  7.11k|    do { \
  |  |  360|  7.11k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 854, False: 6.25k]
  |  |  ------------------
  |  |  361|  7.11k|        have--; \
  |  |  362|  6.25k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|  6.25k|        bits += 8; \
  |  |  364|  6.25k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 6.25k]
  |  |  ------------------
  ------------------
  936|  7.11k|                }
  937|  18.7k|                DROPBITS(last.bits);
  ------------------
  |  |  380|  18.7k|    do { \
  |  |  381|  18.7k|        hold >>= (n); \
  |  |  382|  18.7k|        bits -= (unsigned)(n); \
  |  |  383|  18.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 18.7k]
  |  |  ------------------
  ------------------
  938|  18.7k|                state->back += last.bits;
  939|  18.7k|            }
  940|  1.93M|            DROPBITS(here.bits);
  ------------------
  |  |  380|  1.93M|    do { \
  |  |  381|  1.93M|        hold >>= (n); \
  |  |  382|  1.93M|        bits -= (unsigned)(n); \
  |  |  383|  1.93M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 1.93M]
  |  |  ------------------
  ------------------
  941|  1.93M|            state->back += here.bits;
  942|  1.93M|            state->length = (unsigned)here.val;
  943|  1.93M|            if ((int)(here.op) == 0) {
  ------------------
  |  Branch (943:17): [True: 1.43M, False: 497k]
  ------------------
  944|  1.43M|                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
  945|  1.43M|                        "inflate:         literal '%c'\n" :
  946|  1.43M|                        "inflate:         literal 0x%02x\n", here.val));
  947|  1.43M|                state->mode = LIT;
  948|  1.43M|                break;
  949|  1.43M|            }
  950|   497k|            if (here.op & 32) {
  ------------------
  |  Branch (950:17): [True: 8.22k, False: 489k]
  ------------------
  951|  8.22k|                Tracevv((stderr, "inflate:         end of block\n"));
  952|  8.22k|                state->back = -1;
  953|  8.22k|                state->mode = TYPE;
  954|  8.22k|                break;
  955|  8.22k|            }
  956|   489k|            if (here.op & 64) {
  ------------------
  |  Branch (956:17): [True: 55, False: 489k]
  ------------------
  957|     55|                strm->msg = (z_const char *)"invalid literal/length code";
  958|     55|                state->mode = BAD;
  959|     55|                break;
  960|     55|            }
  961|   489k|            state->extra = (unsigned)(here.op) & 15;
  962|   489k|            state->mode = LENEXT;
  963|       |                /* fallthrough */
  964|   496k|        case LENEXT:
  ------------------
  |  Branch (964:9): [True: 7.89k, False: 4.32M]
  ------------------
  965|   496k|            if (state->extra) {
  ------------------
  |  Branch (965:17): [True: 296k, False: 200k]
  ------------------
  966|   296k|                NEEDBITS(state->extra);
  ------------------
  |  |  369|   296k|    do { \
  |  |  370|   321k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 32.6k, False: 288k]
  |  |  ------------------
  |  |  371|   296k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  32.6k|    do { \
  |  |  |  |  360|  32.6k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 8.10k, False: 24.5k]
  |  |  |  |  ------------------
  |  |  |  |  361|  32.6k|        have--; \
  |  |  |  |  362|  24.5k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  24.5k|        bits += 8; \
  |  |  |  |  364|  24.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 24.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   296k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 288k]
  |  |  ------------------
  ------------------
  967|   288k|                state->length += BITS(state->extra);
  ------------------
  |  |  376|   288k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  968|   288k|                DROPBITS(state->extra);
  ------------------
  |  |  380|   288k|    do { \
  |  |  381|   288k|        hold >>= (n); \
  |  |  382|   288k|        bits -= (unsigned)(n); \
  |  |  383|   288k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 288k]
  |  |  ------------------
  ------------------
  969|   288k|                state->back += state->extra;
  970|   288k|            }
  971|   488k|            Tracevv((stderr, "inflate:         length %u\n", state->length));
  972|   488k|            state->was = state->length;
  973|   488k|            state->mode = DIST;
  974|       |                /* fallthrough */
  975|   502k|        case DIST:
  ------------------
  |  Branch (975:9): [True: 13.6k, False: 4.32M]
  ------------------
  976|   668k|            for (;;) {
  977|   668k|                here = state->distcode[BITS(state->distbits)];
  ------------------
  |  |  376|   668k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  978|   668k|                if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (978:21): [True: 488k, False: 180k]
  ------------------
  979|   180k|                PULLBYTE();
  ------------------
  |  |  359|   180k|    do { \
  |  |  360|   180k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 14.2k, False: 166k]
  |  |  ------------------
  |  |  361|   180k|        have--; \
  |  |  362|   166k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|   166k|        bits += 8; \
  |  |  364|   166k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 166k]
  |  |  ------------------
  ------------------
  980|   180k|            }
  981|   488k|            if ((here.op & 0xf0) == 0) {
  ------------------
  |  Branch (981:17): [True: 3.05k, False: 485k]
  ------------------
  982|  3.05k|                last = here;
  983|  4.45k|                for (;;) {
  984|  4.45k|                    here = state->distcode[last.val +
  985|  4.45k|                            (BITS(last.bits + last.op) >> last.bits)];
  ------------------
  |  |  376|  4.45k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  986|  4.45k|                    if ((unsigned)(last.bits + here.bits) <= bits) break;
  ------------------
  |  Branch (986:25): [True: 3.00k, False: 1.45k]
  ------------------
  987|  1.45k|                    PULLBYTE();
  ------------------
  |  |  359|  1.45k|    do { \
  |  |  360|  1.45k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 56, False: 1.40k]
  |  |  ------------------
  |  |  361|  1.45k|        have--; \
  |  |  362|  1.40k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|  1.40k|        bits += 8; \
  |  |  364|  1.40k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 1.40k]
  |  |  ------------------
  ------------------
  988|  1.45k|                }
  989|  3.00k|                DROPBITS(last.bits);
  ------------------
  |  |  380|  3.00k|    do { \
  |  |  381|  3.00k|        hold >>= (n); \
  |  |  382|  3.00k|        bits -= (unsigned)(n); \
  |  |  383|  3.00k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 3.00k]
  |  |  ------------------
  ------------------
  990|  3.00k|                state->back += last.bits;
  991|  3.00k|            }
  992|   488k|            DROPBITS(here.bits);
  ------------------
  |  |  380|   488k|    do { \
  |  |  381|   488k|        hold >>= (n); \
  |  |  382|   488k|        bits -= (unsigned)(n); \
  |  |  383|   488k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 488k]
  |  |  ------------------
  ------------------
  993|   488k|            state->back += here.bits;
  994|   488k|            if (here.op & 64) {
  ------------------
  |  Branch (994:17): [True: 90, False: 488k]
  ------------------
  995|     90|                strm->msg = (z_const char *)"invalid distance code";
  996|     90|                state->mode = BAD;
  997|     90|                break;
  998|     90|            }
  999|   488k|            state->offset = (unsigned)here.val;
 1000|   488k|            state->extra = (unsigned)(here.op) & 15;
 1001|   488k|            state->mode = DISTEXT;
 1002|       |                /* fallthrough */
 1003|   497k|        case DISTEXT:
  ------------------
  |  Branch (1003:9): [True: 9.23k, False: 4.32M]
  ------------------
 1004|   497k|            if (state->extra) {
  ------------------
  |  Branch (1004:17): [True: 380k, False: 117k]
  ------------------
 1005|   380k|                NEEDBITS(state->extra);
  ------------------
  |  |  369|   380k|    do { \
  |  |  370|   466k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 95.7k, False: 370k]
  |  |  ------------------
  |  |  371|   380k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  95.7k|    do { \
  |  |  |  |  360|  95.7k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 9.89k, False: 85.8k]
  |  |  |  |  ------------------
  |  |  |  |  361|  95.7k|        have--; \
  |  |  |  |  362|  85.8k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  85.8k|        bits += 8; \
  |  |  |  |  364|  85.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 85.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   380k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 370k]
  |  |  ------------------
  ------------------
 1006|   370k|                state->offset += BITS(state->extra);
  ------------------
  |  |  376|   370k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
 1007|   370k|                DROPBITS(state->extra);
  ------------------
  |  |  380|   370k|    do { \
  |  |  381|   370k|        hold >>= (n); \
  |  |  382|   370k|        bits -= (unsigned)(n); \
  |  |  383|   370k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 370k]
  |  |  ------------------
  ------------------
 1008|   370k|                state->back += state->extra;
 1009|   370k|            }
 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|   487k|            Tracevv((stderr, "inflate:         distance %u\n", state->offset));
 1018|   487k|            state->mode = MATCH;
 1019|       |                /* fallthrough */
 1020|   611k|        case MATCH:
  ------------------
  |  Branch (1020:9): [True: 123k, False: 4.21M]
  ------------------
 1021|   611k|            if (left == 0) goto inf_leave;
  ------------------
  |  Branch (1021:17): [True: 46.4k, False: 564k]
  ------------------
 1022|   564k|            copy = out - left;
 1023|   564k|            if (state->offset > copy) {         /* copy from window */
  ------------------
  |  Branch (1023:17): [True: 77.1k, False: 487k]
  ------------------
 1024|  77.1k|                copy = state->offset - copy;
 1025|  77.1k|                if (copy > state->whave) {
  ------------------
  |  Branch (1025:21): [True: 838, False: 76.2k]
  ------------------
 1026|    838|                    if (state->sane) {
  ------------------
  |  Branch (1026:25): [True: 838, False: 0]
  ------------------
 1027|    838|                        strm->msg = (z_const char *)
 1028|    838|                            "invalid distance too far back";
 1029|    838|                        state->mode = BAD;
 1030|    838|                        break;
 1031|    838|                    }
 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|    838|                }
 1046|  76.2k|                if (copy > state->wnext) {
  ------------------
  |  Branch (1046:21): [True: 15.7k, False: 60.4k]
  ------------------
 1047|  15.7k|                    copy -= state->wnext;
 1048|  15.7k|                    from = state->window + (state->wsize - copy);
 1049|  15.7k|                }
 1050|  60.4k|                else
 1051|  60.4k|                    from = state->window + (state->wnext - copy);
 1052|  76.2k|                if (copy > state->length) copy = state->length;
  ------------------
  |  Branch (1052:21): [True: 38.6k, False: 37.6k]
  ------------------
 1053|  76.2k|            }
 1054|   487k|            else {                              /* copy from output */
 1055|   487k|                from = put - state->offset;
 1056|   487k|                copy = state->length;
 1057|   487k|            }
 1058|   564k|            if (copy > left) copy = left;
  ------------------
  |  Branch (1058:17): [True: 43.5k, False: 520k]
  ------------------
 1059|   564k|            left -= copy;
 1060|   564k|            state->length -= copy;
 1061|  27.9M|            do {
 1062|  27.9M|                *put++ = *from++;
 1063|  27.9M|            } while (--copy);
  ------------------
  |  Branch (1063:22): [True: 27.3M, False: 564k]
  ------------------
 1064|   564k|            if (state->length == 0) state->mode = LEN;
  ------------------
  |  Branch (1064:17): [True: 486k, False: 77.7k]
  ------------------
 1065|   564k|            break;
 1066|  1.44M|        case LIT:
  ------------------
  |  Branch (1066:9): [True: 1.44M, False: 2.89M]
  ------------------
 1067|  1.44M|            if (left == 0) goto inf_leave;
  ------------------
  |  Branch (1067:17): [True: 8.11k, False: 1.43M]
  ------------------
 1068|  1.43M|            *put++ = (unsigned char)(state->length);
 1069|  1.43M|            left--;
 1070|  1.43M|            state->mode = LEN;
 1071|  1.43M|            break;
 1072|  86.8k|        case CHECK:
  ------------------
  |  Branch (1072:9): [True: 86.8k, False: 4.24M]
  ------------------
 1073|  86.8k|            if (state->wrap) {
  ------------------
  |  Branch (1073:17): [True: 86.8k, False: 0]
  ------------------
 1074|  86.8k|                NEEDBITS(32);
  ------------------
  |  |  369|  86.8k|    do { \
  |  |  370|   431k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 346k, False: 85.0k]
  |  |  ------------------
  |  |  371|   346k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   346k|    do { \
  |  |  |  |  360|   346k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.79k, False: 344k]
  |  |  |  |  ------------------
  |  |  |  |  361|   346k|        have--; \
  |  |  |  |  362|   344k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   344k|        bits += 8; \
  |  |  |  |  364|   344k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 344k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  86.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 85.0k]
  |  |  ------------------
  ------------------
 1075|  85.0k|                out -= left;
 1076|  85.0k|                strm->total_out += out;
 1077|  85.0k|                state->total += out;
 1078|  85.0k|                if ((state->wrap & 4) && out)
  ------------------
  |  Branch (1078:21): [True: 85.0k, False: 0]
  |  Branch (1078:42): [True: 84.6k, False: 448]
  ------------------
 1079|  84.6k|                    strm->adler = state->check =
 1080|  84.6k|                        UPDATE_CHECK(state->check, put - out, out);
  ------------------
  |  |  305|  84.6k|#  define UPDATE_CHECK(check, buf, len) adler32(check, buf, len)
  ------------------
 1081|  85.0k|                out = left;
 1082|  85.0k|                if ((state->wrap & 4) && (
  ------------------
  |  Branch (1082:21): [True: 85.0k, False: 0]
  |  Branch (1082:42): [True: 8.11k, False: 76.9k]
  ------------------
 1083|       |#ifdef GUNZIP
 1084|       |                     state->flags ? hold :
 1085|       |#endif
 1086|  85.0k|                     ZSWAP32(hold)) != state->check) {
  ------------------
  |  |  258|  85.0k|#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
  |  |  259|  85.0k|                    (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
  ------------------
 1087|  8.11k|                    strm->msg = (z_const char *)"incorrect data check";
 1088|  8.11k|                    state->mode = BAD;
 1089|  8.11k|                    break;
 1090|  8.11k|                }
 1091|  76.9k|                INITBITS();
  ------------------
  |  |  351|  76.9k|    do { \
  |  |  352|  76.9k|        hold = 0; \
  |  |  353|  76.9k|        bits = 0; \
  |  |  354|  76.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 76.9k]
  |  |  ------------------
  ------------------
 1092|  76.9k|                Tracev((stderr, "inflate:   check matches trailer\n"));
 1093|  76.9k|            }
 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.9k|            state->mode = DONE;
 1110|       |                /* fallthrough */
 1111|  76.9k|        case DONE:
  ------------------
  |  Branch (1111:9): [True: 12, False: 4.33M]
  ------------------
 1112|  76.9k|            ret = Z_STREAM_END;
  ------------------
  |  |  182|  76.9k|#define Z_STREAM_END    1
  ------------------
 1113|  76.9k|            goto inf_leave;
 1114|  28.7k|        case BAD:
  ------------------
  |  Branch (1114:9): [True: 28.7k, False: 4.30M]
  ------------------
 1115|  28.7k|            ret = Z_DATA_ERROR;
  ------------------
  |  |  186|  28.7k|#define Z_DATA_ERROR   (-3)
  ------------------
 1116|  28.7k|            goto inf_leave;
 1117|      0|        case MEM:
  ------------------
  |  Branch (1117:9): [True: 0, False: 4.33M]
  ------------------
 1118|      0|            return Z_MEM_ERROR;
  ------------------
  |  |  187|      0|#define Z_MEM_ERROR    (-4)
  ------------------
 1119|      0|        case SYNC:
  ------------------
  |  Branch (1119:9): [True: 0, False: 4.33M]
  ------------------
 1120|       |                /* fallthrough */
 1121|      0|        default:
  ------------------
  |  Branch (1121:9): [True: 0, False: 4.33M]
  ------------------
 1122|      0|            return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
 1123|  4.33M|        }
 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|   311k|  inf_leave:
 1132|   311k|    RESTORE();
  ------------------
  |  |  340|   311k|    do { \
  |  |  341|   311k|        strm->next_out = put; \
  |  |  342|   311k|        strm->avail_out = left; \
  |  |  343|   311k|        strm->next_in = next; \
  |  |  344|   311k|        strm->avail_in = have; \
  |  |  345|   311k|        state->hold = hold; \
  |  |  346|   311k|        state->bits = bits; \
  |  |  347|   311k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 311k]
  |  |  ------------------
  ------------------
 1133|   311k|    if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
  ------------------
  |  Branch (1133:9): [True: 147k, False: 164k]
  |  Branch (1133:26): [True: 11.8k, False: 152k]
  |  Branch (1133:52): [True: 10.2k, False: 1.69k]
  ------------------
 1134|  10.2k|            (state->mode < CHECK || flush != Z_FINISH)))
  ------------------
  |  |  176|  1.47k|#define Z_FINISH        4
  ------------------
  |  Branch (1134:14): [True: 8.73k, False: 1.47k]
  |  Branch (1134:37): [True: 1.47k, False: 0]
  ------------------
 1135|   157k|        if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
  ------------------
  |  Branch (1135:13): [True: 0, False: 157k]
  ------------------
 1136|      0|            state->mode = MEM;
 1137|      0|            return Z_MEM_ERROR;
  ------------------
  |  |  187|      0|#define Z_MEM_ERROR    (-4)
  ------------------
 1138|      0|        }
 1139|   311k|    in -= strm->avail_in;
 1140|   311k|    out -= strm->avail_out;
 1141|   311k|    strm->total_in += in;
 1142|   311k|    strm->total_out += out;
 1143|   311k|    state->total += out;
 1144|   311k|    if ((state->wrap & 4) && out)
  ------------------
  |  Branch (1144:9): [True: 311k, False: 0]
  |  Branch (1144:30): [True: 122k, False: 188k]
  ------------------
 1145|   122k|        strm->adler = state->check =
 1146|   122k|            UPDATE_CHECK(state->check, strm->next_out - out, out);
  ------------------
  |  |  305|   122k|#  define UPDATE_CHECK(check, buf, len) adler32(check, buf, len)
  ------------------
 1147|   311k|    strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
  ------------------
  |  Branch (1147:43): [True: 256k, False: 55.4k]
  ------------------
 1148|   311k|                      (state->mode == TYPE ? 128 : 0) +
  ------------------
  |  Branch (1148:24): [True: 960, False: 310k]
  ------------------
 1149|   311k|                      (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
  ------------------
  |  Branch (1149:24): [True: 0, False: 311k]
  |  Branch (1149:47): [True: 0, False: 311k]
  ------------------
 1150|   311k|    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
  ------------------
  |  |  176|   260k|#define Z_FINISH        4
  ------------------
                  if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
  ------------------
  |  |  181|  51.0k|#define Z_OK            0
  ------------------
  |  Branch (1150:11): [True: 57.2k, False: 254k]
  |  Branch (1150:22): [True: 51.0k, False: 6.14k]
  |  Branch (1150:35): [True: 0, False: 260k]
  |  Branch (1150:57): [True: 50.9k, False: 70]
  ------------------
 1151|  50.9k|        ret = Z_BUF_ERROR;
  ------------------
  |  |  188|  50.9k|#define Z_BUF_ERROR    (-5)
  ------------------
 1152|   311k|    return ret;
 1153|   311k|}
inflateEnd:
 1155|   128k|int ZEXPORT inflateEnd(z_streamp strm) {
 1156|   128k|    struct inflate_state FAR *state;
 1157|   128k|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (1157:9): [True: 13.9k, False: 114k]
  ------------------
 1158|  13.9k|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|  13.9k|#define Z_STREAM_ERROR (-2)
  ------------------
 1159|   114k|    state = (struct inflate_state FAR *)strm->state;
 1160|   114k|    if (state->window != Z_NULL) ZFREE(strm, state->window);
  ------------------
  |  |  216|   114k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
                  if (state->window != Z_NULL) ZFREE(strm, state->window);
  ------------------
  |  |  254|  10.2k|#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  ------------------
  |  Branch (1160:9): [True: 10.2k, False: 103k]
  ------------------
 1161|   114k|    ZFREE(strm, strm->state);
  ------------------
  |  |  254|   114k|#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  ------------------
 1162|   114k|    strm->state = Z_NULL;
  ------------------
  |  |  216|   114k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
 1163|   114k|    Tracev((stderr, "inflate: end\n"));
 1164|   114k|    return Z_OK;
  ------------------
  |  |  181|   114k|#define Z_OK            0
  ------------------
 1165|   128k|}
inflateValidate:
 1385|   114k|int ZEXPORT inflateValidate(z_streamp strm, int check) {
 1386|   114k|    struct inflate_state FAR *state;
 1387|       |
 1388|   114k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (1388:9): [True: 0, False: 114k]
  ------------------
 1389|   114k|    state = (struct inflate_state FAR *)strm->state;
 1390|   114k|    if (check && state->wrap)
  ------------------
  |  Branch (1390:9): [True: 114k, False: 0]
  |  Branch (1390:18): [True: 114k, False: 0]
  ------------------
 1391|   114k|        state->wrap |= 4;
 1392|      0|    else
 1393|      0|        state->wrap &= ~4;
 1394|   114k|    return Z_OK;
  ------------------
  |  |  181|   114k|#define Z_OK            0
  ------------------
 1395|   114k|}
inflate.c:inflateStateCheck:
   88|   896k|local int inflateStateCheck(z_streamp strm) {
   89|   896k|    struct inflate_state FAR *state;
   90|   896k|    if (strm == Z_NULL ||
  ------------------
  |  |  216|  1.79M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (90:9): [True: 0, False: 896k]
  ------------------
   91|   896k|        strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
  ------------------
  |  Branch (91:9): [True: 13.9k, False: 882k]
  |  Branch (91:42): [True: 0, False: 882k]
  ------------------
   92|  13.9k|        return 1;
   93|   882k|    state = (struct inflate_state FAR *)strm->state;
   94|   882k|    if (state == Z_NULL || state->strm != strm ||
  ------------------
  |  |  216|  1.76M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (94:9): [True: 0, False: 882k]
  |  Branch (94:28): [True: 0, False: 882k]
  ------------------
   95|   882k|        state->mode < HEAD || state->mode > SYNC)
  ------------------
  |  Branch (95:9): [True: 0, False: 882k]
  |  Branch (95:31): [True: 0, False: 882k]
  ------------------
   96|      0|        return 1;
   97|   882k|    return 0;
   98|   882k|}
inflate.c:updatewindow:
  252|   157k|local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
  253|   157k|    struct inflate_state FAR *state;
  254|   157k|    unsigned dist;
  255|       |
  256|   157k|    state = (struct inflate_state FAR *)strm->state;
  257|       |
  258|       |    /* if it hasn't been done already, allocate space for the window */
  259|   157k|    if (state->window == Z_NULL) {
  ------------------
  |  |  216|   157k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (259:9): [True: 10.2k, False: 147k]
  ------------------
  260|  10.2k|        state->window = (unsigned char FAR *)
  261|  10.2k|                        ZALLOC(strm, 1U << state->wbits,
  ------------------
  |  |  253|  10.2k|           (*((strm)->zalloc))((strm)->opaque, (items), (size))
  ------------------
  262|  10.2k|                               sizeof(unsigned char));
  263|  10.2k|        if (state->window == Z_NULL) return 1;
  ------------------
  |  |  216|  10.2k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (263:13): [True: 0, False: 10.2k]
  ------------------
  264|  10.2k|    }
  265|       |
  266|       |    /* if window not in use yet, initialize */
  267|   157k|    if (state->wsize == 0) {
  ------------------
  |  Branch (267:9): [True: 10.2k, False: 147k]
  ------------------
  268|  10.2k|        state->wsize = 1U << state->wbits;
  269|  10.2k|        state->wnext = 0;
  270|  10.2k|        state->whave = 0;
  271|  10.2k|    }
  272|       |
  273|       |    /* copy state->wsize or less output bytes into the circular window */
  274|   157k|    if (copy >= state->wsize) {
  ------------------
  |  Branch (274:9): [True: 19.7k, False: 137k]
  ------------------
  275|  19.7k|        zmemcpy(state->window, end - state->wsize, state->wsize);
  ------------------
  |  |  216|  19.7k|#    define zmemcpy memcpy
  ------------------
  276|  19.7k|        state->wnext = 0;
  277|  19.7k|        state->whave = state->wsize;
  278|  19.7k|    }
  279|   137k|    else {
  280|   137k|        dist = state->wsize - state->wnext;
  281|   137k|        if (dist > copy) dist = copy;
  ------------------
  |  Branch (281:13): [True: 131k, False: 6.04k]
  ------------------
  282|   137k|        zmemcpy(state->window + state->wnext, end - copy, dist);
  ------------------
  |  |  216|   137k|#    define zmemcpy memcpy
  ------------------
  283|   137k|        copy -= dist;
  284|   137k|        if (copy) {
  ------------------
  |  Branch (284:13): [True: 2.26k, False: 135k]
  ------------------
  285|  2.26k|            zmemcpy(state->window, end - copy, copy);
  ------------------
  |  |  216|  2.26k|#    define zmemcpy memcpy
  ------------------
  286|  2.26k|            state->wnext = copy;
  287|  2.26k|            state->whave = state->wsize;
  288|  2.26k|        }
  289|   135k|        else {
  290|   135k|            state->wnext += dist;
  291|   135k|            if (state->wnext == state->wsize) state->wnext = 0;
  ------------------
  |  Branch (291:17): [True: 3.78k, False: 131k]
  ------------------
  292|   135k|            if (state->whave < state->wsize) state->whave += dist;
  ------------------
  |  Branch (292:17): [True: 117k, False: 17.5k]
  ------------------
  293|   135k|        }
  294|   137k|    }
  295|   157k|    return 0;
  296|   157k|}

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

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

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

