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

jsimd_set_rgb_ycc:
  118|  10.4k|{
  119|  10.4k|  init_simd((j_common_ptr)cinfo);
  120|       |
  121|  10.4k|  if (BITS_IN_JSAMPLE != 8)
  ------------------
  |  |   34|  10.4k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (121:7): [Folded, False: 10.4k]
  ------------------
  122|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  123|  10.4k|  if (sizeof(JDIMENSION) != 4)
  ------------------
  |  Branch (123:7): [Folded, False: 10.4k]
  ------------------
  124|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  125|  10.4k|  if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
  ------------------
  |  |  302|  10.4k|#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 (125:7): [Folded, False: 10.4k]
  |  Branch (125:31): [True: 0, Folded]
  ------------------
  126|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  127|  10.4k|  if (!cinfo->cconvert)
  ------------------
  |  Branch (127:7): [True: 0, False: 10.4k]
  ------------------
  128|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  129|       |
  130|  10.4k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
  131|  10.4k|  if ((cinfo->master->simd_support & JSIMD_AVX2) &&
  ------------------
  |  |   46|  10.4k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (131:7): [True: 10.4k, False: 0]
  ------------------
  132|  10.4k|      IS_ALIGNED_AVX(jconst_rgb_ycc_convert_avx2)) {
  ------------------
  |  |   46|  10.4k|#define IS_ALIGNED_AVX(ptr)  (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
  |  |  ------------------
  |  |  |  |   43|  10.4k|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (46:30): [True: 10.4k, False: 0]
  |  |  ------------------
  ------------------
  133|  10.4k|    SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, avx2);
  ------------------
  |  |   41|  10.4k|#define SET_SIMD_EXTRGB_COLOR_CONVERTER(cs, instrset) { \
  |  |   42|  10.4k|  switch (cinfo->in_color_space) { \
  |  |   43|      0|    case JCS_EXT_RGB: \
  |  |  ------------------
  |  |  |  Branch (43:5): [True: 0, False: 10.4k]
  |  |  ------------------
  |  |   44|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   45|      0|        jsimd_extrgb_##cs##_convert_##instrset; \
  |  |   46|      0|      break; \
  |  |   47|  3.42k|    case JCS_EXT_RGBX: \
  |  |  ------------------
  |  |  |  Branch (47:5): [True: 3.42k, False: 6.99k]
  |  |  ------------------
  |  |   48|  3.42k|    case JCS_EXT_RGBA: \
  |  |  ------------------
  |  |  |  Branch (48:5): [True: 0, False: 10.4k]
  |  |  ------------------
  |  |   49|  3.42k|      cinfo->cconvert->color_convert_simd = \
  |  |   50|  3.42k|        jsimd_extrgbx_##cs##_convert_##instrset; \
  |  |   51|  3.42k|      break; \
  |  |   52|  3.57k|    case JCS_EXT_BGR: \
  |  |  ------------------
  |  |  |  Branch (52:5): [True: 3.57k, False: 6.85k]
  |  |  ------------------
  |  |   53|  3.57k|      cinfo->cconvert->color_convert_simd = \
  |  |   54|  3.57k|        jsimd_extbgr_##cs##_convert_##instrset; \
  |  |   55|  3.57k|      break; \
  |  |   56|  3.42k|    case JCS_EXT_BGRX: \
  |  |  ------------------
  |  |  |  Branch (56:5): [True: 0, False: 10.4k]
  |  |  ------------------
  |  |   57|  3.42k|    case JCS_EXT_BGRA: \
  |  |  ------------------
  |  |  |  Branch (57:5): [True: 3.42k, False: 6.99k]
  |  |  ------------------
  |  |   58|  3.42k|      cinfo->cconvert->color_convert_simd = \
  |  |   59|  3.42k|        jsimd_extbgrx_##cs##_convert_##instrset; \
  |  |   60|  3.42k|      break; \
  |  |   61|      0|    case JCS_EXT_XBGR: \
  |  |  ------------------
  |  |  |  Branch (61:5): [True: 0, False: 10.4k]
  |  |  ------------------
  |  |   62|      0|    case JCS_EXT_ABGR: \
  |  |  ------------------
  |  |  |  Branch (62:5): [True: 0, False: 10.4k]
  |  |  ------------------
  |  |   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.4k]
  |  |  ------------------
  |  |   67|      0|    case JCS_EXT_ARGB: \
  |  |  ------------------
  |  |  |  Branch (67:5): [True: 0, False: 10.4k]
  |  |  ------------------
  |  |   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.4k]
  |  |  ------------------
  |  |   72|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   73|      0|        jsimd_rgb_##cs##_convert_##instrset; \
  |  |   74|  10.4k|  } \
  |  |   75|  10.4k|}
  ------------------
  134|  10.4k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  10.4k|#define JSIMD_AVX2       0x80
  ------------------
  135|  10.4k|  }
  136|      0|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (136:7): [True: 0, False: 0]
  ------------------
  137|      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]
  |  |  ------------------
  ------------------
  138|      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|}
  ------------------
  139|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  140|      0|  }
  141|       |#if SIMD_ARCHITECTURE == I386
  142|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
  143|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, mmx);
  144|       |    return JSIMD_MMX;
  145|       |  }
  146|       |#endif
  147|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
  148|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
  149|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, neon);
  150|       |    return JSIMD_NEON;
  151|       |  }
  152|       |#elif SIMD_ARCHITECTURE == POWERPC
  153|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
  154|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, altivec);
  155|       |    return JSIMD_ALTIVEC;
  156|       |  }
  157|       |#elif SIMD_ARCHITECTURE == RISCV64
  158|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
  159|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, rvv);
  160|       |    return JSIMD_RVV;
  161|       |  }
  162|       |#elif SIMD_ARCHITECTURE == MIPS64
  163|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
  164|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, mmi);
  165|       |    return JSIMD_MMI;
  166|       |  }
  167|       |#endif
  168|       |
  169|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  170|      0|}
jsimd_set_rgb_gray:
  175|  3.42k|{
  176|  3.42k|  init_simd((j_common_ptr)cinfo);
  177|       |
  178|  3.42k|  if (BITS_IN_JSAMPLE != 8)
  ------------------
  |  |   34|  3.42k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (178:7): [Folded, False: 3.42k]
  ------------------
  179|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  180|  3.42k|  if (sizeof(JDIMENSION) != 4)
  ------------------
  |  Branch (180:7): [Folded, False: 3.42k]
  ------------------
  181|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  182|  3.42k|  if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
  ------------------
  |  |  302|  3.42k|#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 (182:7): [Folded, False: 3.42k]
  |  Branch (182:31): [True: 0, Folded]
  ------------------
  183|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  184|  3.42k|  if (!cinfo->cconvert)
  ------------------
  |  Branch (184:7): [True: 0, False: 3.42k]
  ------------------
  185|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  186|       |
  187|  3.42k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
  188|  3.42k|  if ((cinfo->master->simd_support & JSIMD_AVX2) &&
  ------------------
  |  |   46|  3.42k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (188:7): [True: 3.42k, False: 0]
  ------------------
  189|  3.42k|      IS_ALIGNED_AVX(jconst_rgb_gray_convert_avx2)) {
  ------------------
  |  |   46|  3.42k|#define IS_ALIGNED_AVX(ptr)  (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
  |  |  ------------------
  |  |  |  |   43|  3.42k|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (46:30): [True: 3.42k, False: 0]
  |  |  ------------------
  ------------------
  190|  3.42k|    SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, avx2);
  ------------------
  |  |   41|  3.42k|#define SET_SIMD_EXTRGB_COLOR_CONVERTER(cs, instrset) { \
  |  |   42|  3.42k|  switch (cinfo->in_color_space) { \
  |  |   43|      0|    case JCS_EXT_RGB: \
  |  |  ------------------
  |  |  |  Branch (43:5): [True: 0, False: 3.42k]
  |  |  ------------------
  |  |   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.42k]
  |  |  ------------------
  |  |   48|      0|    case JCS_EXT_RGBA: \
  |  |  ------------------
  |  |  |  Branch (48:5): [True: 0, False: 3.42k]
  |  |  ------------------
  |  |   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.42k]
  |  |  ------------------
  |  |   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.42k]
  |  |  ------------------
  |  |   57|      0|    case JCS_EXT_BGRA: \
  |  |  ------------------
  |  |  |  Branch (57:5): [True: 0, False: 3.42k]
  |  |  ------------------
  |  |   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.42k]
  |  |  ------------------
  |  |   62|      0|    case JCS_EXT_ABGR: \
  |  |  ------------------
  |  |  |  Branch (62:5): [True: 0, False: 3.42k]
  |  |  ------------------
  |  |   63|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   64|      0|        jsimd_extxbgr_##cs##_convert_##instrset; \
  |  |   65|      0|      break; \
  |  |   66|  3.42k|    case JCS_EXT_XRGB: \
  |  |  ------------------
  |  |  |  Branch (66:5): [True: 3.42k, False: 0]
  |  |  ------------------
  |  |   67|  3.42k|    case JCS_EXT_ARGB: \
  |  |  ------------------
  |  |  |  Branch (67:5): [True: 0, False: 3.42k]
  |  |  ------------------
  |  |   68|  3.42k|      cinfo->cconvert->color_convert_simd = \
  |  |   69|  3.42k|        jsimd_extxrgb_##cs##_convert_##instrset; \
  |  |   70|  3.42k|      break; \
  |  |   71|  3.42k|    default: \
  |  |  ------------------
  |  |  |  Branch (71:5): [True: 0, False: 3.42k]
  |  |  ------------------
  |  |   72|      0|      cinfo->cconvert->color_convert_simd = \
  |  |   73|      0|        jsimd_rgb_##cs##_convert_##instrset; \
  |  |   74|  3.42k|  } \
  |  |   75|  3.42k|}
  ------------------
  191|  3.42k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  3.42k|#define JSIMD_AVX2       0x80
  ------------------
  192|  3.42k|  }
  193|      0|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (193:7): [True: 0, False: 0]
  ------------------
  194|      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]
  |  |  ------------------
  ------------------
  195|      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|}
  ------------------
  196|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  197|      0|  }
  198|       |#if SIMD_ARCHITECTURE == I386
  199|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
  200|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, mmx);
  201|       |    return JSIMD_MMX;
  202|       |  }
  203|       |#endif
  204|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
  205|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
  206|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, neon);
  207|       |    return JSIMD_NEON;
  208|       |  }
  209|       |#elif SIMD_ARCHITECTURE == POWERPC
  210|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
  211|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, altivec);
  212|       |    return JSIMD_ALTIVEC;
  213|       |  }
  214|       |#elif SIMD_ARCHITECTURE == RISCV64
  215|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
  216|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, rvv);
  217|       |    return JSIMD_RVV;
  218|       |  }
  219|       |#elif SIMD_ARCHITECTURE == MIPS64
  220|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
  221|       |    SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, mmi);
  222|       |    return JSIMD_MMI;
  223|       |  }
  224|       |#endif
  225|       |
  226|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  227|      0|}
jsimd_color_convert:
  233|  19.2M|{
  234|  19.2M|  cinfo->cconvert->color_convert_simd(cinfo->image_width, input_buf,
  235|  19.2M|                                      output_buf, output_row, num_rows);
  236|  19.2M|}
jsimd_set_h2v1_downsample:
  331|  7.14k|{
  332|  7.14k|  init_simd((j_common_ptr)cinfo);
  333|       |
  334|  7.14k|  if (BITS_IN_JSAMPLE != 8)
  ------------------
  |  |   34|  7.14k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (334:7): [Folded, False: 7.14k]
  ------------------
  335|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  336|  7.14k|  if (sizeof(JDIMENSION) != 4)
  ------------------
  |  Branch (336:7): [Folded, False: 7.14k]
  ------------------
  337|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  338|  7.14k|  if (!cinfo->downsample)
  ------------------
  |  Branch (338:7): [True: 0, False: 7.14k]
  ------------------
  339|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  340|       |
  341|  7.14k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
  342|  7.14k|  if (cinfo->master->simd_support & JSIMD_AVX2) {
  ------------------
  |  |   46|  7.14k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (342:7): [True: 7.14k, False: 0]
  ------------------
  343|  7.14k|    cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_avx2;
  344|  7.14k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  7.14k|#define JSIMD_AVX2       0x80
  ------------------
  345|  7.14k|  }
  346|      0|  if (cinfo->master->simd_support & JSIMD_SSE2) {
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (346:7): [True: 0, False: 0]
  ------------------
  347|      0|    cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_sse2;
  348|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  349|      0|  }
  350|       |#if SIMD_ARCHITECTURE == I386
  351|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
  352|       |    cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_mmx;
  353|       |    return JSIMD_MMX;
  354|       |  }
  355|       |#endif
  356|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
  357|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
  358|       |    cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_neon;
  359|       |    return JSIMD_NEON;
  360|       |  }
  361|       |#elif SIMD_ARCHITECTURE == POWERPC
  362|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
  363|       |    cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_altivec;
  364|       |    return JSIMD_ALTIVEC;
  365|       |  }
  366|       |#elif SIMD_ARCHITECTURE == RISCV64
  367|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
  368|       |    cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_rvv;
  369|       |    return JSIMD_RVV;
  370|       |  }
  371|       |#endif
  372|       |
  373|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  374|      0|}
jsimd_h2v1_downsample:
  380|  10.9M|{
  381|  10.9M|  cinfo->downsample->h2v1_downsample_simd(cinfo->image_width,
  382|  10.9M|                                          cinfo->max_v_samp_factor,
  383|  10.9M|                                          compptr->v_samp_factor,
  384|  10.9M|                                          compptr->width_in_blocks, input_data,
  385|  10.9M|                                          output_data);
  386|  10.9M|}
jsimd_set_h2v2_downsample:
  391|  6.85k|{
  392|  6.85k|  init_simd((j_common_ptr)cinfo);
  393|       |
  394|  6.85k|  if (BITS_IN_JSAMPLE != 8)
  ------------------
  |  |   34|  6.85k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (394:7): [Folded, False: 6.85k]
  ------------------
  395|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  396|  6.85k|  if (sizeof(JDIMENSION) != 4)
  ------------------
  |  Branch (396:7): [Folded, False: 6.85k]
  ------------------
  397|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  398|  6.85k|  if (!cinfo->downsample)
  ------------------
  |  Branch (398:7): [True: 0, False: 6.85k]
  ------------------
  399|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  400|       |
  401|  6.85k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
  402|  6.85k|  if (cinfo->master->simd_support & JSIMD_AVX2) {
  ------------------
  |  |   46|  6.85k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (402:7): [True: 6.85k, False: 0]
  ------------------
  403|  6.85k|    cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_avx2;
  404|  6.85k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  6.85k|#define JSIMD_AVX2       0x80
  ------------------
  405|  6.85k|  }
  406|      0|  if (cinfo->master->simd_support & JSIMD_SSE2) {
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (406:7): [True: 0, False: 0]
  ------------------
  407|      0|    cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_sse2;
  408|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  409|      0|  }
  410|       |#if SIMD_ARCHITECTURE == I386
  411|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
  412|       |    cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_mmx;
  413|       |    return JSIMD_MMX;
  414|       |  }
  415|       |#endif
  416|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
  417|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
  418|       |    cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_neon;
  419|       |    return JSIMD_NEON;
  420|       |  }
  421|       |#elif SIMD_ARCHITECTURE == POWERPC
  422|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
  423|       |    cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_altivec;
  424|       |    return JSIMD_ALTIVEC;
  425|       |  }
  426|       |#elif SIMD_ARCHITECTURE == RISCV64
  427|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
  428|       |    cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_rvv;
  429|       |    return JSIMD_RVV;
  430|       |  }
  431|       |#elif SIMD_ARCHITECTURE == MIPS64
  432|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
  433|       |    cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_mmi;
  434|       |    return JSIMD_MMI;
  435|       |  }
  436|       |#endif
  437|       |
  438|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  439|      0|}
jsimd_h2v2_downsample:
  445|  5.49M|{
  446|  5.49M|  cinfo->downsample->h2v2_downsample_simd(cinfo->image_width,
  447|  5.49M|                                          cinfo->max_v_samp_factor,
  448|  5.49M|                                          compptr->v_samp_factor,
  449|  5.49M|                                          compptr->width_in_blocks, input_data,
  450|  5.49M|                                          output_data);
  451|  5.49M|}
jsimd_set_convsamp:
  865|  25.4k|{
  866|  25.4k|  init_simd((j_common_ptr)cinfo);
  867|       |
  868|  25.4k|  if (BITS_IN_JSAMPLE != 8)
  ------------------
  |  |   34|  25.4k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (868:7): [Folded, False: 25.4k]
  ------------------
  869|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  870|  25.4k|  if (sizeof(JDIMENSION) != 4)
  ------------------
  |  Branch (870:7): [Folded, False: 25.4k]
  ------------------
  871|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  872|  25.4k|  if (sizeof(DCTELEM) != 2)
  ------------------
  |  Branch (872:7): [Folded, False: 25.4k]
  ------------------
  873|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  874|       |
  875|  25.4k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
  876|  25.4k|  if (cinfo->master->simd_support & JSIMD_AVX2) {
  ------------------
  |  |   46|  25.4k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (876:7): [True: 25.4k, False: 0]
  ------------------
  877|  25.4k|    *method = jsimd_convsamp_avx2;
  878|  25.4k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  25.4k|#define JSIMD_AVX2       0x80
  ------------------
  879|  25.4k|  }
  880|      0|  if (cinfo->master->simd_support & JSIMD_SSE2) {
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (880:7): [True: 0, False: 0]
  ------------------
  881|      0|    *method = jsimd_convsamp_sse2;
  882|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  883|      0|  }
  884|       |#if SIMD_ARCHITECTURE == I386
  885|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
  886|       |    *method = jsimd_convsamp_mmx;
  887|       |    return JSIMD_MMX;
  888|       |  }
  889|       |#endif
  890|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
  891|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
  892|       |    *method = jsimd_convsamp_neon;
  893|       |    return JSIMD_NEON;
  894|       |  }
  895|       |#elif SIMD_ARCHITECTURE == POWERPC
  896|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
  897|       |    *method = jsimd_convsamp_altivec;
  898|       |    return JSIMD_ALTIVEC;
  899|       |  }
  900|       |#elif SIMD_ARCHITECTURE == RISCV64
  901|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
  902|       |    *method = jsimd_convsamp_rvv;
  903|       |    return JSIMD_RVV;
  904|       |  }
  905|       |#endif
  906|       |
  907|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  908|      0|}
jsimd_set_fdct_islow:
  947|  22.0k|{
  948|  22.0k|  init_simd((j_common_ptr)cinfo);
  949|       |
  950|  22.0k|  if (sizeof(DCTELEM) != 2)
  ------------------
  |  Branch (950:7): [Folded, False: 22.0k]
  ------------------
  951|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  952|       |
  953|  22.0k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
  954|  22.0k|  if ((cinfo->master->simd_support & JSIMD_AVX2) &&
  ------------------
  |  |   46|  22.0k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (954:7): [True: 22.0k, False: 0]
  ------------------
  955|  22.0k|      IS_ALIGNED_AVX(jconst_fdct_islow_avx2)) {
  ------------------
  |  |   46|  22.0k|#define IS_ALIGNED_AVX(ptr)  (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
  |  |  ------------------
  |  |  |  |   43|  22.0k|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (46:30): [True: 22.0k, False: 0]
  |  |  ------------------
  ------------------
  956|  22.0k|    *method = jsimd_fdct_islow_avx2;
  957|  22.0k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  22.0k|#define JSIMD_AVX2       0x80
  ------------------
  958|  22.0k|  }
  959|      0|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (959:7): [True: 0, False: 0]
  ------------------
  960|      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]
  |  |  ------------------
  ------------------
  961|      0|    *method = jsimd_fdct_islow_sse2;
  962|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  963|      0|  }
  964|       |#if SIMD_ARCHITECTURE == I386
  965|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
  966|       |    *method = jsimd_fdct_islow_mmx;
  967|       |    return JSIMD_MMX;
  968|       |  }
  969|       |#endif
  970|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
  971|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
  972|       |    *method = jsimd_fdct_islow_neon;
  973|       |    return JSIMD_NEON;
  974|       |  }
  975|       |#elif SIMD_ARCHITECTURE == POWERPC
  976|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
  977|       |    *method = jsimd_fdct_islow_altivec;
  978|       |    return JSIMD_ALTIVEC;
  979|       |  }
  980|       |#elif SIMD_ARCHITECTURE == RISCV64
  981|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
  982|       |    *method = jsimd_fdct_islow_rvv;
  983|       |    return JSIMD_RVV;
  984|       |  }
  985|       |#elif SIMD_ARCHITECTURE == MIPS64
  986|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
  987|       |    *method = jsimd_fdct_islow_mmi;
  988|       |    return JSIMD_MMI;
  989|       |  }
  990|       |#endif
  991|       |
  992|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
  993|      0|}
jsimd_set_fdct_ifast:
  998|  3.42k|{
  999|  3.42k|  init_simd((j_common_ptr)cinfo);
 1000|       |
 1001|  3.42k|  if (sizeof(DCTELEM) != 2)
  ------------------
  |  Branch (1001:7): [Folded, False: 3.42k]
  ------------------
 1002|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1003|       |
 1004|  3.42k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1005|  3.42k|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|  3.42k|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (1005:7): [True: 3.42k, False: 0]
  ------------------
 1006|  3.42k|      IS_ALIGNED_SSE(jconst_fdct_ifast_sse2)) {
  ------------------
  |  |   45|  3.42k|#define IS_ALIGNED_SSE(ptr)  (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
  |  |  ------------------
  |  |  |  |   43|  3.42k|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (45:30): [True: 3.42k, False: 0]
  |  |  ------------------
  ------------------
 1007|  3.42k|    *method = jsimd_fdct_ifast_sse2;
 1008|  3.42k|    return JSIMD_SSE2;
  ------------------
  |  |   42|  3.42k|#define JSIMD_SSE2       0x08
  ------------------
 1009|  3.42k|  }
 1010|       |#if SIMD_ARCHITECTURE == I386
 1011|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
 1012|       |    *method = jsimd_fdct_ifast_mmx;
 1013|       |    return JSIMD_MMX;
 1014|       |  }
 1015|       |#endif
 1016|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
 1017|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
 1018|       |    *method = jsimd_fdct_ifast_neon;
 1019|       |    return JSIMD_NEON;
 1020|       |  }
 1021|       |#elif SIMD_ARCHITECTURE == POWERPC
 1022|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
 1023|       |    *method = jsimd_fdct_ifast_altivec;
 1024|       |    return JSIMD_ALTIVEC;
 1025|       |  }
 1026|       |#elif SIMD_ARCHITECTURE == RISCV64
 1027|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
 1028|       |    *method = jsimd_fdct_ifast_rvv;
 1029|       |    return JSIMD_RVV;
 1030|       |  }
 1031|       |#elif SIMD_ARCHITECTURE == MIPS64
 1032|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
 1033|       |    *method = jsimd_fdct_ifast_mmi;
 1034|       |    return JSIMD_MMI;
 1035|       |  }
 1036|       |#endif
 1037|       |
 1038|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1039|  3.42k|}
jsimd_set_quantize:
 1070|  25.4k|{
 1071|  25.4k|  init_simd((j_common_ptr)cinfo);
 1072|       |
 1073|  25.4k|  if (sizeof(JCOEF) != 2)
  ------------------
  |  Branch (1073:7): [Folded, False: 25.4k]
  ------------------
 1074|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1075|  25.4k|  if (sizeof(DCTELEM) != 2)
  ------------------
  |  Branch (1075:7): [Folded, False: 25.4k]
  ------------------
 1076|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1077|       |
 1078|  25.4k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1079|  25.4k|  if (cinfo->master->simd_support & JSIMD_AVX2) {
  ------------------
  |  |   46|  25.4k|#define JSIMD_AVX2       0x80
  ------------------
  |  Branch (1079:7): [True: 25.4k, False: 0]
  ------------------
 1080|  25.4k|    *method = jsimd_quantize_avx2;
 1081|  25.4k|    return JSIMD_AVX2;
  ------------------
  |  |   46|  25.4k|#define JSIMD_AVX2       0x80
  ------------------
 1082|  25.4k|  }
 1083|      0|  if (cinfo->master->simd_support & JSIMD_SSE2) {
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (1083:7): [True: 0, False: 0]
  ------------------
 1084|      0|    *method = jsimd_quantize_sse2;
 1085|      0|    return JSIMD_SSE2;
  ------------------
  |  |   42|      0|#define JSIMD_SSE2       0x08
  ------------------
 1086|      0|  }
 1087|       |#if SIMD_ARCHITECTURE == I386
 1088|       |  if (cinfo->master->simd_support & JSIMD_MMX) {
 1089|       |    *method = jsimd_quantize_mmx;
 1090|       |    return JSIMD_MMX;
 1091|       |  }
 1092|       |#endif
 1093|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
 1094|       |  if (cinfo->master->simd_support & JSIMD_NEON) {
 1095|       |    *method = jsimd_quantize_neon;
 1096|       |    return JSIMD_NEON;
 1097|       |  }
 1098|       |#elif SIMD_ARCHITECTURE == POWERPC
 1099|       |  if (cinfo->master->simd_support & JSIMD_ALTIVEC) {
 1100|       |    *method = jsimd_quantize_altivec;
 1101|       |    return JSIMD_ALTIVEC;
 1102|       |  }
 1103|       |#elif SIMD_ARCHITECTURE == RISCV64
 1104|       |  if (cinfo->master->simd_support & JSIMD_RVV) {
 1105|       |    *method = jsimd_quantize_rvv;
 1106|       |    return JSIMD_RVV;
 1107|       |  }
 1108|       |#elif SIMD_ARCHITECTURE == MIPS64
 1109|       |  if (cinfo->master->simd_support & JSIMD_MMI) {
 1110|       |    *method = jsimd_quantize_mmi;
 1111|       |    return JSIMD_MMI;
 1112|       |  }
 1113|       |#endif
 1114|       |
 1115|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1116|      0|}
jsimd_set_huff_encode_one_block:
 1437|  18.4k|{
 1438|  18.4k|  init_simd((j_common_ptr)cinfo);
 1439|       |
 1440|  18.4k|  if (sizeof(JCOEF) != 2)
  ------------------
  |  Branch (1440:7): [Folded, False: 18.4k]
  ------------------
 1441|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1442|  18.4k|  if (!cinfo->entropy)
  ------------------
  |  Branch (1442:7): [True: 0, False: 18.4k]
  ------------------
 1443|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1444|       |
 1445|  18.4k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1446|  18.4k|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|  18.4k|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (1446:7): [True: 18.4k, False: 0]
  ------------------
 1447|  18.4k|      cinfo->master->simd_huffman &&
  ------------------
  |  Branch (1447:7): [True: 18.4k, False: 0]
  ------------------
 1448|  18.4k|      IS_ALIGNED_SSE(jconst_huff_encode_one_block)) {
  ------------------
  |  |   45|  18.4k|#define IS_ALIGNED_SSE(ptr)  (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
  |  |  ------------------
  |  |  |  |   43|  18.4k|#define IS_ALIGNED(ptr, order)  (((JUINTPTR)ptr & ((1 << order) - 1)) == 0)
  |  |  ------------------
  |  |  |  Branch (45:30): [True: 18.4k, False: 0]
  |  |  ------------------
  ------------------
 1449|  18.4k|    cinfo->entropy->huff_encode_one_block_simd =
 1450|  18.4k|      jsimd_huff_encode_one_block_sse2;
 1451|  18.4k|    return JSIMD_SSE2;
  ------------------
  |  |   42|  18.4k|#define JSIMD_SSE2       0x08
  ------------------
 1452|  18.4k|  }
 1453|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
 1454|       |  if ((cinfo->master->simd_support & JSIMD_NEON) &&
 1455|       |      cinfo->master->simd_huffman) {
 1456|       |    cinfo->entropy->huff_encode_one_block_simd =
 1457|       |      jsimd_huff_encode_one_block_neon;
 1458|       |    return JSIMD_NEON;
 1459|       |  }
 1460|       |#endif
 1461|       |
 1462|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1463|  18.4k|}
jsimd_set_encode_mcu_AC_first_prepare:
 1469|  35.7k|{
 1470|  35.7k|  init_simd((j_common_ptr)cinfo);
 1471|       |
 1472|  35.7k|  if (sizeof(JCOEF) != 2)
  ------------------
  |  Branch (1472:7): [Folded, False: 35.7k]
  ------------------
 1473|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1474|       |
 1475|  35.7k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1476|  35.7k|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|  35.7k|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (1476:7): [True: 35.7k, False: 0]
  ------------------
 1477|  35.7k|      cinfo->master->simd_huffman) {
  ------------------
  |  Branch (1477:7): [True: 35.7k, False: 0]
  ------------------
 1478|  35.7k|    *method = jsimd_encode_mcu_AC_first_prepare_sse2;
 1479|  35.7k|    return JSIMD_SSE2;
  ------------------
  |  |   42|  35.7k|#define JSIMD_SSE2       0x08
  ------------------
 1480|  35.7k|  }
 1481|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
 1482|       |  if ((cinfo->master->simd_support & JSIMD_NEON) &&
 1483|       |      cinfo->master->simd_huffman) {
 1484|       |    *method = jsimd_encode_mcu_AC_first_prepare_neon;
 1485|       |    return JSIMD_NEON;
 1486|       |  }
 1487|       |#endif
 1488|       |
 1489|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1490|  35.7k|}
jsimd_set_encode_mcu_AC_refine_prepare:
 1496|  28.5k|{
 1497|  28.5k|  init_simd((j_common_ptr)cinfo);
 1498|       |
 1499|  28.5k|  if (sizeof(JCOEF) != 2)
  ------------------
  |  Branch (1499:7): [Folded, False: 28.5k]
  ------------------
 1500|      0|    return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1501|       |
 1502|  28.5k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
 1503|  28.5k|  if ((cinfo->master->simd_support & JSIMD_SSE2) &&
  ------------------
  |  |   42|  28.5k|#define JSIMD_SSE2       0x08
  ------------------
  |  Branch (1503:7): [True: 28.5k, False: 0]
  ------------------
 1504|  28.5k|      cinfo->master->simd_huffman) {
  ------------------
  |  Branch (1504:7): [True: 28.5k, False: 0]
  ------------------
 1505|  28.5k|    *method = jsimd_encode_mcu_AC_refine_prepare_sse2;
 1506|  28.5k|    return JSIMD_SSE2;
  ------------------
  |  |   42|  28.5k|#define JSIMD_SSE2       0x08
  ------------------
 1507|  28.5k|  }
 1508|       |#elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM
 1509|       |  if ((cinfo->master->simd_support & JSIMD_NEON) &&
 1510|       |      cinfo->master->simd_huffman) {
 1511|       |    *method = jsimd_encode_mcu_AC_refine_prepare_neon;
 1512|       |    return JSIMD_NEON;
 1513|       |  }
 1514|       |#endif
 1515|       |
 1516|      0|  return JSIMD_NONE;
  ------------------
  |  |   38|      0|#define JSIMD_NONE       0x00
  ------------------
 1517|  28.5k|}
jsimd.c:init_simd:
   56|   187k|{
   57|   187k|#ifndef NO_GETENV
   58|   187k|  char env[2] = { 0 };
   59|   187k|#endif
   60|   187k|  unsigned int simd_support = cinfo->is_decompressor ?
  ------------------
  |  Branch (60:31): [True: 0, False: 187k]
  ------------------
   61|      0|                              ((j_decompress_ptr)cinfo)->master->simd_support :
   62|   187k|                              ((j_compress_ptr)cinfo)->master->simd_support;
   63|   187k|  unsigned int simd_huffman = cinfo->is_decompressor ?
  ------------------
  |  Branch (63:31): [True: 0, False: 187k]
  ------------------
   64|      0|                              ((j_decompress_ptr)cinfo)->master->simd_huffman :
   65|   187k|                              ((j_compress_ptr)cinfo)->master->simd_huffman;
   66|       |
   67|   187k|  if (simd_support != JSIMD_UNDEFINED)
  ------------------
  |  |   49|   187k|#define JSIMD_UNDEFINED  ~(JSIMD_MAX * 2U - 1U)
  |  |  ------------------
  |  |  |  |   48|   187k|#define JSIMD_MAX        0x100
  |  |  ------------------
  ------------------
  |  Branch (67:7): [True: 182k, False: 4.83k]
  ------------------
   68|   182k|    return;
   69|       |
   70|  4.83k|  simd_support = jpeg_simd_cpu_support();
   71|       |
   72|  4.83k|#ifndef NO_GETENV
   73|       |  /* Force different settings through environment variables */
   74|  4.83k|#if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386
   75|  4.83k|  if (!GETENV_S(env, 2, "JSIMD_FORCESSE2") && !strcmp(env, "1"))
  ------------------
  |  Branch (75:7): [True: 4.83k, False: 0]
  |  Branch (75:47): [True: 0, False: 4.83k]
  ------------------
   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.83k|  if (!GETENV_S(env, 2, "JSIMD_FORCENONE") && !strcmp(env, "1"))
  ------------------
  |  Branch (95:7): [True: 4.83k, False: 0]
  |  Branch (95:47): [True: 0, False: 4.83k]
  ------------------
   96|      0|    simd_support = 0;
   97|       |#ifdef WITH_SIMDE
   98|       |  if (!GETENV_S(env, 2, "JSIMD_HUFFENC") && !strcmp(env, "1"))
   99|       |    simd_huffman = 1;
  100|       |#else
  101|  4.83k|  if (!GETENV_S(env, 2, "JSIMD_NOHUFFENC") && !strcmp(env, "1"))
  ------------------
  |  Branch (101:7): [True: 4.83k, False: 0]
  |  Branch (101:47): [True: 0, False: 4.83k]
  ------------------
  102|      0|    simd_huffman = 0;
  103|  4.83k|#endif
  104|  4.83k|#endif
  105|       |
  106|  4.83k|  if (cinfo->is_decompressor) {
  ------------------
  |  Branch (106:7): [True: 0, False: 4.83k]
  ------------------
  107|      0|    ((j_decompress_ptr)cinfo)->master->simd_support = simd_support;
  108|      0|    ((j_decompress_ptr)cinfo)->master->simd_huffman = simd_huffman;
  109|  4.83k|  } else {
  110|  4.83k|    ((j_compress_ptr)cinfo)->master->simd_support = simd_support;
  111|  4.83k|    ((j_compress_ptr)cinfo)->master->simd_huffman = simd_huffman;
  112|  4.83k|  }
  113|  4.83k|}

rdbmp.c:rgb_to_cmyk:
   29|  17.5M|{
   30|  17.5M|  double ctmp = 1.0 - ((double)r / (double)maxval);
   31|  17.5M|  double mtmp = 1.0 - ((double)g / (double)maxval);
   32|  17.5M|  double ytmp = 1.0 - ((double)b / (double)maxval);
   33|  17.5M|  double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
  ------------------
  |  |  515|  35.0M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 6.93M, False: 10.6M]
  |  |  |  Branch (515:27): [True: 3.32M, False: 14.2M]
  |  |  |  Branch (515:39): [True: 2.69M, False: 4.24M]
  |  |  ------------------
  ------------------
   34|       |
   35|  17.5M|  if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
  ------------------
  |  Branch (35:7): [True: 3.37M, False: 14.1M]
  ------------------
   36|  14.1M|  else {
   37|  14.1M|    ctmp = (ctmp - ktmp) / (1.0 - ktmp);
   38|  14.1M|    mtmp = (mtmp - ktmp) / (1.0 - ktmp);
   39|  14.1M|    ytmp = (ytmp - ktmp) / (1.0 - ktmp);
   40|  14.1M|  }
   41|  17.5M|  *c = (_JSAMPLE)((double)maxval - ctmp * (double)maxval + 0.5);
   42|  17.5M|  *m = (_JSAMPLE)((double)maxval - mtmp * (double)maxval + 0.5);
   43|  17.5M|  *y = (_JSAMPLE)((double)maxval - ytmp * (double)maxval + 0.5);
   44|  17.5M|  *k = (_JSAMPLE)((double)maxval - ktmp * (double)maxval + 0.5);
   45|  17.5M|}
rdpng-8.c:rgb_to_cmyk:
   29|  8.34M|{
   30|  8.34M|  double ctmp = 1.0 - ((double)r / (double)maxval);
   31|  8.34M|  double mtmp = 1.0 - ((double)g / (double)maxval);
   32|  8.34M|  double ytmp = 1.0 - ((double)b / (double)maxval);
   33|  8.34M|  double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
  ------------------
  |  |  515|  16.6M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 4.11M, False: 4.22M]
  |  |  |  Branch (515:27): [True: 3.14M, False: 5.20M]
  |  |  |  Branch (515:39): [True: 2.10M, False: 2.01M]
  |  |  ------------------
  ------------------
   34|       |
   35|  8.34M|  if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
  ------------------
  |  Branch (35:7): [True: 1.53M, False: 6.81M]
  ------------------
   36|  6.81M|  else {
   37|  6.81M|    ctmp = (ctmp - ktmp) / (1.0 - ktmp);
   38|  6.81M|    mtmp = (mtmp - ktmp) / (1.0 - ktmp);
   39|  6.81M|    ytmp = (ytmp - ktmp) / (1.0 - ktmp);
   40|  6.81M|  }
   41|  8.34M|  *c = (_JSAMPLE)((double)maxval - ctmp * (double)maxval + 0.5);
   42|  8.34M|  *m = (_JSAMPLE)((double)maxval - mtmp * (double)maxval + 0.5);
   43|  8.34M|  *y = (_JSAMPLE)((double)maxval - ytmp * (double)maxval + 0.5);
   44|  8.34M|  *k = (_JSAMPLE)((double)maxval - ktmp * (double)maxval + 0.5);
   45|  8.34M|}
rdppm-8.c:rgb_to_cmyk:
   29|  9.80M|{
   30|  9.80M|  double ctmp = 1.0 - ((double)r / (double)maxval);
   31|  9.80M|  double mtmp = 1.0 - ((double)g / (double)maxval);
   32|  9.80M|  double ytmp = 1.0 - ((double)b / (double)maxval);
   33|  9.80M|  double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
  ------------------
  |  |  515|  19.6M|#define MIN(a, b)       ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (515:26): [True: 8.40k, False: 9.79M]
  |  |  |  Branch (515:27): [True: 5.65k, False: 9.79M]
  |  |  |  Branch (515:39): [True: 3.95k, False: 4.45k]
  |  |  ------------------
  ------------------
   34|       |
   35|  9.80M|  if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
  ------------------
  |  Branch (35:7): [True: 6.55M, False: 3.24M]
  ------------------
   36|  3.24M|  else {
   37|  3.24M|    ctmp = (ctmp - ktmp) / (1.0 - ktmp);
   38|  3.24M|    mtmp = (mtmp - ktmp) / (1.0 - ktmp);
   39|  3.24M|    ytmp = (ytmp - ktmp) / (1.0 - ktmp);
   40|  3.24M|  }
   41|  9.80M|  *c = (_JSAMPLE)((double)maxval - ctmp * (double)maxval + 0.5);
   42|  9.80M|  *m = (_JSAMPLE)((double)maxval - mtmp * (double)maxval + 0.5);
   43|  9.80M|  *y = (_JSAMPLE)((double)maxval - ytmp * (double)maxval + 0.5);
   44|  9.80M|  *k = (_JSAMPLE)((double)maxval - ktmp * (double)maxval + 0.5);
   45|  9.80M|}

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

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

jinit_arith_encoder:
  913|  6.85k|{
  914|  6.85k|  arith_entropy_ptr entropy;
  915|  6.85k|  int i;
  916|       |
  917|  6.85k|  entropy = (arith_entropy_ptr)
  918|  6.85k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  6.85k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  919|  6.85k|                                sizeof(arith_entropy_encoder));
  920|  6.85k|  cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
  921|  6.85k|  entropy->pub.start_pass = start_pass;
  922|  6.85k|  entropy->pub.finish_pass = finish_pass;
  923|       |
  924|       |  /* Mark tables unallocated */
  925|   116k|  for (i = 0; i < NUM_ARITH_TBLS; i++) {
  ------------------
  |  |   70|   116k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (925:15): [True: 109k, False: 6.85k]
  ------------------
  926|   109k|    entropy->dc_stats[i] = NULL;
  927|   109k|    entropy->ac_stats[i] = NULL;
  928|   109k|  }
  929|       |
  930|       |  /* Initialize index for fixed probability estimation */
  931|  6.85k|  entropy->fixed_bin[0] = 113;
  932|  6.85k|}
jcarith.c:start_pass:
  829|  37.6k|{
  830|  37.6k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  831|  37.6k|  int ci, tbl;
  832|  37.6k|  jpeg_component_info *compptr;
  833|       |
  834|  37.6k|  if (gather_statistics)
  ------------------
  |  Branch (834:7): [True: 0, False: 37.6k]
  ------------------
  835|       |    /* Make sure to avoid that in the master control logic!
  836|       |     * We are fully adaptive here and need no extra
  837|       |     * statistics gathering pass!
  838|       |     */
  839|      0|    ERREXIT(cinfo, JERR_NOTIMPL);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  840|       |
  841|       |  /* We assume jcmaster.c already validated the progressive scan parameters. */
  842|       |
  843|       |  /* Select execution routines */
  844|  37.6k|  if (cinfo->progressive_mode) {
  ------------------
  |  Branch (844:7): [True: 34.2k, False: 3.42k]
  ------------------
  845|  34.2k|    if (cinfo->Ah == 0) {
  ------------------
  |  Branch (845:9): [True: 17.1k, False: 17.1k]
  ------------------
  846|  17.1k|      if (cinfo->Ss == 0)
  ------------------
  |  Branch (846:11): [True: 3.42k, False: 13.7k]
  ------------------
  847|  3.42k|        entropy->pub.encode_mcu = encode_mcu_DC_first;
  848|  13.7k|      else
  849|  13.7k|        entropy->pub.encode_mcu = encode_mcu_AC_first;
  850|  17.1k|    } else {
  851|  17.1k|      if (cinfo->Ss == 0)
  ------------------
  |  Branch (851:11): [True: 3.42k, False: 13.7k]
  ------------------
  852|  3.42k|        entropy->pub.encode_mcu = encode_mcu_DC_refine;
  853|  13.7k|      else
  854|  13.7k|        entropy->pub.encode_mcu = encode_mcu_AC_refine;
  855|  17.1k|    }
  856|  34.2k|  } else
  857|  3.42k|    entropy->pub.encode_mcu = encode_mcu;
  858|       |
  859|       |  /* Allocate & initialize requested statistics areas */
  860|  95.9k|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (860:16): [True: 58.2k, False: 37.6k]
  ------------------
  861|  58.2k|    compptr = cinfo->cur_comp_info[ci];
  862|       |    /* DC needs no table for refinement scan */
  863|  58.2k|    if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
  ------------------
  |  Branch (863:9): [True: 10.2k, False: 47.9k]
  |  Branch (863:42): [True: 20.5k, False: 27.4k]
  |  Branch (863:60): [True: 10.2k, False: 10.2k]
  ------------------
  864|  20.5k|      tbl = compptr->dc_tbl_no;
  865|  20.5k|      if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
  ------------------
  |  |   70|  20.5k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (865:11): [True: 0, False: 20.5k]
  |  Branch (865:22): [True: 0, False: 20.5k]
  ------------------
  866|      0|        ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  867|  20.5k|      if (entropy->dc_stats[tbl] == NULL)
  ------------------
  |  Branch (867:11): [True: 13.7k, False: 6.85k]
  ------------------
  868|  13.7k|        entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
  869|  13.7k|          ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
  ------------------
  |  |  889|  13.7k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                        ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
  ------------------
  |  |   69|  13.7k|#define DC_STAT_BINS  64
  ------------------
  870|  20.5k|      memset(entropy->dc_stats[tbl], 0, DC_STAT_BINS);
  ------------------
  |  |   69|  20.5k|#define DC_STAT_BINS  64
  ------------------
  871|       |      /* Initialize DC predictions to 0 */
  872|  20.5k|      entropy->last_dc_val[ci] = 0;
  873|  20.5k|      entropy->dc_context[ci] = 0;
  874|  20.5k|    }
  875|       |    /* AC needs no table when not present */
  876|  58.2k|    if (cinfo->progressive_mode == 0 || cinfo->Se) {
  ------------------
  |  Branch (876:9): [True: 10.2k, False: 47.9k]
  |  Branch (876:41): [True: 27.4k, False: 20.5k]
  ------------------
  877|  37.6k|      tbl = compptr->ac_tbl_no;
  878|  37.6k|      if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
  ------------------
  |  |   70|  37.6k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (878:11): [True: 0, False: 37.6k]
  |  Branch (878:22): [True: 0, False: 37.6k]
  ------------------
  879|      0|        ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  880|  37.6k|      if (entropy->ac_stats[tbl] == NULL)
  ------------------
  |  Branch (880:11): [True: 13.7k, False: 23.9k]
  ------------------
  881|  13.7k|        entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
  882|  13.7k|          ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
  ------------------
  |  |  889|  13.7k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                        ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
  ------------------
  |  |   70|  13.7k|#define AC_STAT_BINS  256
  ------------------
  883|  37.6k|      memset(entropy->ac_stats[tbl], 0, AC_STAT_BINS);
  ------------------
  |  |   70|  37.6k|#define AC_STAT_BINS  256
  ------------------
  884|       |#ifdef CALCULATE_SPECTRAL_CONDITIONING
  885|       |      if (cinfo->progressive_mode)
  886|       |        /* Section G.1.3.2: Set appropriate arithmetic conditioning value Kx */
  887|       |        cinfo->arith_ac_K[tbl] = cinfo->Ss +
  888|       |                                 ((8 + cinfo->Se - cinfo->Ss) >> 4);
  889|       |#endif
  890|  37.6k|    }
  891|  58.2k|  }
  892|       |
  893|       |  /* Initialize arithmetic encoding variables */
  894|  37.6k|  entropy->c = 0;
  895|  37.6k|  entropy->a = 0x10000L;
  896|  37.6k|  entropy->sc = 0;
  897|  37.6k|  entropy->zc = 0;
  898|  37.6k|  entropy->ct = 11;
  899|  37.6k|  entropy->buffer = -1;  /* empty */
  900|       |
  901|       |  /* Initialize restart stuff */
  902|  37.6k|  entropy->restarts_to_go = cinfo->restart_interval;
  903|  37.6k|  entropy->next_restart_num = 0;
  904|  37.6k|}
jcarith.c:encode_mcu_DC_first:
  369|   850k|{
  370|   850k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  371|   850k|  JBLOCKROW block;
  372|   850k|  unsigned char *st;
  373|   850k|  int blkn, ci, tbl;
  374|   850k|  int v, v2, m;
  375|   850k|  ISHIFT_TEMPS
  376|       |
  377|       |  /* Emit restart marker if needed */
  378|   850k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (378:7): [True: 0, False: 850k]
  ------------------
  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|  5.95M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (389:18): [True: 5.10M, False: 850k]
  ------------------
  390|  5.10M|    block = MCU_data[blkn];
  391|  5.10M|    ci = cinfo->MCU_membership[blkn];
  392|  5.10M|    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.10M|    m = IRIGHT_SHIFT((int)((*block)[0]), cinfo->Al);
  ------------------
  |  |  117|  5.10M|#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.10M|    st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
  403|       |
  404|       |    /* Figure F.4: Encode_DC_DIFF */
  405|  5.10M|    if ((v = m - entropy->last_dc_val[ci]) == 0) {
  ------------------
  |  Branch (405:9): [True: 3.82M, False: 1.27M]
  ------------------
  406|  3.82M|      arith_encode(cinfo, st, 0);
  407|  3.82M|      entropy->dc_context[ci] = 0;      /* zero diff category */
  408|  3.82M|    } else {
  409|  1.27M|      entropy->last_dc_val[ci] = m;
  410|  1.27M|      arith_encode(cinfo, st, 1);
  411|       |      /* Figure F.6: Encoding nonzero value v */
  412|       |      /* Figure F.7: Encoding the sign of v */
  413|  1.27M|      if (v > 0) {
  ------------------
  |  Branch (413:11): [True: 644k, False: 633k]
  ------------------
  414|   644k|        arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
  415|   644k|        st += 2;                        /* Table F.4: SP = S0 + 2 */
  416|   644k|        entropy->dc_context[ci] = 4;    /* small positive diff category */
  417|   644k|      } else {
  418|   633k|        v = -v;
  419|   633k|        arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
  420|   633k|        st += 3;                        /* Table F.4: SN = S0 + 3 */
  421|   633k|        entropy->dc_context[ci] = 8;    /* small negative diff category */
  422|   633k|      }
  423|       |      /* Figure F.8: Encoding the magnitude category of v */
  424|  1.27M|      m = 0;
  425|  1.27M|      if (v -= 1) {
  ------------------
  |  Branch (425:11): [True: 1.03M, False: 246k]
  ------------------
  426|  1.03M|        arith_encode(cinfo, st, 1);
  427|  1.03M|        m = 1;
  428|  1.03M|        v2 = v;
  429|  1.03M|        st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
  430|  2.78M|        while (v2 >>= 1) {
  ------------------
  |  Branch (430:16): [True: 1.74M, False: 1.03M]
  ------------------
  431|  1.74M|          arith_encode(cinfo, st, 1);
  432|  1.74M|          m <<= 1;
  433|  1.74M|          st += 1;
  434|  1.74M|        }
  435|  1.03M|      }
  436|  1.27M|      arith_encode(cinfo, st, 0);
  437|       |      /* Section F.1.4.4.1.2: Establish dc_context conditioning category */
  438|  1.27M|      if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
  ------------------
  |  Branch (438:11): [True: 0, False: 1.27M]
  ------------------
  439|      0|        entropy->dc_context[ci] = 0;    /* zero diff category */
  440|  1.27M|      else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
  ------------------
  |  Branch (440:16): [True: 844k, False: 433k]
  ------------------
  441|   844k|        entropy->dc_context[ci] += 8;   /* large diff category */
  442|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  443|  1.27M|      st += 14;
  444|  3.02M|      while (m >>= 1)
  ------------------
  |  Branch (444:14): [True: 1.74M, False: 1.27M]
  ------------------
  445|  1.74M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (445:33): [True: 754k, False: 993k]
  ------------------
  446|  1.27M|    }
  447|  5.10M|  }
  448|       |
  449|   850k|  return TRUE;
  ------------------
  |  |  210|   850k|#define TRUE    1
  ------------------
  450|   850k|}
jcarith.c:emit_byte:
  124|  41.5M|{
  125|  41.5M|  struct jpeg_destination_mgr *dest = cinfo->dest;
  126|       |
  127|  41.5M|  *dest->next_output_byte++ = (JOCTET)val;
  128|  41.5M|  if (--dest->free_in_buffer == 0)
  ------------------
  |  Branch (128:7): [True: 3.74k, False: 41.4M]
  ------------------
  129|  3.74k|    if (!(*dest->empty_output_buffer) (cinfo))
  ------------------
  |  Branch (129:9): [True: 0, False: 3.74k]
  ------------------
  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.5M|}
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.2M, False: 34.0M]
  ------------------
  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.2M|      e->c += e->a;
  250|  94.2M|      e->a = qe;
  251|  94.2M|    }
  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: 127M]
  ------------------
  256|   223M|      return;  /* A >= 0x8000 -> ready, no renormalization required */
  257|   127M|    if (e->a < qe) {
  ------------------
  |  Branch (257:9): [True: 37.2M, False: 90.5M]
  ------------------
  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.2M|      e->c += e->a;
  262|  37.2M|      e->a = qe;
  263|  37.2M|    }
  264|   127M|    *st = (sv & 0x80) ^ nm;     /* Estimate_after_MPS */
  265|   127M|  }
  266|       |
  267|       |  /* Renormalization & data output per section D.1.6 */
  268|   330M|  do {
  269|   330M|    e->a <<= 1;
  270|   330M|    e->c <<= 1;
  271|   330M|    if (--e->ct == 0) {
  ------------------
  |  Branch (271:9): [True: 41.2M, False: 289M]
  ------------------
  272|       |      /* Another byte is ready for output */
  273|  41.2M|      temp = e->c >> 19;
  274|  41.2M|      if (temp > 0xFF) {
  ------------------
  |  Branch (274:11): [True: 1.73M, False: 39.5M]
  ------------------
  275|       |        /* Handle overflow over all stacked 0xFF bytes */
  276|  1.73M|        if (e->buffer >= 0) {
  ------------------
  |  Branch (276:13): [True: 1.73M, False: 0]
  ------------------
  277|  1.73M|          if (e->zc)
  ------------------
  |  Branch (277:15): [True: 7.15k, False: 1.73M]
  ------------------
  278|  13.7k|            do emit_byte(0x00, cinfo);
  279|  13.7k|            while (--e->zc);
  ------------------
  |  Branch (279:20): [True: 6.59k, False: 7.15k]
  ------------------
  280|  1.73M|          emit_byte(e->buffer + 1, cinfo);
  281|  1.73M|          if (e->buffer + 1 == 0xFF)
  ------------------
  |  Branch (281:15): [True: 7.55k, False: 1.72M]
  ------------------
  282|  7.55k|            emit_byte(0x00, cinfo);
  283|  1.73M|        }
  284|  1.73M|        e->zc += e->sc;  /* carry-over converts stacked 0xFF bytes to 0x00 */
  285|  1.73M|        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.73M|        e->buffer = temp & 0xFF;  /* new output byte, might overflow later */
  290|  39.5M|      } else if (temp == 0xFF) {
  ------------------
  |  Branch (290:18): [True: 223k, False: 39.3M]
  ------------------
  291|   223k|        ++e->sc;  /* stack 0xFF byte (which might overflow later) */
  292|  39.3M|      } else {
  293|       |        /* Output all stacked 0xFF bytes, they will not overflow any more */
  294|  39.3M|        if (e->buffer == 0)
  ------------------
  |  Branch (294:13): [True: 413k, False: 38.9M]
  ------------------
  295|   413k|          ++e->zc;
  296|  38.9M|        else if (e->buffer >= 0) {
  ------------------
  |  Branch (296:18): [True: 38.8M, False: 26.9k]
  ------------------
  297|  38.8M|          if (e->zc)
  ------------------
  |  Branch (297:15): [True: 161k, False: 38.7M]
  ------------------
  298|   326k|            do emit_byte(0x00, cinfo);
  299|   326k|            while (--e->zc);
  ------------------
  |  Branch (299:20): [True: 165k, False: 161k]
  ------------------
  300|  38.8M|          emit_byte(e->buffer, cinfo);
  301|  38.8M|        }
  302|  39.3M|        if (e->sc) {
  ------------------
  |  Branch (302:13): [True: 162k, False: 39.1M]
  ------------------
  303|   162k|          if (e->zc)
  ------------------
  |  Branch (303:15): [True: 843, False: 161k]
  ------------------
  304|  1.11k|            do emit_byte(0x00, cinfo);
  305|  1.11k|            while (--e->zc);
  ------------------
  |  Branch (305:20): [True: 272, False: 843]
  ------------------
  306|   189k|          do {
  307|   189k|            emit_byte(0xFF, cinfo);
  308|   189k|            emit_byte(0x00, cinfo);
  309|   189k|          } while (--e->sc);
  ------------------
  |  Branch (309:20): [True: 27.2k, False: 162k]
  ------------------
  310|   162k|        }
  311|  39.3M|        e->buffer = temp & 0xFF;  /* new output byte (can still overflow) */
  312|  39.3M|      }
  313|  41.2M|      e->c &= 0x7FFFFL;
  314|  41.2M|      e->ct += 8;
  315|  41.2M|    }
  316|   330M|  } while (e->a < 0x8000L);
  ------------------
  |  Branch (316:12): [True: 74.4M, False: 256M]
  ------------------
  317|   256M|}
jcarith.c:encode_mcu_AC_first:
  460|  4.55M|{
  461|  4.55M|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  462|  4.55M|  JBLOCKROW block;
  463|  4.55M|  unsigned char *st;
  464|  4.55M|  int tbl, k, ke;
  465|  4.55M|  int v, v2, m;
  466|       |
  467|       |  /* Emit restart marker if needed */
  468|  4.55M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (468:7): [True: 0, False: 4.55M]
  ------------------
  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.55M|  block = MCU_data[0];
  480|  4.55M|  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|   179M|  for (ke = cinfo->Se; ke > 0; ke--)
  ------------------
  |  Branch (485:24): [True: 177M, False: 2.37M]
  ------------------
  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|   177M|    if ((v = (*block)[jpeg_natural_order[ke]]) >= 0) {
  ------------------
  |  Branch (490:9): [True: 170M, False: 7.49M]
  ------------------
  491|   170M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (491:11): [True: 1.08M, False: 168M]
  ------------------
  492|   170M|    } else {
  493|  7.49M|      v = -v;
  494|  7.49M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (494:11): [True: 1.09M, False: 6.40M]
  ------------------
  495|  7.49M|    }
  496|       |
  497|       |  /* Figure F.5: Encode_AC_Coefficients */
  498|  13.1M|  for (k = cinfo->Ss; k <= ke; k++) {
  ------------------
  |  Branch (498:23): [True: 8.58M, False: 4.55M]
  ------------------
  499|  8.58M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  500|  8.58M|    arith_encode(cinfo, st, 0);         /* EOB decision */
  501|  24.5M|    for (;;) {
  502|  24.5M|      if ((v = (*block)[jpeg_natural_order[k]]) >= 0) {
  ------------------
  |  Branch (502:11): [True: 16.5M, False: 7.99M]
  ------------------
  503|  16.5M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (503:13): [True: 4.30M, False: 12.2M]
  ------------------
  504|  4.30M|          arith_encode(cinfo, st + 1, 1);
  505|  4.30M|          arith_encode(cinfo, entropy->fixed_bin, 0);
  506|  4.30M|          break;
  507|  4.30M|        }
  508|  16.5M|      } else {
  509|  7.99M|        v = -v;
  510|  7.99M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (510:13): [True: 4.28M, False: 3.70M]
  ------------------
  511|  4.28M|          arith_encode(cinfo, st + 1, 1);
  512|  4.28M|          arith_encode(cinfo, entropy->fixed_bin, 1);
  513|  4.28M|          break;
  514|  4.28M|        }
  515|  7.99M|      }
  516|  15.9M|      arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  517|  15.9M|    }
  518|  8.58M|    st += 2;
  519|       |    /* Figure F.8: Encoding the magnitude category of v */
  520|  8.58M|    m = 0;
  521|  8.58M|    if (v -= 1) {
  ------------------
  |  Branch (521:9): [True: 3.53M, False: 5.05M]
  ------------------
  522|  3.53M|      arith_encode(cinfo, st, 1);
  523|  3.53M|      m = 1;
  524|  3.53M|      v2 = v;
  525|  3.53M|      if (v2 >>= 1) {
  ------------------
  |  Branch (525:11): [True: 1.83M, False: 1.69M]
  ------------------
  526|  1.83M|        arith_encode(cinfo, st, 1);
  527|  1.83M|        m <<= 1;
  528|  1.83M|        st = entropy->ac_stats[tbl] +
  529|  1.83M|             (k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
  ------------------
  |  Branch (529:15): [True: 1.21M, False: 621k]
  ------------------
  530|  2.61M|        while (v2 >>= 1) {
  ------------------
  |  Branch (530:16): [True: 779k, False: 1.83M]
  ------------------
  531|   779k|          arith_encode(cinfo, st, 1);
  532|   779k|          m <<= 1;
  533|   779k|          st += 1;
  534|   779k|        }
  535|  1.83M|      }
  536|  3.53M|    }
  537|  8.58M|    arith_encode(cinfo, st, 0);
  538|       |    /* Figure F.9: Encoding the magnitude bit pattern of v */
  539|  8.58M|    st += 14;
  540|  11.2M|    while (m >>= 1)
  ------------------
  |  Branch (540:12): [True: 2.61M, False: 8.58M]
  ------------------
  541|  2.61M|      arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (541:31): [True: 892k, False: 1.72M]
  ------------------
  542|  8.58M|  }
  543|       |  /* Encode EOB decision only if k <= cinfo->Se */
  544|  4.55M|  if (k <= cinfo->Se) {
  ------------------
  |  Branch (544:7): [True: 4.04M, False: 510k]
  ------------------
  545|  4.04M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  546|  4.04M|    arith_encode(cinfo, st, 1);
  547|  4.04M|  }
  548|       |
  549|  4.55M|  return TRUE;
  ------------------
  |  |  210|  4.55M|#define TRUE    1
  ------------------
  550|  4.55M|}
jcarith.c:encode_mcu_DC_refine:
  559|   850k|{
  560|   850k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  561|   850k|  unsigned char *st;
  562|   850k|  int Al, blkn;
  563|       |
  564|       |  /* Emit restart marker if needed */
  565|   850k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (565:7): [True: 0, False: 850k]
  ------------------
  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|   850k|  st = entropy->fixed_bin;      /* use fixed probability estimation */
  576|   850k|  Al = cinfo->Al;
  577|       |
  578|       |  /* Encode the MCU data blocks */
  579|  5.95M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (579:18): [True: 5.10M, False: 850k]
  ------------------
  580|       |    /* We simply emit the Al'th bit of the DC coefficient value. */
  581|  5.10M|    arith_encode(cinfo, st, (MCU_data[blkn][0][0] >> Al) & 1);
  582|  5.10M|  }
  583|       |
  584|   850k|  return TRUE;
  ------------------
  |  |  210|   850k|#define TRUE    1
  ------------------
  585|   850k|}
jcarith.c:encode_mcu_AC_refine:
  594|  4.55M|{
  595|  4.55M|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  596|  4.55M|  JBLOCKROW block;
  597|  4.55M|  unsigned char *st;
  598|  4.55M|  int tbl, k, ke, kex;
  599|  4.55M|  int v;
  600|       |
  601|       |  /* Emit restart marker if needed */
  602|  4.55M|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (602:7): [True: 0, False: 4.55M]
  ------------------
  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.55M|  block = MCU_data[0];
  614|  4.55M|  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|   205M|  for (ke = cinfo->Se; ke > 0; ke--)
  ------------------
  |  Branch (619:24): [True: 203M, False: 2.23M]
  ------------------
  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|   203M|    if ((v = (*block)[jpeg_natural_order[ke]]) >= 0) {
  ------------------
  |  Branch (624:9): [True: 200M, False: 3.39M]
  ------------------
  625|   200M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (625:11): [True: 1.16M, False: 199M]
  ------------------
  626|   200M|    } else {
  627|  3.39M|      v = -v;
  628|  3.39M|      if (v >>= cinfo->Al) break;
  ------------------
  |  Branch (628:11): [True: 1.15M, False: 2.24M]
  ------------------
  629|  3.39M|    }
  630|       |
  631|       |  /* Establish EOBx (previous stage end-of-block) index */
  632|  35.2M|  for (kex = ke; kex > 0; kex--)
  ------------------
  |  Branch (632:18): [True: 32.9M, False: 2.32M]
  ------------------
  633|  32.9M|    if ((v = (*block)[jpeg_natural_order[kex]]) >= 0) {
  ------------------
  |  Branch (633:9): [True: 25.6M, False: 7.29M]
  ------------------
  634|  25.6M|      if (v >>= cinfo->Ah) break;
  ------------------
  |  Branch (634:11): [True: 1.11M, False: 24.5M]
  ------------------
  635|  25.6M|    } else {
  636|  7.29M|      v = -v;
  637|  7.29M|      if (v >>= cinfo->Ah) break;
  ------------------
  |  Branch (637:11): [True: 1.11M, False: 6.18M]
  ------------------
  638|  7.29M|    }
  639|       |
  640|       |  /* Figure G.10: Encode_AC_Coefficients_SA */
  641|  46.4M|  for (k = cinfo->Ss; k <= ke; k++) {
  ------------------
  |  Branch (641:23): [True: 41.8M, False: 4.55M]
  ------------------
  642|  41.8M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  643|  41.8M|    if (k > kex)
  ------------------
  |  Branch (643:9): [True: 8.80M, False: 33.0M]
  ------------------
  644|  8.80M|      arith_encode(cinfo, st, 0);       /* EOB decision */
  645|  85.6M|    for (;;) {
  646|  85.6M|      if ((v = (*block)[jpeg_natural_order[k]]) >= 0) {
  ------------------
  |  Branch (646:11): [True: 61.4M, False: 24.1M]
  ------------------
  647|  61.4M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (647:13): [True: 21.0M, False: 40.4M]
  ------------------
  648|  21.0M|          if (v >> 1)                   /* previously nonzero coef */
  ------------------
  |  Branch (648:15): [True: 10.8M, False: 10.1M]
  ------------------
  649|  10.8M|            arith_encode(cinfo, st + 2, (v & 1));
  650|  10.1M|          else {                        /* newly nonzero coef */
  651|  10.1M|            arith_encode(cinfo, st + 1, 1);
  652|  10.1M|            arith_encode(cinfo, entropy->fixed_bin, 0);
  653|  10.1M|          }
  654|  21.0M|          break;
  655|  21.0M|        }
  656|  61.4M|      } else {
  657|  24.1M|        v = -v;
  658|  24.1M|        if (v >>= cinfo->Al) {
  ------------------
  |  Branch (658:13): [True: 20.8M, False: 3.27M]
  ------------------
  659|  20.8M|          if (v >> 1)                   /* previously nonzero coef */
  ------------------
  |  Branch (659:15): [True: 10.7M, False: 10.0M]
  ------------------
  660|  10.7M|            arith_encode(cinfo, st + 2, (v & 1));
  661|  10.0M|          else {                        /* newly nonzero coef */
  662|  10.0M|            arith_encode(cinfo, st + 1, 1);
  663|  10.0M|            arith_encode(cinfo, entropy->fixed_bin, 1);
  664|  10.0M|          }
  665|  20.8M|          break;
  666|  20.8M|        }
  667|  24.1M|      }
  668|  43.7M|      arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  669|  43.7M|    }
  670|  41.8M|  }
  671|       |  /* Encode EOB decision only if k <= cinfo->Se */
  672|  4.55M|  if (k <= cinfo->Se) {
  ------------------
  |  Branch (672:7): [True: 4.43M, False: 124k]
  ------------------
  673|  4.43M|    st = entropy->ac_stats[tbl] + 3 * (k - 1);
  674|  4.43M|    arith_encode(cinfo, st, 1);
  675|  4.43M|  }
  676|       |
  677|  4.55M|  return TRUE;
  ------------------
  |  |  210|  4.55M|#define TRUE    1
  ------------------
  678|  4.55M|}
jcarith.c:encode_mcu:
  687|   629k|{
  688|   629k|  arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
  689|   629k|  jpeg_component_info *compptr;
  690|   629k|  JBLOCKROW block;
  691|   629k|  unsigned char *st;
  692|   629k|  int blkn, ci, tbl, k, ke;
  693|   629k|  int v, v2, m;
  694|       |
  695|       |  /* Emit restart marker if needed */
  696|   629k|  if (cinfo->restart_interval) {
  ------------------
  |  Branch (696:7): [True: 0, False: 629k]
  ------------------
  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.40M|  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
  ------------------
  |  Branch (707:18): [True: 3.77M, False: 629k]
  ------------------
  708|  3.77M|    block = MCU_data[blkn];
  709|  3.77M|    ci = cinfo->MCU_membership[blkn];
  710|  3.77M|    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.77M|    tbl = compptr->dc_tbl_no;
  715|       |
  716|       |    /* Table F.4: Point to statistics bin S0 for DC coefficient coding */
  717|  3.77M|    st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
  718|       |
  719|       |    /* Figure F.4: Encode_DC_DIFF */
  720|  3.77M|    if ((v = (*block)[0] - entropy->last_dc_val[ci]) == 0) {
  ------------------
  |  Branch (720:9): [True: 2.41M, False: 1.35M]
  ------------------
  721|  2.41M|      arith_encode(cinfo, st, 0);
  722|  2.41M|      entropy->dc_context[ci] = 0;      /* zero diff category */
  723|  2.41M|    } else {
  724|  1.35M|      entropy->last_dc_val[ci] = (*block)[0];
  725|  1.35M|      arith_encode(cinfo, st, 1);
  726|       |      /* Figure F.6: Encoding nonzero value v */
  727|       |      /* Figure F.7: Encoding the sign of v */
  728|  1.35M|      if (v > 0) {
  ------------------
  |  Branch (728:11): [True: 682k, False: 673k]
  ------------------
  729|   682k|        arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
  730|   682k|        st += 2;                        /* Table F.4: SP = S0 + 2 */
  731|   682k|        entropy->dc_context[ci] = 4;    /* small positive diff category */
  732|   682k|      } else {
  733|   673k|        v = -v;
  734|   673k|        arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
  735|   673k|        st += 3;                        /* Table F.4: SN = S0 + 3 */
  736|   673k|        entropy->dc_context[ci] = 8;    /* small negative diff category */
  737|   673k|      }
  738|       |      /* Figure F.8: Encoding the magnitude category of v */
  739|  1.35M|      m = 0;
  740|  1.35M|      if (v -= 1) {
  ------------------
  |  Branch (740:11): [True: 1.27M, False: 83.9k]
  ------------------
  741|  1.27M|        arith_encode(cinfo, st, 1);
  742|  1.27M|        m = 1;
  743|  1.27M|        v2 = v;
  744|  1.27M|        st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
  745|  5.25M|        while (v2 >>= 1) {
  ------------------
  |  Branch (745:16): [True: 3.97M, False: 1.27M]
  ------------------
  746|  3.97M|          arith_encode(cinfo, st, 1);
  747|  3.97M|          m <<= 1;
  748|  3.97M|          st += 1;
  749|  3.97M|        }
  750|  1.27M|      }
  751|  1.35M|      arith_encode(cinfo, st, 0);
  752|       |      /* Section F.1.4.4.1.2: Establish dc_context conditioning category */
  753|  1.35M|      if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
  ------------------
  |  Branch (753:11): [True: 0, False: 1.35M]
  ------------------
  754|      0|        entropy->dc_context[ci] = 0;    /* zero diff category */
  755|  1.35M|      else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
  ------------------
  |  Branch (755:16): [True: 1.19M, False: 160k]
  ------------------
  756|  1.19M|        entropy->dc_context[ci] += 8;   /* large diff category */
  757|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  758|  1.35M|      st += 14;
  759|  5.33M|      while (m >>= 1)
  ------------------
  |  Branch (759:14): [True: 3.97M, False: 1.35M]
  ------------------
  760|  3.97M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (760:33): [True: 1.85M, False: 2.12M]
  ------------------
  761|  1.35M|    }
  762|       |
  763|       |    /* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */
  764|       |
  765|  3.77M|    tbl = compptr->ac_tbl_no;
  766|       |
  767|       |    /* Establish EOB (end-of-block) index */
  768|   179M|    for (ke = DCTSIZE2 - 1; ke > 0; ke--)
  ------------------
  |  |   67|  3.77M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (768:29): [True: 177M, False: 2.37M]
  ------------------
  769|   177M|      if ((*block)[jpeg_natural_order[ke]]) break;
  ------------------
  |  Branch (769:11): [True: 1.39M, False: 176M]
  ------------------
  770|       |
  771|       |    /* Figure F.5: Encode_AC_Coefficients */
  772|  39.3M|    for (k = 1; k <= ke; k++) {
  ------------------
  |  Branch (772:17): [True: 35.6M, False: 3.77M]
  ------------------
  773|  35.6M|      st = entropy->ac_stats[tbl] + 3 * (k - 1);
  774|  35.6M|      arith_encode(cinfo, st, 0);       /* EOB decision */
  775|  61.7M|      while ((v = (*block)[jpeg_natural_order[k]]) == 0) {
  ------------------
  |  Branch (775:14): [True: 26.1M, False: 35.6M]
  ------------------
  776|  26.1M|        arith_encode(cinfo, st + 1, 0);  st += 3;  k++;
  777|  26.1M|      }
  778|  35.6M|      arith_encode(cinfo, st + 1, 1);
  779|       |      /* Figure F.6: Encoding nonzero value v */
  780|       |      /* Figure F.7: Encoding the sign of v */
  781|  35.6M|      if (v > 0) {
  ------------------
  |  Branch (781:11): [True: 17.8M, False: 17.7M]
  ------------------
  782|  17.8M|        arith_encode(cinfo, entropy->fixed_bin, 0);
  783|  17.8M|      } else {
  784|  17.7M|        v = -v;
  785|  17.7M|        arith_encode(cinfo, entropy->fixed_bin, 1);
  786|  17.7M|      }
  787|  35.6M|      st += 2;
  788|       |      /* Figure F.8: Encoding the magnitude category of v */
  789|  35.6M|      m = 0;
  790|  35.6M|      if (v -= 1) {
  ------------------
  |  Branch (790:11): [True: 21.8M, False: 13.7M]
  ------------------
  791|  21.8M|        arith_encode(cinfo, st, 1);
  792|  21.8M|        m = 1;
  793|  21.8M|        v2 = v;
  794|  21.8M|        if (v2 >>= 1) {
  ------------------
  |  Branch (794:13): [True: 15.8M, False: 5.99M]
  ------------------
  795|  15.8M|          arith_encode(cinfo, st, 1);
  796|  15.8M|          m <<= 1;
  797|  15.8M|          st = entropy->ac_stats[tbl] +
  798|  15.8M|               (k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
  ------------------
  |  Branch (798:17): [True: 3.99M, False: 11.8M]
  ------------------
  799|  35.4M|          while (v2 >>= 1) {
  ------------------
  |  Branch (799:18): [True: 19.5M, False: 15.8M]
  ------------------
  800|  19.5M|            arith_encode(cinfo, st, 1);
  801|  19.5M|            m <<= 1;
  802|  19.5M|            st += 1;
  803|  19.5M|          }
  804|  15.8M|        }
  805|  21.8M|      }
  806|  35.6M|      arith_encode(cinfo, st, 0);
  807|       |      /* Figure F.9: Encoding the magnitude bit pattern of v */
  808|  35.6M|      st += 14;
  809|  71.0M|      while (m >>= 1)
  ------------------
  |  Branch (809:14): [True: 35.4M, False: 35.6M]
  ------------------
  810|  35.4M|        arith_encode(cinfo, st, (m & v) ? 1 : 0);
  ------------------
  |  Branch (810:33): [True: 14.5M, False: 20.9M]
  ------------------
  811|  35.6M|    }
  812|       |    /* Encode EOB decision only if k <= DCTSIZE2 - 1 */
  813|  3.77M|    if (k <= DCTSIZE2 - 1) {
  ------------------
  |  |   67|  3.77M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (813:9): [True: 3.54M, False: 229k]
  ------------------
  814|  3.54M|      st = entropy->ac_stats[tbl] + 3 * (k - 1);
  815|  3.54M|      arith_encode(cinfo, st, 1);
  816|  3.54M|    }
  817|  3.77M|  }
  818|       |
  819|   629k|  return TRUE;
  ------------------
  |  |  210|   629k|#define TRUE    1
  ------------------
  820|   629k|}
jcarith.c:finish_pass:
  140|  37.6k|{
  141|  37.6k|  arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
  142|  37.6k|  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|  37.6k|  if ((temp = (e->a - 1 + e->c) & 0xFFFF0000UL) < e->c)
  ------------------
  |  Branch (148:7): [True: 13.8k, False: 23.8k]
  ------------------
  149|  13.8k|    e->c = temp + 0x8000L;
  150|  23.8k|  else
  151|  23.8k|    e->c = temp;
  152|       |  /* Send remaining bytes to output */
  153|  37.6k|  e->c <<= e->ct;
  154|  37.6k|  if (e->c & 0xF8000000UL) {
  ------------------
  |  Branch (154:7): [True: 1.67k, False: 35.9k]
  ------------------
  155|       |    /* One final overflow has to be handled */
  156|  1.67k|    if (e->buffer >= 0) {
  ------------------
  |  Branch (156:9): [True: 1.67k, False: 0]
  ------------------
  157|  1.67k|      if (e->zc)
  ------------------
  |  Branch (157:11): [True: 38, False: 1.64k]
  ------------------
  158|  7.74k|        do emit_byte(0x00, cinfo);
  159|  7.74k|        while (--e->zc);
  ------------------
  |  Branch (159:16): [True: 7.70k, False: 38]
  ------------------
  160|  1.67k|      emit_byte(e->buffer + 1, cinfo);
  161|  1.67k|      if (e->buffer + 1 == 0xFF)
  ------------------
  |  Branch (161:11): [True: 211, False: 1.46k]
  ------------------
  162|    211|        emit_byte(0x00, cinfo);
  163|  1.67k|    }
  164|  1.67k|    e->zc += e->sc;  /* carry-over converts stacked 0xFF bytes to 0x00 */
  165|  1.67k|    e->sc = 0;
  166|  35.9k|  } else {
  167|  35.9k|    if (e->buffer == 0)
  ------------------
  |  Branch (167:9): [True: 712, False: 35.2k]
  ------------------
  168|    712|      ++e->zc;
  169|  35.2k|    else if (e->buffer >= 0) {
  ------------------
  |  Branch (169:14): [True: 24.5k, False: 10.7k]
  ------------------
  170|  24.5k|      if (e->zc)
  ------------------
  |  Branch (170:11): [True: 163, False: 24.3k]
  ------------------
  171|  6.67k|        do emit_byte(0x00, cinfo);
  172|  6.67k|        while (--e->zc);
  ------------------
  |  Branch (172:16): [True: 6.51k, False: 163]
  ------------------
  173|  24.5k|      emit_byte(e->buffer, cinfo);
  174|  24.5k|    }
  175|  35.9k|    if (e->sc) {
  ------------------
  |  Branch (175:9): [True: 203, False: 35.7k]
  ------------------
  176|    203|      if (e->zc)
  ------------------
  |  Branch (176:11): [True: 15, False: 188]
  ------------------
  177|    343|        do emit_byte(0x00, cinfo);
  178|    343|        while (--e->zc);
  ------------------
  |  Branch (178:16): [True: 328, False: 15]
  ------------------
  179|  26.0k|      do {
  180|  26.0k|        emit_byte(0xFF, cinfo);
  181|  26.0k|        emit_byte(0x00, cinfo);
  182|  26.0k|      } while (--e->sc);
  ------------------
  |  Branch (182:16): [True: 25.8k, False: 203]
  ------------------
  183|    203|    }
  184|  35.9k|  }
  185|       |  /* Output final bytes only if they are not 0x00 */
  186|  37.6k|  if (e->c & 0x7FFF800L) {
  ------------------
  |  Branch (186:7): [True: 36.5k, False: 1.12k]
  ------------------
  187|  36.5k|    if (e->zc)  /* output final pending zero bytes */
  ------------------
  |  Branch (187:9): [True: 373, False: 36.1k]
  ------------------
  188|  6.64k|      do emit_byte(0x00, cinfo);
  189|  6.64k|      while (--e->zc);
  ------------------
  |  Branch (189:14): [True: 6.26k, False: 373]
  ------------------
  190|  36.5k|    emit_byte((e->c >> 19) & 0xFF, cinfo);
  191|  36.5k|    if (((e->c >> 19) & 0xFF) == 0xFF)
  ------------------
  |  Branch (191:9): [True: 107, False: 36.4k]
  ------------------
  192|    107|      emit_byte(0x00, cinfo);
  193|  36.5k|    if (e->c & 0x7F800L) {
  ------------------
  |  Branch (193:9): [True: 6.32k, False: 30.2k]
  ------------------
  194|  6.32k|      emit_byte((e->c >> 11) & 0xFF, cinfo);
  195|  6.32k|      if (((e->c >> 11) & 0xFF) == 0xFF)
  ------------------
  |  Branch (195:11): [True: 0, False: 6.32k]
  ------------------
  196|      0|        emit_byte(0x00, cinfo);
  197|  6.32k|    }
  198|  36.5k|  }
  199|  37.6k|}

jinit_c_coef_controller:
  437|  25.4k|{
  438|  25.4k|  my_coef_ptr coef;
  439|       |
  440|  25.4k|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  25.4k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (440:7): [True: 0, False: 25.4k]
  ------------------
  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|  25.4k|  coef = (my_coef_ptr)
  444|  25.4k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  25.4k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  445|  25.4k|                                sizeof(my_coef_controller));
  446|  25.4k|  memset(coef, 0, sizeof(my_coef_controller));
  447|  25.4k|  cinfo->coef = (struct jpeg_c_coef_controller *)coef;
  448|  25.4k|  coef->pub.start_pass = start_pass_coef;
  449|       |
  450|       |  /* Create the coefficient buffer. */
  451|  25.4k|  if (need_full_buffer) {
  ------------------
  |  Branch (451:7): [True: 10.4k, False: 15.0k]
  ------------------
  452|  10.4k|#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.4k|    int ci;
  456|  10.4k|    jpeg_component_info *compptr;
  457|       |
  458|  45.1k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (458:46): [True: 34.6k, False: 10.4k]
  ------------------
  459|  34.6k|         ci++, compptr++) {
  460|  34.6k|      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
  461|  34.6k|        ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
  ------------------
  |  |  889|  34.6k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
                      ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
  ------------------
  |  |  207|  34.6k|#define FALSE   0               /* values of boolean */
  ------------------
  462|  34.6k|         (JDIMENSION)jround_up((long)compptr->width_in_blocks,
  463|  34.6k|                               (long)compptr->h_samp_factor),
  464|  34.6k|         (JDIMENSION)jround_up((long)compptr->height_in_blocks,
  465|  34.6k|                               (long)compptr->v_samp_factor),
  466|  34.6k|         (JDIMENSION)compptr->v_samp_factor);
  467|  34.6k|    }
  468|       |#else
  469|       |    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
  470|       |#endif
  471|  15.0k|  } else {
  472|       |    /* We only need a single-MCU buffer. */
  473|  15.0k|    JBLOCKROW buffer;
  474|  15.0k|    int i;
  475|       |
  476|  15.0k|    buffer = (JBLOCKROW)
  477|  15.0k|      (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  15.0k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  478|  15.0k|                                  C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
  ------------------
  |  |   80|  15.0k|#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on data units/MCU */
  ------------------
  479|   165k|    for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
  ------------------
  |  |   80|   165k|#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on data units/MCU */
  ------------------
  |  Branch (479:17): [True: 150k, False: 15.0k]
  ------------------
  480|   150k|      coef->MCU_buffer[i] = buffer + i;
  481|   150k|    }
  482|       |    coef->whole_image[0] = NULL; /* flag for no virtual arrays */
  483|  15.0k|  }
  484|  25.4k|}
jccoefct-8.c:start_pass_coef:
  104|   124k|{
  105|   124k|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  106|       |
  107|   124k|  coef->iMCU_row_num = 0;
  108|   124k|  start_iMCU_row(cinfo);
  109|       |
  110|   124k|  switch (pass_mode) {
  111|  15.0k|  case JBUF_PASS_THRU:
  ------------------
  |  Branch (111:3): [True: 15.0k, False: 108k]
  ------------------
  112|  15.0k|    if (coef->whole_image[0] != NULL)
  ------------------
  |  Branch (112:9): [True: 0, False: 15.0k]
  ------------------
  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.0k|    coef->pub._compress_data = compress_data;
  ------------------
  |  |  248|  15.0k|#define _compress_data  compress_data
  ------------------
  115|  15.0k|    break;
  116|      0|#ifdef FULL_COEF_BUFFER_SUPPORTED
  117|  10.4k|  case JBUF_SAVE_AND_PASS:
  ------------------
  |  Branch (117:3): [True: 10.4k, False: 113k]
  ------------------
  118|  10.4k|    if (coef->whole_image[0] == NULL)
  ------------------
  |  Branch (118:9): [True: 0, False: 10.4k]
  ------------------
  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.4k|    coef->pub._compress_data = compress_first_pass;
  ------------------
  |  |  248|  10.4k|#define _compress_data  compress_data
  ------------------
  121|  10.4k|    break;
  122|  98.5k|  case JBUF_CRANK_DEST:
  ------------------
  |  Branch (122:3): [True: 98.5k, False: 25.4k]
  ------------------
  123|  98.5k|    if (coef->whole_image[0] == NULL)
  ------------------
  |  Branch (123:9): [True: 0, False: 98.5k]
  ------------------
  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|  98.5k|    coef->pub._compress_data = compress_output;
  ------------------
  |  |  248|  98.5k|#define _compress_data  compress_data
  ------------------
  126|  98.5k|    break;
  127|      0|#endif
  128|      0|  default:
  ------------------
  |  Branch (128:3): [True: 0, False: 124k]
  ------------------
  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|   124k|  }
  132|   124k|}
jccoefct-8.c:start_iMCU_row:
   77|  22.8M|{
   78|  22.8M|  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|  22.8M|  if (cinfo->comps_in_scan > 1) {
  ------------------
  |  Branch (84:7): [True: 5.19M, False: 17.6M]
  ------------------
   85|  5.19M|    coef->MCU_rows_per_iMCU_row = 1;
   86|  17.6M|  } else {
   87|  17.6M|    if (coef->iMCU_row_num < (cinfo->total_iMCU_rows - 1))
  ------------------
  |  Branch (87:9): [True: 17.5M, False: 185k]
  ------------------
   88|  17.5M|      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
   89|   185k|    else
   90|   185k|      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
   91|  17.6M|  }
   92|       |
   93|  22.8M|  coef->mcu_ctr = 0;
   94|  22.8M|  coef->MCU_vert_offset = 0;
   95|  22.8M|}
jccoefct-8.c:compress_data:
  147|  2.12M|{
  148|  2.12M|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  149|  2.12M|  JDIMENSION MCU_col_num;       /* index of current MCU within row */
  150|  2.12M|  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
  151|  2.12M|  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
  152|  2.12M|  int blkn, bi, ci, yindex, yoffset, blockcnt;
  153|  2.12M|  JDIMENSION ypos, xpos;
  154|  2.12M|  jpeg_component_info *compptr;
  155|       |
  156|       |  /* Loop to write as much as one whole iMCU row */
  157|  4.24M|  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
  ------------------
  |  Branch (157:41): [True: 2.12M, False: 2.12M]
  ------------------
  158|  2.12M|       yoffset++) {
  159|  6.29M|    for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col;
  ------------------
  |  Branch (159:39): [True: 4.16M, False: 2.12M]
  ------------------
  160|  4.16M|         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.16M|      blkn = 0;
  171|  12.4M|      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (171:20): [True: 8.28M, False: 4.16M]
  ------------------
  172|  8.28M|        compptr = cinfo->cur_comp_info[ci];
  173|  8.28M|        blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width :
  ------------------
  |  Branch (173:20): [True: 4.08M, False: 4.19M]
  ------------------
  174|  8.28M|                                                  compptr->last_col_width;
  175|  8.28M|        xpos = MCU_col_num * compptr->MCU_sample_width;
  176|  8.28M|        ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */
  ------------------
  |  |   66|  8.28M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  177|  17.1M|        for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
  ------------------
  |  Branch (177:26): [True: 8.90M, False: 8.28M]
  ------------------
  178|  8.90M|          if (coef->iMCU_row_num < last_iMCU_row ||
  ------------------
  |  Branch (178:15): [True: 5.40M, False: 3.50M]
  ------------------
  179|  8.66M|              yoffset + yindex < compptr->last_row_height) {
  ------------------
  |  Branch (179:15): [True: 3.25M, False: 242k]
  ------------------
  180|  8.66M|            (*cinfo->fdct->_forward_DCT) (cinfo, compptr,
  ------------------
  |  |  254|  8.66M|#define _forward_DCT  forward_DCT
  ------------------
  181|  8.66M|                                          input_buf[compptr->component_index],
  182|  8.66M|                                          coef->MCU_buffer[blkn],
  183|  8.66M|                                          ypos, xpos, (JDIMENSION)blockcnt);
  184|  8.66M|            if (blockcnt < compptr->MCU_width) {
  ------------------
  |  Branch (184:17): [True: 605k, False: 8.06M]
  ------------------
  185|       |              /* Create some dummy blocks at the right edge of the image. */
  186|   605k|              jzero_far((void *)coef->MCU_buffer[blkn + blockcnt],
  187|   605k|                        (compptr->MCU_width - blockcnt) * sizeof(JBLOCK));
  188|  1.21M|              for (bi = blockcnt; bi < compptr->MCU_width; bi++) {
  ------------------
  |  Branch (188:35): [True: 605k, False: 605k]
  ------------------
  189|   605k|                coef->MCU_buffer[blkn + bi][0][0] =
  190|   605k|                  coef->MCU_buffer[blkn + bi - 1][0][0];
  191|   605k|              }
  192|   605k|            }
  193|  8.66M|          } else {
  194|       |            /* Create a row of dummy blocks at the bottom of the image. */
  195|   242k|            jzero_far((void *)coef->MCU_buffer[blkn],
  196|   242k|                      compptr->MCU_width * sizeof(JBLOCK));
  197|   727k|            for (bi = 0; bi < compptr->MCU_width; bi++) {
  ------------------
  |  Branch (197:26): [True: 484k, False: 242k]
  ------------------
  198|   484k|              coef->MCU_buffer[blkn + bi][0][0] =
  199|   484k|                coef->MCU_buffer[blkn - 1][0][0];
  200|   484k|            }
  201|   242k|          }
  202|  8.90M|          blkn += compptr->MCU_width;
  203|  8.90M|          ypos += DCTSIZE;
  ------------------
  |  |   66|  8.90M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  204|  8.90M|        }
  205|  8.28M|      }
  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.16M|      if (!(*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
  ------------------
  |  Branch (212:11): [True: 0, False: 4.16M]
  ------------------
  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.16M|    }
  229|       |    /* Completed an MCU row, but perhaps not an iMCU row */
  230|  2.12M|    coef->mcu_ctr = 0;
  231|  2.12M|  }
  232|       |  /* Completed the iMCU row, advance counters for next one */
  233|  2.12M|  coef->iMCU_row_num++;
  234|  2.12M|  start_iMCU_row(cinfo);
  235|  2.12M|  return TRUE;
  ------------------
  |  |  210|  2.12M|#define TRUE    1
  ------------------
  236|  2.12M|}
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.23M|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (274:44): [True: 5.50M, False: 1.72M]
  ------------------
  275|  5.50M|       ci++, compptr++) {
  276|       |    /* Align the virtual buffer for this component. */
  277|  5.50M|    buffer = (*cinfo->mem->access_virt_barray)
  278|  5.50M|      ((j_common_ptr)cinfo, coef->whole_image[ci],
  279|  5.50M|       coef->iMCU_row_num * compptr->v_samp_factor,
  280|  5.50M|       (JDIMENSION)compptr->v_samp_factor, TRUE);
  ------------------
  |  |  210|  5.50M|#define TRUE    1
  ------------------
  281|       |    /* Count non-dummy DCT block rows in this iMCU row. */
  282|  5.50M|    if (coef->iMCU_row_num < last_iMCU_row)
  ------------------
  |  Branch (282:9): [True: 5.47M, False: 34.6k]
  ------------------
  283|  5.47M|      block_rows = compptr->v_samp_factor;
  284|  34.6k|    else {
  285|       |      /* NB: can't use last_row_height here, since may not be set! */
  286|  34.6k|      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
  287|  34.6k|      if (block_rows == 0) block_rows = compptr->v_samp_factor;
  ------------------
  |  Branch (287:11): [True: 28.9k, False: 5.75k]
  ------------------
  288|  34.6k|    }
  289|  5.50M|    blocks_across = compptr->width_in_blocks;
  290|  5.50M|    h_samp_factor = compptr->h_samp_factor;
  291|       |    /* Count number of dummy blocks to be added at the right margin. */
  292|  5.50M|    ndummy = (int)(blocks_across % h_samp_factor);
  293|  5.50M|    if (ndummy > 0)
  ------------------
  |  Branch (293:9): [True: 1.29M, False: 4.21M]
  ------------------
  294|  1.29M|      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.19M, False: 5.50M]
  ------------------
  299|  6.19M|      thisblockrow = buffer[block_row];
  300|  6.19M|      (*cinfo->fdct->_forward_DCT) (cinfo, compptr,
  ------------------
  |  |  254|  6.19M|#define _forward_DCT  forward_DCT
  ------------------
  301|  6.19M|                                    input_buf[ci], thisblockrow,
  302|  6.19M|                                    (JDIMENSION)(block_row * DCTSIZE),
  ------------------
  |  |   66|  6.19M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  303|  6.19M|                                    (JDIMENSION)0, blocks_across);
  304|  6.19M|      if (ndummy > 0) {
  ------------------
  |  Branch (304:11): [True: 1.29M, False: 4.90M]
  ------------------
  305|       |        /* Create dummy blocks at the right edge of the image. */
  306|  1.29M|        thisblockrow += blocks_across; /* => first dummy block */
  307|  1.29M|        jzero_far((void *)thisblockrow, ndummy * sizeof(JBLOCK));
  308|  1.29M|        lastDC = thisblockrow[-1][0];
  309|  3.87M|        for (bi = 0; bi < ndummy; bi++) {
  ------------------
  |  Branch (309:22): [True: 2.58M, False: 1.29M]
  ------------------
  310|  2.58M|          thisblockrow[bi][0] = lastDC;
  311|  2.58M|        }
  312|  1.29M|      }
  313|  6.19M|    }
  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.50M|    if (coef->iMCU_row_num == last_iMCU_row) {
  ------------------
  |  Branch (319:9): [True: 34.6k, False: 5.47M]
  ------------------
  320|  34.6k|      blocks_across += ndummy;  /* include lower right corner */
  321|  34.6k|      MCUs_across = blocks_across / h_samp_factor;
  322|  40.4k|      for (block_row = block_rows; block_row < compptr->v_samp_factor;
  ------------------
  |  Branch (322:36): [True: 5.75k, False: 34.6k]
  ------------------
  323|  34.6k|           block_row++) {
  324|  5.75k|        thisblockrow = buffer[block_row];
  325|  5.75k|        lastblockrow = buffer[block_row - 1];
  326|  5.75k|        jzero_far((void *)thisblockrow,
  327|  5.75k|                  (size_t)(blocks_across * sizeof(JBLOCK)));
  328|   970k|        for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
  ------------------
  |  Branch (328:28): [True: 964k, False: 5.75k]
  ------------------
  329|   964k|          lastDC = lastblockrow[h_samp_factor - 1][0];
  330|  1.92M|          for (bi = 0; bi < h_samp_factor; bi++) {
  ------------------
  |  Branch (330:24): [True: 964k, False: 964k]
  ------------------
  331|   964k|            thisblockrow[bi][0] = lastDC;
  332|   964k|          }
  333|   964k|          thisblockrow += h_samp_factor; /* advance to next MCU in row */
  334|   964k|          lastblockrow += h_samp_factor;
  335|   964k|        }
  336|  5.75k|      }
  337|  34.6k|    }
  338|  5.50M|  }
  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.6M|{
  361|  20.6M|  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
  362|  20.6M|  JDIMENSION MCU_col_num;       /* index of current MCU within row */
  363|  20.6M|  int blkn, ci, xindex, yindex, yoffset;
  364|  20.6M|  JDIMENSION start_col;
  365|  20.6M|  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
  366|  20.6M|  JBLOCKROW buffer_ptr;
  367|  20.6M|  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.2M|  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (373:16): [True: 29.5M, False: 20.6M]
  ------------------
  374|  29.5M|    compptr = cinfo->cur_comp_info[ci];
  375|  29.5M|    buffer[ci] = (*cinfo->mem->access_virt_barray)
  376|  29.5M|      ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
  377|  29.5M|       coef->iMCU_row_num * compptr->v_samp_factor,
  378|  29.5M|       (JDIMENSION)compptr->v_samp_factor, FALSE);
  ------------------
  |  |  207|  29.5M|#define FALSE   0               /* values of boolean */
  ------------------
  379|  29.5M|  }
  380|       |
  381|       |  /* Loop to process one whole iMCU row */
  382|  41.2M|  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
  ------------------
  |  Branch (382:41): [True: 20.6M, False: 20.6M]
  ------------------
  383|  20.6M|       yoffset++) {
  384|  55.9M|    for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row;
  ------------------
  |  Branch (384:39): [True: 35.3M, False: 20.6M]
  ------------------
  385|  35.3M|         MCU_col_num++) {
  386|       |      /* Construct list of pointers to DCT blocks belonging to this MCU */
  387|  35.3M|      blkn = 0;                 /* index of current DCT block within MCU */
  388|  85.8M|      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
  ------------------
  |  Branch (388:20): [True: 50.5M, False: 35.3M]
  ------------------
  389|  50.5M|        compptr = cinfo->cur_comp_info[ci];
  390|  50.5M|        start_col = MCU_col_num * compptr->MCU_width;
  391|   104M|        for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
  ------------------
  |  Branch (391:26): [True: 54.3M, False: 50.5M]
  ------------------
  392|  54.3M|          buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
  393|   116M|          for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
  ------------------
  |  Branch (393:28): [True: 62.5M, False: 54.3M]
  ------------------
  394|  62.5M|            coef->MCU_buffer[blkn++] = buffer_ptr++;
  395|  62.5M|          }
  396|  54.3M|        }
  397|  50.5M|      }
  398|       |      /* Try to write the MCU. */
  399|       |#ifdef WITH_PROFILE
  400|       |      cinfo->master->start = getTime();
  401|       |#endif
  402|  35.3M|      if (!(*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
  ------------------
  |  Branch (402:11): [True: 0, False: 35.3M]
  ------------------
  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|  35.3M|    }
  419|       |    /* Completed an MCU row, but perhaps not an iMCU row */
  420|  20.6M|    coef->mcu_ctr = 0;
  421|  20.6M|  }
  422|       |  /* Completed the iMCU row, advance counters for next one */
  423|  20.6M|  coef->iMCU_row_num++;
  424|  20.6M|  start_iMCU_row(cinfo);
  425|  20.6M|  return TRUE;
  ------------------
  |  |  210|  20.6M|#define TRUE    1
  ------------------
  426|  20.6M|}

jinit_color_converter:
  418|  25.4k|{
  419|  25.4k|  my_cconvert_ptr cconvert;
  420|       |
  421|  25.4k|#ifdef C_LOSSLESS_SUPPORTED
  422|  25.4k|  if (cinfo->master->lossless) {
  ------------------
  |  Branch (422:7): [True: 0, False: 25.4k]
  ------------------
  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|  25.4k|#endif
  432|  25.4k|  {
  433|  25.4k|    if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  25.4k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (433:9): [True: 0, False: 25.4k]
  ------------------
  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|  25.4k|  }
  436|       |
  437|  25.4k|  cconvert = (my_cconvert_ptr)
  438|  25.4k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  25.4k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  439|  25.4k|                                sizeof(my_color_converter));
  440|  25.4k|  cinfo->cconvert = (struct jpeg_color_converter *)cconvert;
  441|       |  /* set start_pass to null method until we find out differently */
  442|  25.4k|  cconvert->pub.start_pass = null_method;
  443|       |
  444|       |  /* Make sure input_components agrees with in_color_space */
  445|  25.4k|  switch (cinfo->in_color_space) {
  446|  4.64k|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (446:3): [True: 4.64k, False: 20.8k]
  ------------------
  447|  4.64k|    if (cinfo->input_components != 1)
  ------------------
  |  Branch (447:9): [True: 0, False: 4.64k]
  ------------------
  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.64k|    break;
  450|       |
  451|      0|  case JCS_RGB:
  ------------------
  |  Branch (451:3): [True: 0, False: 25.4k]
  ------------------
  452|  3.57k|  case JCS_EXT_RGB:
  ------------------
  |  Branch (452:3): [True: 3.57k, False: 21.9k]
  ------------------
  453|  6.99k|  case JCS_EXT_RGBX:
  ------------------
  |  Branch (453:3): [True: 3.42k, False: 22.0k]
  ------------------
  454|  10.5k|  case JCS_EXT_BGR:
  ------------------
  |  Branch (454:3): [True: 3.57k, False: 21.9k]
  ------------------
  455|  10.5k|  case JCS_EXT_BGRX:
  ------------------
  |  Branch (455:3): [True: 0, False: 25.4k]
  ------------------
  456|  10.5k|  case JCS_EXT_XBGR:
  ------------------
  |  Branch (456:3): [True: 0, False: 25.4k]
  ------------------
  457|  13.9k|  case JCS_EXT_XRGB:
  ------------------
  |  Branch (457:3): [True: 3.42k, False: 22.0k]
  ------------------
  458|  13.9k|  case JCS_EXT_RGBA:
  ------------------
  |  Branch (458:3): [True: 0, False: 25.4k]
  ------------------
  459|  17.4k|  case JCS_EXT_BGRA:
  ------------------
  |  Branch (459:3): [True: 3.42k, False: 22.0k]
  ------------------
  460|  17.4k|  case JCS_EXT_ABGR:
  ------------------
  |  Branch (460:3): [True: 0, False: 25.4k]
  ------------------
  461|  17.4k|  case JCS_EXT_ARGB:
  ------------------
  |  Branch (461:3): [True: 0, False: 25.4k]
  ------------------
  462|  17.4k|    if (cinfo->input_components != rgb_pixelsize[cinfo->in_color_space])
  ------------------
  |  Branch (462:9): [True: 0, False: 17.4k]
  ------------------
  463|      0|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  464|  17.4k|    break;
  465|       |
  466|      0|  case JCS_YCbCr:
  ------------------
  |  Branch (466:3): [True: 0, False: 25.4k]
  ------------------
  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.42k|  case JCS_CMYK:
  ------------------
  |  Branch (471:3): [True: 3.42k, False: 22.0k]
  ------------------
  472|  3.42k|  case JCS_YCCK:
  ------------------
  |  Branch (472:3): [True: 0, False: 25.4k]
  ------------------
  473|  3.42k|    if (cinfo->input_components != 4)
  ------------------
  |  Branch (473:9): [True: 0, False: 3.42k]
  ------------------
  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.42k|    break;
  476|       |
  477|      0|  default:                      /* JCS_UNKNOWN can be anything */
  ------------------
  |  Branch (477:3): [True: 0, False: 25.4k]
  ------------------
  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|  25.4k|  }
  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|  25.4k|  switch (cinfo->jpeg_color_space) {
  488|  8.06k|  case JCS_GRAYSCALE:
  ------------------
  |  Branch (488:3): [True: 8.06k, False: 17.4k]
  ------------------
  489|  8.06k|#ifdef C_LOSSLESS_SUPPORTED
  490|  8.06k|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (490:9): [True: 0, False: 8.06k]
  ------------------
  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.06k|#endif
  494|  8.06k|    if (cinfo->num_components != 1)
  ------------------
  |  Branch (494:9): [True: 0, False: 8.06k]
  ------------------
  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.06k|    if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (496:9): [True: 4.64k, False: 3.42k]
  ------------------
  497|  4.64k|      cconvert->pub._color_convert = grayscale_convert;
  ------------------
  |  |  267|  4.64k|#define _color_convert  color_convert
  ------------------
  498|  3.42k|    else if (IsExtRGB(cinfo->in_color_space)) {
  ------------------
  |  |   78|  3.42k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 3.42k]
  |  |  |  Branch (78:22): [True: 3.42k, False: 0]
  |  |  |  Branch (78:43): [True: 3.42k, False: 0]
  |  |  ------------------
  ------------------
  499|  3.42k|#ifdef WITH_SIMD
  500|  3.42k|      if (jsimd_set_rgb_gray(cinfo))
  ------------------
  |  Branch (500:11): [True: 3.42k, False: 0]
  ------------------
  501|  3.42k|        cconvert->pub._color_convert = jsimd_color_convert;
  ------------------
  |  |  267|  3.42k|#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.42k|    } 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.06k|    break;
  538|       |
  539|  8.06k|  case JCS_RGB:
  ------------------
  |  Branch (539:3): [True: 3.57k, False: 21.9k]
  ------------------
  540|  3.57k|#ifdef C_LOSSLESS_SUPPORTED
  541|  3.57k|    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.57k]
  ------------------
  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.57k|#endif
  544|  3.57k|    if (cinfo->num_components != 3)
  ------------------
  |  Branch (544:9): [True: 0, False: 3.57k]
  ------------------
  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.57k|    if (rgb_red[cinfo->in_color_space] == 0 &&
  ------------------
  |  Branch (546:9): [True: 3.57k, False: 0]
  ------------------
  547|  3.57k|        rgb_green[cinfo->in_color_space] == 1 &&
  ------------------
  |  Branch (547:9): [True: 3.57k, False: 0]
  ------------------
  548|  3.57k|        rgb_blue[cinfo->in_color_space] == 2 &&
  ------------------
  |  Branch (548:9): [True: 3.57k, False: 0]
  ------------------
  549|  3.57k|        rgb_pixelsize[cinfo->in_color_space] == 3) {
  ------------------
  |  Branch (549:9): [True: 3.57k, False: 0]
  ------------------
  550|  3.57k|      cconvert->pub._color_convert = null_convert;
  ------------------
  |  |  267|  3.57k|#define _color_convert  color_convert
  ------------------
  551|  3.57k|    } 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.57k|    break;
  581|       |
  582|  10.4k|  case JCS_YCbCr:
  ------------------
  |  Branch (582:3): [True: 10.4k, False: 15.0k]
  ------------------
  583|  10.4k|#ifdef C_LOSSLESS_SUPPORTED
  584|  10.4k|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (584:9): [True: 0, False: 10.4k]
  ------------------
  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.4k|#endif
  588|  10.4k|    if (cinfo->num_components != 3)
  ------------------
  |  Branch (588:9): [True: 0, False: 10.4k]
  ------------------
  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.4k|    if (IsExtRGB(cinfo->in_color_space)) {
  ------------------
  |  |   78|  10.4k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 10.4k]
  |  |  |  Branch (78:22): [True: 10.4k, False: 0]
  |  |  |  Branch (78:43): [True: 10.4k, False: 0]
  |  |  ------------------
  ------------------
  591|  10.4k|#ifdef WITH_SIMD
  592|  10.4k|      if (jsimd_set_rgb_ycc(cinfo))
  ------------------
  |  Branch (592:11): [True: 10.4k, False: 0]
  ------------------
  593|  10.4k|        cconvert->pub._color_convert = jsimd_color_convert;
  ------------------
  |  |  267|  10.4k|#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.4k|    } 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.4k|    break;
  630|       |
  631|  10.4k|  case JCS_CMYK:
  ------------------
  |  Branch (631:3): [True: 0, False: 25.4k]
  ------------------
  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.42k|  case JCS_YCCK:
  ------------------
  |  Branch (645:3): [True: 3.42k, False: 22.0k]
  ------------------
  646|  3.42k|#ifdef C_LOSSLESS_SUPPORTED
  647|  3.42k|    if (cinfo->master->lossless &&
  ------------------
  |  Branch (647:9): [True: 0, False: 3.42k]
  ------------------
  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.42k|#endif
  651|  3.42k|    if (cinfo->num_components != 4)
  ------------------
  |  Branch (651:9): [True: 0, False: 3.42k]
  ------------------
  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.42k|    if (cinfo->in_color_space == JCS_CMYK) {
  ------------------
  |  Branch (653:9): [True: 3.42k, False: 0]
  ------------------
  654|  3.42k|      cconvert->pub.start_pass = rgb_ycc_start;
  655|  3.42k|      cconvert->pub._color_convert = cmyk_ycck_convert;
  ------------------
  |  |  267|  3.42k|#define _color_convert  color_convert
  ------------------
  656|  3.42k|    } 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.42k|    break;
  661|       |
  662|      0|  default:                      /* allow null conversion of JCS_UNKNOWN */
  ------------------
  |  Branch (662:3): [True: 0, False: 25.4k]
  ------------------
  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|  25.4k|  }
  669|  25.4k|}
jccolor-8.c:null_method:
  407|  22.0k|{
  408|       |  /* no work needed */
  409|  22.0k|}
jccolor-8.c:grayscale_convert:
  319|  3.21M|{
  320|  3.21M|  register _JSAMPROW inptr;
  321|  3.21M|  register _JSAMPROW outptr;
  322|  3.21M|  register JDIMENSION col;
  323|  3.21M|  JDIMENSION num_cols = cinfo->image_width;
  324|  3.21M|  int instride = cinfo->input_components;
  325|       |
  326|  6.42M|  while (--num_rows >= 0) {
  ------------------
  |  Branch (326:10): [True: 3.21M, False: 3.21M]
  ------------------
  327|  3.21M|    inptr = *input_buf++;
  328|  3.21M|    outptr = output_buf[0][output_row];
  329|  3.21M|    output_row++;
  330|  13.7M|    for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (330:19): [True: 10.5M, False: 3.21M]
  ------------------
  331|  10.5M|      outptr[col] = inptr[0];
  332|  10.5M|      inptr += instride;
  333|  10.5M|    }
  334|  3.21M|  }
  335|  3.21M|}
jccolor-8.c:rgb_ycc_start:
  216|  3.42k|{
  217|  3.42k|#if BITS_IN_JSAMPLE != 16
  218|  3.42k|  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
  219|  3.42k|  JLONG *rgb_ycc_tab;
  220|  3.42k|  JLONG i;
  221|       |
  222|       |  /* Allocate and fill in the conversion tables. */
  223|  3.42k|  cconvert->rgb_ycc_tab = rgb_ycc_tab = (JLONG *)
  224|  3.42k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  3.42k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  225|  3.42k|                                (TABLE_SIZE * sizeof(JLONG)));
  ------------------
  |  |   90|  3.42k|#define TABLE_SIZE      (8 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|  3.42k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  3.42k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  226|       |
  227|   880k|  for (i = 0; i <= _MAXJSAMPLE; i++) {
  ------------------
  |  |  226|   880k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|   880k|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
  |  Branch (227:15): [True: 876k, False: 3.42k]
  ------------------
  228|   876k|    rgb_ycc_tab[i + R_Y_OFF] = FIX(0.29900) * i;
  ------------------
  |  |   81|   876k|#define R_Y_OFF         0                       /* offset to R => Y section */
  ------------------
                  rgb_ycc_tab[i + R_Y_OFF] = FIX(0.29900) * i;
  ------------------
  |  |   73|   876k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   876k|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  229|   876k|    rgb_ycc_tab[i + G_Y_OFF] = FIX(0.58700) * i;
  ------------------
  |  |   82|   876k|#define G_Y_OFF         (1 * (_MAXJSAMPLE + 1)) /* offset to G => Y section */
  |  |  ------------------
  |  |  |  |  226|   876k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|   876k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + G_Y_OFF] = FIX(0.58700) * i;
  ------------------
  |  |   73|   876k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   876k|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  230|   876k|    rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i   + ONE_HALF;
  ------------------
  |  |   83|   876k|#define B_Y_OFF         (2 * (_MAXJSAMPLE + 1)) /* etc. */
  |  |  ------------------
  |  |  |  |  226|   876k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|   876k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i   + ONE_HALF;
  ------------------
  |  |   73|   876k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   876k|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i   + ONE_HALF;
  ------------------
  |  |   72|   876k|#define ONE_HALF        ((JLONG)1 << (SCALEBITS - 1))
  |  |  ------------------
  |  |  |  |   70|   876k|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  231|   876k|    rgb_ycc_tab[i + R_CB_OFF] = (-FIX(0.16874)) * i;
  ------------------
  |  |   84|   876k|#define R_CB_OFF        (3 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|   876k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|   876k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + R_CB_OFF] = (-FIX(0.16874)) * i;
  ------------------
  |  |   73|   876k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   876k|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  232|   876k|    rgb_ycc_tab[i + G_CB_OFF] = (-FIX(0.33126)) * i;
  ------------------
  |  |   85|   876k|#define G_CB_OFF        (4 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|   876k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|   876k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + G_CB_OFF] = (-FIX(0.33126)) * i;
  ------------------
  |  |   73|   876k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   876k|#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|   876k|    rgb_ycc_tab[i + B_CB_OFF] = FIX(0.50000) * i  + CBCR_OFFSET + ONE_HALF - 1;
  ------------------
  |  |   86|   876k|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|   876k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|   876k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_CB_OFF] = FIX(0.50000) * i  + CBCR_OFFSET + ONE_HALF - 1;
  ------------------
  |  |   73|   876k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   876k|#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|   876k|#define CBCR_OFFSET     ((JLONG)_CENTERJSAMPLE << SCALEBITS)
  |  |  ------------------
  |  |  |  |  227|   876k|#define _CENTERJSAMPLE   CENTERJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   53|   876k|#define CENTERJSAMPLE    128
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define CBCR_OFFSET     ((JLONG)_CENTERJSAMPLE << SCALEBITS)
  |  |  ------------------
  |  |  |  |   70|   876k|#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|   876k|#define ONE_HALF        ((JLONG)1 << (SCALEBITS - 1))
  |  |  ------------------
  |  |  |  |   70|   876k|#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|   876k|    rgb_ycc_tab[i + G_CR_OFF] = (-FIX(0.41869)) * i;
  ------------------
  |  |   88|   876k|#define G_CR_OFF        (6 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|   876k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|   876k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + G_CR_OFF] = (-FIX(0.41869)) * i;
  ------------------
  |  |   73|   876k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   876k|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  242|   876k|    rgb_ycc_tab[i + B_CR_OFF] = (-FIX(0.08131)) * i;
  ------------------
  |  |   89|   876k|#define B_CR_OFF        (7 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|   876k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|   876k|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  rgb_ycc_tab[i + B_CR_OFF] = (-FIX(0.08131)) * i;
  ------------------
  |  |   73|   876k|#define FIX(x)          ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
  |  |  ------------------
  |  |  |  |   70|   876k|#define SCALEBITS       16      /* speediest right-shift on some machines */
  |  |  ------------------
  ------------------
  243|   876k|  }
  244|       |#else
  245|       |  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  246|       |#endif
  247|  3.42k|}
jccolor-8.c:null_convert:
  347|  5.49M|{
  348|  5.49M|  register _JSAMPROW inptr;
  349|  5.49M|  register _JSAMPROW outptr, outptr0, outptr1, outptr2, outptr3;
  350|  5.49M|  register JDIMENSION col;
  351|  5.49M|  register int ci;
  352|  5.49M|  int nc = cinfo->num_components;
  353|  5.49M|  JDIMENSION num_cols = cinfo->image_width;
  354|       |
  355|  5.49M|  if (nc == 3) {
  ------------------
  |  Branch (355:7): [True: 5.49M, False: 0]
  ------------------
  356|  10.9M|    while (--num_rows >= 0) {
  ------------------
  |  Branch (356:12): [True: 5.49M, False: 5.49M]
  ------------------
  357|  5.49M|      inptr = *input_buf++;
  358|  5.49M|      outptr0 = output_buf[0][output_row];
  359|  5.49M|      outptr1 = output_buf[1][output_row];
  360|  5.49M|      outptr2 = output_buf[2][output_row];
  361|  5.49M|      output_row++;
  362|  36.0M|      for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (362:21): [True: 30.5M, False: 5.49M]
  ------------------
  363|  30.5M|        outptr0[col] = *inptr++;
  364|  30.5M|        outptr1[col] = *inptr++;
  365|  30.5M|        outptr2[col] = *inptr++;
  366|  30.5M|      }
  367|  5.49M|    }
  368|  5.49M|  } 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.49M|}
jccolor-8.c:cmyk_ycck_convert:
  264|  2.74M|{
  265|  2.74M|#if BITS_IN_JSAMPLE != 16
  266|  2.74M|  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
  267|  2.74M|  register int r, g, b;
  268|  2.74M|  register JLONG *ctab = cconvert->rgb_ycc_tab;
  269|  2.74M|  register _JSAMPROW inptr;
  270|  2.74M|  register _JSAMPROW outptr0, outptr1, outptr2, outptr3;
  271|  2.74M|  register JDIMENSION col;
  272|  2.74M|  JDIMENSION num_cols = cinfo->image_width;
  273|       |
  274|  8.24M|  while (--num_rows >= 0) {
  ------------------
  |  Branch (274:10): [True: 5.49M, False: 2.74M]
  ------------------
  275|  5.49M|    inptr = *input_buf++;
  276|  5.49M|    outptr0 = output_buf[0][output_row];
  277|  5.49M|    outptr1 = output_buf[1][output_row];
  278|  5.49M|    outptr2 = output_buf[2][output_row];
  279|  5.49M|    outptr3 = output_buf[3][output_row];
  280|  5.49M|    output_row++;
  281|  36.0M|    for (col = 0; col < num_cols; col++) {
  ------------------
  |  Branch (281:19): [True: 30.5M, False: 5.49M]
  ------------------
  282|  30.5M|      r = _MAXJSAMPLE - RANGE_LIMIT(inptr[0]);
  ------------------
  |  |  226|  30.5M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|  30.5M|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
                    r = _MAXJSAMPLE - RANGE_LIMIT(inptr[0]);
  ------------------
  |  |  101|  30.5M|#define RANGE_LIMIT(value)  (value)
  ------------------
  283|  30.5M|      g = _MAXJSAMPLE - RANGE_LIMIT(inptr[1]);
  ------------------
  |  |  226|  30.5M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|  30.5M|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
                    g = _MAXJSAMPLE - RANGE_LIMIT(inptr[1]);
  ------------------
  |  |  101|  30.5M|#define RANGE_LIMIT(value)  (value)
  ------------------
  284|  30.5M|      b = _MAXJSAMPLE - RANGE_LIMIT(inptr[2]);
  ------------------
  |  |  226|  30.5M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|  30.5M|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
                    b = _MAXJSAMPLE - RANGE_LIMIT(inptr[2]);
  ------------------
  |  |  101|  30.5M|#define RANGE_LIMIT(value)  (value)
  ------------------
  285|       |      /* K passes through as-is */
  286|  30.5M|      outptr3[col] = inptr[3];
  287|  30.5M|      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|  30.5M|      outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   81|  30.5M|#define R_Y_OFF         0                       /* offset to R => Y section */
  ------------------
                    outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
  ------------------
  |  |   82|  30.5M|#define G_Y_OFF         (1 * (_MAXJSAMPLE + 1)) /* offset to G => Y section */
  |  |  ------------------
  |  |  |  |  226|  30.5M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  30.5M|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  295|  30.5M|                                 ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   83|  30.5M|#define B_Y_OFF         (2 * (_MAXJSAMPLE + 1)) /* etc. */
  |  |  ------------------
  |  |  |  |  226|  30.5M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  30.5M|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_Y_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  30.5M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
  296|       |      /* Cb */
  297|  30.5M|      outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
  ------------------
  |  |   84|  30.5M|#define R_CB_OFF        (3 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|  30.5M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  30.5M|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
  ------------------
  |  |   85|  30.5M|#define G_CB_OFF        (4 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|  30.5M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  30.5M|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  298|  30.5M|                                 ctab[b + B_CB_OFF]) >> SCALEBITS);
  ------------------
  |  |   86|  30.5M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|  30.5M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  30.5M|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_CB_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  30.5M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
  299|       |      /* Cr */
  300|  30.5M|      outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
  ------------------
  |  |   87|  30.5M|#define R_CR_OFF        B_CB_OFF                /* B=>Cb, R=>Cr are the same */
  |  |  ------------------
  |  |  |  |   86|  30.5M|#define B_CB_OFF        (5 * (_MAXJSAMPLE + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |  226|  30.5M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   52|  30.5M|#define MAXJSAMPLE       255
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
  ------------------
  |  |   88|  30.5M|#define G_CR_OFF        (6 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|  30.5M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  30.5M|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  301|  30.5M|                                 ctab[b + B_CR_OFF]) >> SCALEBITS);
  ------------------
  |  |   89|  30.5M|#define B_CR_OFF        (7 * (_MAXJSAMPLE + 1))
  |  |  ------------------
  |  |  |  |  226|  30.5M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|  30.5M|#define MAXJSAMPLE       255
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                                               ctab[b + B_CR_OFF]) >> SCALEBITS);
  ------------------
  |  |   70|  30.5M|#define SCALEBITS       16      /* speediest right-shift on some machines */
  ------------------
  302|  30.5M|    }
  303|  5.49M|  }
  304|       |#else
  305|       |  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
  306|       |#endif
  307|  2.74M|}

jinit_forward_dct:
  672|  25.4k|{
  673|  25.4k|  my_fdct_ptr fdct;
  674|  25.4k|  int i;
  675|       |
  676|  25.4k|  if (cinfo->data_precision != BITS_IN_JSAMPLE)
  ------------------
  |  |   12|  25.4k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (676:7): [True: 0, False: 25.4k]
  ------------------
  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|  25.4k|  fdct = (my_fdct_ptr)
  680|  25.4k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  25.4k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  681|  25.4k|                                sizeof(my_fdct_controller));
  682|  25.4k|  cinfo->fdct = (struct jpeg_forward_dct *)fdct;
  683|  25.4k|  fdct->pub.start_pass = start_pass_fdctmgr;
  684|       |
  685|       |  /* First determine the DCT... */
  686|  25.4k|  switch (cinfo->dct_method) {
  687|      0|#ifdef DCT_ISLOW_SUPPORTED
  688|  22.0k|  case JDCT_ISLOW:
  ------------------
  |  Branch (688:3): [True: 22.0k, False: 3.42k]
  ------------------
  689|  22.0k|    fdct->pub._forward_DCT = forward_DCT;
  ------------------
  |  |  254|  22.0k|#define _forward_DCT  forward_DCT
  ------------------
  690|  22.0k|#ifdef WITH_SIMD
  691|  22.0k|    if (!jsimd_set_fdct_islow(cinfo, &fdct->dct))
  ------------------
  |  Branch (691:9): [True: 0, False: 22.0k]
  ------------------
  692|      0|#endif
  693|      0|      fdct->dct = _jpeg_fdct_islow;
  ------------------
  |  |  300|      0|#define _jpeg_fdct_islow  jpeg_fdct_islow
  ------------------
  694|  22.0k|    break;
  695|      0|#endif
  696|      0|#ifdef DCT_IFAST_SUPPORTED
  697|  3.42k|  case JDCT_IFAST:
  ------------------
  |  Branch (697:3): [True: 3.42k, False: 22.0k]
  ------------------
  698|  3.42k|    fdct->pub._forward_DCT = forward_DCT;
  ------------------
  |  |  254|  3.42k|#define _forward_DCT  forward_DCT
  ------------------
  699|  3.42k|#ifdef WITH_SIMD
  700|  3.42k|    if (!jsimd_set_fdct_ifast(cinfo, &fdct->dct))
  ------------------
  |  Branch (700:9): [True: 0, False: 3.42k]
  ------------------
  701|      0|#endif
  702|      0|      fdct->dct = _jpeg_fdct_ifast;
  ------------------
  |  |  301|      0|#define _jpeg_fdct_ifast  jpeg_fdct_ifast
  ------------------
  703|  3.42k|    break;
  704|      0|#endif
  705|      0|#ifdef DCT_FLOAT_SUPPORTED
  706|      0|  case JDCT_FLOAT:
  ------------------
  |  Branch (706:3): [True: 0, False: 25.4k]
  ------------------
  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: 25.4k]
  ------------------
  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|  25.4k|  }
  718|       |
  719|       |  /* ...then the supporting stages. */
  720|  25.4k|  switch (cinfo->dct_method) {
  721|      0|#ifdef DCT_ISLOW_SUPPORTED
  722|  22.0k|  case JDCT_ISLOW:
  ------------------
  |  Branch (722:3): [True: 22.0k, False: 3.42k]
  ------------------
  723|  22.0k|#endif
  724|  22.0k|#ifdef DCT_IFAST_SUPPORTED
  725|  25.4k|  case JDCT_IFAST:
  ------------------
  |  Branch (725:3): [True: 3.42k, False: 22.0k]
  ------------------
  726|  25.4k|#endif
  727|  25.4k|#if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED)
  728|  25.4k|#ifdef WITH_SIMD
  729|  25.4k|    if (!jsimd_set_convsamp(cinfo, &fdct->convsamp))
  ------------------
  |  Branch (729:9): [True: 0, False: 25.4k]
  ------------------
  730|      0|#endif
  731|      0|      fdct->convsamp = convsamp;
  732|  25.4k|#ifdef WITH_SIMD
  733|  25.4k|    if (!jsimd_set_quantize(cinfo, &fdct->quantize))
  ------------------
  |  Branch (733:9): [True: 0, False: 25.4k]
  ------------------
  734|      0|#endif
  735|      0|      fdct->quantize = quantize;
  736|  25.4k|    break;
  737|      0|#endif
  738|      0|#ifdef DCT_FLOAT_SUPPORTED
  739|      0|  case JDCT_FLOAT:
  ------------------
  |  Branch (739:3): [True: 0, False: 25.4k]
  ------------------
  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: 25.4k]
  ------------------
  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|  25.4k|  }
  754|       |
  755|       |  /* Allocate workspace memory */
  756|  25.4k|#ifdef DCT_FLOAT_SUPPORTED
  757|  25.4k|  if (cinfo->dct_method == JDCT_FLOAT)
  ------------------
  |  Branch (757:7): [True: 0, False: 25.4k]
  ------------------
  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|  25.4k|  else
  762|  25.4k|#endif
  763|  25.4k|    fdct->workspace = (DCTELEM *)
  764|  25.4k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  25.4k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  765|  25.4k|                                  sizeof(DCTELEM) * DCTSIZE2);
  ------------------
  |  |   67|  25.4k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  766|       |
  767|       |  /* Mark divisor tables unallocated */
  768|   127k|  for (i = 0; i < NUM_QUANT_TBLS; i++) {
  ------------------
  |  |   68|   127k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (768:15): [True: 101k, False: 25.4k]
  ------------------
  769|   101k|    fdct->divisors[i] = NULL;
  770|   101k|#ifdef DCT_FLOAT_SUPPORTED
  771|       |    fdct->float_divisors[i] = NULL;
  772|   101k|#endif
  773|   101k|  }
  774|  25.4k|}
jcdctmgr-8.c:start_pass_fdctmgr:
  235|  25.4k|{
  236|  25.4k|  my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
  237|  25.4k|  int ci, qtblno, i;
  238|  25.4k|  jpeg_component_info *compptr;
  239|  25.4k|  JQUANT_TBL *qtbl;
  240|  25.4k|  DCTELEM *dtbl;
  241|       |
  242|  89.2k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (242:44): [True: 63.7k, False: 25.4k]
  ------------------
  243|  63.7k|       ci++, compptr++) {
  244|  63.7k|    qtblno = compptr->quant_tbl_no;
  245|       |    /* Make sure specified quantization table is present */
  246|  63.7k|    if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
  ------------------
  |  |   68|   127k|#define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  ------------------
  |  Branch (246:9): [True: 0, False: 63.7k]
  |  Branch (246:23): [True: 0, False: 63.7k]
  ------------------
  247|  63.7k|        cinfo->quant_tbl_ptrs[qtblno] == NULL)
  ------------------
  |  Branch (247:9): [True: 0, False: 63.7k]
  ------------------
  248|      0|      ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  249|  63.7k|    qtbl = cinfo->quant_tbl_ptrs[qtblno];
  250|       |    /* Compute divisors for this quant table */
  251|       |    /* We may do this more than once for same table, but it's not a big deal */
  252|  63.7k|    switch (cinfo->dct_method) {
  253|      0|#ifdef DCT_ISLOW_SUPPORTED
  254|  53.4k|    case JDCT_ISLOW:
  ------------------
  |  Branch (254:5): [True: 53.4k, False: 10.2k]
  ------------------
  255|       |      /* For LL&M IDCT method, divisors are equal to raw quantization
  256|       |       * coefficients multiplied by 8 (to counteract scaling).
  257|       |       */
  258|  53.4k|      if (fdct->divisors[qtblno] == NULL) {
  ------------------
  |  Branch (258:11): [True: 32.4k, False: 20.9k]
  ------------------
  259|  32.4k|        fdct->divisors[qtblno] = (DCTELEM *)
  260|  32.4k|          (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  32.4k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  261|  32.4k|                                      (DCTSIZE2 * 4) * sizeof(DCTELEM));
  ------------------
  |  |   67|  32.4k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  262|  32.4k|      }
  263|  53.4k|      dtbl = fdct->divisors[qtblno];
  264|  3.47M|      for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  3.47M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (264:19): [True: 3.42M, False: 53.4k]
  ------------------
  265|  3.42M|#if BITS_IN_JSAMPLE == 8
  266|  3.42M|#ifdef WITH_SIMD
  267|  3.42M|        if (!compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]) &&
  ------------------
  |  Branch (267:13): [True: 0, False: 3.42M]
  ------------------
  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.42M|      }
  277|  53.4k|      break;
  278|      0|#endif
  279|      0|#ifdef DCT_IFAST_SUPPORTED
  280|  10.2k|    case JDCT_IFAST:
  ------------------
  |  Branch (280:5): [True: 10.2k, False: 53.4k]
  ------------------
  281|  10.2k|      {
  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.2k|#define CONST_BITS  14
  289|  10.2k|        static const INT16 aanscales[DCTSIZE2] = {
  290|       |          /* precomputed values scaled up by 14 bits */
  291|  10.2k|          16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
  292|  10.2k|          22725, 31521, 29692, 26722, 22725, 17855, 12299,  6270,
  293|  10.2k|          21407, 29692, 27969, 25172, 21407, 16819, 11585,  5906,
  294|  10.2k|          19266, 26722, 25172, 22654, 19266, 15137, 10426,  5315,
  295|  10.2k|          16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
  296|  10.2k|          12873, 17855, 16819, 15137, 12873, 10114,  6967,  3552,
  297|  10.2k|           8867, 12299, 11585, 10426,  8867,  6967,  4799,  2446,
  298|  10.2k|           4520,  6270,  5906,  5315,  4520,  3552,  2446,  1247
  299|  10.2k|        };
  300|  10.2k|        SHIFT_TEMPS
  301|       |
  302|  10.2k|        if (fdct->divisors[qtblno] == NULL) {
  ------------------
  |  Branch (302:13): [True: 6.85k, False: 3.42k]
  ------------------
  303|  6.85k|          fdct->divisors[qtblno] = (DCTELEM *)
  304|  6.85k|            (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  6.85k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  305|  6.85k|                                        (DCTSIZE2 * 4) * sizeof(DCTELEM));
  ------------------
  |  |   67|  6.85k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  306|  6.85k|        }
  307|  10.2k|        dtbl = fdct->divisors[qtblno];
  308|   667k|        for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|   667k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (308:21): [True: 657k, False: 10.2k]
  ------------------
  309|   657k|#if BITS_IN_JSAMPLE == 8
  310|   657k|#ifdef WITH_SIMD
  311|   657k|          if (!compute_reciprocal(
  ------------------
  |  Branch (311:15): [True: 0, False: 657k]
  ------------------
  312|   657k|                DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
  ------------------
  |  |  216|   657k|#define DESCALE(x, n)  RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
  |  |  ------------------
  |  |  |  |  542|   657k|#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
  |  |  ------------------
  ------------------
  313|   657k|                                      (JLONG)aanscales[i]),
  314|   657k|                        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|   657k|        }
  330|  10.2k|      }
  331|  10.2k|      break;
  332|      0|#endif
  333|      0|#ifdef DCT_FLOAT_SUPPORTED
  334|      0|    case JDCT_FLOAT:
  ------------------
  |  Branch (334:5): [True: 0, False: 63.7k]
  ------------------
  335|      0|      {
  336|       |        /* For float AA&N IDCT method, divisors are equal to quantization
  337|       |         * coefficients scaled by scalefactor[row]*scalefactor[col], where
  338|       |         *   scalefactor[0] = 1
  339|       |         *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
  340|       |         * We apply a further scale factor of 8.
  341|       |         * What's actually stored is 1/divisor so that the inner loop can
  342|       |         * use a multiplication rather than a division.
  343|       |         */
  344|      0|        FAST_FLOAT *fdtbl;
  ------------------
  |  |  386|      0|#define FAST_FLOAT  float
  ------------------
  345|      0|        int row, col;
  346|      0|        static const double aanscalefactor[DCTSIZE] = {
  347|      0|          1.0, 1.387039845, 1.306562965, 1.175875602,
  348|      0|          1.0, 0.785694958, 0.541196100, 0.275899379
  349|      0|        };
  350|       |
  351|      0|        if (fdct->float_divisors[qtblno] == NULL) {
  ------------------
  |  Branch (351:13): [True: 0, False: 0]
  ------------------
  352|      0|          fdct->float_divisors[qtblno] = (FAST_FLOAT *)
  353|      0|            (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|      0|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  354|      0|                                        DCTSIZE2 * sizeof(FAST_FLOAT));
  ------------------
  |  |   67|      0|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  355|      0|        }
  356|      0|        fdtbl = fdct->float_divisors[qtblno];
  357|      0|        i = 0;
  358|      0|        for (row = 0; row < DCTSIZE; row++) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (358:23): [True: 0, False: 0]
  ------------------
  359|      0|          for (col = 0; col < DCTSIZE; col++) {
  ------------------
  |  |   66|      0|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (359:25): [True: 0, False: 0]
  ------------------
  360|      0|            fdtbl[i] = (FAST_FLOAT)
  361|      0|              (1.0 / (((double)qtbl->quantval[i] *
  362|      0|                       aanscalefactor[row] * aanscalefactor[col] * 8.0)));
  363|      0|            i++;
  364|      0|          }
  365|      0|        }
  366|      0|      }
  367|      0|      break;
  368|      0|#endif
  369|      0|    default:
  ------------------
  |  Branch (369:5): [True: 0, False: 63.7k]
  ------------------
  370|      0|      ERREXIT(cinfo, JERR_NOT_COMPILED);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  371|      0|      break;
  372|  63.7k|    }
  373|  63.7k|  }
  374|  25.4k|}
jcdctmgr-8.c:compute_reciprocal:
  166|  4.07M|{
  167|  4.07M|  UDCTELEM2 fq, fr;
  168|  4.07M|  UDCTELEM c;
  169|  4.07M|  int b, r;
  170|       |
  171|  4.07M|  if (divisor <= 1) {
  ------------------
  |  Branch (171:7): [True: 0, False: 4.07M]
  ------------------
  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.07M|  b = flss(divisor) - 1;
  191|  4.07M|  r  = sizeof(DCTELEM) * 8 + b;
  192|       |
  193|  4.07M|  fq = ((UDCTELEM2)1 << r) / divisor;
  194|  4.07M|  fr = ((UDCTELEM2)1 << r) % divisor;
  195|       |
  196|  4.07M|  c = divisor / 2;                      /* for rounding */
  197|       |
  198|  4.07M|  if (fr == 0) {                        /* divisor is power of two */
  ------------------
  |  Branch (198:7): [True: 791k, False: 3.28M]
  ------------------
  199|       |    /* fq will be one bit too large to fit in DCTELEM, so adjust */
  200|   791k|    fq >>= 1;
  201|   791k|    r--;
  202|  3.28M|  } else if (fr <= (divisor / 2U)) {    /* fractional part is < 0.5 */
  ------------------
  |  Branch (202:14): [True: 677k, False: 2.61M]
  ------------------
  203|   677k|    c++;
  204|  2.61M|  } else {                              /* fractional part is > 0.5 */
  205|  2.61M|    fq++;
  206|  2.61M|  }
  207|       |
  208|  4.07M|  dtbl[DCTSIZE2 * 0] = (DCTELEM)fq;     /* reciprocal */
  ------------------
  |  |   67|  4.07M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  209|  4.07M|  dtbl[DCTSIZE2 * 1] = (DCTELEM)c;      /* correction + roundfactor */
  ------------------
  |  |   67|  4.07M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  210|  4.07M|#ifdef WITH_SIMD
  211|  4.07M|  dtbl[DCTSIZE2 * 2] = (DCTELEM)(1 << (sizeof(DCTELEM) * 8 * 2 - r)); /* scale */
  ------------------
  |  |   67|  4.07M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  212|       |#else
  213|       |  dtbl[DCTSIZE2 * 2] = 1;
  214|       |#endif
  215|  4.07M|  dtbl[DCTSIZE2 * 3] = (DCTELEM)r - sizeof(DCTELEM) * 8; /* shift */
  ------------------
  |  |   67|  4.07M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  216|       |
  217|  4.07M|  if (r <= 16) return 0;
  ------------------
  |  Branch (217:7): [True: 0, False: 4.07M]
  ------------------
  218|  4.07M|  else return 1;
  219|  4.07M|}
jcdctmgr-8.c:flss:
   76|  4.07M|{
   77|  4.07M|  int bit;
   78|       |
   79|  4.07M|  bit = 16;
   80|       |
   81|  4.07M|  if (!val)
  ------------------
  |  Branch (81:7): [True: 0, False: 4.07M]
  ------------------
   82|      0|    return 0;
   83|       |
   84|  4.07M|  if (!(val & 0xff00)) {
  ------------------
  |  Branch (84:7): [True: 1.96M, False: 2.11M]
  ------------------
   85|  1.96M|    bit -= 8;
   86|  1.96M|    val <<= 8;
   87|  1.96M|  }
   88|  4.07M|  if (!(val & 0xf000)) {
  ------------------
  |  Branch (88:7): [True: 2.80M, False: 1.27M]
  ------------------
   89|  2.80M|    bit -= 4;
   90|  2.80M|    val <<= 4;
   91|  2.80M|  }
   92|  4.07M|  if (!(val & 0xc000)) {
  ------------------
  |  Branch (92:7): [True: 1.11M, False: 2.96M]
  ------------------
   93|  1.11M|    bit -= 2;
   94|  1.11M|    val <<= 2;
   95|  1.11M|  }
   96|  4.07M|  if (!(val & 0x8000)) {
  ------------------
  |  Branch (96:7): [True: 1.86M, False: 2.21M]
  ------------------
   97|  1.86M|    bit -= 1;
   98|  1.86M|    val <<= 1;
   99|  1.86M|  }
  100|       |
  101|  4.07M|  return bit;
  102|  4.07M|}
jcdctmgr-8.c:forward_DCT:
  503|  14.8M|{
  504|       |  /* This routine is heavily used, so it's worth coding it tightly. */
  505|  14.8M|  my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
  506|  14.8M|  DCTELEM *divisors = fdct->divisors[compptr->quant_tbl_no];
  507|  14.8M|  DCTELEM *workspace;
  508|  14.8M|  JDIMENSION bi;
  509|       |
  510|       |  /* Make sure the compiler doesn't look up these every pass */
  511|  14.8M|  forward_DCT_method_ptr do_dct = fdct->dct;
  512|  14.8M|  convsamp_method_ptr do_convsamp = fdct->convsamp;
  513|  14.8M|  quantize_method_ptr do_quantize = fdct->quantize;
  514|  14.8M|  workspace = fdct->workspace;
  515|       |
  516|  14.8M|  sample_data += start_row;     /* fold in the vertical offset once */
  517|       |
  518|  35.2M|  for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {
  ------------------
  |  |   66|  20.4M|#define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  ------------------
  |  Branch (518:16): [True: 20.4M, False: 14.8M]
  ------------------
  519|       |    /* Load data into workspace, applying unsigned->signed conversion */
  520|       |#ifdef WITH_PROFILE
  521|       |    cinfo->master->start = getTime();
  522|       |#endif
  523|  20.4M|    (*do_convsamp) (sample_data, start_col, workspace);
  524|       |#ifdef WITH_PROFILE
  525|       |    cinfo->master->convsamp_elapsed += getTime() - cinfo->master->start;
  526|       |    cinfo->master->convsamp_msamples += (double)DCTSIZE2 / 1000000.;
  527|       |#endif
  528|       |
  529|       |    /* Perform the DCT */
  530|       |#ifdef WITH_PROFILE
  531|       |    cinfo->master->start = getTime();
  532|       |#endif
  533|  20.4M|    (*do_dct) (workspace);
  534|       |#ifdef WITH_PROFILE
  535|       |    cinfo->master->fdct_elapsed += getTime() - cinfo->master->start;
  536|       |    cinfo->master->fdct_mcoeffs += (double)DCTSIZE2 / 1000000.;
  537|       |#endif
  538|       |
  539|       |    /* Quantize/descale the coefficients, and store into coef_blocks[] */
  540|       |#ifdef WITH_PROFILE
  541|       |    cinfo->master->start = getTime();
  542|       |#endif
  543|  20.4M|    (*do_quantize) (coef_blocks[bi], divisors, workspace);
  544|       |#ifdef WITH_PROFILE
  545|       |    cinfo->master->quantize_elapsed += getTime() - cinfo->master->start;
  546|       |    cinfo->master->quantize_mcoeffs += (double)DCTSIZE2 / 1000000.;
  547|       |#endif
  548|  20.4M|  }
  549|  14.8M|}

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

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

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

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

jinit_marker_writer:
  652|  25.4k|{
  653|  25.4k|  my_marker_ptr marker;
  654|       |
  655|       |  /* Create the subobject */
  656|  25.4k|  marker = (my_marker_ptr)
  657|  25.4k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  25.4k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  658|  25.4k|                                sizeof(my_marker_writer));
  659|  25.4k|  cinfo->marker = (struct jpeg_marker_writer *)marker;
  660|       |  /* Initialize method pointers */
  661|  25.4k|  marker->pub.write_file_header = write_file_header;
  662|  25.4k|  marker->pub.write_frame_header = write_frame_header;
  663|  25.4k|  marker->pub.write_scan_header = write_scan_header;
  664|  25.4k|  marker->pub.write_file_trailer = write_file_trailer;
  665|  25.4k|  marker->pub.write_tables_only = write_tables_only;
  666|  25.4k|  marker->pub.write_marker_header = write_marker_header;
  667|  25.4k|  marker->pub.write_marker_byte = write_marker_byte;
  668|       |  /* Initialize private state */
  669|  25.4k|  marker->last_restart_interval = 0;
  670|  25.4k|}
jcmarker.c:write_file_header:
  476|  25.4k|{
  477|  25.4k|  my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
  478|       |
  479|  25.4k|  emit_marker(cinfo, M_SOI);    /* first the SOI */
  480|       |
  481|       |  /* SOI is defined to reset restart interval to 0 */
  482|  25.4k|  marker->last_restart_interval = 0;
  483|       |
  484|  25.4k|  if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */
  ------------------
  |  Branch (484:7): [True: 18.4k, False: 6.99k]
  ------------------
  485|  18.4k|    emit_jfif_app0(cinfo);
  486|  25.4k|  if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */
  ------------------
  |  Branch (486:7): [True: 6.99k, False: 18.4k]
  ------------------
  487|  6.99k|    emit_adobe_app14(cinfo);
  488|  25.4k|}
jcmarker.c:emit_marker:
  131|   366k|{
  132|   366k|  emit_byte(cinfo, 0xFF);
  133|   366k|  emit_byte(cinfo, (int)mark);
  134|   366k|}
jcmarker.c:emit_byte:
  117|  10.0M|{
  118|  10.0M|  struct jpeg_destination_mgr *dest = cinfo->dest;
  119|       |
  120|  10.0M|  *(dest->next_output_byte)++ = (JOCTET)val;
  121|  10.0M|  if (--dest->free_in_buffer == 0) {
  ------------------
  |  Branch (121:7): [True: 49.0k, False: 9.95M]
  ------------------
  122|  49.0k|    if (!(*dest->empty_output_buffer) (cinfo))
  ------------------
  |  Branch (122:9): [True: 0, False: 49.0k]
  ------------------
  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|  49.0k|  }
  125|  10.0M|}
jcmarker.c:emit_jfif_app0:
  357|  18.4k|{
  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|  18.4k|  emit_marker(cinfo, M_APP0);
  371|       |
  372|  18.4k|  emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */
  373|       |
  374|  18.4k|  emit_byte(cinfo, 0x4A);       /* Identifier: ASCII "JFIF" */
  375|  18.4k|  emit_byte(cinfo, 0x46);
  376|  18.4k|  emit_byte(cinfo, 0x49);
  377|  18.4k|  emit_byte(cinfo, 0x46);
  378|  18.4k|  emit_byte(cinfo, 0);
  379|  18.4k|  emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */
  380|  18.4k|  emit_byte(cinfo, cinfo->JFIF_minor_version);
  381|  18.4k|  emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */
  382|  18.4k|  emit_2bytes(cinfo, (int)cinfo->X_density);
  383|  18.4k|  emit_2bytes(cinfo, (int)cinfo->Y_density);
  384|  18.4k|  emit_byte(cinfo, 0);          /* No thumbnail image */
  385|  18.4k|  emit_byte(cinfo, 0);
  386|  18.4k|}
jcmarker.c:emit_2bytes:
  140|   431k|{
  141|   431k|  emit_byte(cinfo, (value >> 8) & 0xFF);
  142|   431k|  emit_byte(cinfo, value & 0xFF);
  143|   431k|}
jcmarker.c:emit_adobe_app14:
  392|  6.99k|{
  393|       |  /*
  394|       |   * Length of APP14 block      (2 bytes)
  395|       |   * Block ID                   (5 bytes - ASCII "Adobe")
  396|       |   * Version Number             (2 bytes - currently 100)
  397|       |   * Flags0                     (2 bytes - currently 0)
  398|       |   * Flags1                     (2 bytes - currently 0)
  399|       |   * Color transform            (1 byte)
  400|       |   *
  401|       |   * Although Adobe TN 5116 mentions Version = 101, all the Adobe files
  402|       |   * now in circulation seem to use Version = 100, so that's what we write.
  403|       |   *
  404|       |   * We write the color transform byte as 1 if the JPEG color space is
  405|       |   * YCbCr, 2 if it's YCCK, 0 otherwise.  Adobe's definition has to do with
  406|       |   * whether the encoder performed a transformation, which is pretty useless.
  407|       |   */
  408|       |
  409|  6.99k|  emit_marker(cinfo, M_APP14);
  410|       |
  411|  6.99k|  emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */
  412|       |
  413|  6.99k|  emit_byte(cinfo, 0x41);       /* Identifier: ASCII "Adobe" */
  414|  6.99k|  emit_byte(cinfo, 0x64);
  415|  6.99k|  emit_byte(cinfo, 0x6F);
  416|  6.99k|  emit_byte(cinfo, 0x62);
  417|  6.99k|  emit_byte(cinfo, 0x65);
  418|  6.99k|  emit_2bytes(cinfo, 100);      /* Version */
  419|  6.99k|  emit_2bytes(cinfo, 0);        /* Flags0 */
  420|  6.99k|  emit_2bytes(cinfo, 0);        /* Flags1 */
  421|  6.99k|  switch (cinfo->jpeg_color_space) {
  422|      0|  case JCS_YCbCr:
  ------------------
  |  Branch (422:3): [True: 0, False: 6.99k]
  ------------------
  423|      0|    emit_byte(cinfo, 1);        /* Color transform = 1 */
  424|      0|    break;
  425|  3.42k|  case JCS_YCCK:
  ------------------
  |  Branch (425:3): [True: 3.42k, False: 3.57k]
  ------------------
  426|  3.42k|    emit_byte(cinfo, 2);        /* Color transform = 2 */
  427|  3.42k|    break;
  428|  3.57k|  default:
  ------------------
  |  Branch (428:3): [True: 3.57k, False: 3.42k]
  ------------------
  429|  3.57k|    emit_byte(cinfo, 0);        /* Color transform = 0 */
  430|  3.57k|    break;
  431|  6.99k|  }
  432|  6.99k|}
jcmarker.c:write_frame_header:
  501|  25.4k|{
  502|  25.4k|  int ci, prec = 0;
  503|  25.4k|  boolean is_baseline;
  504|  25.4k|  jpeg_component_info *compptr;
  505|       |
  506|  25.4k|  if (!cinfo->master->lossless) {
  ------------------
  |  Branch (506:7): [True: 25.4k, False: 0]
  ------------------
  507|       |    /* Emit DQT for each quantization table.
  508|       |     * Note that emit_dqt() suppresses any duplicate tables.
  509|       |     */
  510|  89.2k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (510:46): [True: 63.7k, False: 25.4k]
  ------------------
  511|  63.7k|         ci++, compptr++) {
  512|  63.7k|      prec += emit_dqt(cinfo, compptr->quant_tbl_no);
  513|  63.7k|    }
  514|       |    /* now prec is nonzero iff there are any 16-bit quant tables. */
  515|  25.4k|  }
  516|       |
  517|       |  /* Check for a non-baseline specification.
  518|       |   * Note we assume that Huffman table numbers won't be changed later.
  519|       |   */
  520|  25.4k|  if (cinfo->arith_code || cinfo->progressive_mode ||
  ------------------
  |  Branch (520:7): [True: 6.85k, False: 18.6k]
  |  Branch (520:28): [True: 3.57k, False: 15.0k]
  ------------------
  521|  15.0k|      cinfo->master->lossless || cinfo->data_precision != 8) {
  ------------------
  |  Branch (521:7): [True: 0, False: 15.0k]
  |  Branch (521:34): [True: 0, False: 15.0k]
  ------------------
  522|  10.4k|    is_baseline = FALSE;
  ------------------
  |  |  207|  10.4k|#define FALSE   0               /* values of boolean */
  ------------------
  523|  15.0k|  } else {
  524|  15.0k|    is_baseline = TRUE;
  ------------------
  |  |  210|  15.0k|#define TRUE    1
  ------------------
  525|  47.5k|    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (525:46): [True: 32.4k, False: 15.0k]
  ------------------
  526|  32.4k|         ci++, compptr++) {
  527|  32.4k|      if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1)
  ------------------
  |  Branch (527:11): [True: 0, False: 32.4k]
  |  Branch (527:37): [True: 0, False: 32.4k]
  ------------------
  528|      0|        is_baseline = FALSE;
  ------------------
  |  |  207|      0|#define FALSE   0               /* values of boolean */
  ------------------
  529|  32.4k|    }
  530|  15.0k|    if (prec && is_baseline) {
  ------------------
  |  Branch (530:9): [True: 0, False: 15.0k]
  |  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.0k|  }
  536|       |
  537|       |  /* Emit the proper SOF marker */
  538|  25.4k|  if (cinfo->arith_code) {
  ------------------
  |  Branch (538:7): [True: 6.85k, False: 18.6k]
  ------------------
  539|  6.85k|    if (cinfo->progressive_mode)
  ------------------
  |  Branch (539:9): [True: 3.42k, False: 3.42k]
  ------------------
  540|  3.42k|      emit_sof(cinfo, M_SOF10); /* SOF code for progressive arithmetic */
  541|  3.42k|    else
  542|  3.42k|      emit_sof(cinfo, M_SOF9);  /* SOF code for sequential arithmetic */
  543|  18.6k|  } else {
  544|  18.6k|    if (cinfo->progressive_mode)
  ------------------
  |  Branch (544:9): [True: 3.57k, False: 15.0k]
  ------------------
  545|  3.57k|      emit_sof(cinfo, M_SOF2);  /* SOF code for progressive Huffman */
  546|  15.0k|    else if (cinfo->master->lossless)
  ------------------
  |  Branch (546:14): [True: 0, False: 15.0k]
  ------------------
  547|      0|      emit_sof(cinfo, M_SOF3);  /* SOF code for lossless Huffman */
  548|  15.0k|    else if (is_baseline)
  ------------------
  |  Branch (548:14): [True: 15.0k, False: 0]
  ------------------
  549|  15.0k|      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|  18.6k|  }
  553|  25.4k|}
jcmarker.c:emit_dqt:
  154|  63.7k|{
  155|  63.7k|  JQUANT_TBL *qtbl = cinfo->quant_tbl_ptrs[index];
  156|  63.7k|  int prec;
  157|  63.7k|  int i;
  158|       |
  159|  63.7k|  if (qtbl == NULL)
  ------------------
  |  Branch (159:7): [True: 0, False: 63.7k]
  ------------------
  160|      0|    ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  161|       |
  162|  63.7k|  prec = 0;
  163|  4.14M|  for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  4.14M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (163:15): [True: 4.07M, False: 63.7k]
  ------------------
  164|  4.07M|    if (qtbl->quantval[i] > 255)
  ------------------
  |  Branch (164:9): [True: 0, False: 4.07M]
  ------------------
  165|      0|      prec = 1;
  166|  4.07M|  }
  167|       |
  168|  63.7k|  if (!qtbl->sent_table) {
  ------------------
  |  Branch (168:7): [True: 39.3k, False: 24.4k]
  ------------------
  169|  39.3k|    emit_marker(cinfo, M_DQT);
  170|       |
  171|  39.3k|    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|  39.3k|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (171:24): [True: 0, False: 39.3k]
  ------------------
  172|       |
  173|  39.3k|    emit_byte(cinfo, index + (prec << 4));
  174|       |
  175|  2.55M|    for (i = 0; i < DCTSIZE2; i++) {
  ------------------
  |  |   67|  2.55M|#define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  ------------------
  |  Branch (175:17): [True: 2.51M, False: 39.3k]
  ------------------
  176|       |      /* The table entries must be emitted in zigzag order. */
  177|  2.51M|      unsigned int qval = qtbl->quantval[jpeg_natural_order[i]];
  178|  2.51M|      if (prec)
  ------------------
  |  Branch (178:11): [True: 0, False: 2.51M]
  ------------------
  179|      0|        emit_byte(cinfo, (int)(qval >> 8));
  180|  2.51M|      emit_byte(cinfo, (int)(qval & 0xFF));
  181|  2.51M|    }
  182|       |
  183|  39.3k|    qtbl->sent_table = TRUE;
  ------------------
  |  |  210|  39.3k|#define TRUE    1
  ------------------
  184|  39.3k|  }
  185|       |
  186|  63.7k|  return prec;
  187|  63.7k|}
jcmarker.c:emit_sof:
  292|  25.4k|{
  293|  25.4k|  int ci;
  294|  25.4k|  jpeg_component_info *compptr;
  295|       |
  296|  25.4k|  emit_marker(cinfo, code);
  297|       |
  298|  25.4k|  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|  25.4k|  if ((long)cinfo->_jpeg_height > 65535L || (long)cinfo->_jpeg_width > 65535L)
  ------------------
  |  |   31|  25.4k|#define _jpeg_height  image_height
  ------------------
                if ((long)cinfo->_jpeg_height > 65535L || (long)cinfo->_jpeg_width > 65535L)
  ------------------
  |  |   30|  25.4k|#define _jpeg_width  image_width
  ------------------
  |  Branch (301:7): [True: 0, False: 25.4k]
  |  Branch (301:45): [True: 0, False: 25.4k]
  ------------------
  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|  25.4k|  emit_byte(cinfo, cinfo->data_precision);
  305|  25.4k|  emit_2bytes(cinfo, (int)cinfo->_jpeg_height);
  ------------------
  |  |   31|  25.4k|#define _jpeg_height  image_height
  ------------------
  306|  25.4k|  emit_2bytes(cinfo, (int)cinfo->_jpeg_width);
  ------------------
  |  |   30|  25.4k|#define _jpeg_width  image_width
  ------------------
  307|       |
  308|  25.4k|  emit_byte(cinfo, cinfo->num_components);
  309|       |
  310|  89.2k|  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  ------------------
  |  Branch (310:44): [True: 63.7k, False: 25.4k]
  ------------------
  311|  63.7k|       ci++, compptr++) {
  312|  63.7k|    emit_byte(cinfo, compptr->component_id);
  313|  63.7k|    emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor);
  314|  63.7k|    emit_byte(cinfo, compptr->quant_tbl_no);
  315|  63.7k|  }
  316|  25.4k|}
jcmarker.c:write_scan_header:
  564|  88.4k|{
  565|  88.4k|  my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
  566|  88.4k|  int i;
  567|  88.4k|  jpeg_component_info *compptr;
  568|       |
  569|  88.4k|  if (cinfo->arith_code) {
  ------------------
  |  Branch (569:7): [True: 37.6k, False: 50.7k]
  ------------------
  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|  37.6k|    emit_dac(cinfo);
  575|  50.7k|  } else {
  576|       |    /* Emit Huffman tables.
  577|       |     * Note that emit_dht() suppresses any duplicate tables.
  578|       |     */
  579|   133k|    for (i = 0; i < cinfo->comps_in_scan; i++) {
  ------------------
  |  Branch (579:17): [True: 82.4k, False: 50.7k]
  ------------------
  580|  82.4k|      compptr = cinfo->cur_comp_info[i];
  581|       |      /* DC needs no table for refinement scan */
  582|  82.4k|      if ((cinfo->Ss == 0 && cinfo->Ah == 0) || cinfo->master->lossless)
  ------------------
  |  Branch (582:12): [True: 53.9k, False: 28.5k]
  |  Branch (582:30): [True: 43.1k, False: 10.7k]
  |  Branch (582:49): [True: 0, False: 39.2k]
  ------------------
  583|  43.1k|        emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
  ------------------
  |  |  207|  43.1k|#define FALSE   0               /* values of boolean */
  ------------------
  584|       |      /* AC needs no table when not present, and lossless mode uses only DC
  585|       |         tables. */
  586|  82.4k|      if (cinfo->Se && !cinfo->master->lossless)
  ------------------
  |  Branch (586:11): [True: 61.0k, False: 21.4k]
  |  Branch (586:24): [True: 61.0k, False: 0]
  ------------------
  587|  61.0k|        emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
  ------------------
  |  |  210|  61.0k|#define TRUE    1
  ------------------
  588|  82.4k|    }
  589|  50.7k|  }
  590|       |
  591|       |  /* Emit DRI if required --- note that DRI value could change for each scan.
  592|       |   * We avoid wasting space with unnecessary DRIs, however.
  593|       |   */
  594|  88.4k|  if (cinfo->restart_interval != marker->last_restart_interval) {
  ------------------
  |  Branch (594:7): [True: 6.99k, False: 81.4k]
  ------------------
  595|  6.99k|    emit_dri(cinfo);
  596|  6.99k|    marker->last_restart_interval = cinfo->restart_interval;
  597|  6.99k|  }
  598|       |
  599|  88.4k|  emit_sos(cinfo);
  600|  88.4k|}
jcmarker.c:emit_dac:
  233|  37.6k|{
  234|  37.6k|#ifdef C_ARITH_CODING_SUPPORTED
  235|  37.6k|  char dc_in_use[NUM_ARITH_TBLS];
  236|  37.6k|  char ac_in_use[NUM_ARITH_TBLS];
  237|  37.6k|  int length, i;
  238|  37.6k|  jpeg_component_info *compptr;
  239|       |
  240|   640k|  for (i = 0; i < NUM_ARITH_TBLS; i++)
  ------------------
  |  |   70|   640k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (240:15): [True: 602k, False: 37.6k]
  ------------------
  241|   602k|    dc_in_use[i] = ac_in_use[i] = 0;
  242|       |
  243|  95.9k|  for (i = 0; i < cinfo->comps_in_scan; i++) {
  ------------------
  |  Branch (243:15): [True: 58.2k, False: 37.6k]
  ------------------
  244|  58.2k|    compptr = cinfo->cur_comp_info[i];
  245|       |    /* DC needs no table for refinement scan */
  246|  58.2k|    if (cinfo->Ss == 0 && cinfo->Ah == 0)
  ------------------
  |  Branch (246:9): [True: 30.8k, False: 27.4k]
  |  Branch (246:27): [True: 20.5k, False: 10.2k]
  ------------------
  247|  20.5k|      dc_in_use[compptr->dc_tbl_no] = 1;
  248|       |    /* AC needs no table when not present */
  249|  58.2k|    if (cinfo->Se)
  ------------------
  |  Branch (249:9): [True: 37.6k, False: 20.5k]
  ------------------
  250|  37.6k|      ac_in_use[compptr->ac_tbl_no] = 1;
  251|  58.2k|  }
  252|       |
  253|  37.6k|  length = 0;
  254|   640k|  for (i = 0; i < NUM_ARITH_TBLS; i++)
  ------------------
  |  |   70|   640k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (254:15): [True: 602k, False: 37.6k]
  ------------------
  255|   602k|    length += dc_in_use[i] + ac_in_use[i];
  256|       |
  257|  37.6k|  if (length) {
  ------------------
  |  Branch (257:7): [True: 34.2k, False: 3.42k]
  ------------------
  258|  34.2k|    emit_marker(cinfo, M_DAC);
  259|       |
  260|  34.2k|    emit_2bytes(cinfo, length * 2 + 2);
  261|       |
  262|   582k|    for (i = 0; i < NUM_ARITH_TBLS; i++) {
  ------------------
  |  |   70|   582k|#define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  ------------------
  |  Branch (262:17): [True: 548k, False: 34.2k]
  ------------------
  263|   548k|      if (dc_in_use[i]) {
  ------------------
  |  Branch (263:11): [True: 13.7k, False: 534k]
  ------------------
  264|  13.7k|        emit_byte(cinfo, i);
  265|  13.7k|        emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i] << 4));
  266|  13.7k|      }
  267|   548k|      if (ac_in_use[i]) {
  ------------------
  |  Branch (267:11): [True: 34.2k, False: 513k]
  ------------------
  268|  34.2k|        emit_byte(cinfo, i + 0x10);
  269|  34.2k|        emit_byte(cinfo, cinfo->arith_ac_K[i]);
  270|  34.2k|      }
  271|   548k|    }
  272|  34.2k|  }
  273|  37.6k|#endif /* C_ARITH_CODING_SUPPORTED */
  274|  37.6k|}
jcmarker.c:emit_dht:
  193|   104k|{
  194|   104k|  JHUFF_TBL *htbl;
  195|   104k|  int length, i;
  196|       |
  197|   104k|  if (is_ac) {
  ------------------
  |  Branch (197:7): [True: 61.0k, False: 43.1k]
  ------------------
  198|  61.0k|    htbl = cinfo->ac_huff_tbl_ptrs[index];
  199|  61.0k|    index += 0x10;              /* output index has AC bit set */
  200|  61.0k|  } else {
  201|  43.1k|    htbl = cinfo->dc_huff_tbl_ptrs[index];
  202|  43.1k|  }
  203|       |
  204|   104k|  if (htbl == NULL)
  ------------------
  |  Branch (204:7): [True: 0, False: 104k]
  ------------------
  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|   104k|  if (!htbl->sent_table) {
  ------------------
  |  Branch (207:7): [True: 72.6k, False: 31.5k]
  ------------------
  208|  72.6k|    emit_marker(cinfo, M_DHT);
  209|       |
  210|  72.6k|    length = 0;
  211|  1.23M|    for (i = 1; i <= 16; i++)
  ------------------
  |  Branch (211:17): [True: 1.16M, False: 72.6k]
  ------------------
  212|  1.16M|      length += htbl->bits[i];
  213|       |
  214|  72.6k|    emit_2bytes(cinfo, length + 2 + 1 + 16);
  215|  72.6k|    emit_byte(cinfo, index);
  216|       |
  217|  1.23M|    for (i = 1; i <= 16; i++)
  ------------------
  |  Branch (217:17): [True: 1.16M, False: 72.6k]
  ------------------
  218|  1.16M|      emit_byte(cinfo, htbl->bits[i]);
  219|       |
  220|  2.44M|    for (i = 0; i < length; i++)
  ------------------
  |  Branch (220:17): [True: 2.37M, False: 72.6k]
  ------------------
  221|  2.37M|      emit_byte(cinfo, htbl->huffval[i]);
  222|       |
  223|  72.6k|    htbl->sent_table = TRUE;
  ------------------
  |  |  210|  72.6k|#define TRUE    1
  ------------------
  224|  72.6k|  }
  225|   104k|}
jcmarker.c:emit_dri:
  280|  6.99k|{
  281|  6.99k|  emit_marker(cinfo, M_DRI);
  282|       |
  283|  6.99k|  emit_2bytes(cinfo, 4);        /* fixed length */
  284|       |
  285|  6.99k|  emit_2bytes(cinfo, (int)cinfo->restart_interval);
  286|  6.99k|}
jcmarker.c:emit_sos:
  322|  88.4k|{
  323|  88.4k|  int i, td, ta;
  324|  88.4k|  jpeg_component_info *compptr;
  325|       |
  326|  88.4k|  emit_marker(cinfo, M_SOS);
  327|       |
  328|  88.4k|  emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */
  329|       |
  330|  88.4k|  emit_byte(cinfo, cinfo->comps_in_scan);
  331|       |
  332|   229k|  for (i = 0; i < cinfo->comps_in_scan; i++) {
  ------------------
  |  Branch (332:15): [True: 140k, False: 88.4k]
  ------------------
  333|   140k|    compptr = cinfo->cur_comp_info[i];
  334|   140k|    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|   140k|    td = cinfo->Ss == 0 && cinfo->Ah == 0 ? compptr->dc_tbl_no : 0;
  ------------------
  |  Branch (341:10): [True: 84.7k, False: 55.9k]
  |  Branch (341:28): [True: 63.7k, False: 20.9k]
  ------------------
  342|       |    /* AC needs no table when not present */
  343|   140k|    ta = cinfo->Se ? compptr->ac_tbl_no : 0;
  ------------------
  |  Branch (343:10): [True: 98.7k, False: 41.9k]
  ------------------
  344|       |
  345|   140k|    emit_byte(cinfo, (td << 4) + ta);
  346|   140k|  }
  347|       |
  348|  88.4k|  emit_byte(cinfo, cinfo->Ss);
  349|  88.4k|  emit_byte(cinfo, cinfo->Se);
  350|  88.4k|  emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al);
  351|  88.4k|}
jcmarker.c:write_file_trailer:
  609|  25.4k|{
  610|  25.4k|  emit_marker(cinfo, M_EOI);
  611|  25.4k|}
jcmarker.c:write_marker_header:
  446|  22.5k|{
  447|  22.5k|  if (datalen > (unsigned int)65533)            /* safety check */
  ------------------
  |  Branch (447:7): [True: 0, False: 22.5k]
  ------------------
  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|  22.5k|  emit_marker(cinfo, (JPEG_MARKER)marker);
  451|       |
  452|  22.5k|  emit_2bytes(cinfo, (int)(datalen + 2));       /* total length */
  453|  22.5k|}
jcmarker.c:write_marker_byte:
  458|  1.03M|{
  459|  1.03M|  emit_byte(cinfo, val);
  460|  1.03M|}

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

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

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

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

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

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

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

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

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

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

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

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

jinit_read_bmp:
  662|  6.62k|{
  663|  6.62k|  bmp_source_ptr source;
  664|       |
  665|  6.62k|  if (cinfo->data_precision != 8)
  ------------------
  |  Branch (665:7): [True: 0, False: 6.62k]
  ------------------
  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.62k|  source = (bmp_source_ptr)
  670|  6.62k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  6.62k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  671|  6.62k|                                sizeof(bmp_source_struct));
  672|  6.62k|  source->cinfo = cinfo;        /* make back link for subroutines */
  673|       |  /* Fill in method ptrs, except get_pixel_rows which start_input sets */
  674|  6.62k|  source->pub.start_input = start_input_bmp;
  675|  6.62k|  source->pub.read_icc_profile = read_icc_profile_bmp;
  676|  6.62k|  source->pub.finish_input = finish_input_bmp;
  677|  6.62k|  source->pub.max_pixels = 0;
  678|       |
  679|  6.62k|  source->use_inversion_array = use_inversion_array;
  680|       |
  681|  6.62k|  return (cjpeg_source_ptr)source;
  682|  6.62k|}
rdbmp.c:start_input_bmp:
  408|  6.62k|{
  409|  6.62k|  bmp_source_ptr source = (bmp_source_ptr)sinfo;
  410|  6.62k|  unsigned char bmpfileheader[14];
  411|  6.62k|  unsigned char bmpinfoheader[64];
  412|       |
  413|  6.62k|#define GET_2B(array, offset) \
  414|  6.62k|  ((unsigned short)array[offset] + \
  415|  6.62k|   (((unsigned short)array[offset + 1]) << 8))
  416|  6.62k|#define GET_4B(array, offset) \
  417|  6.62k|  ((unsigned int)array[offset] + \
  418|  6.62k|   (((unsigned int)array[offset + 1]) << 8) + \
  419|  6.62k|   (((unsigned int)array[offset + 2]) << 16) + \
  420|  6.62k|   (((unsigned int)array[offset + 3]) << 24))
  421|       |
  422|  6.62k|  int bfOffBits;
  423|  6.62k|  int headerSize;
  424|  6.62k|  int biWidth;
  425|  6.62k|  int biHeight;
  426|  6.62k|  unsigned short biPlanes;
  427|  6.62k|  unsigned int biCompression;
  428|  6.62k|  int biXPelsPerMeter, biYPelsPerMeter;
  429|  6.62k|  int biClrUsed = 0;
  430|  6.62k|  int mapentrysize = 0;         /* 0 indicates no colormap */
  431|  6.62k|  int bPad;
  432|  6.62k|  JDIMENSION row_width = 0;
  433|       |
  434|       |  /* Read and verify the bitmap file header */
  435|  6.62k|  if (!ReadOK(source->pub.input_file, bmpfileheader, 14))
  ------------------
  |  |   36|  6.62k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (435:7): [True: 49, False: 6.57k]
  ------------------
  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.62k|  if (GET_2B(bmpfileheader, 0) != 0x4D42) /* 'BM' */
  ------------------
  |  |  414|  6.62k|  ((unsigned short)array[offset] + \
  |  |  415|  6.62k|   (((unsigned short)array[offset + 1]) << 8))
  ------------------
  |  Branch (437:7): [True: 77, False: 6.54k]
  ------------------
  438|     77|    ERREXIT(cinfo, JERR_BMP_NOT);
  ------------------
  |  |  240|     77|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     77|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  439|  6.62k|  bfOffBits = GET_4B(bmpfileheader, 10);
  ------------------
  |  |  417|  6.62k|  ((unsigned int)array[offset] + \
  |  |  418|  6.62k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  6.62k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  6.62k|   (((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.62k|  if (!ReadOK(source->pub.input_file, bmpinfoheader, 4))
  ------------------
  |  |   36|  6.62k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (445:7): [True: 21, False: 6.60k]
  ------------------
  446|     21|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     21|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     21|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  447|  6.62k|  headerSize = GET_4B(bmpinfoheader, 0);
  ------------------
  |  |  417|  6.62k|  ((unsigned int)array[offset] + \
  |  |  418|  6.62k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  6.62k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  6.62k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  448|  6.62k|  if (headerSize < 12 || headerSize > 64 || (headerSize + 14) > bfOffBits)
  ------------------
  |  Branch (448:7): [True: 364, False: 6.25k]
  |  Branch (448:26): [True: 182, False: 6.07k]
  |  Branch (448:45): [True: 210, False: 5.86k]
  ------------------
  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.62k|  if (!ReadOK(source->pub.input_file, bmpinfoheader + 4, headerSize - 4))
  ------------------
  |  |   36|  6.62k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (450:7): [True: 42, False: 6.58k]
  ------------------
  451|     42|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     42|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     42|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  452|       |
  453|  6.62k|  switch (headerSize) {
  454|  3.18k|  case 12:
  ------------------
  |  Branch (454:3): [True: 3.18k, False: 3.43k]
  ------------------
  455|       |    /* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */
  456|  3.18k|    biWidth = (int)GET_2B(bmpinfoheader, 4);
  ------------------
  |  |  414|  3.18k|  ((unsigned short)array[offset] + \
  |  |  415|  3.18k|   (((unsigned short)array[offset + 1]) << 8))
  ------------------
  457|  3.18k|    biHeight = (int)GET_2B(bmpinfoheader, 6);
  ------------------
  |  |  414|  3.18k|  ((unsigned short)array[offset] + \
  |  |  415|  3.18k|   (((unsigned short)array[offset + 1]) << 8))
  ------------------
  458|  3.18k|    biPlanes = GET_2B(bmpinfoheader, 8);
  ------------------
  |  |  414|  3.18k|  ((unsigned short)array[offset] + \
  |  |  415|  3.18k|   (((unsigned short)array[offset + 1]) << 8))
  ------------------
  459|  3.18k|    source->bits_per_pixel = (int)GET_2B(bmpinfoheader, 10);
  ------------------
  |  |  414|  3.18k|  ((unsigned short)array[offset] + \
  |  |  415|  3.18k|   (((unsigned short)array[offset + 1]) << 8))
  ------------------
  460|       |
  461|  3.18k|    switch (source->bits_per_pixel) {
  462|  1.62k|    case 8:                     /* colormapped image */
  ------------------
  |  Branch (462:5): [True: 1.62k, False: 1.56k]
  ------------------
  463|  1.62k|      mapentrysize = 3;         /* OS/2 uses RGBTRIPLE colormap */
  464|  1.62k|      TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, biWidth, biHeight);
  ------------------
  |  |  304|  1.62k|  ((cinfo)->err->msg_code = (code), \
  |  |  305|  1.62k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  306|  1.62k|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  307|  1.62k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  465|  1.62k|      break;
  466|    966|    case 24:                    /* RGB image */
  ------------------
  |  Branch (466:5): [True: 966, False: 2.21k]
  ------------------
  467|  1.55k|    case 32:                    /* RGB image + Alpha channel */
  ------------------
  |  Branch (467:5): [True: 588, False: 2.59k]
  ------------------
  468|  1.55k|      TRACEMS3(cinfo, 1, JTRC_BMP_OS2, biWidth, biHeight,
  ------------------
  |  |  309|  1.55k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.55k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.55k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  1.55k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  1.55k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  1.55k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  469|  1.55k|               source->bits_per_pixel);
  470|  1.55k|      break;
  471|      7|    default:
  ------------------
  |  Branch (471:5): [True: 7, False: 3.17k]
  ------------------
  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.18k|    }
  475|  3.17k|    break;
  476|  3.17k|  case 40:
  ------------------
  |  Branch (476:3): [True: 2.60k, False: 4.01k]
  ------------------
  477|  2.63k|  case 64:
  ------------------
  |  Branch (477:3): [True: 28, False: 6.59k]
  ------------------
  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.63k|    biWidth = (int)GET_4B(bmpinfoheader, 4);
  ------------------
  |  |  417|  2.63k|  ((unsigned int)array[offset] + \
  |  |  418|  2.63k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  2.63k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  2.63k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  481|  2.63k|    biHeight = (int)GET_4B(bmpinfoheader, 8);
  ------------------
  |  |  417|  2.63k|  ((unsigned int)array[offset] + \
  |  |  418|  2.63k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  2.63k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  2.63k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  482|  2.63k|    biPlanes = GET_2B(bmpinfoheader, 12);
  ------------------
  |  |  414|  2.63k|  ((unsigned short)array[offset] + \
  |  |  415|  2.63k|   (((unsigned short)array[offset + 1]) << 8))
  ------------------
  483|  2.63k|    source->bits_per_pixel = (int)GET_2B(bmpinfoheader, 14);
  ------------------
  |  |  414|  2.63k|  ((unsigned short)array[offset] + \
  |  |  415|  2.63k|   (((unsigned short)array[offset + 1]) << 8))
  ------------------
  484|  2.63k|    biCompression = GET_4B(bmpinfoheader, 16);
  ------------------
  |  |  417|  2.63k|  ((unsigned int)array[offset] + \
  |  |  418|  2.63k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  2.63k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  2.63k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  485|  2.63k|    biXPelsPerMeter = (int)GET_4B(bmpinfoheader, 24);
  ------------------
  |  |  417|  2.63k|  ((unsigned int)array[offset] + \
  |  |  418|  2.63k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  2.63k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  2.63k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  486|  2.63k|    biYPelsPerMeter = (int)GET_4B(bmpinfoheader, 28);
  ------------------
  |  |  417|  2.63k|  ((unsigned int)array[offset] + \
  |  |  418|  2.63k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  2.63k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  2.63k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  487|  2.63k|    biClrUsed = GET_4B(bmpinfoheader, 32);
  ------------------
  |  |  417|  2.63k|  ((unsigned int)array[offset] + \
  |  |  418|  2.63k|   (((unsigned int)array[offset + 1]) << 8) + \
  |  |  419|  2.63k|   (((unsigned int)array[offset + 2]) << 16) + \
  |  |  420|  2.63k|   (((unsigned int)array[offset + 3]) << 24))
  ------------------
  488|       |    /* biSizeImage, biClrImportant fields are ignored */
  489|       |
  490|  2.63k|    switch (source->bits_per_pixel) {
  491|  2.38k|    case 8:                     /* colormapped image */
  ------------------
  |  Branch (491:5): [True: 2.38k, False: 252]
  ------------------
  492|  2.38k|      mapentrysize = 4;         /* Windows uses RGBQUAD colormap */
  493|  2.38k|      TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, biWidth, biHeight);
  ------------------
  |  |  304|  2.38k|  ((cinfo)->err->msg_code = (code), \
  |  |  305|  2.38k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  306|  2.38k|   (cinfo)->err->msg_parm.i[1] = (p2), \
  |  |  307|  2.38k|   (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
  ------------------
  494|  2.38k|      break;
  495|     35|    case 24:                    /* RGB image */
  ------------------
  |  Branch (495:5): [True: 35, False: 2.59k]
  ------------------
  496|    231|    case 32:                    /* RGB image + Alpha channel */
  ------------------
  |  Branch (496:5): [True: 196, False: 2.43k]
  ------------------
  497|    231|      TRACEMS3(cinfo, 1, JTRC_BMP, biWidth, biHeight, source->bits_per_pixel);
  ------------------
  |  |  309|    231|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|    231|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 231]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|    231|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|    231|           (cinfo)->err->msg_code = (code); \
  |  |  312|    231|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  498|    231|      break;
  499|     21|    default:
  ------------------
  |  Branch (499:5): [True: 21, False: 2.61k]
  ------------------
  500|     21|      ERREXIT(cinfo, JERR_BMP_BADDEPTH);
  ------------------
  |  |  240|     21|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     21|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  501|     21|      break;
  502|  2.63k|    }
  503|  2.61k|    if (biCompression != 0)
  ------------------
  |  Branch (503:9): [True: 217, False: 2.39k]
  ------------------
  504|    217|      ERREXIT(cinfo, JERR_BMP_COMPRESSED);
  ------------------
  |  |  240|    217|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    217|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  505|       |
  506|  2.61k|    if (biXPelsPerMeter > 0 && biYPelsPerMeter > 0) {
  ------------------
  |  Branch (506:9): [True: 1.42k, False: 1.19k]
  |  Branch (506:32): [True: 728, False: 693]
  ------------------
  507|       |      /* Set JFIF density parameters from the BMP data */
  508|    728|      cinfo->X_density = (UINT16)(biXPelsPerMeter / 100); /* 100 cm per meter */
  509|    728|      cinfo->Y_density = (UINT16)(biYPelsPerMeter / 100);
  510|    728|      cinfo->density_unit = 2;  /* dots/cm */
  511|    728|    }
  512|  2.61k|    break;
  513|      7|  default:
  ------------------
  |  Branch (513:3): [True: 7, False: 6.61k]
  ------------------
  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.62k|  }
  517|       |
  518|  5.57k|  if (biWidth <= 0 || biHeight <= 0)
  ------------------
  |  Branch (518:7): [True: 224, False: 5.34k]
  |  Branch (518:23): [True: 224, False: 5.12k]
  ------------------
  519|    448|    ERREXIT(cinfo, JERR_BMP_EMPTY);
  ------------------
  |  |  240|    448|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    448|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  520|  5.57k|  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.08k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (520:7): [True: 490, False: 5.08k]
  |  Branch (520:39): [True: 112, False: 4.97k]
  ------------------
  521|    154|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, JPEG_MAX_DIMENSION);
  ------------------
  |  |  243|    154|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    154|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    154|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  522|  5.57k|  if (sinfo->max_pixels &&
  ------------------
  |  Branch (522:7): [True: 4.97k, False: 602]
  ------------------
  523|  4.97k|      (unsigned long long)biWidth * biHeight > sinfo->max_pixels)
  ------------------
  |  Branch (523:7): [True: 280, False: 4.69k]
  ------------------
  524|    280|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
  ------------------
  |  |  243|    280|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    280|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    280|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  525|  5.57k|  if (biPlanes != 1)
  ------------------
  |  Branch (525:7): [True: 112, False: 5.46k]
  ------------------
  526|    112|    ERREXIT(cinfo, JERR_BMP_BADPLANES);
  ------------------
  |  |  240|    112|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    112|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  527|       |
  528|       |  /* Compute distance to bitmap data --- will adjust for colormap below */
  529|  5.57k|  bPad = bfOffBits - (headerSize + 14);
  530|       |
  531|       |  /* Read the colormap, if any */
  532|  5.57k|  if (mapentrysize > 0) {
  ------------------
  |  Branch (532:7): [True: 3.24k, False: 2.33k]
  ------------------
  533|  3.24k|    if (biClrUsed <= 0)
  ------------------
  |  Branch (533:9): [True: 2.37k, False: 868]
  ------------------
  534|  2.37k|      biClrUsed = 256;          /* assume it's 256 */
  535|    868|    else if (biClrUsed > 256)
  ------------------
  |  Branch (535:14): [True: 161, False: 707]
  ------------------
  536|    161|      ERREXIT(cinfo, JERR_BMP_BADCMAP);
  ------------------
  |  |  240|    161|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    161|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  537|       |    /* Allocate space to store the colormap */
  538|  3.24k|    source->colormap = (*cinfo->mem->alloc_sarray)
  539|  3.24k|      ((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)biClrUsed, (JDIMENSION)3);
  ------------------
  |  |  889|  3.24k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  540|  3.24k|    source->cmap_length = (int)biClrUsed;
  541|       |    /* and read it from the file */
  542|  3.24k|    read_colormap(source, (int)biClrUsed, mapentrysize);
  543|       |    /* account for size of colormap */
  544|  3.24k|    bPad -= biClrUsed * mapentrysize;
  545|  3.24k|  }
  546|       |
  547|       |  /* Skip any remaining pad bytes */
  548|  5.57k|  if (bPad < 0)                 /* incorrect bfOffBits value? */
  ------------------
  |  Branch (548:7): [True: 26, False: 5.54k]
  ------------------
  549|     26|    ERREXIT(cinfo, JERR_BMP_BADHEADER);
  ------------------
  |  |  240|     26|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     26|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  550|  1.57M|  while (--bPad >= 0) {
  ------------------
  |  Branch (550:10): [True: 1.56M, False: 5.57k]
  ------------------
  551|  1.56M|    (void)read_byte(source);
  552|  1.56M|  }
  553|       |
  554|       |  /* Compute row width in file, including padding to 4-byte boundary */
  555|  5.57k|  switch (source->bits_per_pixel) {
  556|  1.66k|  case 8:
  ------------------
  |  Branch (556:3): [True: 1.66k, False: 3.90k]
  ------------------
  557|  1.66k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (557:9): [True: 0, False: 1.66k]
  ------------------
  558|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  559|  1.66k|    if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  1.66k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 1.66k]
  |  |  |  Branch (78:22): [True: 1.35k, False: 310]
  |  |  |  Branch (78:43): [True: 1.35k, False: 0]
  |  |  ------------------
  ------------------
  560|  1.35k|      cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
  561|    310|    else if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (561:14): [True: 39, False: 271]
  ------------------
  562|     39|      cinfo->input_components = 1;
  563|    271|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (563:14): [True: 271, False: 0]
  ------------------
  564|    271|      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.66k|    row_width = (JDIMENSION)biWidth;
  568|  1.66k|    break;
  569|    532|  case 24:
  ------------------
  |  Branch (569:3): [True: 532, False: 5.04k]
  ------------------
  570|    532|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (570:9): [True: 0, False: 532]
  ------------------
  571|      0|      cinfo->in_color_space = JCS_EXT_BGR;
  572|    532|    if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|    532|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 532]
  |  |  |  Branch (78:22): [True: 380, False: 152]
  |  |  |  Branch (78:43): [True: 380, False: 0]
  |  |  ------------------
  ------------------
  573|    380|      cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
  574|    152|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (574:14): [True: 76, False: 76]
  ------------------
  575|     76|      cinfo->input_components = 4;
  576|     76|    else
  577|     76|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|     76|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     76|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  578|    532|    row_width = (JDIMENSION)biWidth * 3;
  579|    532|    break;
  580|    532|  case 32:
  ------------------
  |  Branch (580:3): [True: 532, False: 5.04k]
  ------------------
  581|    532|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (581:9): [True: 0, False: 532]
  ------------------
  582|      0|      cinfo->in_color_space = JCS_EXT_BGRA;
  583|    532|    if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|    532|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 532]
  |  |  |  Branch (78:22): [True: 380, False: 152]
  |  |  |  Branch (78:43): [True: 380, False: 0]
  |  |  ------------------
  ------------------
  584|    380|      cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
  585|    152|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (585:14): [True: 76, False: 76]
  ------------------
  586|     76|      cinfo->input_components = 4;
  587|     76|    else
  588|     76|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|     76|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     76|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  589|    532|    row_width = (JDIMENSION)biWidth * 4;
  590|    532|    break;
  591|      0|  default:
  ------------------
  |  Branch (591:3): [True: 0, False: 5.57k]
  ------------------
  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.57k|  }
  594|  4.17k|  while ((row_width & 3) != 0) row_width++;
  ------------------
  |  Branch (594:10): [True: 1.59k, False: 2.57k]
  ------------------
  595|  2.57k|  source->row_width = row_width;
  596|       |
  597|  2.57k|  if (source->use_inversion_array) {
  ------------------
  |  Branch (597:7): [True: 0, False: 2.57k]
  ------------------
  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.57k|  } else {
  608|  2.57k|    source->iobuffer = (unsigned char *)
  609|  2.57k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, row_width);
  ------------------
  |  |  889|  2.57k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  610|  2.57k|    switch (source->bits_per_pixel) {
  611|  1.66k|    case 8:
  ------------------
  |  Branch (611:5): [True: 1.66k, False: 912]
  ------------------
  612|  1.66k|      source->pub.get_pixel_rows = get_8bit_row;
  613|  1.66k|      break;
  614|    456|    case 24:
  ------------------
  |  Branch (614:5): [True: 456, False: 2.12k]
  ------------------
  615|    456|      source->pub.get_pixel_rows = get_24bit_row;
  616|    456|      break;
  617|    456|    case 32:
  ------------------
  |  Branch (617:5): [True: 456, False: 2.12k]
  ------------------
  618|    456|      source->pub.get_pixel_rows = get_32bit_row;
  619|    456|      break;
  620|      0|    default:
  ------------------
  |  Branch (620:5): [True: 0, False: 2.57k]
  ------------------
  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.57k|    }
  623|  2.57k|  }
  624|       |
  625|       |  /* Allocate one-row buffer for returned data */
  626|  2.57k|  source->pub.buffer = (*cinfo->mem->alloc_sarray)
  627|  2.57k|    ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  2.57k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  628|  2.57k|     (JDIMENSION)biWidth * (JDIMENSION)cinfo->input_components, (JDIMENSION)1);
  629|  2.57k|  source->pub.buffer_height = 1;
  630|       |
  631|  2.57k|  cinfo->data_precision = 8;
  632|  2.57k|  cinfo->image_width = (JDIMENSION)biWidth;
  633|  2.57k|  cinfo->image_height = (JDIMENSION)biHeight;
  634|  2.57k|}
rdbmp.c:read_colormap:
   90|  3.08k|{
   91|  3.08k|  int i, gray = 1;
   92|       |
   93|  3.08k|  switch (mapentrysize) {
   94|  1.54k|  case 3:
  ------------------
  |  Branch (94:3): [True: 1.54k, False: 1.54k]
  ------------------
   95|       |    /* BGR format (occurs in OS/2 files) */
   96|   292k|    for (i = 0; i < cmaplen; i++) {
  ------------------
  |  Branch (96:17): [True: 290k, False: 1.54k]
  ------------------
   97|   290k|      sinfo->colormap[2][i] = (JSAMPLE)read_byte(sinfo);
   98|   290k|      sinfo->colormap[1][i] = (JSAMPLE)read_byte(sinfo);
   99|   290k|      sinfo->colormap[0][i] = (JSAMPLE)read_byte(sinfo);
  100|   290k|      if (sinfo->colormap[2][i] != sinfo->colormap[1][i] ||
  ------------------
  |  Branch (100:11): [True: 144k, False: 146k]
  ------------------
  101|   146k|          sinfo->colormap[1][i] != sinfo->colormap[0][i])
  ------------------
  |  Branch (101:11): [True: 24.1k, False: 122k]
  ------------------
  102|   168k|        gray = 0;
  103|   290k|    }
  104|  1.54k|    break;
  105|  1.54k|  case 4:
  ------------------
  |  Branch (105:3): [True: 1.54k, False: 1.54k]
  ------------------
  106|       |    /* BGR0 format (occurs in MS Windows files) */
  107|  94.2k|    for (i = 0; i < cmaplen; i++) {
  ------------------
  |  Branch (107:17): [True: 92.7k, False: 1.54k]
  ------------------
  108|  92.7k|      sinfo->colormap[2][i] = (JSAMPLE)read_byte(sinfo);
  109|  92.7k|      sinfo->colormap[1][i] = (JSAMPLE)read_byte(sinfo);
  110|  92.7k|      sinfo->colormap[0][i] = (JSAMPLE)read_byte(sinfo);
  111|  92.7k|      (void)read_byte(sinfo);
  112|  92.7k|      if (sinfo->colormap[2][i] != sinfo->colormap[1][i] ||
  ------------------
  |  Branch (112:11): [True: 43.8k, False: 48.8k]
  ------------------
  113|  48.8k|          sinfo->colormap[1][i] != sinfo->colormap[0][i])
  ------------------
  |  Branch (113:11): [True: 16.0k, False: 32.8k]
  ------------------
  114|  59.1k|        gray = 0;
  115|  92.7k|    }
  116|  1.54k|    break;
  117|      0|  default:
  ------------------
  |  Branch (117:3): [True: 0, False: 3.08k]
  ------------------
  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.08k|  }
  121|       |
  122|  1.93k|  if ((sinfo->cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (122:8): [True: 0, False: 1.93k]
  ------------------
  123|  1.93k|       sinfo->cinfo->in_color_space == JCS_RGB) && gray)
  ------------------
  |  Branch (123:8): [True: 0, False: 1.93k]
  |  Branch (123:52): [True: 0, False: 0]
  ------------------
  124|      0|    sinfo->cinfo->in_color_space = JCS_GRAYSCALE;
  125|       |
  126|  1.93k|  if (sinfo->cinfo->in_color_space == JCS_GRAYSCALE && !gray)
  ------------------
  |  Branch (126:7): [True: 277, False: 1.66k]
  |  Branch (126:56): [True: 236, False: 41]
  ------------------
  127|    236|    ERREXIT(sinfo->cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    236|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    236|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  128|  1.93k|}
rdbmp.c:read_byte:
   77|  2.80M|{
   78|  2.80M|  register FILE *infile = sinfo->pub.input_file;
   79|  2.80M|  register int c;
   80|       |
   81|  2.80M|  if ((c = getc(infile)) == EOF)
  ------------------
  |  Branch (81:7): [True: 1.42k, False: 2.80M]
  ------------------
   82|  1.42k|    ERREXIT(sinfo->cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|  1.42k|  ((cinfo)->err->msg_code = (code), \
  |  |  241|  1.42k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   83|  2.80M|  return c;
   84|  2.80M|}
rdbmp.c:get_8bit_row:
  141|  12.0M|{
  142|  12.0M|  bmp_source_ptr source = (bmp_source_ptr)sinfo;
  143|  12.0M|  register JSAMPARRAY colormap = source->colormap;
  144|  12.0M|  int cmaplen = source->cmap_length;
  145|  12.0M|  JSAMPARRAY image_ptr;
  146|  12.0M|  register int t;
  147|  12.0M|  register JSAMPROW inptr, outptr;
  148|  12.0M|  register JDIMENSION col;
  149|       |
  150|  12.0M|  if (source->use_inversion_array) {
  ------------------
  |  Branch (150:7): [True: 0, False: 12.0M]
  ------------------
  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|  12.0M|  } else {
  158|  12.0M|    if (!ReadOK(source->pub.input_file, source->iobuffer, source->row_width))
  ------------------
  |  |   36|  12.0M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (158:9): [True: 406, False: 12.0M]
  ------------------
  159|    406|      ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    406|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    406|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  160|  12.0M|    inptr = source->iobuffer;
  161|  12.0M|  }
  162|       |
  163|       |  /* Expand the colormap indexes to real data */
  164|  12.0M|  outptr = source->pub.buffer[0];
  165|  12.0M|  if (cinfo->in_color_space == JCS_GRAYSCALE) {
  ------------------
  |  Branch (165:7): [True: 691, False: 12.0M]
  ------------------
  166|  3.34k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (166:36): [True: 2.65k, False: 691]
  ------------------
  167|  2.65k|      t = *inptr++;
  168|  2.65k|      if (t >= cmaplen)
  ------------------
  |  Branch (168:11): [True: 11, False: 2.64k]
  ------------------
  169|     11|        ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
  ------------------
  |  |  240|     11|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     11|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  170|  2.65k|      *outptr++ = colormap[0][t];
  171|  2.65k|    }
  172|  12.0M|  } else if (cinfo->in_color_space == JCS_CMYK) {
  ------------------
  |  Branch (172:14): [True: 2.00M, False: 10.0M]
  ------------------
  173|  18.8M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (173:36): [True: 16.8M, False: 2.00M]
  ------------------
  174|  16.8M|      t = *inptr++;
  175|  16.8M|      if (t >= cmaplen)
  ------------------
  |  Branch (175:11): [True: 23, False: 16.8M]
  ------------------
  176|     23|        ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
  ------------------
  |  |  240|     23|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     23|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  177|  16.8M|      rgb_to_cmyk(255, colormap[0][t], colormap[1][t], colormap[2][t], outptr,
  178|  16.8M|                  outptr + 1, outptr + 2, outptr + 3);
  179|  16.8M|      outptr += 4;
  180|  16.8M|    }
  181|  10.0M|  } else {
  182|  10.0M|    register int rindex = rgb_red[cinfo->in_color_space];
  183|  10.0M|    register int gindex = rgb_green[cinfo->in_color_space];
  184|  10.0M|    register int bindex = rgb_blue[cinfo->in_color_space];
  185|  10.0M|    register int aindex = alpha_index[cinfo->in_color_space];
  186|  10.0M|    register int ps = rgb_pixelsize[cinfo->in_color_space];
  187|       |
  188|  10.0M|    if (aindex >= 0) {
  ------------------
  |  Branch (188:9): [True: 2.00M, False: 8.04M]
  ------------------
  189|  18.8M|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (189:38): [True: 16.8M, False: 2.00M]
  ------------------
  190|  16.8M|        t = *inptr++;
  191|  16.8M|        if (t >= cmaplen)
  ------------------
  |  Branch (191:13): [True: 23, False: 16.8M]
  ------------------
  192|     23|          ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
  ------------------
  |  |  240|     23|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     23|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  193|  16.8M|        outptr[rindex] = colormap[0][t];
  194|  16.8M|        outptr[gindex] = colormap[1][t];
  195|  16.8M|        outptr[bindex] = colormap[2][t];
  196|  16.8M|        outptr[aindex] = 0xFF;
  197|  16.8M|        outptr += ps;
  198|  16.8M|      }
  199|  8.04M|    } else {
  200|  75.4M|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (200:38): [True: 67.3M, False: 8.04M]
  ------------------
  201|  67.3M|        t = *inptr++;
  202|  67.3M|        if (t >= cmaplen)
  ------------------
  |  Branch (202:13): [True: 92, False: 67.3M]
  ------------------
  203|     92|          ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
  ------------------
  |  |  240|     92|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     92|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  204|  67.3M|        outptr[rindex] = colormap[0][t];
  205|  67.3M|        outptr[gindex] = colormap[1][t];
  206|  67.3M|        outptr[bindex] = colormap[2][t];
  207|  67.3M|        outptr += ps;
  208|  67.3M|      }
  209|  8.04M|    }
  210|  10.0M|  }
  211|       |
  212|  12.0M|  return 1;
  213|  12.0M|}
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: 432, False: 483k]
  ------------------
  234|    432|      ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    432|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    432|   (*(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|   236k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (245:36): [True: 155k, False: 80.6k]
  ------------------
  246|   155k|      JSAMPLE b = *inptr++, g = *inptr++, r = *inptr++;
  247|   155k|      rgb_to_cmyk(255, r, g, b, outptr, outptr + 1, outptr + 2, outptr + 3);
  248|   155k|      outptr += 4;
  249|   155k|    }
  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|   236k|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (258:38): [True: 155k, False: 80.6k]
  ------------------
  259|   155k|        outptr[bindex] = *inptr++;
  260|   155k|        outptr[gindex] = *inptr++;
  261|   155k|        outptr[rindex] = *inptr++;
  262|   155k|        outptr[aindex] = 0xFF;
  263|   155k|        outptr += ps;
  264|   155k|      }
  265|   242k|    } else {
  266|   710k|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (266:38): [True: 467k, False: 242k]
  ------------------
  267|   467k|        outptr[bindex] = *inptr++;
  268|   467k|        outptr[gindex] = *inptr++;
  269|   467k|        outptr[rindex] = *inptr++;
  270|   467k|        outptr += ps;
  271|   467k|      }
  272|   242k|    }
  273|   323k|  }
  274|       |
  275|   484k|  return 1;
  276|   484k|}
rdbmp.c:get_32bit_row:
  282|  1.29M|{
  283|  1.29M|  bmp_source_ptr source = (bmp_source_ptr)sinfo;
  284|  1.29M|  JSAMPARRAY image_ptr;
  285|  1.29M|  register JSAMPROW inptr, outptr;
  286|  1.29M|  register JDIMENSION col;
  287|       |
  288|  1.29M|  if (source->use_inversion_array) {
  ------------------
  |  Branch (288:7): [True: 0, False: 1.29M]
  ------------------
  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.29M|  } else {
  296|  1.29M|    if (!ReadOK(source->pub.input_file, source->iobuffer, source->row_width))
  ------------------
  |  |   36|  1.29M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (296:9): [True: 360, False: 1.29M]
  ------------------
  297|    360|      ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    360|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    360|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  298|  1.29M|    inptr = source->iobuffer;
  299|  1.29M|  }
  300|       |
  301|       |  /* Transfer data.  Note source values are in BGR order
  302|       |   * (even though Microsoft's own documents say the opposite).
  303|       |   */
  304|  1.29M|  outptr = source->pub.buffer[0];
  305|  1.29M|  if (cinfo->in_color_space == JCS_EXT_BGRX ||
  ------------------
  |  Branch (305:7): [True: 360, False: 1.29M]
  ------------------
  306|  1.29M|      cinfo->in_color_space == JCS_EXT_BGRA) {
  ------------------
  |  Branch (306:7): [True: 215k, False: 1.07M]
  ------------------
  307|   215k|    memcpy(outptr, inptr, source->row_width);
  308|  1.07M|  } else if (cinfo->in_color_space == JCS_CMYK) {
  ------------------
  |  Branch (308:14): [True: 215k, False: 860k]
  ------------------
  309|   756k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (309:36): [True: 541k, False: 215k]
  ------------------
  310|   541k|      JSAMPLE b = *inptr++, g = *inptr++, r = *inptr++;
  311|   541k|      rgb_to_cmyk(255, r, g, b, outptr, outptr + 1, outptr + 2, outptr + 3);
  312|   541k|      inptr++;                          /* skip the 4th byte (Alpha channel) */
  313|   541k|      outptr += 4;
  314|   541k|    }
  315|   860k|  } else {
  316|   860k|    register int rindex = rgb_red[cinfo->in_color_space];
  317|   860k|    register int gindex = rgb_green[cinfo->in_color_space];
  318|   860k|    register int bindex = rgb_blue[cinfo->in_color_space];
  319|   860k|    register int aindex = alpha_index[cinfo->in_color_space];
  320|   860k|    register int ps = rgb_pixelsize[cinfo->in_color_space];
  321|       |
  322|   860k|    if (aindex >= 0) {
  ------------------
  |  Branch (322:9): [True: 0, False: 860k]
  ------------------
  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|   860k|    } else {
  331|  3.02M|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (331:38): [True: 2.16M, False: 860k]
  ------------------
  332|  2.16M|        outptr[bindex] = *inptr++;
  333|  2.16M|        outptr[gindex] = *inptr++;
  334|  2.16M|        outptr[rindex] = *inptr++;
  335|  2.16M|        inptr++;                        /* skip the 4th byte (Alpha channel) */
  336|  2.16M|        outptr += ps;
  337|  2.16M|      }
  338|   860k|    }
  339|   860k|  }
  340|       |
  341|  1.29M|  return 1;
  342|  1.29M|}
rdbmp.c:finish_input_bmp:
  651|  6.62k|{
  652|       |  /* no work */
  653|  6.62k|}

jinit_read_png:
  705|  30.6k|{
  706|  30.6k|  png_source_ptr source;
  707|       |
  708|  30.6k|#if BITS_IN_JSAMPLE == 8
  709|  30.6k|  if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|  61.2k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (709:7): [True: 0, False: 30.6k]
  |  Branch (709:50): [True: 0, False: 30.6k]
  ------------------
  710|       |#else
  711|       |  if (cinfo->data_precision > BITS_IN_JSAMPLE ||
  712|       |      cinfo->data_precision < BITS_IN_JSAMPLE - 3)
  713|       |#endif
  714|      0|    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
  ------------------
  |  |  243|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  244|      0|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  715|       |
  716|       |  /* Create module interface object */
  717|  30.6k|  source = (png_source_ptr)
  718|  30.6k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  30.6k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  719|  30.6k|                                sizeof(png_source_struct));
  720|       |  /* Fill in method ptrs, except get_pixel_rows which start_input sets */
  721|  30.6k|  source->pub.start_input = start_input_png;
  722|  30.6k|  source->pub.read_icc_profile = read_icc_profile_png;
  723|  30.6k|  source->pub.finish_input = finish_input_png;
  724|  30.6k|  source->pub.max_pixels = 0;
  725|       |
  726|  30.6k|  return (cjpeg_source_ptr)source;
  727|  30.6k|}
rdpng-8.c:start_input_png:
  472|  30.6k|{
  473|  30.6k|  png_source_ptr source = (png_source_ptr)sinfo;
  474|  30.6k|  struct spng_ihdr ihdr;
  475|  30.6k|  int png_components = 3;
  476|  30.6k|  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|  30.6k|  source->ctx = spng_ctx_new(0);
  487|  30.6k|#endif
  488|  30.6k|  if (!source->ctx)
  ------------------
  |  Branch (488:7): [True: 0, False: 30.6k]
  ------------------
  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|  30.6k|  TRY_SPNG(spng_set_png_file(source->ctx, sinfo->input_file));
  ------------------
  |  |   33|  30.6k|#define TRY_SPNG(f) { \
  |  |   34|  30.6k|  int __spng_error = (f); \
  |  |   35|  30.6k|  if (__spng_error) \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 0, False: 30.6k]
  |  |  ------------------
  |  |   36|  30.6k|    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|  30.6k|}
  ------------------
  492|       |
  493|  30.6k|  TRY_SPNG(spng_get_ihdr(source->ctx, &ihdr));
  ------------------
  |  |   33|  30.6k|#define TRY_SPNG(f) { \
  |  |   34|  30.6k|  int __spng_error = (f); \
  |  |   35|  30.6k|  if (__spng_error) \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 1.33k, False: 29.2k]
  |  |  ------------------
  |  |   36|  30.6k|    ERREXITS(cinfo, JERR_PNG_LIBSPNG, spng_strerror(__spng_error)); \
  |  |  ------------------
  |  |  |  |  274|  1.33k|  ((cinfo)->err->msg_code = (code), \
  |  |  |  |  275|  1.33k|   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX - 1), \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|  1.33k|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  276|  1.33k|   (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|  1.33k|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  277|  1.33k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  |  |  ------------------
  |  |   37|  30.6k|}
  ------------------
  494|       |
  495|  30.6k|  if (ihdr.width > JPEG_MAX_DIMENSION || ihdr.height > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  61.2k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
                if (ihdr.width > JPEG_MAX_DIMENSION || ihdr.height > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  27.8k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (495:7): [True: 2.79k, False: 27.8k]
  |  Branch (495:42): [True: 217, False: 27.6k]
  ------------------
  496|  1.68k|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, JPEG_MAX_DIMENSION);
  ------------------
  |  |  243|  1.68k|  ((cinfo)->err->msg_code = (code), \
  |  |  244|  1.68k|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|  1.68k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  497|  30.6k|  if (ihdr.bit_depth != 8 && ihdr.bit_depth != 16)
  ------------------
  |  Branch (497:7): [True: 11.6k, False: 18.9k]
  |  Branch (497:30): [True: 5.57k, False: 6.08k]
  ------------------
  498|  5.57k|    ERREXIT(cinfo, JERR_PNG_BADDEPTH);
  ------------------
  |  |  240|  5.57k|  ((cinfo)->err->msg_code = (code), \
  |  |  241|  5.57k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  499|  30.6k|  if (sinfo->max_pixels &&
  ------------------
  |  Branch (499:7): [True: 22.0k, False: 8.58k]
  ------------------
  500|  22.0k|      (unsigned long long)ihdr.width * ihdr.height > sinfo->max_pixels)
  ------------------
  |  Branch (500:7): [True: 280, False: 21.7k]
  ------------------
  501|    280|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
  ------------------
  |  |  243|    280|  ((cinfo)->err->msg_code = (code), \
  |  |  244|    280|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|    280|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  502|       |
  503|  30.6k|  cinfo->image_width = (JDIMENSION)ihdr.width;
  504|  30.6k|  cinfo->image_height = (JDIMENSION)ihdr.height;
  505|  30.6k|  source->png_bit_depth = ihdr.bit_depth;
  506|  30.6k|  source->png_color_type = ihdr.color_type;
  507|       |
  508|       |  /* initialize flags to most common settings */
  509|  30.6k|  use_raw_buffer = FALSE;       /* do we map input buffer onto I/O buffer? */
  ------------------
  |  |  207|  30.6k|#define FALSE   0               /* values of boolean */
  ------------------
  510|       |
  511|  30.6k|  switch (ihdr.color_type) {
  512|  1.61k|  case SPNG_COLOR_TYPE_GRAYSCALE_ALPHA:
  ------------------
  |  Branch (512:3): [True: 1.61k, False: 29.0k]
  ------------------
  513|  4.61k|  case SPNG_COLOR_TYPE_GRAYSCALE:
  ------------------
  |  Branch (513:3): [True: 3.00k, False: 27.6k]
  ------------------
  514|  4.61k|    if (cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (514:9): [True: 0, False: 4.61k]
  ------------------
  515|  4.61k|        cinfo->in_color_space == JCS_RGB)
  ------------------
  |  Branch (515:9): [True: 0, False: 4.61k]
  ------------------
  516|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  517|  4.61k|    TRACEMS3(cinfo, 1, JTRC_PNG_GRAYSCALE, ihdr.width, ihdr.height,
  ------------------
  |  |  309|  4.61k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  4.61k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 4.61k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  4.61k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  4.61k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  4.61k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  518|  4.61k|             ihdr.bit_depth);
  519|  4.61k|    if (cinfo->in_color_space == JCS_GRAYSCALE) {
  ------------------
  |  Branch (519:9): [True: 659, False: 3.95k]
  ------------------
  520|    659|      if (ihdr.color_type == SPNG_COLOR_TYPE_GRAYSCALE &&
  ------------------
  |  Branch (520:11): [True: 429, False: 230]
  ------------------
  521|    429|          cinfo->data_precision == ihdr.bit_depth) {
  ------------------
  |  Branch (521:11): [True: 283, False: 146]
  ------------------
  522|    283|        source->pub.get_pixel_rows = get_raw_row;
  523|    283|        use_raw_buffer = TRUE;
  ------------------
  |  |  210|    283|#define TRUE    1
  ------------------
  524|    283|      } else
  525|    376|        source->pub.get_pixel_rows = get_gray_row;
  526|  3.95k|    } else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  3.95k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 3.95k]
  |  |  |  Branch (78:22): [True: 3.29k, False: 659]
  |  |  |  Branch (78:43): [True: 3.29k, False: 0]
  |  |  ------------------
  ------------------
  527|  3.29k|      source->pub.get_pixel_rows = get_gray_rgb_row;
  528|    659|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (528:14): [True: 659, False: 0]
  ------------------
  529|    659|        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|  4.61k|    if (ihdr.color_type == SPNG_COLOR_TYPE_GRAYSCALE_ALPHA) {
  ------------------
  |  Branch (532:9): [True: 1.61k, False: 3.00k]
  ------------------
  533|  1.61k|      png_components = 2;
  534|  1.61k|      source->png_alpha = 1;
  535|  3.00k|    } else {
  536|  3.00k|      png_components = 1;
  537|  3.00k|      source->png_alpha = 0;
  538|  3.00k|    }
  539|  4.61k|    break;
  540|       |
  541|  11.6k|  case SPNG_COLOR_TYPE_TRUECOLOR:
  ------------------
  |  Branch (541:3): [True: 11.6k, False: 18.9k]
  ------------------
  542|  15.9k|  case SPNG_COLOR_TYPE_TRUECOLOR_ALPHA:
  ------------------
  |  Branch (542:3): [True: 4.29k, False: 26.3k]
  ------------------
  543|  15.9k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (543:9): [True: 0, False: 15.9k]
  ------------------
  544|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  545|  15.9k|    TRACEMS3(cinfo, 1, JTRC_PNG_TRUECOLOR, ihdr.width, ihdr.height,
  ------------------
  |  |  309|  15.9k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  15.9k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 15.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  15.9k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  15.9k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  15.9k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  546|  15.9k|             ihdr.bit_depth);
  547|  15.9k|    if (ihdr.color_type == SPNG_COLOR_TYPE_TRUECOLOR &&
  ------------------
  |  Branch (547:9): [True: 11.6k, False: 4.29k]
  ------------------
  548|  11.6k|        cinfo->data_precision == ihdr.bit_depth &&
  ------------------
  |  Branch (548:9): [True: 9.05k, False: 2.56k]
  ------------------
  549|  9.05k|#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3
  550|  9.05k|        (cinfo->in_color_space == JCS_EXT_RGB ||
  ------------------
  |  Branch (550:10): [True: 1.29k, False: 7.76k]
  ------------------
  551|  7.76k|         cinfo->in_color_space == JCS_RGB)) {
  ------------------
  |  Branch (551:10): [True: 0, False: 7.76k]
  ------------------
  552|       |#else
  553|       |        cinfo->in_color_space == JCS_EXT_RGB) {
  554|       |#endif
  555|  1.29k|      source->pub.get_pixel_rows = get_raw_row;
  556|  1.29k|      use_raw_buffer = TRUE;
  ------------------
  |  |  210|  1.29k|#define TRUE    1
  ------------------
  557|  14.6k|    } else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  14.6k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 14.6k]
  |  |  |  Branch (78:22): [True: 10.0k, False: 4.54k]
  |  |  |  Branch (78:43): [True: 10.0k, False: 0]
  |  |  ------------------
  ------------------
  558|  10.0k|      source->pub.get_pixel_rows = get_rgb_row;
  559|  4.54k|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (559:14): [True: 2.27k, False: 2.27k]
  ------------------
  560|  2.27k|      source->pub.get_pixel_rows = get_rgb_cmyk_row;
  561|  2.27k|    else
  562|  2.27k|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|  2.27k|  ((cinfo)->err->msg_code = (code), \
  |  |  241|  2.27k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  563|  15.9k|    if (ihdr.color_type == SPNG_COLOR_TYPE_TRUECOLOR_ALPHA) {
  ------------------
  |  Branch (563:9): [True: 3.68k, False: 12.2k]
  ------------------
  564|  3.68k|      png_components = 4;
  565|  3.68k|      source->png_alpha = 1;
  566|  12.2k|    } else {
  567|  12.2k|      png_components = 3;
  568|  12.2k|      source->png_alpha = 0;
  569|  12.2k|    }
  570|  15.9k|    break;
  571|       |
  572|  1.21k|  case SPNG_COLOR_TYPE_INDEXED:
  ------------------
  |  Branch (572:3): [True: 1.21k, False: 29.4k]
  ------------------
  573|  1.21k|  {
  574|  1.21k|    int i, gray = 1;
  575|       |
  576|  1.21k|    TRACEMS3(cinfo, 1, JTRC_PNG_INDEXED, ihdr.width, ihdr.height,
  ------------------
  |  |  309|  1.21k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.21k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.21k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  1.21k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  1.21k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  1.21k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  577|  1.21k|             ihdr.bit_depth);
  578|  1.21k|    TRY_SPNG(spng_get_plte(source->ctx, &source->colormap));
  ------------------
  |  |   33|  1.21k|#define TRY_SPNG(f) { \
  |  |   34|  1.21k|  int __spng_error = (f); \
  |  |   35|  1.21k|  if (__spng_error) \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 938, False: 280]
  |  |  ------------------
  |  |   36|  1.21k|    ERREXITS(cinfo, JERR_PNG_LIBSPNG, spng_strerror(__spng_error)); \
  |  |  ------------------
  |  |  |  |  274|    938|  ((cinfo)->err->msg_code = (code), \
  |  |  |  |  275|    938|   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX - 1), \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|    938|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  276|    938|   (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|    938|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  277|    938|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  |  |  ------------------
  |  |   37|  1.21k|}
  ------------------
  579|  1.21k|    if (source->png_bit_depth != 8 || source->colormap.n_entries > 256)
  ------------------
  |  Branch (579:9): [True: 938, False: 280]
  |  Branch (579:39): [True: 0, False: 280]
  ------------------
  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|  13.0k|    for (i = 0; i < (int)source->colormap.n_entries; i++) {
  ------------------
  |  Branch (582:17): [True: 11.8k, False: 1.21k]
  ------------------
  583|  11.8k|      if (source->colormap.entries[i].red !=
  ------------------
  |  Branch (583:11): [True: 6.22k, False: 5.59k]
  ------------------
  584|  11.8k|          source->colormap.entries[i].green ||
  585|  5.59k|          source->colormap.entries[i].green !=
  ------------------
  |  Branch (585:11): [True: 497, False: 5.09k]
  ------------------
  586|  5.59k|          source->colormap.entries[i].blue)
  587|  6.72k|        gray = 0;
  588|  11.8k|    }
  589|       |
  590|  1.21k|    if ((cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (590:10): [True: 938, False: 280]
  ------------------
  591|    280|         cinfo->in_color_space == JCS_RGB) && gray)
  ------------------
  |  Branch (591:10): [True: 0, False: 280]
  |  Branch (591:47): [True: 0, False: 0]
  ------------------
  592|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  593|  1.21k|    else if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (593:14): [True: 0, False: 1.21k]
  ------------------
  594|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  595|  1.21k|    if (cinfo->in_color_space == JCS_GRAYSCALE && !gray)
  ------------------
  |  Branch (595:9): [True: 40, False: 1.17k]
  |  Branch (595:51): [True: 28, False: 12]
  ------------------
  596|     28|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|     28|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     28|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  597|       |
  598|  1.21k|    source->pub.get_pixel_rows = get_indexed_row;
  599|  1.21k|    png_components = 1;
  600|  1.21k|    source->png_alpha = 0;
  601|  1.21k|    break;
  602|  11.6k|  }
  603|       |
  604|      0|  default:
  ------------------
  |  Branch (604:3): [True: 0, False: 30.6k]
  ------------------
  605|      0|    ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  606|  30.6k|  }
  607|       |
  608|  18.5k|  if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  18.5k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 18.5k]
  |  |  |  Branch (78:22): [True: 14.8k, False: 3.64k]
  |  |  |  Branch (78:43): [True: 14.8k, False: 0]
  |  |  ------------------
  ------------------
  609|  14.8k|    cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
  610|  3.64k|  else if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (610:12): [True: 671, False: 2.97k]
  ------------------
  611|    671|    cinfo->input_components = 1;
  612|  2.97k|  else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (612:12): [True: 2.97k, False: 0]
  ------------------
  613|  2.97k|    cinfo->input_components = 4;
  614|       |
  615|       |  /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */
  616|  18.5k|  source->buffer_width =
  617|  18.5k|    (size_t)ihdr.width * png_components * source->png_bit_depth / 8;
  618|  18.5k|  source->iobuffer = (unsigned char *)
  619|  18.5k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  18.5k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  620|  18.5k|                                source->buffer_width);
  621|       |
  622|       |  /* Create compressor input buffer. */
  623|  18.5k|  if (use_raw_buffer) {
  ------------------
  |  Branch (623:7): [True: 1.57k, False: 16.9k]
  ------------------
  624|       |    /* For unscaled raw-input case, we can just map it onto the I/O buffer. */
  625|       |    /* Synthesize a _JSAMPARRAY pointer structure */
  626|  1.57k|    source->pixrow = (_JSAMPROW)source->iobuffer;
  627|  1.57k|    source->pub._buffer = &source->pixrow;
  ------------------
  |  |  326|  1.57k|#define _buffer  buffer
  ------------------
  628|  1.57k|    source->pub.buffer_height = 1;
  629|  16.9k|  } else {
  630|  16.9k|    unsigned int maxval = source->png_bit_depth == 16 ? 65535 : 255;
  ------------------
  |  Branch (630:27): [True: 5.32k, False: 11.6k]
  ------------------
  631|  16.9k|    size_t val, half_maxval;
  632|       |
  633|       |    /* Need to translate anyway, so make a separate sample buffer. */
  634|  16.9k|    source->pub._buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  ------------------
  |  |  326|  16.9k|#define _buffer  buffer
  ------------------
  635|  16.9k|      ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  16.9k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  636|  16.9k|       (JDIMENSION)ihdr.width * cinfo->input_components, (JDIMENSION)1);
  637|  16.9k|    source->pub.buffer_height = 1;
  638|       |
  639|       |    /* Compute the rescaling array. */
  640|  16.9k|    source->rescale = (_JSAMPLE *)
  641|  16.9k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  16.9k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  642|  16.9k|                                  (maxval + 1L) * sizeof(_JSAMPLE));
  643|  16.9k|    memset(source->rescale, 0, (maxval + 1L) * sizeof(_JSAMPLE));
  644|  16.9k|    half_maxval = maxval / 2;
  645|   351M|    for (val = 0; val <= maxval; val++) {
  ------------------
  |  Branch (645:19): [True: 351M, False: 16.9k]
  ------------------
  646|       |      /* The multiplication here must be done in 32 bits to avoid overflow */
  647|   351M|      source->rescale[val] =
  648|   351M|        (_JSAMPLE)((val * ((1 << cinfo->data_precision) - 1) + half_maxval) /
  649|   351M|                   maxval);
  650|   351M|    }
  651|  16.9k|  }
  652|       |
  653|  18.5k|  TRY_SPNG(spng_decode_image(source->ctx, NULL, 0, SPNG_FMT_PNG,
  ------------------
  |  |   33|  18.5k|#define TRY_SPNG(f) { \
  |  |   34|  18.5k|  int __spng_error = (f); \
  |  |   35|  18.5k|  if (__spng_error) \
  |  |  ------------------
  |  |  |  Branch (35:7): [True: 12.3k, False: 6.20k]
  |  |  ------------------
  |  |   36|  18.5k|    ERREXITS(cinfo, JERR_PNG_LIBSPNG, spng_strerror(__spng_error)); \
  |  |  ------------------
  |  |  |  |  274|  12.3k|  ((cinfo)->err->msg_code = (code), \
  |  |  |  |  275|  12.3k|   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX - 1), \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|  12.3k|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  276|  12.3k|   (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
  |  |  |  |  ------------------
  |  |  |  |  |  |  800|  12.3k|#define JMSG_STR_PARM_MAX  80
  |  |  |  |  ------------------
  |  |  |  |  277|  12.3k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  |  |  ------------------
  |  |   37|  18.5k|}
  ------------------
  654|  18.5k|                             SPNG_DECODE_PROGRESSIVE));
  655|  18.5k|}
rdpng-8.c:get_raw_row:
   75|   469k|{
   76|   469k|  png_source_ptr source = (png_source_ptr)sinfo;
   77|   469k|  int spng_error;
   78|       |
   79|   469k|  spng_error = spng_decode_row(source->ctx, source->iobuffer,
   80|   469k|                               source->buffer_width);
   81|   469k|  if (spng_error && spng_error != SPNG_EOI)
  ------------------
  |  Branch (81:7): [True: 5.14k, False: 464k]
  |  Branch (81:21): [True: 3.17k, False: 1.96k]
  ------------------
   82|  3.17k|    ERREXITS(cinfo, JERR_PNG_LIBSPNG, spng_strerror(spng_error)); \
  ------------------
  |  |  274|  3.17k|  ((cinfo)->err->msg_code = (code), \
  |  |  275|  3.17k|   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX - 1), \
  |  |  ------------------
  |  |  |  |  800|  3.17k|#define JMSG_STR_PARM_MAX  80
  |  |  ------------------
  |  |  276|  3.17k|   (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
  |  |  ------------------
  |  |  |  |  800|  3.17k|#define JMSG_STR_PARM_MAX  80
  |  |  ------------------
  |  |  277|  3.17k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
   83|   469k|  return 1;
   84|   469k|}
rdpng-8.c:get_gray_row:
  102|  20.5k|{
  103|  20.5k|  png_source_ptr source = (png_source_ptr)sinfo;
  104|  20.5k|  register _JSAMPROW ptr;
  105|  20.5k|  register _JSAMPLE *rescale = source->rescale;
  106|  20.5k|  JDIMENSION col;
  107|       |
  108|  20.5k|  get_raw_row(cinfo, sinfo);
  109|  20.5k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  20.5k|#define _buffer  buffer
  ------------------
  110|  20.5k|#if BITS_IN_JSAMPLE != 12
  111|  20.5k|  if (source->png_bit_depth == cinfo->data_precision) {
  ------------------
  |  Branch (111:7): [True: 13.4k, False: 7.14k]
  ------------------
  112|  13.4k|    _JSAMPLE *bufferptr = (_JSAMPLE *)source->iobuffer;
  ------------------
  |  |  224|  13.4k|#define _JSAMPLE  JSAMPLE
  ------------------
  113|   107k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (113:36): [True: 93.9k, False: 13.4k]
  ------------------
  114|  93.9k|      *ptr++ = *bufferptr++;
  115|  93.9k|      bufferptr += source->png_alpha;
  116|  93.9k|    }
  117|  13.4k|  } else
  118|  7.14k|#endif
  119|  7.14k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (119:7): [True: 7.01k, False: 127]
  ------------------
  120|  7.01k|    register unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  121|   180k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (121:36): [True: 173k, False: 7.01k]
  ------------------
  122|   173k|      *ptr++ = rescale[*bufferptr++];
  123|   173k|      bufferptr += source->png_alpha;
  124|   173k|    }
  125|  7.01k|  } else {
  126|    127|    register unsigned char *bufferptr = source->iobuffer;
  127|    127|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (127:36): [True: 0, False: 127]
  ------------------
  128|      0|      *ptr++ = rescale[*bufferptr++];
  129|      0|      bufferptr += source->png_alpha;
  130|      0|    }
  131|    127|  }
  132|  20.5k|  return 1;
  133|  20.5k|}
rdpng-8.c:get_gray_rgb_row:
  141|   108k|{
  142|   108k|  png_source_ptr source = (png_source_ptr)sinfo;
  143|   108k|  register _JSAMPROW ptr;
  144|   108k|  register _JSAMPLE *rescale = source->rescale;
  145|   108k|  JDIMENSION col;
  146|   108k|  register int rindex = rgb_red[cinfo->in_color_space];
  147|   108k|  register int gindex = rgb_green[cinfo->in_color_space];
  148|   108k|  register int bindex = rgb_blue[cinfo->in_color_space];
  149|   108k|  register int aindex = alpha_index[cinfo->in_color_space];
  150|   108k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  151|       |
  152|   108k|  get_raw_row(cinfo, sinfo);
  153|   108k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|   108k|#define _buffer  buffer
  ------------------
  154|   108k|#if BITS_IN_JSAMPLE != 12
  155|   108k|  if (source->png_bit_depth == cinfo->data_precision) {
  ------------------
  |  Branch (155:7): [True: 72.3k, False: 35.8k]
  ------------------
  156|  72.3k|    _JSAMPLE *bufferptr = (_JSAMPLE *)source->iobuffer;
  ------------------
  |  |  224|  72.3k|#define _JSAMPLE  JSAMPLE
  ------------------
  157|  72.3k|    if (aindex >= 0)
  ------------------
  |  Branch (157:9): [True: 14.4k, False: 57.8k]
  ------------------
  158|  14.4k|      GRAY_RGB_READ_LOOP(*bufferptr++, ptr[aindex] = _MAXJSAMPLE;,
  ------------------
  |  |   87|  14.4k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |   88|   196k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (88:34): [True: 181k, False: 14.4k]
  |  |  ------------------
  |  |   89|   181k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |   90|   181k|    alpha_set_op \
  |  |   91|   181k|    ptr += ps; \
  |  |   92|   181k|    pointer_op \
  |  |   93|   181k|  } \
  |  |   94|  14.4k|}
  ------------------
  159|  72.3k|                         bufferptr += source->png_alpha;)
  160|  57.8k|    else
  161|  57.8k|      GRAY_RGB_READ_LOOP(*bufferptr++, {}, bufferptr += source->png_alpha;)
  ------------------
  |  |   87|  57.8k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |   88|   784k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (88:34): [True: 726k, False: 57.8k]
  |  |  ------------------
  |  |   89|   726k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |   90|   726k|    alpha_set_op \
  |  |   91|   726k|    ptr += ps; \
  |  |   92|   726k|    pointer_op \
  |  |   93|   726k|  } \
  |  |   94|  57.8k|}
  ------------------
  162|  72.3k|  } else
  163|  35.8k|#endif
  164|  35.8k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (164:7): [True: 35.0k, False: 775]
  ------------------
  165|  35.0k|    register unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  166|  35.0k|    if (aindex >= 0)
  ------------------
  |  Branch (166:9): [True: 7.01k, False: 28.0k]
  ------------------
  167|  7.01k|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |   87|  7.01k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |   88|   180k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (88:34): [True: 173k, False: 7.01k]
  |  |  ------------------
  |  |   89|   173k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |   90|   173k|    alpha_set_op \
  |  |   91|   173k|    ptr += ps; \
  |  |   92|   173k|    pointer_op \
  |  |   93|   173k|  } \
  |  |   94|  7.01k|}
  ------------------
  168|  35.0k|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;,
  169|  35.0k|                         bufferptr += source->png_alpha;)
  170|  28.0k|    else
  171|  28.0k|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++], {},
  ------------------
  |  |   87|  28.0k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |   88|   723k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (88:34): [True: 695k, False: 28.0k]
  |  |  ------------------
  |  |   89|   695k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |   90|   695k|    alpha_set_op \
  |  |   91|   695k|    ptr += ps; \
  |  |   92|   695k|    pointer_op \
  |  |   93|   695k|  } \
  |  |   94|  28.0k|}
  ------------------
  172|  35.0k|                         bufferptr += source->png_alpha;)
  173|  35.0k|  } else {
  174|    775|    register unsigned char *bufferptr = source->iobuffer;
  175|    775|    if (aindex >= 0)
  ------------------
  |  Branch (175:9): [True: 0, False: 775]
  ------------------
  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|    775|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;,
  178|    775|                         bufferptr += source->png_alpha;)
  179|    775|    else
  180|    775|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++], {},
  ------------------
  |  |   87|    775|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |   88|    775|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (88:34): [True: 0, False: 775]
  |  |  ------------------
  |  |   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|    775|}
  ------------------
  181|    775|                         bufferptr += source->png_alpha;)
  182|    775|  }
  183|   108k|  return 1;
  184|   108k|}
rdpng-8.c:get_gray_cmyk_row:
  192|  21.6k|{
  193|  21.6k|  png_source_ptr source = (png_source_ptr)sinfo;
  194|  21.6k|  register _JSAMPROW ptr;
  195|  21.6k|  register _JSAMPLE *rescale = source->rescale;
  196|  21.6k|  JDIMENSION col;
  197|       |
  198|  21.6k|  get_raw_row(cinfo, sinfo);
  199|  21.6k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  21.6k|#define _buffer  buffer
  ------------------
  200|  21.6k|#if BITS_IN_JSAMPLE != 12
  201|  21.6k|  if (source->png_bit_depth == cinfo->data_precision) {
  ------------------
  |  Branch (201:7): [True: 14.4k, False: 7.17k]
  ------------------
  202|  14.4k|    register _JSAMPLE *bufferptr = (_JSAMPLE *)source->iobuffer;
  203|   196k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (203:36): [True: 181k, False: 14.4k]
  ------------------
  204|   181k|      _JSAMPLE gray = *bufferptr++;
  ------------------
  |  |  224|   181k|#define _JSAMPLE  JSAMPLE
  ------------------
  205|   181k|      bufferptr += source->png_alpha;
  206|   181k|      rgb_to_cmyk(_MAXJSAMPLE, gray, gray, gray, ptr, ptr + 1, ptr + 2,
  ------------------
  |  |  226|   181k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|   181k|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
  207|   181k|                  ptr + 3);
  208|   181k|      ptr += 4;
  209|   181k|    }
  210|  14.4k|  } else
  211|  7.17k|#endif
  212|  7.17k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (212:7): [True: 7.01k, False: 155]
  ------------------
  213|  7.01k|    unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  214|   180k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (214:36): [True: 173k, False: 7.01k]
  ------------------
  215|   173k|      _JSAMPLE gray = rescale[*bufferptr++];
  ------------------
  |  |  224|   173k|#define _JSAMPLE  JSAMPLE
  ------------------
  216|   173k|      bufferptr += source->png_alpha;
  217|   173k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  218|   173k|                  ptr + 1, ptr + 2, ptr + 3);
  219|   173k|      ptr += 4;
  220|   173k|    }
  221|  7.01k|  } else {
  222|    155|    register unsigned char *bufferptr = source->iobuffer;
  223|    155|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (223:36): [True: 0, False: 155]
  ------------------
  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|    155|  }
  231|  21.6k|  return 1;
  232|  21.6k|}
rdpng-8.c:get_rgb_row:
  252|   220k|{
  253|   220k|  png_source_ptr source = (png_source_ptr)sinfo;
  254|   220k|  register _JSAMPROW ptr;
  255|   220k|  register _JSAMPLE *rescale = source->rescale;
  256|   220k|  JDIMENSION col;
  257|   220k|  register int rindex = rgb_red[cinfo->in_color_space];
  258|   220k|  register int gindex = rgb_green[cinfo->in_color_space];
  259|   220k|  register int bindex = rgb_blue[cinfo->in_color_space];
  260|   220k|  register int aindex = alpha_index[cinfo->in_color_space];
  261|   220k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  262|       |
  263|   220k|  get_raw_row(cinfo, sinfo);
  264|   220k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|   220k|#define _buffer  buffer
  ------------------
  265|   220k|#if BITS_IN_JSAMPLE != 12
  266|   220k|  if (source->png_bit_depth == cinfo->data_precision) {
  ------------------
  |  Branch (266:7): [True: 185k, False: 35.5k]
  ------------------
  267|   185k|    register _JSAMPLE *bufferptr = (_JSAMPLE *)source->iobuffer;
  268|   185k|    if (aindex >= 0)
  ------------------
  |  Branch (268:9): [True: 45.7k, False: 139k]
  ------------------
  269|  45.7k|      RGB_READ_LOOP(*bufferptr++, ptr[aindex] = _MAXJSAMPLE;,
  ------------------
  |  |  235|  45.7k|#define RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |  236|  6.96M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (236:34): [True: 6.91M, False: 45.7k]
  |  |  ------------------
  |  |  237|  6.91M|    ptr[rindex] = read_op; \
  |  |  238|  6.91M|    ptr[gindex] = read_op; \
  |  |  239|  6.91M|    ptr[bindex] = read_op; \
  |  |  240|  6.91M|    alpha_set_op \
  |  |  241|  6.91M|    pointer_op \
  |  |  242|  6.91M|    ptr += ps; \
  |  |  243|  6.91M|  } \
  |  |  244|  45.7k|}
  ------------------
  270|   185k|                    bufferptr += source->png_alpha;)
  271|   139k|    else
  272|   139k|      RGB_READ_LOOP(*bufferptr++, {}, bufferptr += source->png_alpha;)
  ------------------
  |  |  235|   139k|#define RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |  236|  21.4M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (236:34): [True: 21.3M, False: 139k]
  |  |  ------------------
  |  |  237|  21.3M|    ptr[rindex] = read_op; \
  |  |  238|  21.3M|    ptr[gindex] = read_op; \
  |  |  239|  21.3M|    ptr[bindex] = read_op; \
  |  |  240|  21.3M|    alpha_set_op \
  |  |  241|  21.3M|    pointer_op \
  |  |  242|  21.3M|    ptr += ps; \
  |  |  243|  21.3M|  } \
  |  |  244|   139k|}
  ------------------
  273|   185k|  } else
  274|  35.5k|#endif
  275|  35.5k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (275:7): [True: 33.9k, False: 1.51k]
  ------------------
  276|  33.9k|    unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  277|  33.9k|    if (aindex >= 0)
  ------------------
  |  Branch (277:9): [True: 6.79k, False: 27.1k]
  ------------------
  278|  6.79k|      RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  235|  6.79k|#define RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |  236|  1.07M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (236:34): [True: 1.07M, False: 6.79k]
  |  |  ------------------
  |  |  237|  1.07M|    ptr[rindex] = read_op; \
  |  |  238|  1.07M|    ptr[gindex] = read_op; \
  |  |  239|  1.07M|    ptr[bindex] = read_op; \
  |  |  240|  1.07M|    alpha_set_op \
  |  |  241|  1.07M|    pointer_op \
  |  |  242|  1.07M|    ptr += ps; \
  |  |  243|  1.07M|  } \
  |  |  244|  6.79k|}
  ------------------
  279|  33.9k|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;,
  280|  33.9k|                    bufferptr += source->png_alpha;)
  281|  27.1k|    else
  282|  27.1k|      RGB_READ_LOOP(rescale[*bufferptr++], {},
  ------------------
  |  |  235|  27.1k|#define RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |  236|  4.31M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (236:34): [True: 4.29M, False: 27.1k]
  |  |  ------------------
  |  |  237|  4.29M|    ptr[rindex] = read_op; \
  |  |  238|  4.29M|    ptr[gindex] = read_op; \
  |  |  239|  4.29M|    ptr[bindex] = read_op; \
  |  |  240|  4.29M|    alpha_set_op \
  |  |  241|  4.29M|    pointer_op \
  |  |  242|  4.29M|    ptr += ps; \
  |  |  243|  4.29M|  } \
  |  |  244|  27.1k|}
  ------------------
  283|  33.9k|                    bufferptr += source->png_alpha;)
  284|  33.9k|  } else {
  285|  1.51k|    register unsigned char *bufferptr = source->iobuffer;
  286|  1.51k|    if (aindex >= 0)
  ------------------
  |  Branch (286:9): [True: 0, False: 1.51k]
  ------------------
  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.51k|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;,
  289|  1.51k|                    bufferptr += source->png_alpha;)
  290|  1.51k|    else
  291|  1.51k|      RGB_READ_LOOP(rescale[*bufferptr++], {},
  ------------------
  |  |  235|  1.51k|#define RGB_READ_LOOP(read_op, alpha_set_op, pointer_op) { \
  |  |  236|  1.51k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (236:34): [True: 0, False: 1.51k]
  |  |  ------------------
  |  |  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.51k|}
  ------------------
  292|  1.51k|                    bufferptr += source->png_alpha;)
  293|  1.51k|  }
  294|   220k|  return 1;
  295|   220k|}
rdpng-8.c:get_rgb_cmyk_row:
  303|  52.9k|{
  304|  52.9k|  png_source_ptr source = (png_source_ptr)sinfo;
  305|  52.9k|  register _JSAMPROW ptr;
  306|  52.9k|  register _JSAMPLE *rescale = source->rescale;
  307|  52.9k|  JDIMENSION col;
  308|       |
  309|  52.9k|  get_raw_row(cinfo, sinfo);
  310|  52.9k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  52.9k|#define _buffer  buffer
  ------------------
  311|  52.9k|#if BITS_IN_JSAMPLE != 12
  312|  52.9k|  if (source->png_bit_depth == cinfo->data_precision) {
  ------------------
  |  Branch (312:7): [True: 45.7k, False: 7.13k]
  ------------------
  313|  45.7k|    register _JSAMPLE *bufferptr = (_JSAMPLE *)source->iobuffer;
  314|  6.96M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (314:36): [True: 6.91M, False: 45.7k]
  ------------------
  315|  6.91M|      _JSAMPLE r = *bufferptr++;
  ------------------
  |  |  224|  6.91M|#define _JSAMPLE  JSAMPLE
  ------------------
  316|  6.91M|      _JSAMPLE g = *bufferptr++;
  ------------------
  |  |  224|  6.91M|#define _JSAMPLE  JSAMPLE
  ------------------
  317|  6.91M|      _JSAMPLE b = *bufferptr++;
  ------------------
  |  |  224|  6.91M|#define _JSAMPLE  JSAMPLE
  ------------------
  318|  6.91M|      bufferptr += source->png_alpha;
  319|  6.91M|      rgb_to_cmyk(_MAXJSAMPLE, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
  ------------------
  |  |  226|  6.91M|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|  6.91M|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
  320|  6.91M|      ptr += 4;
  321|  6.91M|    }
  322|  45.7k|  } else
  323|  7.13k|#endif
  324|  7.13k|  if (source->png_bit_depth == 16) {
  ------------------
  |  Branch (324:7): [True: 6.79k, False: 339]
  ------------------
  325|  6.79k|    unsigned short *bufferptr = (unsigned short *)source->iobuffer;
  326|  1.07M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (326:36): [True: 1.07M, False: 6.79k]
  ------------------
  327|  1.07M|      _JSAMPLE r = rescale[*bufferptr++];
  ------------------
  |  |  224|  1.07M|#define _JSAMPLE  JSAMPLE
  ------------------
  328|  1.07M|      _JSAMPLE g = rescale[*bufferptr++];
  ------------------
  |  |  224|  1.07M|#define _JSAMPLE  JSAMPLE
  ------------------
  329|  1.07M|      _JSAMPLE b = rescale[*bufferptr++];
  ------------------
  |  |  224|  1.07M|#define _JSAMPLE  JSAMPLE
  ------------------
  330|  1.07M|      bufferptr += source->png_alpha;
  331|  1.07M|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  332|  1.07M|                  ptr + 2, ptr + 3);
  333|  1.07M|      ptr += 4;
  334|  1.07M|    }
  335|  6.79k|  } else {
  336|    339|    register unsigned char *bufferptr = source->iobuffer;
  337|    339|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (337:36): [True: 0, False: 339]
  ------------------
  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|    339|  }
  347|  52.9k|  return 1;
  348|  52.9k|}
rdpng-8.c:get_indexed_row:
  353|    500|{
  354|       |/* This version is for reading 8-bit-per-channel indexed-color PNG files and
  355|       | * converting to extended RGB or CMYK.
  356|       | */
  357|    500|  png_source_ptr source = (png_source_ptr)sinfo;
  358|    500|  register _JSAMPROW ptr;
  359|    500|  register JSAMPLE *bufferptr = (JSAMPLE *)source->iobuffer;
  360|    500|  register _JSAMPLE *rescale = source->rescale;
  361|    500|  JDIMENSION col;
  362|       |
  363|    500|  get_raw_row(cinfo, sinfo);
  364|    500|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|    500|#define _buffer  buffer
  ------------------
  365|    500|#if BITS_IN_JSAMPLE == 8
  366|    500|  if (source->png_bit_depth == cinfo->data_precision) {
  ------------------
  |  Branch (366:7): [True: 442, False: 58]
  ------------------
  367|    442|    if (cinfo->in_color_space == JCS_GRAYSCALE) {
  ------------------
  |  Branch (367:9): [True: 34, False: 408]
  ------------------
  368|    283|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (368:38): [True: 249, False: 34]
  ------------------
  369|    249|        JSAMPLE index = *bufferptr++;
  370|       |
  371|    249|        if (index >= source->colormap.n_entries)
  ------------------
  |  Branch (371:13): [True: 5, False: 244]
  ------------------
  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|    249|        *ptr++ = source->colormap.entries[index].red;
  374|    249|      }
  375|    408|    } else if (cinfo->in_color_space == JCS_CMYK) {
  ------------------
  |  Branch (375:16): [True: 68, False: 340]
  ------------------
  376|  1.21k|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (376:38): [True: 1.15k, False: 68]
  ------------------
  377|  1.15k|        JSAMPLE index = *bufferptr++;
  378|       |
  379|  1.15k|        if (index >= source->colormap.n_entries)
  ------------------
  |  Branch (379:13): [True: 14, False: 1.13k]
  ------------------
  380|     14|          ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  ------------------
  |  |  240|     14|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     14|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  381|  1.15k|        rgb_to_cmyk(_MAXJSAMPLE, source->colormap.entries[index].red,
  ------------------
  |  |  226|  1.15k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|  1.15k|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
  382|  1.15k|                    source->colormap.entries[index].green,
  383|  1.15k|                    source->colormap.entries[index].blue, ptr, ptr + 1,
  384|  1.15k|                    ptr + 2, ptr + 3);
  385|  1.15k|        ptr += 4;
  386|  1.15k|      }
  387|    340|    } else {
  388|    340|      register int rindex = rgb_red[cinfo->in_color_space];
  389|    340|      register int gindex = rgb_green[cinfo->in_color_space];
  390|    340|      register int bindex = rgb_blue[cinfo->in_color_space];
  391|    340|      register int aindex = alpha_index[cinfo->in_color_space];
  392|    340|      register int ps = rgb_pixelsize[cinfo->in_color_space];
  393|       |
  394|  6.09k|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (394:38): [True: 5.75k, False: 340]
  ------------------
  395|  5.75k|        JSAMPLE index = *bufferptr++;
  396|       |
  397|  5.75k|        if (index >= source->colormap.n_entries)
  ------------------
  |  Branch (397:13): [True: 70, False: 5.68k]
  ------------------
  398|     70|          ERREXIT(cinfo, JERR_PNG_OUTOFRANGE);
  ------------------
  |  |  240|     70|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     70|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  399|  5.75k|        ptr[rindex] = source->colormap.entries[index].red;
  400|  5.75k|        ptr[gindex] = source->colormap.entries[index].green;
  401|  5.75k|        ptr[bindex] = source->colormap.entries[index].blue;
  402|  5.75k|        if (aindex >= 0)
  ------------------
  |  Branch (402:13): [True: 1.13k, False: 4.61k]
  ------------------
  403|  1.13k|          ptr[aindex] = _MAXJSAMPLE;
  ------------------
  |  |  226|  1.13k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|  1.13k|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
  404|  5.75k|        ptr += ps;
  405|  5.75k|      }
  406|    340|    }
  407|    442|  } else
  408|     58|#endif
  409|     58|  {
  410|     58|    if (cinfo->in_color_space == JCS_GRAYSCALE) {
  ------------------
  |  Branch (410:9): [True: 0, False: 58]
  ------------------
  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|     58|    } else if (cinfo->in_color_space == JCS_CMYK) {
  ------------------
  |  Branch (418:16): [True: 0, False: 58]
  ------------------
  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|     58|    } else {
  432|     58|      register int rindex = rgb_red[cinfo->in_color_space];
  433|     58|      register int gindex = rgb_green[cinfo->in_color_space];
  434|     58|      register int bindex = rgb_blue[cinfo->in_color_space];
  435|     58|      register int aindex = alpha_index[cinfo->in_color_space];
  436|     58|      register int ps = rgb_pixelsize[cinfo->in_color_space];
  437|       |
  438|     58|      for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (438:38): [True: 0, False: 58]
  ------------------
  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|     58|    }
  451|     58|  }
  452|    500|  return 1;
  453|    500|}
rdpng-8.c:read_icc_profile_png:
  665|  6.20k|{
  666|  6.20k|  png_source_ptr source = (png_source_ptr)sinfo;
  667|  6.20k|  struct spng_iccp iccp;
  668|       |
  669|  6.20k|  if (!icc_data_ptr || !icc_data_len)
  ------------------
  |  Branch (669:7): [True: 0, False: 6.20k]
  |  Branch (669:24): [True: 0, False: 6.20k]
  ------------------
  670|      0|    ERREXIT(cinfo, JERR_BUFFER_SIZE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  671|       |
  672|  6.20k|  if (source->ctx && spng_get_iccp(source->ctx, &iccp) == 0) {
  ------------------
  |  Branch (672:7): [True: 6.20k, False: 0]
  |  Branch (672:22): [True: 6, False: 6.20k]
  ------------------
  673|      6|    *icc_data_ptr = (JOCTET *)iccp.profile;
  674|      6|    *icc_data_len = (unsigned int)iccp.profile_len;
  675|      6|    return TRUE;
  ------------------
  |  |  210|      6|#define TRUE    1
  ------------------
  676|      6|  }
  677|       |
  678|  6.20k|  return FALSE;
  ------------------
  |  |  207|  6.20k|#define FALSE   0               /* values of boolean */
  ------------------
  679|  6.20k|}
rdpng-8.c:finish_input_png:
  688|  30.6k|{
  689|  30.6k|  png_source_ptr source = (png_source_ptr)sinfo;
  690|       |
  691|  30.6k|  if (source->ctx) {
  ------------------
  |  Branch (691:7): [True: 30.6k, False: 0]
  ------------------
  692|  30.6k|    spng_decode_chunks(source->ctx);
  693|  30.6k|    spng_ctx_free(source->ctx);
  694|       |    source->ctx = NULL;
  695|  30.6k|  }
  696|  30.6k|}

jinit_read_ppm:
  924|  15.3k|{
  925|  15.3k|  ppm_source_ptr source;
  926|       |
  927|  15.3k|#if BITS_IN_JSAMPLE == 8
  928|  15.3k|  if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
  ------------------
  |  |   12|  30.6k|#define BITS_IN_JSAMPLE  8
  ------------------
  |  Branch (928:7): [True: 0, False: 15.3k]
  |  Branch (928:50): [True: 0, False: 15.3k]
  ------------------
  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|  15.3k|  source = (ppm_source_ptr)
  937|  15.3k|    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  15.3k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  938|  15.3k|                                sizeof(ppm_source_struct));
  939|       |  /* Fill in method ptrs, except get_pixel_rows which start_input sets */
  940|  15.3k|  source->pub.start_input = start_input_ppm;
  941|  15.3k|  source->pub.read_icc_profile = read_icc_profile_ppm;
  942|  15.3k|  source->pub.finish_input = finish_input_ppm;
  943|  15.3k|  source->pub.max_pixels = 0;
  944|       |
  945|  15.3k|  return (cjpeg_source_ptr)source;
  946|  15.3k|}
rdppm-8.c:start_input_ppm:
  703|  15.3k|{
  704|  15.3k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  705|  15.3k|  int c;
  706|  15.3k|  unsigned int w, h, maxval;
  707|  15.3k|  boolean need_iobuffer, use_raw_buffer, need_rescale;
  708|       |
  709|  15.3k|  if (getc(source->pub.input_file) != 'P')
  ------------------
  |  Branch (709:7): [True: 0, False: 15.3k]
  ------------------
  710|      0|    ERREXIT(cinfo, JERR_PPM_NOT);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  711|       |
  712|  15.3k|  c = getc(source->pub.input_file); /* subformat discriminator character */
  713|       |
  714|       |  /* detect unsupported variants (ie, PBM) before trying to read header */
  715|  15.3k|  switch (c) {
  716|  1.32k|  case '2':                     /* it's a text-format PGM file */
  ------------------
  |  Branch (716:3): [True: 1.32k, False: 13.9k]
  ------------------
  717|  2.87k|  case '3':                     /* it's a text-format PPM file */
  ------------------
  |  Branch (717:3): [True: 1.55k, False: 13.7k]
  ------------------
  718|  11.6k|  case '5':                     /* it's a raw-format PGM file */
  ------------------
  |  Branch (718:3): [True: 8.82k, False: 6.48k]
  ------------------
  719|  15.2k|  case '6':                     /* it's a raw-format PPM file */
  ------------------
  |  Branch (719:3): [True: 3.59k, False: 11.7k]
  ------------------
  720|  15.2k|    break;
  721|     21|  default:
  ------------------
  |  Branch (721:3): [True: 21, False: 15.2k]
  ------------------
  722|     21|    ERREXIT(cinfo, JERR_PPM_NOT);
  ------------------
  |  |  240|     21|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     21|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  723|     21|    break;
  724|  15.3k|  }
  725|       |
  726|       |  /* fetch the remaining header info */
  727|  15.2k|  w = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  728|  15.2k|  h = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  729|  15.2k|  maxval = read_pbm_integer(cinfo, source->pub.input_file, 65535);
  730|       |
  731|  15.2k|  if (w <= 0 || h <= 0 || maxval <= 0) /* error check */
  ------------------
  |  Branch (731:7): [True: 1.14k, False: 14.1k]
  |  Branch (731:17): [True: 14, False: 14.1k]
  |  Branch (731:27): [True: 7, False: 14.1k]
  ------------------
  732|     35|    ERREXIT(cinfo, JERR_PPM_NOT);
  ------------------
  |  |  240|     35|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     35|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  733|  15.2k|  if (w > JPEG_MAX_DIMENSION || h > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  30.5k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
                if (w > JPEG_MAX_DIMENSION || h > JPEG_MAX_DIMENSION)
  ------------------
  |  |  158|  14.1k|#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  ------------------
  |  Branch (733:7): [True: 1.16k, False: 14.1k]
  |  Branch (733:33): [True: 7, False: 14.1k]
  ------------------
  734|     14|    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, JPEG_MAX_DIMENSION);
  ------------------
  |  |  243|     14|  ((cinfo)->err->msg_code = (code), \
  |  |  244|     14|   (cinfo)->err->msg_parm.i[0] = (p1), \
  |  |  245|     14|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  735|  15.2k|  if (sinfo->max_pixels && (unsigned long long)w * h > sinfo->max_pixels)
  ------------------
  |  Branch (735:7): [True: 14.1k, False: 1.17k]
  |  Branch (735:28): [True: 231, False: 13.8k]
  ------------------
  736|    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)))
  ------------------
  737|       |
  738|  15.2k|  cinfo->image_width = (JDIMENSION)w;
  739|  15.2k|  cinfo->image_height = (JDIMENSION)h;
  740|  15.2k|  source->maxval = maxval;
  741|       |
  742|       |  /* initialize flags to most common settings */
  743|  15.2k|  need_iobuffer = TRUE;         /* do we need an I/O buffer? */
  ------------------
  |  |  210|  15.2k|#define TRUE    1
  ------------------
  744|  15.2k|  use_raw_buffer = FALSE;       /* do we map input buffer onto I/O buffer? */
  ------------------
  |  |  207|  15.2k|#define FALSE   0               /* values of boolean */
  ------------------
  745|  15.2k|  need_rescale = TRUE;          /* do we need a rescale array? */
  ------------------
  |  |  210|  15.2k|#define TRUE    1
  ------------------
  746|       |
  747|  15.2k|  switch (c) {
  ------------------
  |  Branch (747:11): [True: 13.8k, False: 1.40k]
  ------------------
  748|    994|  case '2':                     /* it's a text-format PGM file */
  ------------------
  |  Branch (748:3): [True: 994, False: 14.2k]
  ------------------
  749|    994|    if (cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (749:9): [True: 0, False: 994]
  ------------------
  750|    994|        cinfo->in_color_space == JCS_RGB)
  ------------------
  |  Branch (750:9): [True: 0, False: 994]
  ------------------
  751|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  752|    994|    TRACEMS3(cinfo, 1, JTRC_PGM_TEXT, w, h, maxval);
  ------------------
  |  |  309|    994|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|    994|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 994]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|    994|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|    994|           (cinfo)->err->msg_code = (code); \
  |  |  312|    994|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  753|    994|    if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (753:9): [True: 142, False: 852]
  ------------------
  754|    142|      source->pub.get_pixel_rows = get_text_gray_row;
  755|    852|    else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|    852|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 852]
  |  |  |  Branch (78:22): [True: 710, False: 142]
  |  |  |  Branch (78:43): [True: 710, False: 0]
  |  |  ------------------
  ------------------
  756|    710|      source->pub.get_pixel_rows = get_text_gray_rgb_row;
  757|    142|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (757:14): [True: 142, False: 0]
  ------------------
  758|    142|      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|    994|    need_iobuffer = FALSE;
  ------------------
  |  |  207|    994|#define FALSE   0               /* values of boolean */
  ------------------
  762|    994|    break;
  763|       |
  764|  1.19k|  case '3':                     /* it's a text-format PPM file */
  ------------------
  |  Branch (764:3): [True: 1.19k, False: 14.0k]
  ------------------
  765|  1.19k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (765:9): [True: 0, False: 1.19k]
  ------------------
  766|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  767|  1.19k|    TRACEMS3(cinfo, 1, JTRC_PPM_TEXT, w, h, maxval);
  ------------------
  |  |  309|  1.19k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  1.19k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 1.19k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  1.19k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  1.19k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  1.19k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  768|  1.19k|    if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  1.19k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 1.19k]
  |  |  |  Branch (78:22): [True: 850, False: 340]
  |  |  |  Branch (78:43): [True: 850, False: 0]
  |  |  ------------------
  ------------------
  769|    850|      source->pub.get_pixel_rows = get_text_rgb_row;
  770|    340|    else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (770:14): [True: 170, False: 170]
  ------------------
  771|    170|      source->pub.get_pixel_rows = get_text_rgb_cmyk_row;
  772|    170|    else
  773|    170|      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    170|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    170|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  774|  1.19k|    need_iobuffer = FALSE;
  ------------------
  |  |  207|  1.19k|#define FALSE   0               /* values of boolean */
  ------------------
  775|  1.19k|    break;
  776|       |
  777|  8.36k|  case '5':                     /* it's a raw-format PGM file */
  ------------------
  |  Branch (777:3): [True: 8.36k, False: 6.92k]
  ------------------
  778|  8.36k|    if (cinfo->in_color_space == JCS_UNKNOWN ||
  ------------------
  |  Branch (778:9): [True: 0, False: 8.36k]
  ------------------
  779|  8.36k|        cinfo->in_color_space == JCS_RGB)
  ------------------
  |  Branch (779:9): [True: 0, False: 8.36k]
  ------------------
  780|      0|      cinfo->in_color_space = JCS_GRAYSCALE;
  781|  8.36k|    TRACEMS3(cinfo, 1, JTRC_PGM, w, h, maxval);
  ------------------
  |  |  309|  8.36k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  8.36k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 8.36k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  8.36k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  8.36k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  8.36k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  782|  8.36k|    if (maxval > 255) {
  ------------------
  |  Branch (782:9): [True: 798, False: 7.56k]
  ------------------
  783|    798|      if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (783:11): [True: 114, False: 684]
  ------------------
  784|    114|        source->pub.get_pixel_rows = get_word_gray_row;
  785|    684|      else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|    684|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 684]
  |  |  |  Branch (78:22): [True: 570, False: 114]
  |  |  |  Branch (78:43): [True: 570, False: 0]
  |  |  ------------------
  ------------------
  786|    570|        source->pub.get_pixel_rows = get_word_gray_rgb_row;
  787|    114|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (787:16): [True: 114, False: 0]
  ------------------
  788|    114|        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|    798|#if BITS_IN_JSAMPLE == 8
  792|  7.56k|    } else if (maxval <= _MAXJSAMPLE &&
  ------------------
  |  |  226|  7.56k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|  15.1k|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
  |  Branch (792:16): [True: 7.56k, False: 0]
  ------------------
  793|  7.56k|               maxval == ((1U << cinfo->data_precision) - 1U) &&
  ------------------
  |  Branch (793:16): [True: 896, False: 6.67k]
  ------------------
  794|    896|               cinfo->in_color_space == JCS_GRAYSCALE) {
  ------------------
  |  Branch (794:16): [True: 128, False: 768]
  ------------------
  795|    128|      source->pub.get_pixel_rows = get_raw_row;
  796|    128|      use_raw_buffer = TRUE;
  ------------------
  |  |  210|    128|#define TRUE    1
  ------------------
  797|    128|      need_rescale = FALSE;
  ------------------
  |  |  207|    128|#define FALSE   0               /* values of boolean */
  ------------------
  798|    128|#endif
  799|  7.43k|    } else {
  800|  7.43k|      if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (800:11): [True: 953, False: 6.48k]
  ------------------
  801|    953|        source->pub.get_pixel_rows = get_scaled_gray_row;
  802|  6.48k|      else if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  6.48k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 6.48k]
  |  |  |  Branch (78:22): [True: 5.40k, False: 1.08k]
  |  |  |  Branch (78:43): [True: 5.40k, False: 0]
  |  |  ------------------
  ------------------
  803|  5.40k|        source->pub.get_pixel_rows = get_gray_rgb_row;
  804|  1.08k|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (804:16): [True: 1.08k, False: 0]
  ------------------
  805|  1.08k|        source->pub.get_pixel_rows = get_gray_cmyk_row;
  806|      0|      else
  807|      0|        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|      0|  ((cinfo)->err->msg_code = (code), \
  |  |  241|      0|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  808|  7.43k|    }
  809|  8.36k|    break;
  810|       |
  811|  3.33k|  case '6':                     /* it's a raw-format PPM file */
  ------------------
  |  Branch (811:3): [True: 3.33k, False: 11.9k]
  ------------------
  812|  3.33k|    if (cinfo->in_color_space == JCS_UNKNOWN)
  ------------------
  |  Branch (812:9): [True: 0, False: 3.33k]
  ------------------
  813|      0|      cinfo->in_color_space = JCS_EXT_RGB;
  814|  3.33k|    TRACEMS3(cinfo, 1, JTRC_PPM, w, h, maxval);
  ------------------
  |  |  309|  3.33k|  MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
  |  |  ------------------
  |  |  |  |  279|  3.33k|#define MAKESTMT(stuff)         do { stuff } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (279:53): [Folded, False: 3.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  310|  3.33k|           _mp[0] = (p1);  _mp[1] = (p2);  _mp[2] = (p3); \
  |  |  311|  3.33k|           (cinfo)->err->msg_code = (code); \
  |  |  312|  3.33k|           (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
  ------------------
  815|  3.33k|    if (maxval > 255) {
  ------------------
  |  Branch (815:9): [True: 1.04k, False: 2.28k]
  ------------------
  816|  1.04k|      if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  1.04k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 1.04k]
  |  |  |  Branch (78:22): [True: 745, False: 298]
  |  |  |  Branch (78:43): [True: 745, False: 0]
  |  |  ------------------
  ------------------
  817|    745|        source->pub.get_pixel_rows = get_word_rgb_row;
  818|    298|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (818:16): [True: 149, False: 149]
  ------------------
  819|    149|        source->pub.get_pixel_rows = get_word_rgb_cmyk_row;
  820|    149|      else
  821|    149|        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    149|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    149|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  822|  1.04k|#if BITS_IN_JSAMPLE == 8
  823|  2.28k|    } else if (maxval <= _MAXJSAMPLE &&
  ------------------
  |  |  226|  2.28k|#define _MAXJSAMPLE  MAXJSAMPLE
  |  |  ------------------
  |  |  |  |   52|  4.57k|#define MAXJSAMPLE       255
  |  |  ------------------
  ------------------
  |  Branch (823:16): [True: 2.28k, False: 0]
  ------------------
  824|  2.28k|               maxval == ((1U << cinfo->data_precision) - 1U) &&
  ------------------
  |  Branch (824:16): [True: 462, False: 1.82k]
  ------------------
  825|    462|#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3
  826|    462|               (cinfo->in_color_space == JCS_EXT_RGB ||
  ------------------
  |  Branch (826:17): [True: 66, False: 396]
  ------------------
  827|    396|                cinfo->in_color_space == JCS_RGB)) {
  ------------------
  |  Branch (827:17): [True: 0, False: 396]
  ------------------
  828|       |#else
  829|       |               cinfo->in_color_space == JCS_EXT_RGB) {
  830|       |#endif
  831|     66|      source->pub.get_pixel_rows = get_raw_row;
  832|     66|      use_raw_buffer = TRUE;
  ------------------
  |  |  210|     66|#define TRUE    1
  ------------------
  833|     66|      need_rescale = FALSE;
  ------------------
  |  |  207|     66|#define FALSE   0               /* values of boolean */
  ------------------
  834|     66|#endif
  835|  2.22k|    } else {
  836|  2.22k|      if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  2.22k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 2.22k]
  |  |  |  Branch (78:22): [True: 1.56k, False: 654]
  |  |  |  Branch (78:43): [True: 1.56k, False: 0]
  |  |  ------------------
  ------------------
  837|  1.56k|        source->pub.get_pixel_rows = get_rgb_row;
  838|    654|      else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (838:16): [True: 327, False: 327]
  ------------------
  839|    327|        source->pub.get_pixel_rows = get_rgb_cmyk_row;
  840|    327|      else
  841|    327|        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
  ------------------
  |  |  240|    327|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    327|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  842|  2.22k|    }
  843|  3.33k|    break;
  844|  15.2k|  }
  845|       |
  846|  13.2k|  if (IsExtRGB(cinfo->in_color_space))
  ------------------
  |  |   78|  13.2k|  (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
  |  |  ------------------
  |  |  |  Branch (78:4): [True: 0, False: 13.2k]
  |  |  |  Branch (78:22): [True: 9.91k, False: 3.32k]
  |  |  |  Branch (78:43): [True: 9.91k, False: 0]
  |  |  ------------------
  ------------------
  847|  9.91k|    cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
  848|  3.32k|  else if (cinfo->in_color_space == JCS_GRAYSCALE)
  ------------------
  |  Branch (848:12): [True: 1.33k, False: 1.98k]
  ------------------
  849|  1.33k|    cinfo->input_components = 1;
  850|  1.98k|  else if (cinfo->in_color_space == JCS_CMYK)
  ------------------
  |  Branch (850:12): [True: 1.98k, False: 0]
  ------------------
  851|  1.98k|    cinfo->input_components = 4;
  852|       |
  853|       |  /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */
  854|  13.2k|  if (need_iobuffer) {
  ------------------
  |  Branch (854:7): [True: 11.2k, False: 2.01k]
  ------------------
  855|  11.2k|    if (c == '6')
  ------------------
  |  Branch (855:9): [True: 2.85k, False: 8.36k]
  ------------------
  856|  2.85k|      source->buffer_width = (size_t)w * 3 * (maxval <= 255 ? 1 : 2);
  ------------------
  |  Branch (856:47): [True: 1.96k, False: 894]
  ------------------
  857|  8.36k|    else
  858|  8.36k|      source->buffer_width = (size_t)w * (maxval <= 255 ? 1 : 2);
  ------------------
  |  Branch (858:43): [True: 7.56k, False: 798]
  ------------------
  859|  11.2k|    source->iobuffer = (unsigned char *)
  860|  11.2k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  11.2k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  861|  11.2k|                                  source->buffer_width);
  862|  11.2k|  }
  863|       |
  864|       |  /* Create compressor input buffer. */
  865|  13.2k|  if (use_raw_buffer) {
  ------------------
  |  Branch (865:7): [True: 194, False: 13.0k]
  ------------------
  866|       |    /* For unscaled raw-input case, we can just map it onto the I/O buffer. */
  867|       |    /* Synthesize a _JSAMPARRAY pointer structure */
  868|    194|    source->pixrow = (_JSAMPROW)source->iobuffer;
  869|    194|    source->pub._buffer = &source->pixrow;
  ------------------
  |  |  326|    194|#define _buffer  buffer
  ------------------
  870|    194|    source->pub.buffer_height = 1;
  871|  13.0k|  } else {
  872|       |    /* Need to translate anyway, so make a separate sample buffer. */
  873|  13.0k|    source->pub._buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
  ------------------
  |  |  326|  13.0k|#define _buffer  buffer
  ------------------
  874|  13.0k|      ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  13.0k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  875|  13.0k|       (JDIMENSION)w * cinfo->input_components, (JDIMENSION)1);
  876|  13.0k|    source->pub.buffer_height = 1;
  877|  13.0k|  }
  878|       |
  879|       |  /* Compute the rescaling array if required. */
  880|  13.2k|  if (need_rescale) {
  ------------------
  |  Branch (880:7): [True: 13.0k, False: 194]
  ------------------
  881|  13.0k|    size_t val, half_maxval;
  882|       |
  883|       |    /* On 16-bit-int machines we have to be careful of maxval = 65535 */
  884|  13.0k|    source->rescale = (_JSAMPLE *)
  885|  13.0k|      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
  ------------------
  |  |  889|  13.0k|#define JPOOL_IMAGE      1      /* lasts until done with image/datastream */
  ------------------
  886|  13.0k|                                  (MAX(maxval, 255) + 1L) * sizeof(_JSAMPLE));
  ------------------
  |  |  513|  13.0k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 1.89k, False: 11.1k]
  |  |  ------------------
  ------------------
  887|  13.0k|    memset(source->rescale, 0, (MAX(maxval, 255) + 1L) * sizeof(_JSAMPLE));
  ------------------
  |  |  513|  13.0k|#define MAX(a, b)       ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (513:26): [True: 1.89k, False: 11.1k]
  |  |  ------------------
  ------------------
  888|  13.0k|    half_maxval = (size_t)maxval / 2;
  889|  22.5M|    for (val = 0; val <= (size_t)maxval; val++) {
  ------------------
  |  Branch (889:19): [True: 22.4M, False: 13.0k]
  ------------------
  890|       |      /* The multiplication here must be done in 32 bits to avoid overflow */
  891|  22.4M|      source->rescale[val] =
  892|  22.4M|        (_JSAMPLE)((val * ((1 << cinfo->data_precision) - 1) + half_maxval) /
  893|  22.4M|                   maxval);
  894|  22.4M|    }
  895|  13.0k|  }
  896|  13.2k|}
rdppm-8.c:read_pbm_integer:
   92|   113k|{
   93|   113k|  register int ch;
   94|   113k|  register unsigned int val;
   95|       |
   96|       |  /* Skip any leading whitespace */
   97|   119k|  do {
   98|   119k|    ch = pbm_getc(infile);
   99|   119k|    if (ch == EOF)
  ------------------
  |  Branch (99:9): [True: 2.60k, False: 117k]
  ------------------
  100|  2.60k|      ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|  2.60k|  ((cinfo)->err->msg_code = (code), \
  |  |  241|  2.60k|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  101|   119k|  } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
  ------------------
  |  Branch (101:12): [True: 3.98k, False: 115k]
  |  Branch (101:25): [True: 1.35k, False: 114k]
  |  Branch (101:39): [True: 2.99k, False: 111k]
  |  Branch (101:53): [True: 1.11k, False: 110k]
  ------------------
  102|       |
  103|   113k|  if (ch < '0' || ch > '9')
  ------------------
  |  Branch (103:7): [True: 2.73k, False: 110k]
  |  Branch (103:19): [True: 84, False: 110k]
  ------------------
  104|    213|    ERREXIT(cinfo, JERR_PPM_NONNUMERIC);
  ------------------
  |  |  240|    213|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    213|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  105|       |
  106|   113k|  val = ch - '0';
  107|   148k|  while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') {
  ------------------
  |  Branch (107:10): [True: 102k, False: 46.3k]
  |  Branch (107:44): [True: 35.5k, False: 66.7k]
  ------------------
  108|  35.5k|    val *= 10;
  109|  35.5k|    val += ch - '0';
  110|  35.5k|    if (val > maxval)
  ------------------
  |  Branch (110:9): [True: 132, False: 35.3k]
  ------------------
  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|  35.5k|  }
  113|       |
  114|   113k|  return val;
  115|   113k|}
rdppm-8.c:pbm_getc:
   73|   265k|{
   74|   265k|  register int ch;
   75|       |
   76|   265k|  ch = getc(infile);
   77|   265k|  if (ch == '#') {
  ------------------
  |  Branch (77:7): [True: 3.56k, False: 262k]
  ------------------
   78|  24.4k|    do {
   79|  24.4k|      ch = getc(infile);
   80|  24.4k|    } while (ch != '\n' && ch != EOF);
  ------------------
  |  Branch (80:14): [True: 21.2k, False: 3.19k]
  |  Branch (80:28): [True: 20.8k, False: 362]
  ------------------
   81|  3.56k|  }
   82|   265k|  return ch;
   83|   265k|}
rdppm-8.c:get_text_gray_row:
  133|  1.28k|{
  134|  1.28k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  135|  1.28k|  FILE *infile = source->pub.input_file;
  136|  1.28k|  register _JSAMPROW ptr;
  137|  1.28k|  register _JSAMPLE *rescale = source->rescale;
  138|  1.28k|  JDIMENSION col;
  139|  1.28k|  unsigned int maxval = source->maxval;
  140|       |
  141|  1.28k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  1.28k|#define _buffer  buffer
  ------------------
  142|  3.80k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (142:34): [True: 2.52k, False: 1.28k]
  ------------------
  143|  2.52k|    *ptr++ = rescale[read_pbm_integer(cinfo, infile, maxval)];
  144|  2.52k|  }
  145|  1.28k|  return 1;
  146|  1.28k|}
rdppm-8.c:get_text_gray_rgb_row:
  161|  6.41k|{
  162|  6.41k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  163|  6.41k|  FILE *infile = source->pub.input_file;
  164|  6.41k|  register _JSAMPROW ptr;
  165|  6.41k|  register _JSAMPLE *rescale = source->rescale;
  166|  6.41k|  JDIMENSION col;
  167|  6.41k|  unsigned int maxval = source->maxval;
  168|  6.41k|  register int rindex = rgb_red[cinfo->in_color_space];
  169|  6.41k|  register int gindex = rgb_green[cinfo->in_color_space];
  170|  6.41k|  register int bindex = rgb_blue[cinfo->in_color_space];
  171|  6.41k|  register int aindex = alpha_index[cinfo->in_color_space];
  172|  6.41k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  173|       |
  174|  6.41k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  6.41k|#define _buffer  buffer
  ------------------
  175|  6.41k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (175:7): [True: 1.25k, False: 5.16k]
  ------------------
  176|  1.25k|    if (aindex >= 0)
  ------------------
  |  Branch (176:9): [True: 250, False: 1.00k]
  ------------------
  177|    250|      GRAY_RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
  ------------------
  |  |  149|    250|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|    899|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 649, False: 250]
  |  |  ------------------
  |  |  151|    649|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|    649|    alpha_set_op \
  |  |  153|    649|    ptr += ps; \
  |  |  154|    649|  } \
  |  |  155|    250|}
  ------------------
  178|  1.25k|                         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.59k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 2.59k, False: 1.00k]
  |  |  ------------------
  |  |  151|  2.59k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  2.59k|    alpha_set_op \
  |  |  153|  2.59k|    ptr += ps; \
  |  |  154|  2.59k|  } \
  |  |  155|  1.00k|}
  ------------------
  181|  5.16k|  } else {
  182|  5.16k|    if (aindex >= 0)
  ------------------
  |  Branch (182:9): [True: 1.03k, False: 4.13k]
  ------------------
  183|  1.03k|      GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
  ------------------
  |  |  149|  1.03k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  2.90k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 1.87k, False: 1.03k]
  |  |  ------------------
  |  |  151|  1.87k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  1.87k|    alpha_set_op \
  |  |  153|  1.87k|    ptr += ps; \
  |  |  154|  1.87k|  } \
  |  |  155|  1.03k|}
  ------------------
  184|  5.16k|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  185|  4.13k|    else
  186|  4.13k|      GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
  ------------------
  |  |  149|  4.13k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  11.6k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 7.48k, False: 4.13k]
  |  |  ------------------
  |  |  151|  7.48k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  7.48k|    alpha_set_op \
  |  |  153|  7.48k|    ptr += ps; \
  |  |  154|  7.48k|  } \
  |  |  155|  4.13k|}
  ------------------
  187|  5.16k|  }
  188|  6.41k|  return 1;
  189|  6.41k|}
rdppm-8.c:get_text_gray_cmyk_row:
  196|  1.28k|{
  197|  1.28k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  198|  1.28k|  FILE *infile = source->pub.input_file;
  199|  1.28k|  register _JSAMPROW ptr;
  200|  1.28k|  register _JSAMPLE *rescale = source->rescale;
  201|  1.28k|  JDIMENSION col;
  202|  1.28k|  unsigned int maxval = source->maxval;
  203|       |
  204|  1.28k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  1.28k|#define _buffer  buffer
  ------------------
  205|  1.28k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (205:7): [True: 250, False: 1.03k]
  ------------------
  206|    899|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (206:36): [True: 649, False: 250]
  ------------------
  207|    649|      _JSAMPLE gray = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  224|    649|#define _JSAMPLE  JSAMPLE
  ------------------
  208|    649|      rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
  209|    649|      ptr += 4;
  210|    649|    }
  211|  1.03k|  } else {
  212|  2.90k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (212:36): [True: 1.87k, False: 1.03k]
  ------------------
  213|  1.87k|      _JSAMPLE gray = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  224|  1.87k|#define _JSAMPLE  JSAMPLE
  ------------------
  214|  1.87k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  215|  1.87k|                  ptr + 1, ptr + 2, ptr + 3);
  216|  1.87k|      ptr += 4;
  217|  1.87k|    }
  218|  1.03k|  }
  219|  1.28k|  return 1;
  220|  1.28k|}
rdppm-8.c:get_text_rgb_row:
  236|  8.72k|{
  237|  8.72k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  238|  8.72k|  FILE *infile = source->pub.input_file;
  239|  8.72k|  register _JSAMPROW ptr;
  240|  8.72k|  register _JSAMPLE *rescale = source->rescale;
  241|  8.72k|  JDIMENSION col;
  242|  8.72k|  unsigned int maxval = source->maxval;
  243|  8.72k|  register int rindex = rgb_red[cinfo->in_color_space];
  244|  8.72k|  register int gindex = rgb_green[cinfo->in_color_space];
  245|  8.72k|  register int bindex = rgb_blue[cinfo->in_color_space];
  246|  8.72k|  register int aindex = alpha_index[cinfo->in_color_space];
  247|  8.72k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  248|       |
  249|  8.72k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  8.72k|#define _buffer  buffer
  ------------------
  250|  8.72k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (250:7): [True: 2.61k, False: 6.11k]
  ------------------
  251|  2.61k|    if (aindex >= 0)
  ------------------
  |  Branch (251:9): [True: 523, False: 2.09k]
  ------------------
  252|    523|      RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
  ------------------
  |  |  223|    523|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  1.50k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 984, False: 523]
  |  |  ------------------
  |  |  225|    984|    ptr[rindex] = read_op; \
  |  |  226|    984|    ptr[gindex] = read_op; \
  |  |  227|    984|    ptr[bindex] = read_op; \
  |  |  228|    984|    alpha_set_op \
  |  |  229|    984|    ptr += ps; \
  |  |  230|    984|  } \
  |  |  231|    523|}
  ------------------
  253|  2.61k|                    ptr[aindex] = (_JSAMPLE)maxval;)
  254|  2.09k|    else
  255|  2.09k|      RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
  ------------------
  |  |  223|  2.09k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  6.02k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 3.93k, False: 2.09k]
  |  |  ------------------
  |  |  225|  3.93k|    ptr[rindex] = read_op; \
  |  |  226|  3.93k|    ptr[gindex] = read_op; \
  |  |  227|  3.93k|    ptr[bindex] = read_op; \
  |  |  228|  3.93k|    alpha_set_op \
  |  |  229|  3.93k|    ptr += ps; \
  |  |  230|  3.93k|  } \
  |  |  231|  2.09k|}
  ------------------
  256|  6.11k|  } else {
  257|  6.11k|    if (aindex >= 0)
  ------------------
  |  Branch (257:9): [True: 1.22k, False: 4.88k]
  ------------------
  258|  1.22k|      RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
  ------------------
  |  |  223|  1.22k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  3.19k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 1.97k, False: 1.22k]
  |  |  ------------------
  |  |  225|  1.97k|    ptr[rindex] = read_op; \
  |  |  226|  1.97k|    ptr[gindex] = read_op; \
  |  |  227|  1.97k|    ptr[bindex] = read_op; \
  |  |  228|  1.97k|    alpha_set_op \
  |  |  229|  1.97k|    ptr += ps; \
  |  |  230|  1.97k|  } \
  |  |  231|  1.22k|}
  ------------------
  259|  6.11k|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  260|  4.88k|    else
  261|  4.88k|      RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
  ------------------
  |  |  223|  4.88k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  12.7k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 7.90k, False: 4.88k]
  |  |  ------------------
  |  |  225|  7.90k|    ptr[rindex] = read_op; \
  |  |  226|  7.90k|    ptr[gindex] = read_op; \
  |  |  227|  7.90k|    ptr[bindex] = read_op; \
  |  |  228|  7.90k|    alpha_set_op \
  |  |  229|  7.90k|    ptr += ps; \
  |  |  230|  7.90k|  } \
  |  |  231|  4.88k|}
  ------------------
  262|  6.11k|  }
  263|  8.72k|  return 1;
  264|  8.72k|}
rdppm-8.c:get_text_rgb_cmyk_row:
  271|  1.74k|{
  272|  1.74k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  273|  1.74k|  FILE *infile = source->pub.input_file;
  274|  1.74k|  register _JSAMPROW ptr;
  275|  1.74k|  register _JSAMPLE *rescale = source->rescale;
  276|  1.74k|  JDIMENSION col;
  277|  1.74k|  unsigned int maxval = source->maxval;
  278|       |
  279|  1.74k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  1.74k|#define _buffer  buffer
  ------------------
  280|  1.74k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (280:7): [True: 523, False: 1.22k]
  ------------------
  281|  1.50k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (281:36): [True: 984, False: 523]
  ------------------
  282|    984|      _JSAMPLE r = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  224|    984|#define _JSAMPLE  JSAMPLE
  ------------------
  283|    984|      _JSAMPLE g = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  224|    984|#define _JSAMPLE  JSAMPLE
  ------------------
  284|    984|      _JSAMPLE b = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
  ------------------
  |  |  224|    984|#define _JSAMPLE  JSAMPLE
  ------------------
  285|    984|      rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
  286|    984|      ptr += 4;
  287|    984|    }
  288|  1.22k|  } else {
  289|  3.19k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (289:36): [True: 1.97k, False: 1.22k]
  ------------------
  290|  1.97k|      _JSAMPLE r = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  224|  1.97k|#define _JSAMPLE  JSAMPLE
  ------------------
  291|  1.97k|      _JSAMPLE g = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  224|  1.97k|#define _JSAMPLE  JSAMPLE
  ------------------
  292|  1.97k|      _JSAMPLE b = rescale[read_pbm_integer(cinfo, infile, maxval)];
  ------------------
  |  |  224|  1.97k|#define _JSAMPLE  JSAMPLE
  ------------------
  293|  1.97k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  294|  1.97k|                  ptr + 2, ptr + 3);
  295|  1.97k|      ptr += 4;
  296|  1.97k|    }
  297|  1.22k|  }
  298|  1.74k|  return 1;
  299|  1.74k|}
rdppm-8.c:get_word_gray_row:
  491|  1.56k|{
  492|  1.56k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  493|  1.56k|  register _JSAMPROW ptr;
  494|  1.56k|  register unsigned char *bufferptr;
  495|  1.56k|  register _JSAMPLE *rescale = source->rescale;
  496|  1.56k|  JDIMENSION col;
  497|  1.56k|  unsigned int maxval = source->maxval;
  498|       |
  499|  1.56k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  1.56k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (499:7): [True: 66, False: 1.50k]
  ------------------
  500|     66|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     66|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     66|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  501|  1.56k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  1.56k|#define _buffer  buffer
  ------------------
  502|  1.56k|  bufferptr = source->iobuffer;
  503|  4.09k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (503:34): [True: 2.52k, False: 1.56k]
  ------------------
  504|  2.52k|    register unsigned int temp;
  505|  2.52k|    temp  = (*bufferptr++) << 8;
  506|  2.52k|    temp |= (*bufferptr++);
  507|  2.52k|    if (temp > maxval)
  ------------------
  |  Branch (507:9): [True: 41, False: 2.48k]
  ------------------
  508|     41|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     41|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     41|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  509|  2.52k|    *ptr++ = rescale[temp];
  510|  2.52k|  }
  511|  1.56k|  return 1;
  512|  1.56k|}
rdppm-8.c:get_word_gray_rgb_row:
  518|  7.83k|{
  519|  7.83k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  520|  7.83k|  register _JSAMPROW ptr;
  521|  7.83k|  register unsigned char *bufferptr;
  522|  7.83k|  register _JSAMPLE *rescale = source->rescale;
  523|  7.83k|  JDIMENSION col;
  524|  7.83k|  unsigned int maxval = source->maxval;
  525|  7.83k|  register int rindex = rgb_red[cinfo->in_color_space];
  526|  7.83k|  register int gindex = rgb_green[cinfo->in_color_space];
  527|  7.83k|  register int bindex = rgb_blue[cinfo->in_color_space];
  528|  7.83k|  register int aindex = alpha_index[cinfo->in_color_space];
  529|  7.83k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  530|       |
  531|  7.83k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  7.83k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (531:7): [True: 330, False: 7.50k]
  ------------------
  532|    330|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    330|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    330|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  533|  7.83k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  7.83k|#define _buffer  buffer
  ------------------
  534|  7.83k|  bufferptr = source->iobuffer;
  535|  20.4k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (535:34): [True: 12.6k, False: 7.83k]
  ------------------
  536|  12.6k|    register unsigned int temp;
  537|  12.6k|    temp  = (*bufferptr++) << 8;
  538|  12.6k|    temp |= (*bufferptr++);
  539|  12.6k|    if (temp > maxval)
  ------------------
  |  Branch (539:9): [True: 205, False: 12.4k]
  ------------------
  540|    205|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    205|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    205|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  541|  12.6k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = rescale[temp];
  542|  12.6k|    if (aindex >= 0)
  ------------------
  |  Branch (542:9): [True: 2.48k, False: 10.1k]
  ------------------
  543|  2.48k|      ptr[aindex] = (1 << cinfo->data_precision) - 1;
  544|  12.6k|    ptr += ps;
  545|  12.6k|  }
  546|  7.83k|  return 1;
  547|  7.83k|}
rdppm-8.c:get_word_gray_cmyk_row:
  553|  1.56k|{
  554|  1.56k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  555|  1.56k|  register _JSAMPROW ptr;
  556|  1.56k|  register unsigned char *bufferptr;
  557|  1.56k|  register _JSAMPLE *rescale = source->rescale;
  558|  1.56k|  JDIMENSION col;
  559|  1.56k|  unsigned int maxval = source->maxval;
  560|       |
  561|  1.56k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  1.56k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (561:7): [True: 66, False: 1.50k]
  ------------------
  562|     66|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     66|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     66|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  563|  1.56k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  1.56k|#define _buffer  buffer
  ------------------
  564|  1.56k|  bufferptr = source->iobuffer;
  565|  1.56k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (565:7): [True: 0, False: 1.56k]
  ------------------
  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.56k|  } else {
  577|  4.09k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (577:36): [True: 2.52k, False: 1.56k]
  ------------------
  578|  2.52k|      register unsigned int temp;
  579|  2.52k|      _JSAMPLE gray;
  ------------------
  |  |  224|  2.52k|#define _JSAMPLE  JSAMPLE
  ------------------
  580|  2.52k|      temp  = (*bufferptr++) << 8;
  581|  2.52k|      temp |= (*bufferptr++);
  582|  2.52k|      if (temp > maxval)
  ------------------
  |  Branch (582:11): [True: 41, False: 2.48k]
  ------------------
  583|     41|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     41|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     41|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  584|  2.52k|      gray = rescale[temp];
  585|  2.52k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  586|  2.52k|                  ptr + 1, ptr + 2, ptr + 3);
  587|  2.52k|      ptr += 4;
  588|  2.52k|    }
  589|  1.56k|  }
  590|  1.56k|  return 1;
  591|  1.56k|}
rdppm-8.c:get_raw_row:
  477|   175k|{
  478|   175k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  479|       |
  480|   175k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|   175k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (480:7): [True: 75, False: 175k]
  ------------------
  481|     75|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     75|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     75|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  482|   175k|  return 1;
  483|   175k|}
rdppm-8.c:get_scaled_gray_row:
  305|  2.98M|{
  306|  2.98M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  307|  2.98M|  register _JSAMPROW ptr;
  308|  2.98M|  register unsigned char *bufferptr;
  309|  2.98M|  register _JSAMPLE *rescale = source->rescale;
  310|  2.98M|  JDIMENSION col;
  311|       |
  312|  2.98M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  2.98M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (312:7): [True: 69, False: 2.98M]
  ------------------
  313|     69|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     69|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     69|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  314|  2.98M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  2.98M|#define _buffer  buffer
  ------------------
  315|  2.98M|  bufferptr = source->iobuffer;
  316|  12.4M|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (316:34): [True: 9.43M, False: 2.98M]
  ------------------
  317|  9.43M|    *ptr++ = rescale[*bufferptr++];
  318|  9.43M|  }
  319|  2.98M|  return 1;
  320|  2.98M|}
rdppm-8.c:get_gray_rgb_row:
  327|  15.7M|{
  328|  15.7M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  329|  15.7M|  register _JSAMPROW ptr;
  330|  15.7M|  register unsigned char *bufferptr;
  331|  15.7M|  register _JSAMPLE *rescale = source->rescale;
  332|  15.7M|  JDIMENSION col;
  333|  15.7M|  unsigned int maxval = source->maxval;
  334|  15.7M|  register int rindex = rgb_red[cinfo->in_color_space];
  335|  15.7M|  register int gindex = rgb_green[cinfo->in_color_space];
  336|  15.7M|  register int bindex = rgb_blue[cinfo->in_color_space];
  337|  15.7M|  register int aindex = alpha_index[cinfo->in_color_space];
  338|  15.7M|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  339|       |
  340|  15.7M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  15.7M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (340:7): [True: 480, False: 15.7M]
  ------------------
  341|    480|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    480|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    480|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  342|  15.7M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  15.7M|#define _buffer  buffer
  ------------------
  343|  15.7M|  bufferptr = source->iobuffer;
  344|  15.7M|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (344:7): [True: 866k, False: 14.9M]
  ------------------
  345|   866k|    if (aindex >= 0)
  ------------------
  |  Branch (345:9): [True: 173k, False: 693k]
  ------------------
  346|   173k|      GRAY_RGB_READ_LOOP(*bufferptr++, ptr[aindex] = (_JSAMPLE)maxval;)
  ------------------
  |  |  149|   173k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|   513k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 340k, False: 173k]
  |  |  ------------------
  |  |  151|   340k|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|   340k|    alpha_set_op \
  |  |  153|   340k|    ptr += ps; \
  |  |  154|   340k|  } \
  |  |  155|   173k|}
  ------------------
  347|   693k|    else
  348|   693k|      GRAY_RGB_READ_LOOP(*bufferptr++, {})
  ------------------
  |  |  149|   693k|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  2.05M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 1.36M, False: 693k]
  |  |  ------------------
  |  |  151|  1.36M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  1.36M|    alpha_set_op \
  |  |  153|  1.36M|    ptr += ps; \
  |  |  154|  1.36M|  } \
  |  |  155|   693k|}
  ------------------
  349|  14.9M|  } else {
  350|  14.9M|    if (aindex >= 0)
  ------------------
  |  Branch (350:9): [True: 2.98M, False: 11.9M]
  ------------------
  351|  2.98M|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  149|  2.98M|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  12.4M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 9.43M, False: 2.98M]
  |  |  ------------------
  |  |  151|  9.43M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  9.43M|    alpha_set_op \
  |  |  153|  9.43M|    ptr += ps; \
  |  |  154|  9.43M|  } \
  |  |  155|  2.98M|}
  ------------------
  352|  14.9M|                         ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  353|  11.9M|    else
  354|  11.9M|      GRAY_RGB_READ_LOOP(rescale[*bufferptr++], {})
  ------------------
  |  |  149|  11.9M|#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  150|  49.6M|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (150:34): [True: 37.7M, False: 11.9M]
  |  |  ------------------
  |  |  151|  37.7M|    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
  |  |  152|  37.7M|    alpha_set_op \
  |  |  153|  37.7M|    ptr += ps; \
  |  |  154|  37.7M|  } \
  |  |  155|  11.9M|}
  ------------------
  355|  14.9M|  }
  356|  15.7M|  return 1;
  357|  15.7M|}
rdppm-8.c:get_gray_cmyk_row:
  364|  3.15M|{
  365|  3.15M|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  366|  3.15M|  register _JSAMPROW ptr;
  367|  3.15M|  register unsigned char *bufferptr;
  368|  3.15M|  register _JSAMPLE *rescale = source->rescale;
  369|  3.15M|  JDIMENSION col;
  370|  3.15M|  unsigned int maxval = source->maxval;
  371|       |
  372|  3.15M|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  3.15M|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (372:7): [True: 96, False: 3.15M]
  ------------------
  373|     96|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     96|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     96|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  374|  3.15M|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  3.15M|#define _buffer  buffer
  ------------------
  375|  3.15M|  bufferptr = source->iobuffer;
  376|  3.15M|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (376:7): [True: 173k, False: 2.98M]
  ------------------
  377|   513k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (377:36): [True: 340k, False: 173k]
  ------------------
  378|   340k|      _JSAMPLE gray = *bufferptr++;
  ------------------
  |  |  224|   340k|#define _JSAMPLE  JSAMPLE
  ------------------
  379|   340k|      rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
  380|   340k|      ptr += 4;
  381|   340k|    }
  382|  2.98M|  } else {
  383|  12.4M|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (383:36): [True: 9.43M, False: 2.98M]
  ------------------
  384|  9.43M|      _JSAMPLE gray = rescale[*bufferptr++];
  ------------------
  |  |  224|  9.43M|#define _JSAMPLE  JSAMPLE
  ------------------
  385|  9.43M|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, gray, gray, gray, ptr,
  386|  9.43M|                  ptr + 1, ptr + 2, ptr + 3);
  387|  9.43M|      ptr += 4;
  388|  9.43M|    }
  389|  2.98M|  }
  390|  3.15M|  return 1;
  391|  3.15M|}
rdppm-8.c:get_word_rgb_row:
  597|  11.3k|{
  598|  11.3k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  599|  11.3k|  register _JSAMPROW ptr;
  600|  11.3k|  register unsigned char *bufferptr;
  601|  11.3k|  register _JSAMPLE *rescale = source->rescale;
  602|  11.3k|  JDIMENSION col;
  603|  11.3k|  unsigned int maxval = source->maxval;
  604|  11.3k|  register int rindex = rgb_red[cinfo->in_color_space];
  605|  11.3k|  register int gindex = rgb_green[cinfo->in_color_space];
  606|  11.3k|  register int bindex = rgb_blue[cinfo->in_color_space];
  607|  11.3k|  register int aindex = alpha_index[cinfo->in_color_space];
  608|  11.3k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  609|       |
  610|  11.3k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  11.3k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (610:7): [True: 340, False: 10.9k]
  ------------------
  611|    340|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    340|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    340|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  612|  11.3k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  11.3k|#define _buffer  buffer
  ------------------
  613|  11.3k|  bufferptr = source->iobuffer;
  614|  28.0k|  for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (614:34): [True: 16.7k, False: 11.3k]
  ------------------
  615|  16.7k|    register unsigned int temp;
  616|  16.7k|    temp  = (*bufferptr++) << 8;
  617|  16.7k|    temp |= (*bufferptr++);
  618|  16.7k|    if (temp > maxval)
  ------------------
  |  Branch (618:9): [True: 135, False: 16.6k]
  ------------------
  619|    135|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    135|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    135|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  620|  16.7k|    ptr[rindex] = rescale[temp];
  621|  16.7k|    temp  = (*bufferptr++) << 8;
  622|  16.7k|    temp |= (*bufferptr++);
  623|  16.7k|    if (temp > maxval)
  ------------------
  |  Branch (623:9): [True: 100, False: 16.6k]
  ------------------
  624|    100|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    100|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    100|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  625|  16.7k|    ptr[gindex] = rescale[temp];
  626|  16.7k|    temp  = (*bufferptr++) << 8;
  627|  16.7k|    temp |= (*bufferptr++);
  628|  16.7k|    if (temp > maxval)
  ------------------
  |  Branch (628:9): [True: 120, False: 16.6k]
  ------------------
  629|    120|      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|    120|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    120|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  630|  16.7k|    ptr[bindex] = rescale[temp];
  631|  16.7k|    if (aindex >= 0)
  ------------------
  |  Branch (631:9): [True: 3.27k, False: 13.4k]
  ------------------
  632|  3.27k|      ptr[aindex] = (1 << cinfo->data_precision) - 1;
  633|  16.7k|    ptr += ps;
  634|  16.7k|  }
  635|  11.3k|  return 1;
  636|  11.3k|}
rdppm-8.c:get_word_rgb_cmyk_row:
  642|  2.26k|{
  643|  2.26k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  644|  2.26k|  register _JSAMPROW ptr;
  645|  2.26k|  register unsigned char *bufferptr;
  646|  2.26k|  register _JSAMPLE *rescale = source->rescale;
  647|  2.26k|  JDIMENSION col;
  648|  2.26k|  unsigned int maxval = source->maxval;
  649|       |
  650|  2.26k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  2.26k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (650:7): [True: 68, False: 2.19k]
  ------------------
  651|     68|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|     68|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     68|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  652|  2.26k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  2.26k|#define _buffer  buffer
  ------------------
  653|  2.26k|  bufferptr = source->iobuffer;
  654|  2.26k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (654:7): [True: 0, False: 2.26k]
  ------------------
  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.26k|  } else {
  674|  5.60k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (674:36): [True: 3.34k, False: 2.26k]
  ------------------
  675|  3.34k|      register unsigned int r, g, b;
  676|  3.34k|      r  = (*bufferptr++) << 8;
  677|  3.34k|      r |= (*bufferptr++);
  678|  3.34k|      if (r > maxval)
  ------------------
  |  Branch (678:11): [True: 27, False: 3.32k]
  ------------------
  679|     27|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     27|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     27|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  680|  3.34k|      g  = (*bufferptr++) << 8;
  681|  3.34k|      g |= (*bufferptr++);
  682|  3.34k|      if (g > maxval)
  ------------------
  |  Branch (682:11): [True: 20, False: 3.32k]
  ------------------
  683|     20|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     20|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     20|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  684|  3.34k|      b  = (*bufferptr++) << 8;
  685|  3.34k|      b |= (*bufferptr++);
  686|  3.34k|      if (b > maxval)
  ------------------
  |  Branch (686:11): [True: 24, False: 3.32k]
  ------------------
  687|     24|        ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
  ------------------
  |  |  240|     24|  ((cinfo)->err->msg_code = (code), \
  |  |  241|     24|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  688|  3.34k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, rescale[r], rescale[g],
  689|  3.34k|                  rescale[b], ptr, ptr + 1, ptr + 2, ptr + 3);
  690|  3.34k|      ptr += 4;
  691|  3.34k|    }
  692|  2.26k|  }
  693|  2.26k|  return 1;
  694|  2.26k|}
rdppm-8.c:get_rgb_row:
  397|  28.6k|{
  398|  28.6k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  399|  28.6k|  register _JSAMPROW ptr;
  400|  28.6k|  register unsigned char *bufferptr;
  401|  28.6k|  register _JSAMPLE *rescale = source->rescale;
  402|  28.6k|  JDIMENSION col;
  403|  28.6k|  unsigned int maxval = source->maxval;
  404|  28.6k|  register int rindex = rgb_red[cinfo->in_color_space];
  405|  28.6k|  register int gindex = rgb_green[cinfo->in_color_space];
  406|  28.6k|  register int bindex = rgb_blue[cinfo->in_color_space];
  407|  28.6k|  register int aindex = alpha_index[cinfo->in_color_space];
  408|  28.6k|  register int ps = rgb_pixelsize[cinfo->in_color_space];
  409|       |
  410|  28.6k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  28.6k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (410:7): [True: 672, False: 27.9k]
  ------------------
  411|    672|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    672|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    672|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  412|  28.6k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  28.6k|#define _buffer  buffer
  ------------------
  413|  28.6k|  bufferptr = source->iobuffer;
  414|  28.6k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (414:7): [True: 7.19k, False: 21.4k]
  ------------------
  415|  7.19k|    if (aindex >= 0)
  ------------------
  |  Branch (415:9): [True: 1.79k, False: 5.39k]
  ------------------
  416|  1.79k|      RGB_READ_LOOP(*bufferptr++, ptr[aindex] = (_JSAMPLE)maxval;)
  ------------------
  |  |  223|  1.79k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  13.4k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 11.6k, False: 1.79k]
  |  |  ------------------
  |  |  225|  11.6k|    ptr[rindex] = read_op; \
  |  |  226|  11.6k|    ptr[gindex] = read_op; \
  |  |  227|  11.6k|    ptr[bindex] = read_op; \
  |  |  228|  11.6k|    alpha_set_op \
  |  |  229|  11.6k|    ptr += ps; \
  |  |  230|  11.6k|  } \
  |  |  231|  1.79k|}
  ------------------
  417|  5.39k|    else
  418|  5.39k|      RGB_READ_LOOP(*bufferptr++, {})
  ------------------
  |  |  223|  5.39k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  40.3k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 34.9k, False: 5.39k]
  |  |  ------------------
  |  |  225|  34.9k|    ptr[rindex] = read_op; \
  |  |  226|  34.9k|    ptr[gindex] = read_op; \
  |  |  227|  34.9k|    ptr[bindex] = read_op; \
  |  |  228|  34.9k|    alpha_set_op \
  |  |  229|  34.9k|    ptr += ps; \
  |  |  230|  34.9k|  } \
  |  |  231|  5.39k|}
  ------------------
  419|  21.4k|  } else {
  420|  21.4k|    if (aindex >= 0)
  ------------------
  |  Branch (420:9): [True: 4.14k, False: 17.2k]
  ------------------
  421|  4.14k|      RGB_READ_LOOP(rescale[*bufferptr++],
  ------------------
  |  |  223|  4.14k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  10.3k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 6.15k, False: 4.14k]
  |  |  ------------------
  |  |  225|  6.15k|    ptr[rindex] = read_op; \
  |  |  226|  6.15k|    ptr[gindex] = read_op; \
  |  |  227|  6.15k|    ptr[bindex] = read_op; \
  |  |  228|  6.15k|    alpha_set_op \
  |  |  229|  6.15k|    ptr += ps; \
  |  |  230|  6.15k|  } \
  |  |  231|  4.14k|}
  ------------------
  422|  21.4k|                    ptr[aindex] = (1 << cinfo->data_precision) - 1;)
  423|  17.2k|    else
  424|  17.2k|      RGB_READ_LOOP(rescale[*bufferptr++], {})
  ------------------
  |  |  223|  17.2k|#define RGB_READ_LOOP(read_op, alpha_set_op) { \
  |  |  224|  41.9k|  for (col = cinfo->image_width; col > 0; col--) { \
  |  |  ------------------
  |  |  |  Branch (224:34): [True: 24.6k, False: 17.2k]
  |  |  ------------------
  |  |  225|  24.6k|    ptr[rindex] = read_op; \
  |  |  226|  24.6k|    ptr[gindex] = read_op; \
  |  |  227|  24.6k|    ptr[bindex] = read_op; \
  |  |  228|  24.6k|    alpha_set_op \
  |  |  229|  24.6k|    ptr += ps; \
  |  |  230|  24.6k|  } \
  |  |  231|  17.2k|}
  ------------------
  425|  21.4k|  }
  426|  28.6k|  return 1;
  427|  28.6k|}
rdppm-8.c:get_rgb_cmyk_row:
  434|  6.09k|{
  435|  6.09k|  ppm_source_ptr source = (ppm_source_ptr)sinfo;
  436|  6.09k|  register _JSAMPROW ptr;
  437|  6.09k|  register unsigned char *bufferptr;
  438|  6.09k|  register _JSAMPLE *rescale = source->rescale;
  439|  6.09k|  JDIMENSION col;
  440|  6.09k|  unsigned int maxval = source->maxval;
  441|       |
  442|  6.09k|  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
  ------------------
  |  |   46|  6.09k|  (fread(buffer, 1, len, file) == ((size_t)(len)))
  ------------------
  |  Branch (442:7): [True: 144, False: 5.94k]
  ------------------
  443|    144|    ERREXIT(cinfo, JERR_INPUT_EOF);
  ------------------
  |  |  240|    144|  ((cinfo)->err->msg_code = (code), \
  |  |  241|    144|   (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
  ------------------
  444|  6.09k|  ptr = source->pub._buffer[0];
  ------------------
  |  |  326|  6.09k|#define _buffer  buffer
  ------------------
  445|  6.09k|  bufferptr = source->iobuffer;
  446|  6.09k|  if (maxval == (1U << cinfo->data_precision) - 1U) {
  ------------------
  |  Branch (446:7): [True: 1.79k, False: 4.29k]
  ------------------
  447|  13.4k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (447:36): [True: 11.6k, False: 1.79k]
  ------------------
  448|  11.6k|      _JSAMPLE r = *bufferptr++;
  ------------------
  |  |  224|  11.6k|#define _JSAMPLE  JSAMPLE
  ------------------
  449|  11.6k|      _JSAMPLE g = *bufferptr++;
  ------------------
  |  |  224|  11.6k|#define _JSAMPLE  JSAMPLE
  ------------------
  450|  11.6k|      _JSAMPLE b = *bufferptr++;
  ------------------
  |  |  224|  11.6k|#define _JSAMPLE  JSAMPLE
  ------------------
  451|  11.6k|      rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
  452|  11.6k|      ptr += 4;
  453|  11.6k|    }
  454|  4.29k|  } else {
  455|  10.4k|    for (col = cinfo->image_width; col > 0; col--) {
  ------------------
  |  Branch (455:36): [True: 6.15k, False: 4.29k]
  ------------------
  456|  6.15k|      _JSAMPLE r = rescale[*bufferptr++];
  ------------------
  |  |  224|  6.15k|#define _JSAMPLE  JSAMPLE
  ------------------
  457|  6.15k|      _JSAMPLE g = rescale[*bufferptr++];
  ------------------
  |  |  224|  6.15k|#define _JSAMPLE  JSAMPLE
  ------------------
  458|  6.15k|      _JSAMPLE b = rescale[*bufferptr++];
  ------------------
  |  |  224|  6.15k|#define _JSAMPLE  JSAMPLE
  ------------------
  459|  6.15k|      rgb_to_cmyk((1 << cinfo->data_precision) - 1, r, g, b, ptr, ptr + 1,
  460|  6.15k|                  ptr + 2, ptr + 3);
  461|  6.15k|      ptr += 4;
  462|  6.15k|    }
  463|  4.29k|  }
  464|  6.09k|  return 1;
  465|  6.09k|}
rdppm-8.c:finish_input_ppm:
  913|  15.3k|{
  914|       |  /* no work */
  915|  15.3k|}

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

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

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

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

z_inflateResetKeep:
  100|   113k|int ZEXPORT inflateResetKeep(z_streamp strm) {
  101|   113k|    struct inflate_state FAR *state;
  102|       |
  103|   113k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (103:9): [True: 0, False: 113k]
  ------------------
  104|   113k|    state = (struct inflate_state FAR *)strm->state;
  105|   113k|    strm->total_in = strm->total_out = state->total = 0;
  106|   113k|    strm->msg = Z_NULL;
  ------------------
  |  |  216|   113k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  107|   113k|    strm->data_type = 0;
  108|   113k|    if (state->wrap)        /* to support ill-conceived Java test suite */
  ------------------
  |  Branch (108:9): [True: 113k, False: 0]
  ------------------
  109|   113k|        strm->adler = state->wrap & 1;
  110|   113k|    state->mode = HEAD;
  111|   113k|    state->last = 0;
  112|   113k|    state->havedict = 0;
  113|   113k|    state->flags = -1;
  114|   113k|    state->dmax = 32768U;
  115|   113k|    state->head = Z_NULL;
  ------------------
  |  |  216|   113k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  116|   113k|    state->hold = 0;
  117|   113k|    state->bits = 0;
  118|   113k|    state->lencode = state->distcode = state->next = state->codes;
  119|   113k|    state->sane = 1;
  120|   113k|    state->back = -1;
  121|   113k|    Tracev((stderr, "inflate: reset\n"));
  122|   113k|    return Z_OK;
  ------------------
  |  |  181|   113k|#define Z_OK            0
  ------------------
  123|   113k|}
z_inflateReset:
  125|   113k|int ZEXPORT inflateReset(z_streamp strm) {
  126|   113k|    struct inflate_state FAR *state;
  127|       |
  128|   113k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (128:9): [True: 0, False: 113k]
  ------------------
  129|   113k|    state = (struct inflate_state FAR *)strm->state;
  130|   113k|    state->wsize = 0;
  131|   113k|    state->whave = 0;
  132|   113k|    state->wnext = 0;
  133|   113k|    return inflateResetKeep(strm);
  ------------------
  |  |  132|   113k|#  define inflateResetKeep      z_inflateResetKeep
  ------------------
  134|   113k|}
z_inflateReset2:
  136|   113k|int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
  137|   113k|    int wrap;
  138|   113k|    struct inflate_state FAR *state;
  139|       |
  140|       |    /* get the state */
  141|   113k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (141:9): [True: 0, False: 113k]
  ------------------
  142|   113k|    state = (struct inflate_state FAR *)strm->state;
  143|       |
  144|       |    /* extract wrap request from windowBits parameter */
  145|   113k|    if (windowBits < 0) {
  ------------------
  |  Branch (145:9): [True: 0, False: 113k]
  ------------------
  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|   113k|    else {
  152|   113k|        wrap = (windowBits >> 4) + 5;
  153|       |#ifdef GUNZIP
  154|       |        if (windowBits < 48)
  155|       |            windowBits &= 15;
  156|       |#endif
  157|   113k|    }
  158|       |
  159|       |    /* set number of window bits, free window if different */
  160|   113k|    if (windowBits && (windowBits < 8 || windowBits > 15))
  ------------------
  |  Branch (160:9): [True: 113k, False: 0]
  |  Branch (160:24): [True: 0, False: 113k]
  |  Branch (160:42): [True: 0, False: 113k]
  ------------------
  161|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  162|   113k|    if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
  ------------------
  |  |  216|   226k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (162:9): [True: 0, False: 113k]
  |  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|   113k|    state->wrap = wrap;
  169|   113k|    state->wbits = (unsigned)windowBits;
  170|   113k|    return inflateReset(strm);
  ------------------
  |  |  130|   113k|#  define inflateReset          z_inflateReset
  ------------------
  171|   113k|}
z_inflateInit2_:
  174|   113k|                          const char *version, int stream_size) {
  175|   113k|    int ret;
  176|   113k|    struct inflate_state FAR *state;
  177|       |
  178|   113k|    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
  ------------------
  |  |  216|   226k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
                  if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
  ------------------
  |  |   44|   113k|#define ZLIB_VERSION "1.3.2"
  ------------------
  |  Branch (178:9): [True: 0, False: 113k]
  |  Branch (178:30): [True: 0, False: 113k]
  ------------------
  179|   113k|        stream_size != (int)(sizeof(z_stream)))
  ------------------
  |  Branch (179:9): [True: 0, False: 113k]
  ------------------
  180|      0|        return Z_VERSION_ERROR;
  ------------------
  |  |  189|      0|#define Z_VERSION_ERROR (-6)
  ------------------
  181|   113k|    if (strm == Z_NULL) return Z_STREAM_ERROR;
  ------------------
  |  |  216|   113k|#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: 113k]
  ------------------
  182|   113k|    strm->msg = Z_NULL;                 /* in case we return an error */
  ------------------
  |  |  216|   113k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  183|   113k|    if (strm->zalloc == (alloc_func)0) {
  ------------------
  |  Branch (183:9): [True: 0, False: 113k]
  ------------------
  184|       |#ifdef Z_SOLO
  185|       |        return Z_STREAM_ERROR;
  186|       |#else
  187|      0|        strm->zalloc = zcalloc;
  ------------------
  |  |  150|      0|#    define zcalloc               z_zcalloc
  ------------------
  188|      0|        strm->opaque = (voidpf)0;
  189|      0|#endif
  190|      0|    }
  191|   113k|    if (strm->zfree == (free_func)0)
  ------------------
  |  Branch (191:9): [True: 0, False: 113k]
  ------------------
  192|       |#ifdef Z_SOLO
  193|       |        return Z_STREAM_ERROR;
  194|       |#else
  195|      0|        strm->zfree = zcfree;
  ------------------
  |  |  151|      0|#    define zcfree                z_zcfree
  ------------------
  196|   113k|#endif
  197|   113k|    state = (struct inflate_state FAR *)
  198|   113k|            ZALLOC(strm, 1, sizeof(struct inflate_state));
  ------------------
  |  |  253|   113k|           (*((strm)->zalloc))((strm)->opaque, (items), (size))
  ------------------
  199|   113k|    if (state == Z_NULL) return Z_MEM_ERROR;
  ------------------
  |  |  216|   113k|#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: 113k]
  ------------------
  200|   113k|    zmemzero(state, sizeof(struct inflate_state));
  ------------------
  |  |  218|   113k|#    define zmemzero(dest, len) memset(dest, 0, len)
  ------------------
  201|   113k|    Tracev((stderr, "inflate: allocated\n"));
  202|   113k|    strm->state = (struct internal_state FAR *)state;
  203|   113k|    state->strm = strm;
  204|   113k|    state->window = Z_NULL;
  ------------------
  |  |  216|   113k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  205|   113k|    state->mode = HEAD;     /* to pass state test in inflateReset2() */
  206|   113k|    ret = inflateReset2(strm, windowBits);
  ------------------
  |  |  131|   113k|#  define inflateReset2         z_inflateReset2
  ------------------
  207|   113k|    if (ret != Z_OK) {
  ------------------
  |  |  181|   113k|#define Z_OK            0
  ------------------
  |  Branch (207:9): [True: 0, False: 113k]
  ------------------
  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|   113k|    return ret;
  212|   113k|}
z_inflate:
  474|   693k|int ZEXPORT inflate(z_streamp strm, int flush) {
  475|   693k|    struct inflate_state FAR *state;
  476|   693k|    z_const unsigned char FAR *next;    /* next input */
  477|   693k|    unsigned char FAR *put;     /* next output */
  478|   693k|    unsigned have, left;        /* available input and output */
  479|   693k|    unsigned long hold;         /* bit buffer */
  480|   693k|    unsigned bits;              /* bits in bit buffer */
  481|   693k|    unsigned in, out;           /* save starting available input and output */
  482|   693k|    unsigned copy;              /* number of stored or match bytes to copy */
  483|   693k|    unsigned char FAR *from;    /* where to copy match bytes from */
  484|   693k|    code here;                  /* current decoding table entry */
  485|   693k|    code last;                  /* parent table entry */
  486|   693k|    unsigned len;               /* length to copy for repeats, bits to drop */
  487|   693k|    int ret;                    /* return code */
  488|       |#ifdef GUNZIP
  489|       |    unsigned char hbuf[4];      /* buffer for gzip header crc calculation */
  490|       |#endif
  491|   693k|    static const unsigned short order[19] = /* permutation of code lengths */
  492|   693k|        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
  493|       |
  494|   693k|    if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
  ------------------
  |  |  216|  1.38M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (494:9): [True: 0, False: 693k]
  |  Branch (494:36): [True: 0, False: 693k]
  ------------------
  495|   693k|        (strm->next_in == Z_NULL && strm->avail_in != 0))
  ------------------
  |  |  216|  1.38M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (495:10): [True: 126, False: 693k]
  |  Branch (495:37): [True: 0, False: 126]
  ------------------
  496|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  497|       |
  498|   693k|    state = (struct inflate_state FAR *)strm->state;
  499|   693k|    if (state->mode == TYPE) state->mode = TYPEDO;      /* skip check */
  ------------------
  |  Branch (499:9): [True: 504, False: 693k]
  ------------------
  500|   693k|    LOAD();
  ------------------
  |  |  329|   693k|    do { \
  |  |  330|   693k|        put = strm->next_out; \
  |  |  331|   693k|        left = strm->avail_out; \
  |  |  332|   693k|        next = strm->next_in; \
  |  |  333|   693k|        have = strm->avail_in; \
  |  |  334|   693k|        hold = state->hold; \
  |  |  335|   693k|        bits = state->bits; \
  |  |  336|   693k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (336:14): [Folded, False: 693k]
  |  |  ------------------
  ------------------
  501|   693k|    in = have;
  502|   693k|    out = left;
  503|   693k|    ret = Z_OK;
  ------------------
  |  |  181|   693k|#define Z_OK            0
  ------------------
  504|   693k|    for (;;)
  505|  12.3M|        switch (state->mode) {
  506|   114k|        case HEAD:
  ------------------
  |  Branch (506:9): [True: 114k, False: 12.2M]
  ------------------
  507|   114k|            if (state->wrap == 0) {
  ------------------
  |  Branch (507:17): [True: 0, False: 114k]
  ------------------
  508|      0|                state->mode = TYPEDO;
  509|      0|                break;
  510|      0|            }
  511|   114k|            NEEDBITS(16);
  ------------------
  |  |  369|   114k|    do { \
  |  |  370|   339k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 227k, False: 111k]
  |  |  ------------------
  |  |  371|   227k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   227k|    do { \
  |  |  |  |  360|   227k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 2.44k, False: 224k]
  |  |  |  |  ------------------
  |  |  |  |  361|   227k|        have--; \
  |  |  |  |  362|   224k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   224k|        bits += 8; \
  |  |  |  |  364|   224k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 224k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   114k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 111k]
  |  |  ------------------
  ------------------
  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|   111k|            if (
  527|   111k|#endif
  528|   111k|                ((BITS(8) << 8) + (hold >> 8)) % 31) {
  ------------------
  |  |  376|   111k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  |  Branch (528:17): [True: 11.0k, False: 100k]
  ------------------
  529|  11.0k|                strm->msg = (z_const char *)"incorrect header check";
  530|  11.0k|                state->mode = BAD;
  531|  11.0k|                break;
  532|  11.0k|            }
  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.09k, False: 99.7k]
  ------------------
  534|  1.09k|                strm->msg = (z_const char *)"unknown compression method";
  535|  1.09k|                state->mode = BAD;
  536|  1.09k|                break;
  537|  1.09k|            }
  538|  99.7k|            DROPBITS(4);
  ------------------
  |  |  380|  99.7k|    do { \
  |  |  381|  99.7k|        hold >>= (n); \
  |  |  382|  99.7k|        bits -= (unsigned)(n); \
  |  |  383|  99.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 99.7k]
  |  |  ------------------
  ------------------
  539|  99.7k|            len = BITS(4) + 8;
  ------------------
  |  |  376|  99.7k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  540|  99.7k|            if (state->wbits == 0)
  ------------------
  |  Branch (540:17): [True: 0, False: 99.7k]
  ------------------
  541|      0|                state->wbits = len;
  542|  99.7k|            if (len > 15 || len > state->wbits) {
  ------------------
  |  Branch (542:17): [True: 76, False: 99.6k]
  |  Branch (542:29): [True: 0, False: 99.6k]
  ------------------
  543|     76|                strm->msg = (z_const char *)"invalid window size";
  544|     76|                state->mode = BAD;
  545|     76|                break;
  546|     76|            }
  547|  99.6k|            state->dmax = 1U << len;
  548|  99.6k|            state->flags = 0;               /* indicate zlib header */
  549|  99.6k|            Tracev((stderr, "inflate:   zlib header ok\n"));
  550|  99.6k|            strm->adler = state->check = adler32(0L, Z_NULL, 0);
  ------------------
  |  |   34|  99.6k|#  define adler32               z_adler32
  ------------------
                          strm->adler = state->check = adler32(0L, Z_NULL, 0);
  ------------------
  |  |  216|  99.6k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  551|  99.6k|            state->mode = hold & 0x200 ? DICTID : TYPE;
  ------------------
  |  Branch (551:27): [True: 395, False: 99.2k]
  ------------------
  552|  99.6k|            INITBITS();
  ------------------
  |  |  351|  99.6k|    do { \
  |  |  352|  99.6k|        hold = 0; \
  |  |  353|  99.6k|        bits = 0; \
  |  |  354|  99.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 99.6k]
  |  |  ------------------
  ------------------
  553|  99.6k|            break;
  554|       |#ifdef GUNZIP
  555|       |        case FLAGS:
  556|       |            NEEDBITS(16);
  557|       |            state->flags = (int)(hold);
  558|       |            if ((state->flags & 0xff) != Z_DEFLATED) {
  559|       |                strm->msg = (z_const char *)"unknown compression method";
  560|       |                state->mode = BAD;
  561|       |                break;
  562|       |            }
  563|       |            if (state->flags & 0xe000) {
  564|       |                strm->msg = (z_const char *)"unknown header flags set";
  565|       |                state->mode = BAD;
  566|       |                break;
  567|       |            }
  568|       |            if (state->head != Z_NULL)
  569|       |                state->head->text = (int)((hold >> 8) & 1);
  570|       |            if ((state->flags & 0x0200) && (state->wrap & 4))
  571|       |                CRC2(state->check, hold);
  572|       |            INITBITS();
  573|       |            state->mode = TIME;
  574|       |                /* fallthrough */
  575|       |        case TIME:
  576|       |            NEEDBITS(32);
  577|       |            if (state->head != Z_NULL)
  578|       |                state->head->time = hold;
  579|       |            if ((state->flags & 0x0200) && (state->wrap & 4))
  580|       |                CRC4(state->check, hold);
  581|       |            INITBITS();
  582|       |            state->mode = OS;
  583|       |                /* fallthrough */
  584|       |        case OS:
  585|       |            NEEDBITS(16);
  586|       |            if (state->head != Z_NULL) {
  587|       |                state->head->xflags = (int)(hold & 0xff);
  588|       |                state->head->os = (int)(hold >> 8);
  589|       |            }
  590|       |            if ((state->flags & 0x0200) && (state->wrap & 4))
  591|       |                CRC2(state->check, hold);
  592|       |            INITBITS();
  593|       |            state->mode = EXLEN;
  594|       |                /* fallthrough */
  595|       |        case EXLEN:
  596|       |            if (state->flags & 0x0400) {
  597|       |                NEEDBITS(16);
  598|       |                state->length = (unsigned)(hold);
  599|       |                if (state->head != Z_NULL)
  600|       |                    state->head->extra_len = (unsigned)hold;
  601|       |                if ((state->flags & 0x0200) && (state->wrap & 4))
  602|       |                    CRC2(state->check, hold);
  603|       |                INITBITS();
  604|       |            }
  605|       |            else if (state->head != Z_NULL)
  606|       |                state->head->extra = Z_NULL;
  607|       |            state->mode = EXTRA;
  608|       |                /* fallthrough */
  609|       |        case EXTRA:
  610|       |            if (state->flags & 0x0400) {
  611|       |                copy = state->length;
  612|       |                if (copy > have) copy = have;
  613|       |                if (copy) {
  614|       |                    if (state->head != Z_NULL &&
  615|       |                        state->head->extra != Z_NULL &&
  616|       |                        (len = state->head->extra_len - state->length) <
  617|       |                            state->head->extra_max) {
  618|       |                        zmemcpy(state->head->extra + len, next,
  619|       |                                len + copy > state->head->extra_max ?
  620|       |                                state->head->extra_max - len : copy);
  621|       |                    }
  622|       |                    if ((state->flags & 0x0200) && (state->wrap & 4))
  623|       |                        state->check = crc32(state->check, next, copy);
  624|       |                    have -= copy;
  625|       |                    next += copy;
  626|       |                    state->length -= copy;
  627|       |                }
  628|       |                if (state->length) goto inf_leave;
  629|       |            }
  630|       |            state->length = 0;
  631|       |            state->mode = NAME;
  632|       |                /* fallthrough */
  633|       |        case NAME:
  634|       |            if (state->flags & 0x0800) {
  635|       |                if (have == 0) goto inf_leave;
  636|       |                copy = 0;
  637|       |                do {
  638|       |                    len = (unsigned)(next[copy++]);
  639|       |                    if (state->head != Z_NULL &&
  640|       |                            state->head->name != Z_NULL &&
  641|       |                            state->length < state->head->name_max)
  642|       |                        state->head->name[state->length++] = (Bytef)len;
  643|       |                } while (len && copy < have);
  644|       |                if ((state->flags & 0x0200) && (state->wrap & 4))
  645|       |                    state->check = crc32(state->check, next, copy);
  646|       |                have -= copy;
  647|       |                next += copy;
  648|       |                if (len) goto inf_leave;
  649|       |            }
  650|       |            else if (state->head != Z_NULL)
  651|       |                state->head->name = Z_NULL;
  652|       |            state->length = 0;
  653|       |            state->mode = COMMENT;
  654|       |                /* fallthrough */
  655|       |        case COMMENT:
  656|       |            if (state->flags & 0x1000) {
  657|       |                if (have == 0) goto inf_leave;
  658|       |                copy = 0;
  659|       |                do {
  660|       |                    len = (unsigned)(next[copy++]);
  661|       |                    if (state->head != Z_NULL &&
  662|       |                            state->head->comment != Z_NULL &&
  663|       |                            state->length < state->head->comm_max)
  664|       |                        state->head->comment[state->length++] = (Bytef)len;
  665|       |                } while (len && copy < have);
  666|       |                if ((state->flags & 0x0200) && (state->wrap & 4))
  667|       |                    state->check = crc32(state->check, next, copy);
  668|       |                have -= copy;
  669|       |                next += copy;
  670|       |                if (len) goto inf_leave;
  671|       |            }
  672|       |            else if (state->head != Z_NULL)
  673|       |                state->head->comment = Z_NULL;
  674|       |            state->mode = HCRC;
  675|       |                /* fallthrough */
  676|       |        case HCRC:
  677|       |            if (state->flags & 0x0200) {
  678|       |                NEEDBITS(16);
  679|       |                if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
  680|       |                    strm->msg = (z_const char *)"header crc mismatch";
  681|       |                    state->mode = BAD;
  682|       |                    break;
  683|       |                }
  684|       |                INITBITS();
  685|       |            }
  686|       |            if (state->head != Z_NULL) {
  687|       |                state->head->hcrc = (int)((state->flags >> 9) & 1);
  688|       |                state->head->done = 1;
  689|       |            }
  690|       |            strm->adler = state->check = crc32(0L, Z_NULL, 0);
  691|       |            state->mode = TYPE;
  692|       |            break;
  693|       |#endif
  694|    456|        case DICTID:
  ------------------
  |  Branch (694:9): [True: 456, False: 12.3M]
  ------------------
  695|    456|            NEEDBITS(32);
  ------------------
  |  |  369|    456|    do { \
  |  |  370|  1.94k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 1.58k, False: 356]
  |  |  ------------------
  |  |  371|  1.58k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  1.58k|    do { \
  |  |  |  |  360|  1.58k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 100, False: 1.48k]
  |  |  |  |  ------------------
  |  |  |  |  361|  1.58k|        have--; \
  |  |  |  |  362|  1.48k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  1.48k|        bits += 8; \
  |  |  |  |  364|  1.48k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 1.48k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|    456|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 356]
  |  |  ------------------
  ------------------
  696|    356|            strm->adler = state->check = ZSWAP32(hold);
  ------------------
  |  |  258|    356|#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
  |  |  259|    356|                    (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
  ------------------
  697|    356|            INITBITS();
  ------------------
  |  |  351|    356|    do { \
  |  |  352|    356|        hold = 0; \
  |  |  353|    356|        bits = 0; \
  |  |  354|    356|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 356]
  |  |  ------------------
  ------------------
  698|    356|            state->mode = DICT;
  699|       |                /* fallthrough */
  700|    356|        case DICT:
  ------------------
  |  Branch (700:9): [True: 0, False: 12.3M]
  ------------------
  701|    356|            if (state->havedict == 0) {
  ------------------
  |  Branch (701:17): [True: 356, False: 0]
  ------------------
  702|    356|                RESTORE();
  ------------------
  |  |  340|    356|    do { \
  |  |  341|    356|        strm->next_out = put; \
  |  |  342|    356|        strm->avail_out = left; \
  |  |  343|    356|        strm->next_in = next; \
  |  |  344|    356|        strm->avail_in = have; \
  |  |  345|    356|        state->hold = hold; \
  |  |  346|    356|        state->bits = bits; \
  |  |  347|    356|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 356]
  |  |  ------------------
  ------------------
  703|    356|                return Z_NEED_DICT;
  ------------------
  |  |  183|    356|#define Z_NEED_DICT     2
  ------------------
  704|    356|            }
  705|      0|            strm->adler = state->check = adler32(0L, Z_NULL, 0);
  ------------------
  |  |   34|      0|#  define adler32               z_adler32
  ------------------
                          strm->adler = state->check = adler32(0L, Z_NULL, 0);
  ------------------
  |  |  216|      0|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  706|      0|            state->mode = TYPE;
  707|       |                /* fallthrough */
  708|   190k|        case TYPE:
  ------------------
  |  Branch (708:9): [True: 190k, False: 12.1M]
  ------------------
  709|   190k|            if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  177|   381k|#define Z_BLOCK         5
  ------------------
                          if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|   190k|#define Z_TREES         6
  ------------------
  |  Branch (709:17): [True: 0, False: 190k]
  |  Branch (709:37): [True: 0, False: 190k]
  ------------------
  710|       |                /* fallthrough */
  711|   191k|        case TYPEDO:
  ------------------
  |  Branch (711:9): [True: 976, False: 12.3M]
  ------------------
  712|   191k|            if (state->last) {
  ------------------
  |  Branch (712:17): [True: 82.8k, False: 109k]
  ------------------
  713|  82.8k|                BYTEBITS();
  ------------------
  |  |  387|  82.8k|    do { \
  |  |  388|  82.8k|        hold >>= bits & 7; \
  |  |  389|  82.8k|        bits -= bits & 7; \
  |  |  390|  82.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (390:14): [Folded, False: 82.8k]
  |  |  ------------------
  ------------------
  714|  82.8k|                state->mode = CHECK;
  715|  82.8k|                break;
  716|  82.8k|            }
  717|   109k|            NEEDBITS(3);
  ------------------
  |  |  369|   109k|    do { \
  |  |  370|   214k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 106k, False: 108k]
  |  |  ------------------
  |  |  371|   109k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   106k|    do { \
  |  |  |  |  360|   106k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.00k, False: 105k]
  |  |  |  |  ------------------
  |  |  |  |  361|   106k|        have--; \
  |  |  |  |  362|   105k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   105k|        bits += 8; \
  |  |  |  |  364|   105k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 105k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   109k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 108k]
  |  |  ------------------
  ------------------
  718|   108k|            state->last = BITS(1);
  ------------------
  |  |  376|   108k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  719|   108k|            DROPBITS(1);
  ------------------
  |  |  380|   108k|    do { \
  |  |  381|   108k|        hold >>= (n); \
  |  |  382|   108k|        bits -= (unsigned)(n); \
  |  |  383|   108k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 108k]
  |  |  ------------------
  ------------------
  720|   108k|            switch (BITS(2)) {
  ------------------
  |  |  376|   108k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  721|  2.05k|            case 0:                             /* stored block */
  ------------------
  |  Branch (721:13): [True: 2.05k, False: 105k]
  ------------------
  722|  2.05k|                Tracev((stderr, "inflate:     stored block%s\n",
  723|  2.05k|                        state->last ? " (last)" : ""));
  724|  2.05k|                state->mode = STORED;
  725|  2.05k|                break;
  726|  86.8k|            case 1:                             /* fixed block */
  ------------------
  |  Branch (726:13): [True: 86.8k, False: 21.1k]
  ------------------
  727|  86.8k|                inflate_fixed(state);
  ------------------
  |  |  141|  86.8k|#  define inflate_fixed         z_inflate_fixed
  ------------------
  728|  86.8k|                Tracev((stderr, "inflate:     fixed codes block%s\n",
  729|  86.8k|                        state->last ? " (last)" : ""));
  730|  86.8k|                state->mode = LEN_;             /* decode codes */
  731|  86.8k|                if (flush == Z_TREES) {
  ------------------
  |  |  178|  86.8k|#define Z_TREES         6
  ------------------
  |  Branch (731:21): [True: 0, False: 86.8k]
  ------------------
  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|  86.8k|                break;
  736|  86.8k|            case 2:                             /* dynamic block */
  ------------------
  |  Branch (736:13): [True: 18.8k, False: 89.1k]
  ------------------
  737|  18.8k|                Tracev((stderr, "inflate:     dynamic codes block%s\n",
  738|  18.8k|                        state->last ? " (last)" : ""));
  739|  18.8k|                state->mode = TABLE;
  740|  18.8k|                break;
  741|    232|            default:
  ------------------
  |  Branch (741:13): [True: 232, False: 107k]
  ------------------
  742|    232|                strm->msg = (z_const char *)"invalid block type";
  743|    232|                state->mode = BAD;
  744|   108k|            }
  745|   108k|            DROPBITS(2);
  ------------------
  |  |  380|   108k|    do { \
  |  |  381|   108k|        hold >>= (n); \
  |  |  382|   108k|        bits -= (unsigned)(n); \
  |  |  383|   108k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 108k]
  |  |  ------------------
  ------------------
  746|   108k|            break;
  747|  2.15k|        case STORED:
  ------------------
  |  Branch (747:9): [True: 2.15k, False: 12.3M]
  ------------------
  748|  2.15k|            BYTEBITS();                         /* go to byte boundary */
  ------------------
  |  |  387|  2.15k|    do { \
  |  |  388|  2.15k|        hold >>= bits & 7; \
  |  |  389|  2.15k|        bits -= bits & 7; \
  |  |  390|  2.15k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (390:14): [Folded, False: 2.15k]
  |  |  ------------------
  ------------------
  749|  2.15k|            NEEDBITS(32);
  ------------------
  |  |  369|  2.15k|    do { \
  |  |  370|  10.0k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 8.16k, False: 1.93k]
  |  |  ------------------
  |  |  371|  8.16k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  8.16k|    do { \
  |  |  |  |  360|  8.16k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 226, False: 7.93k]
  |  |  |  |  ------------------
  |  |  |  |  361|  8.16k|        have--; \
  |  |  |  |  362|  7.93k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  7.93k|        bits += 8; \
  |  |  |  |  364|  7.93k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 7.93k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  2.15k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 1.93k]
  |  |  ------------------
  ------------------
  750|  1.93k|            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
  ------------------
  |  Branch (750:17): [True: 535, False: 1.39k]
  ------------------
  751|    535|                strm->msg = (z_const char *)"invalid stored block lengths";
  752|    535|                state->mode = BAD;
  753|    535|                break;
  754|    535|            }
  755|  1.39k|            state->length = (unsigned)hold & 0xffff;
  756|  1.39k|            Tracev((stderr, "inflate:       stored length %u\n",
  757|  1.39k|                    state->length));
  758|  1.39k|            INITBITS();
  ------------------
  |  |  351|  1.39k|    do { \
  |  |  352|  1.39k|        hold = 0; \
  |  |  353|  1.39k|        bits = 0; \
  |  |  354|  1.39k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 1.39k]
  |  |  ------------------
  ------------------
  759|  1.39k|            state->mode = COPY_;
  760|  1.39k|            if (flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|  1.39k|#define Z_TREES         6
  ------------------
  |  Branch (760:17): [True: 0, False: 1.39k]
  ------------------
  761|       |                /* fallthrough */
  762|  1.39k|        case COPY_:
  ------------------
  |  Branch (762:9): [True: 0, False: 12.3M]
  ------------------
  763|  1.39k|            state->mode = COPY;
  764|       |                /* fallthrough */
  765|  24.4k|        case COPY:
  ------------------
  |  Branch (765:9): [True: 23.0k, False: 12.3M]
  ------------------
  766|  24.4k|            copy = state->length;
  767|  24.4k|            if (copy) {
  ------------------
  |  Branch (767:17): [True: 23.5k, False: 894]
  ------------------
  768|  23.5k|                if (copy > have) copy = have;
  ------------------
  |  Branch (768:21): [True: 21.7k, False: 1.73k]
  ------------------
  769|  23.5k|                if (copy > left) copy = left;
  ------------------
  |  Branch (769:21): [True: 20.4k, False: 3.11k]
  ------------------
  770|  23.5k|                if (copy == 0) goto inf_leave;
  ------------------
  |  Branch (770:21): [True: 11.5k, False: 11.9k]
  ------------------
  771|  11.9k|                zmemcpy(put, next, copy);
  ------------------
  |  |  216|  11.9k|#    define zmemcpy memcpy
  ------------------
  772|  11.9k|                have -= copy;
  773|  11.9k|                next += copy;
  774|  11.9k|                left -= copy;
  775|  11.9k|                put += copy;
  776|  11.9k|                state->length -= copy;
  777|  11.9k|                break;
  778|  23.5k|            }
  779|    894|            Tracev((stderr, "inflate:       stored end\n"));
  780|    894|            state->mode = TYPE;
  781|    894|            break;
  782|  20.5k|        case TABLE:
  ------------------
  |  Branch (782:9): [True: 20.5k, False: 12.3M]
  ------------------
  783|  20.5k|            NEEDBITS(14);
  ------------------
  |  |  369|  20.5k|    do { \
  |  |  370|  57.2k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 38.4k, False: 18.8k]
  |  |  ------------------
  |  |  371|  38.4k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  38.4k|    do { \
  |  |  |  |  360|  38.4k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.71k, False: 36.6k]
  |  |  |  |  ------------------
  |  |  |  |  361|  38.4k|        have--; \
  |  |  |  |  362|  36.6k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  36.6k|        bits += 8; \
  |  |  |  |  364|  36.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 36.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  20.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 18.8k]
  |  |  ------------------
  ------------------
  784|  18.8k|            state->nlen = BITS(5) + 257;
  ------------------
  |  |  376|  18.8k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  785|  18.8k|            DROPBITS(5);
  ------------------
  |  |  380|  18.8k|    do { \
  |  |  381|  18.8k|        hold >>= (n); \
  |  |  382|  18.8k|        bits -= (unsigned)(n); \
  |  |  383|  18.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 18.8k]
  |  |  ------------------
  ------------------
  786|  18.8k|            state->ndist = BITS(5) + 1;
  ------------------
  |  |  376|  18.8k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  787|  18.8k|            DROPBITS(5);
  ------------------
  |  |  380|  18.8k|    do { \
  |  |  381|  18.8k|        hold >>= (n); \
  |  |  382|  18.8k|        bits -= (unsigned)(n); \
  |  |  383|  18.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 18.8k]
  |  |  ------------------
  ------------------
  788|  18.8k|            state->ncode = BITS(4) + 4;
  ------------------
  |  |  376|  18.8k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  789|  18.8k|            DROPBITS(4);
  ------------------
  |  |  380|  18.8k|    do { \
  |  |  381|  18.8k|        hold >>= (n); \
  |  |  382|  18.8k|        bits -= (unsigned)(n); \
  |  |  383|  18.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 18.8k]
  |  |  ------------------
  ------------------
  790|  18.8k|#ifndef PKZIP_BUG_WORKAROUND
  791|  18.8k|            if (state->nlen > 286 || state->ndist > 30) {
  ------------------
  |  Branch (791:17): [True: 48, False: 18.7k]
  |  Branch (791:38): [True: 516, False: 18.2k]
  ------------------
  792|    564|                strm->msg = (z_const char *)
  793|    564|                    "too many length or distance symbols";
  794|    564|                state->mode = BAD;
  795|    564|                break;
  796|    564|            }
  797|  18.2k|#endif
  798|  18.2k|            Tracev((stderr, "inflate:       table sizes ok\n"));
  799|  18.2k|            state->have = 0;
  800|  18.2k|            state->mode = LENLENS;
  801|       |                /* fallthrough */
  802|  22.1k|        case LENLENS:
  ------------------
  |  Branch (802:9): [True: 3.90k, False: 12.3M]
  ------------------
  803|   300k|            while (state->have < state->ncode) {
  ------------------
  |  Branch (803:20): [True: 282k, False: 18.0k]
  ------------------
  804|   282k|                NEEDBITS(3);
  ------------------
  |  |  369|   282k|    do { \
  |  |  370|   377k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 98.9k, False: 278k]
  |  |  ------------------
  |  |  371|   282k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  98.9k|    do { \
  |  |  |  |  360|  98.9k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 4.15k, False: 94.7k]
  |  |  |  |  ------------------
  |  |  |  |  361|  98.9k|        have--; \
  |  |  |  |  362|  94.7k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  94.7k|        bits += 8; \
  |  |  |  |  364|  94.7k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 94.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   282k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 278k]
  |  |  ------------------
  ------------------
  805|   278k|                state->lens[order[state->have++]] = (unsigned short)BITS(3);
  ------------------
  |  |  376|   278k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  806|   278k|                DROPBITS(3);
  ------------------
  |  |  380|   278k|    do { \
  |  |  381|   278k|        hold >>= (n); \
  |  |  382|   278k|        bits -= (unsigned)(n); \
  |  |  383|   278k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 278k]
  |  |  ------------------
  ------------------
  807|   278k|            }
  808|  85.6k|            while (state->have < 19)
  ------------------
  |  Branch (808:20): [True: 67.6k, False: 18.0k]
  ------------------
  809|  67.6k|                state->lens[order[state->have++]] = 0;
  810|  18.0k|            state->next = state->codes;
  811|  18.0k|            state->lencode = state->distcode = (const code FAR *)(state->next);
  812|  18.0k|            state->lenbits = 7;
  813|  18.0k|            ret = inflate_table(CODES, state->lens, 19, &(state->next),
  ------------------
  |  |  140|  18.0k|#  define inflate_table         z_inflate_table
  ------------------
  814|  18.0k|                                &(state->lenbits), state->work);
  815|  18.0k|            if (ret) {
  ------------------
  |  Branch (815:17): [True: 2.27k, False: 15.7k]
  ------------------
  816|  2.27k|                strm->msg = (z_const char *)"invalid code lengths set";
  817|  2.27k|                state->mode = BAD;
  818|  2.27k|                break;
  819|  2.27k|            }
  820|  15.7k|            Tracev((stderr, "inflate:       code lengths ok\n"));
  821|  15.7k|            state->have = 0;
  822|  15.7k|            state->mode = CODELENS;
  823|       |                /* fallthrough */
  824|  30.5k|        case CODELENS:
  ------------------
  |  Branch (824:9): [True: 14.8k, False: 12.3M]
  ------------------
  825|  1.26M|            while (state->have < state->nlen + state->ndist) {
  ------------------
  |  Branch (825:20): [True: 1.24M, False: 14.4k]
  ------------------
  826|  1.65M|                for (;;) {
  827|  1.65M|                    here = state->lencode[BITS(state->lenbits)];
  ------------------
  |  |  376|  1.65M|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  828|  1.65M|                    if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (828:25): [True: 1.23M, False: 417k]
  ------------------
  829|   417k|                    PULLBYTE();
  ------------------
  |  |  359|   417k|    do { \
  |  |  360|   417k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 11.9k, False: 405k]
  |  |  ------------------
  |  |  361|   417k|        have--; \
  |  |  362|   405k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|   405k|        bits += 8; \
  |  |  364|   405k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 405k]
  |  |  ------------------
  ------------------
  830|   417k|                }
  831|  1.23M|                if (here.val < 16) {
  ------------------
  |  Branch (831:21): [True: 1.03M, False: 195k]
  ------------------
  832|  1.03M|                    DROPBITS(here.bits);
  ------------------
  |  |  380|  1.03M|    do { \
  |  |  381|  1.03M|        hold >>= (n); \
  |  |  382|  1.03M|        bits -= (unsigned)(n); \
  |  |  383|  1.03M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 1.03M]
  |  |  ------------------
  ------------------
  833|  1.03M|                    state->lens[state->have++] = here.val;
  834|  1.03M|                }
  835|   195k|                else {
  836|   195k|                    if (here.val == 16) {
  ------------------
  |  Branch (836:25): [True: 138k, False: 57.1k]
  ------------------
  837|   138k|                        NEEDBITS(here.bits + 2);
  ------------------
  |  |  369|   138k|    do { \
  |  |  370|   175k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 37.5k, False: 138k]
  |  |  ------------------
  |  |  371|   138k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  37.5k|    do { \
  |  |  |  |  360|  37.5k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 417, False: 37.1k]
  |  |  |  |  ------------------
  |  |  |  |  361|  37.5k|        have--; \
  |  |  |  |  362|  37.1k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  37.1k|        bits += 8; \
  |  |  |  |  364|  37.1k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 37.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   138k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 138k]
  |  |  ------------------
  ------------------
  838|   138k|                        DROPBITS(here.bits);
  ------------------
  |  |  380|   138k|    do { \
  |  |  381|   138k|        hold >>= (n); \
  |  |  382|   138k|        bits -= (unsigned)(n); \
  |  |  383|   138k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 138k]
  |  |  ------------------
  ------------------
  839|   138k|                        if (state->have == 0) {
  ------------------
  |  Branch (839:29): [True: 104, False: 138k]
  ------------------
  840|    104|                            strm->msg = (z_const char *)
  841|    104|                                "invalid bit length repeat";
  842|    104|                            state->mode = BAD;
  843|    104|                            break;
  844|    104|                        }
  845|   138k|                        len = state->lens[state->have - 1];
  846|   138k|                        copy = 3 + BITS(2);
  ------------------
  |  |  376|   138k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  847|   138k|                        DROPBITS(2);
  ------------------
  |  |  380|   138k|    do { \
  |  |  381|   138k|        hold >>= (n); \
  |  |  382|   138k|        bits -= (unsigned)(n); \
  |  |  383|   138k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 138k]
  |  |  ------------------
  ------------------
  848|   138k|                    }
  849|  57.1k|                    else if (here.val == 17) {
  ------------------
  |  Branch (849:30): [True: 13.1k, False: 44.0k]
  ------------------
  850|  13.1k|                        NEEDBITS(here.bits + 3);
  ------------------
  |  |  369|  13.1k|    do { \
  |  |  370|  18.4k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 6.80k, False: 11.6k]
  |  |  ------------------
  |  |  371|  13.1k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  6.80k|    do { \
  |  |  |  |  360|  6.80k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.47k, False: 5.33k]
  |  |  |  |  ------------------
  |  |  |  |  361|  6.80k|        have--; \
  |  |  |  |  362|  5.33k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  5.33k|        bits += 8; \
  |  |  |  |  364|  5.33k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 5.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  13.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 11.6k]
  |  |  ------------------
  ------------------
  851|  11.6k|                        DROPBITS(here.bits);
  ------------------
  |  |  380|  11.6k|    do { \
  |  |  381|  11.6k|        hold >>= (n); \
  |  |  382|  11.6k|        bits -= (unsigned)(n); \
  |  |  383|  11.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 11.6k]
  |  |  ------------------
  ------------------
  852|  11.6k|                        len = 0;
  853|  11.6k|                        copy = 3 + BITS(3);
  ------------------
  |  |  376|  11.6k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  854|  11.6k|                        DROPBITS(3);
  ------------------
  |  |  380|  11.6k|    do { \
  |  |  381|  11.6k|        hold >>= (n); \
  |  |  382|  11.6k|        bits -= (unsigned)(n); \
  |  |  383|  11.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 11.6k]
  |  |  ------------------
  ------------------
  855|  11.6k|                    }
  856|  44.0k|                    else {
  857|  44.0k|                        NEEDBITS(here.bits + 7);
  ------------------
  |  |  369|  44.0k|    do { \
  |  |  370|  76.4k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 34.1k, False: 42.2k]
  |  |  ------------------
  |  |  371|  44.0k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  34.1k|    do { \
  |  |  |  |  360|  34.1k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 1.79k, False: 32.3k]
  |  |  |  |  ------------------
  |  |  |  |  361|  34.1k|        have--; \
  |  |  |  |  362|  32.3k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  32.3k|        bits += 8; \
  |  |  |  |  364|  32.3k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 32.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  44.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 42.2k]
  |  |  ------------------
  ------------------
  858|  42.2k|                        DROPBITS(here.bits);
  ------------------
  |  |  380|  42.2k|    do { \
  |  |  381|  42.2k|        hold >>= (n); \
  |  |  382|  42.2k|        bits -= (unsigned)(n); \
  |  |  383|  42.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 42.2k]
  |  |  ------------------
  ------------------
  859|  42.2k|                        len = 0;
  860|  42.2k|                        copy = 11 + BITS(7);
  ------------------
  |  |  376|  42.2k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  861|  42.2k|                        DROPBITS(7);
  ------------------
  |  |  380|  42.2k|    do { \
  |  |  381|  42.2k|        hold >>= (n); \
  |  |  382|  42.2k|        bits -= (unsigned)(n); \
  |  |  383|  42.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 42.2k]
  |  |  ------------------
  ------------------
  862|  42.2k|                    }
  863|   192k|                    if (state->have + copy > state->nlen + state->ndist) {
  ------------------
  |  Branch (863:25): [True: 397, False: 191k]
  ------------------
  864|    397|                        strm->msg = (z_const char *)
  865|    397|                            "invalid bit length repeat";
  866|    397|                        state->mode = BAD;
  867|    397|                        break;
  868|    397|                    }
  869|  3.70M|                    while (copy--)
  ------------------
  |  Branch (869:28): [True: 3.51M, False: 191k]
  ------------------
  870|  3.51M|                        state->lens[state->have++] = (unsigned short)len;
  871|   191k|                }
  872|  1.23M|            }
  873|       |
  874|       |            /* handle error breaks in while */
  875|  14.9k|            if (state->mode == BAD) break;
  ------------------
  |  Branch (875:17): [True: 501, False: 14.4k]
  ------------------
  876|       |
  877|       |            /* check for end-of-block code (better have one) */
  878|  14.4k|            if (state->lens[256] == 0) {
  ------------------
  |  Branch (878:17): [True: 145, False: 14.3k]
  ------------------
  879|    145|                strm->msg = (z_const char *)
  880|    145|                    "invalid code -- missing end-of-block";
  881|    145|                state->mode = BAD;
  882|    145|                break;
  883|    145|            }
  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|  14.3k|            state->next = state->codes;
  889|  14.3k|            state->lencode = (const code FAR *)(state->next);
  890|  14.3k|            state->lenbits = 9;
  891|  14.3k|            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
  ------------------
  |  |  140|  14.3k|#  define inflate_table         z_inflate_table
  ------------------
  892|  14.3k|                                &(state->lenbits), state->work);
  893|  14.3k|            if (ret) {
  ------------------
  |  Branch (893:17): [True: 388, False: 13.9k]
  ------------------
  894|    388|                strm->msg = (z_const char *)"invalid literal/lengths set";
  895|    388|                state->mode = BAD;
  896|    388|                break;
  897|    388|            }
  898|  13.9k|            state->distcode = (const code FAR *)(state->next);
  899|  13.9k|            state->distbits = 6;
  900|  13.9k|            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
  ------------------
  |  |  140|  13.9k|#  define inflate_table         z_inflate_table
  ------------------
  901|  13.9k|                            &(state->next), &(state->distbits), state->work);
  902|  13.9k|            if (ret) {
  ------------------
  |  Branch (902:17): [True: 393, False: 13.5k]
  ------------------
  903|    393|                strm->msg = (z_const char *)"invalid distances set";
  904|    393|                state->mode = BAD;
  905|    393|                break;
  906|    393|            }
  907|  13.5k|            Tracev((stderr, "inflate:       codes ok\n"));
  908|  13.5k|            state->mode = LEN_;
  909|  13.5k|            if (flush == Z_TREES) goto inf_leave;
  ------------------
  |  |  178|  13.5k|#define Z_TREES         6
  ------------------
  |  Branch (909:17): [True: 0, False: 13.5k]
  ------------------
  910|       |                /* fallthrough */
  911|   100k|        case LEN_:
  ------------------
  |  Branch (911:9): [True: 86.8k, False: 12.3M]
  ------------------
  912|   100k|            state->mode = LEN;
  913|       |                /* fallthrough */
  914|  5.79M|        case LEN:
  ------------------
  |  Branch (914:9): [True: 5.69M, False: 6.69M]
  ------------------
  915|  5.79M|            if (have >= 6 && left >= 258) {
  ------------------
  |  Branch (915:17): [True: 5.50M, False: 291k]
  |  Branch (915:30): [True: 274k, False: 5.23M]
  ------------------
  916|   274k|                RESTORE();
  ------------------
  |  |  340|   274k|    do { \
  |  |  341|   274k|        strm->next_out = put; \
  |  |  342|   274k|        strm->avail_out = left; \
  |  |  343|   274k|        strm->next_in = next; \
  |  |  344|   274k|        strm->avail_in = have; \
  |  |  345|   274k|        state->hold = hold; \
  |  |  346|   274k|        state->bits = bits; \
  |  |  347|   274k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 274k]
  |  |  ------------------
  ------------------
  917|   274k|                inflate_fast(strm, out);
  ------------------
  |  |  139|   274k|#  define inflate_fast          z_inflate_fast
  ------------------
  918|   274k|                LOAD();
  ------------------
  |  |  329|   274k|    do { \
  |  |  330|   274k|        put = strm->next_out; \
  |  |  331|   274k|        left = strm->avail_out; \
  |  |  332|   274k|        next = strm->next_in; \
  |  |  333|   274k|        have = strm->avail_in; \
  |  |  334|   274k|        hold = state->hold; \
  |  |  335|   274k|        bits = state->bits; \
  |  |  336|   274k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (336:14): [Folded, False: 274k]
  |  |  ------------------
  ------------------
  919|   274k|                if (state->mode == TYPE)
  ------------------
  |  Branch (919:21): [True: 80.2k, False: 193k]
  ------------------
  920|  80.2k|                    state->back = -1;
  921|   274k|                break;
  922|   274k|            }
  923|  5.52M|            state->back = 0;
  924|  10.0M|            for (;;) {
  925|  10.0M|                here = state->lencode[BITS(state->lenbits)];
  ------------------
  |  |  376|  10.0M|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  926|  10.0M|                if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (926:21): [True: 5.46M, False: 4.60M]
  ------------------
  927|  4.60M|                PULLBYTE();
  ------------------
  |  |  359|  4.60M|    do { \
  |  |  360|  4.60M|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 52.2k, False: 4.54M]
  |  |  ------------------
  |  |  361|  4.60M|        have--; \
  |  |  362|  4.54M|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|  4.54M|        bits += 8; \
  |  |  364|  4.54M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 4.54M]
  |  |  ------------------
  ------------------
  928|  4.60M|            }
  929|  5.46M|            if (here.op && (here.op & 0xf0) == 0) {
  ------------------
  |  Branch (929:17): [True: 599k, False: 4.86M]
  |  Branch (929:28): [True: 25.2k, False: 574k]
  ------------------
  930|  25.2k|                last = here;
  931|  32.4k|                for (;;) {
  932|  32.4k|                    here = state->lencode[last.val +
  933|  32.4k|                            (BITS(last.bits + last.op) >> last.bits)];
  ------------------
  |  |  376|  32.4k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  934|  32.4k|                    if ((unsigned)(last.bits + here.bits) <= bits) break;
  ------------------
  |  Branch (934:25): [True: 24.2k, False: 8.27k]
  ------------------
  935|  8.27k|                    PULLBYTE();
  ------------------
  |  |  359|  8.27k|    do { \
  |  |  360|  8.27k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 1.02k, False: 7.24k]
  |  |  ------------------
  |  |  361|  8.27k|        have--; \
  |  |  362|  7.24k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|  7.24k|        bits += 8; \
  |  |  364|  7.24k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 7.24k]
  |  |  ------------------
  ------------------
  936|  8.27k|                }
  937|  24.2k|                DROPBITS(last.bits);
  ------------------
  |  |  380|  24.2k|    do { \
  |  |  381|  24.2k|        hold >>= (n); \
  |  |  382|  24.2k|        bits -= (unsigned)(n); \
  |  |  383|  24.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 24.2k]
  |  |  ------------------
  ------------------
  938|  24.2k|                state->back += last.bits;
  939|  24.2k|            }
  940|  5.46M|            DROPBITS(here.bits);
  ------------------
  |  |  380|  5.46M|    do { \
  |  |  381|  5.46M|        hold >>= (n); \
  |  |  382|  5.46M|        bits -= (unsigned)(n); \
  |  |  383|  5.46M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 5.46M]
  |  |  ------------------
  ------------------
  941|  5.46M|            state->back += here.bits;
  942|  5.46M|            state->length = (unsigned)here.val;
  943|  5.46M|            if ((int)(here.op) == 0) {
  ------------------
  |  Branch (943:17): [True: 4.87M, False: 592k]
  ------------------
  944|  4.87M|                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
  945|  4.87M|                        "inflate:         literal '%c'\n" :
  946|  4.87M|                        "inflate:         literal 0x%02x\n", here.val));
  947|  4.87M|                state->mode = LIT;
  948|  4.87M|                break;
  949|  4.87M|            }
  950|   592k|            if (here.op & 32) {
  ------------------
  |  Branch (950:17): [True: 10.5k, False: 581k]
  ------------------
  951|  10.5k|                Tracevv((stderr, "inflate:         end of block\n"));
  952|  10.5k|                state->back = -1;
  953|  10.5k|                state->mode = TYPE;
  954|  10.5k|                break;
  955|  10.5k|            }
  956|   581k|            if (here.op & 64) {
  ------------------
  |  Branch (956:17): [True: 96, False: 581k]
  ------------------
  957|     96|                strm->msg = (z_const char *)"invalid literal/length code";
  958|     96|                state->mode = BAD;
  959|     96|                break;
  960|     96|            }
  961|   581k|            state->extra = (unsigned)(here.op) & 15;
  962|   581k|            state->mode = LENEXT;
  963|       |                /* fallthrough */
  964|   585k|        case LENEXT:
  ------------------
  |  Branch (964:9): [True: 3.92k, False: 12.3M]
  ------------------
  965|   585k|            if (state->extra) {
  ------------------
  |  Branch (965:17): [True: 195k, False: 390k]
  ------------------
  966|   195k|                NEEDBITS(state->extra);
  ------------------
  |  |  369|   195k|    do { \
  |  |  370|   221k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 30.6k, False: 191k]
  |  |  ------------------
  |  |  371|   195k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|  30.6k|    do { \
  |  |  |  |  360|  30.6k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 4.16k, False: 26.4k]
  |  |  |  |  ------------------
  |  |  |  |  361|  30.6k|        have--; \
  |  |  |  |  362|  26.4k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|  26.4k|        bits += 8; \
  |  |  |  |  364|  26.4k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 26.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   195k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 191k]
  |  |  ------------------
  ------------------
  967|   191k|                state->length += BITS(state->extra);
  ------------------
  |  |  376|   191k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  968|   191k|                DROPBITS(state->extra);
  ------------------
  |  |  380|   191k|    do { \
  |  |  381|   191k|        hold >>= (n); \
  |  |  382|   191k|        bits -= (unsigned)(n); \
  |  |  383|   191k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 191k]
  |  |  ------------------
  ------------------
  969|   191k|                state->back += state->extra;
  970|   191k|            }
  971|   581k|            Tracevv((stderr, "inflate:         length %u\n", state->length));
  972|   581k|            state->was = state->length;
  973|   581k|            state->mode = DIST;
  974|       |                /* fallthrough */
  975|   589k|        case DIST:
  ------------------
  |  Branch (975:9): [True: 7.95k, False: 12.3M]
  ------------------
  976|   804k|            for (;;) {
  977|   804k|                here = state->distcode[BITS(state->distbits)];
  ------------------
  |  |  376|   804k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  978|   804k|                if ((unsigned)(here.bits) <= bits) break;
  ------------------
  |  Branch (978:21): [True: 580k, False: 223k]
  ------------------
  979|   223k|                PULLBYTE();
  ------------------
  |  |  359|   223k|    do { \
  |  |  360|   223k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 8.62k, False: 214k]
  |  |  ------------------
  |  |  361|   223k|        have--; \
  |  |  362|   214k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|   214k|        bits += 8; \
  |  |  364|   214k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 214k]
  |  |  ------------------
  ------------------
  980|   223k|            }
  981|   580k|            if ((here.op & 0xf0) == 0) {
  ------------------
  |  Branch (981:17): [True: 4.66k, False: 576k]
  ------------------
  982|  4.66k|                last = here;
  983|  7.23k|                for (;;) {
  984|  7.23k|                    here = state->distcode[last.val +
  985|  7.23k|                            (BITS(last.bits + last.op) >> last.bits)];
  ------------------
  |  |  376|  7.23k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
  986|  7.23k|                    if ((unsigned)(last.bits + here.bits) <= bits) break;
  ------------------
  |  Branch (986:25): [True: 4.44k, False: 2.78k]
  ------------------
  987|  2.78k|                    PULLBYTE();
  ------------------
  |  |  359|  2.78k|    do { \
  |  |  360|  2.78k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (360:13): [True: 217, False: 2.56k]
  |  |  ------------------
  |  |  361|  2.78k|        have--; \
  |  |  362|  2.56k|        hold += (unsigned long)(*next++) << bits; \
  |  |  363|  2.56k|        bits += 8; \
  |  |  364|  2.56k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (364:14): [Folded, False: 2.56k]
  |  |  ------------------
  ------------------
  988|  2.78k|                }
  989|  4.44k|                DROPBITS(last.bits);
  ------------------
  |  |  380|  4.44k|    do { \
  |  |  381|  4.44k|        hold >>= (n); \
  |  |  382|  4.44k|        bits -= (unsigned)(n); \
  |  |  383|  4.44k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 4.44k]
  |  |  ------------------
  ------------------
  990|  4.44k|                state->back += last.bits;
  991|  4.44k|            }
  992|   580k|            DROPBITS(here.bits);
  ------------------
  |  |  380|   580k|    do { \
  |  |  381|   580k|        hold >>= (n); \
  |  |  382|   580k|        bits -= (unsigned)(n); \
  |  |  383|   580k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 580k]
  |  |  ------------------
  ------------------
  993|   580k|            state->back += here.bits;
  994|   580k|            if (here.op & 64) {
  ------------------
  |  Branch (994:17): [True: 145, False: 580k]
  ------------------
  995|    145|                strm->msg = (z_const char *)"invalid distance code";
  996|    145|                state->mode = BAD;
  997|    145|                break;
  998|    145|            }
  999|   580k|            state->offset = (unsigned)here.val;
 1000|   580k|            state->extra = (unsigned)(here.op) & 15;
 1001|   580k|            state->mode = DISTEXT;
 1002|       |                /* fallthrough */
 1003|   585k|        case DISTEXT:
  ------------------
  |  Branch (1003:9): [True: 5.16k, False: 12.3M]
  ------------------
 1004|   585k|            if (state->extra) {
  ------------------
  |  Branch (1004:17): [True: 385k, False: 200k]
  ------------------
 1005|   385k|                NEEDBITS(state->extra);
  ------------------
  |  |  369|   385k|    do { \
  |  |  370|   491k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 112k, False: 379k]
  |  |  ------------------
  |  |  371|   385k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   112k|    do { \
  |  |  |  |  360|   112k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 6.20k, False: 106k]
  |  |  |  |  ------------------
  |  |  |  |  361|   112k|        have--; \
  |  |  |  |  362|   106k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   106k|        bits += 8; \
  |  |  |  |  364|   106k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 106k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|   385k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 379k]
  |  |  ------------------
  ------------------
 1006|   379k|                state->offset += BITS(state->extra);
  ------------------
  |  |  376|   379k|    ((unsigned)hold & ((1U << (n)) - 1))
  ------------------
 1007|   379k|                DROPBITS(state->extra);
  ------------------
  |  |  380|   379k|    do { \
  |  |  381|   379k|        hold >>= (n); \
  |  |  382|   379k|        bits -= (unsigned)(n); \
  |  |  383|   379k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (383:14): [Folded, False: 379k]
  |  |  ------------------
  ------------------
 1008|   379k|                state->back += state->extra;
 1009|   379k|            }
 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|   579k|            Tracevv((stderr, "inflate:         distance %u\n", state->offset));
 1018|   579k|            state->mode = MATCH;
 1019|       |                /* fallthrough */
 1020|  1.77M|        case MATCH:
  ------------------
  |  Branch (1020:9): [True: 1.19M, False: 11.1M]
  ------------------
 1021|  1.77M|            if (left == 0) goto inf_leave;
  ------------------
  |  Branch (1021:17): [True: 442k, False: 1.32M]
  ------------------
 1022|  1.32M|            copy = out - left;
 1023|  1.32M|            if (state->offset > copy) {         /* copy from window */
  ------------------
  |  Branch (1023:17): [True: 516k, False: 812k]
  ------------------
 1024|   516k|                copy = state->offset - copy;
 1025|   516k|                if (copy > state->whave) {
  ------------------
  |  Branch (1025:21): [True: 1.13k, False: 514k]
  ------------------
 1026|  1.13k|                    if (state->sane) {
  ------------------
  |  Branch (1026:25): [True: 1.13k, False: 0]
  ------------------
 1027|  1.13k|                        strm->msg = (z_const char *)
 1028|  1.13k|                            "invalid distance too far back";
 1029|  1.13k|                        state->mode = BAD;
 1030|  1.13k|                        break;
 1031|  1.13k|                    }
 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|  1.13k|                }
 1046|   514k|                if (copy > state->wnext) {
  ------------------
  |  Branch (1046:21): [True: 16.6k, False: 498k]
  ------------------
 1047|  16.6k|                    copy -= state->wnext;
 1048|  16.6k|                    from = state->window + (state->wsize - copy);
 1049|  16.6k|                }
 1050|   498k|                else
 1051|   498k|                    from = state->window + (state->wnext - copy);
 1052|   514k|                if (copy > state->length) copy = state->length;
  ------------------
  |  Branch (1052:21): [True: 152k, False: 362k]
  ------------------
 1053|   514k|            }
 1054|   812k|            else {                              /* copy from output */
 1055|   812k|                from = put - state->offset;
 1056|   812k|                copy = state->length;
 1057|   812k|            }
 1058|  1.32M|            if (copy > left) copy = left;
  ------------------
  |  Branch (1058:17): [True: 425k, False: 902k]
  ------------------
 1059|  1.32M|            left -= copy;
 1060|  1.32M|            state->length -= copy;
 1061|  52.3M|            do {
 1062|  52.3M|                *put++ = *from++;
 1063|  52.3M|            } while (--copy);
  ------------------
  |  Branch (1063:22): [True: 50.9M, False: 1.32M]
  ------------------
 1064|  1.32M|            if (state->length == 0) state->mode = LEN;
  ------------------
  |  Branch (1064:17): [True: 576k, False: 750k]
  ------------------
 1065|  1.32M|            break;
 1066|  4.91M|        case LIT:
  ------------------
  |  Branch (1066:9): [True: 4.91M, False: 7.47M]
  ------------------
 1067|  4.91M|            if (left == 0) goto inf_leave;
  ------------------
  |  Branch (1067:17): [True: 38.1k, False: 4.87M]
  ------------------
 1068|  4.87M|            *put++ = (unsigned char)(state->length);
 1069|  4.87M|            left--;
 1070|  4.87M|            state->mode = LEN;
 1071|  4.87M|            break;
 1072|  82.9k|        case CHECK:
  ------------------
  |  Branch (1072:9): [True: 82.9k, False: 12.3M]
  ------------------
 1073|  82.9k|            if (state->wrap) {
  ------------------
  |  Branch (1073:17): [True: 82.9k, False: 0]
  ------------------
 1074|  82.9k|                NEEDBITS(32);
  ------------------
  |  |  369|  82.9k|    do { \
  |  |  370|   411k|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (370:16): [True: 330k, False: 80.9k]
  |  |  ------------------
  |  |  371|   330k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  359|   330k|    do { \
  |  |  |  |  360|   330k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (360:13): [True: 2.04k, False: 328k]
  |  |  |  |  ------------------
  |  |  |  |  361|   330k|        have--; \
  |  |  |  |  362|   328k|        hold += (unsigned long)(*next++) << bits; \
  |  |  |  |  363|   328k|        bits += 8; \
  |  |  |  |  364|   328k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (364:14): [Folded, False: 328k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  82.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (372:14): [Folded, False: 80.9k]
  |  |  ------------------
  ------------------
 1075|  80.9k|                out -= left;
 1076|  80.9k|                strm->total_out += out;
 1077|  80.9k|                state->total += out;
 1078|  80.9k|                if ((state->wrap & 4) && out)
  ------------------
  |  Branch (1078:21): [True: 80.9k, False: 0]
  |  Branch (1078:42): [True: 80.0k, False: 900]
  ------------------
 1079|  80.0k|                    strm->adler = state->check =
 1080|  80.0k|                        UPDATE_CHECK(state->check, put - out, out);
  ------------------
  |  |  305|  80.0k|#  define UPDATE_CHECK(check, buf, len) adler32(check, buf, len)
  |  |  ------------------
  |  |  |  |   34|  80.0k|#  define adler32               z_adler32
  |  |  ------------------
  ------------------
 1081|  80.9k|                out = left;
 1082|  80.9k|                if ((state->wrap & 4) && (
  ------------------
  |  Branch (1082:21): [True: 80.9k, False: 0]
  |  Branch (1082:42): [True: 8.79k, False: 72.1k]
  ------------------
 1083|       |#ifdef GUNZIP
 1084|       |                     state->flags ? hold :
 1085|       |#endif
 1086|  80.9k|                     ZSWAP32(hold)) != state->check) {
  ------------------
  |  |  258|  80.9k|#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
  |  |  259|  80.9k|                    (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
  ------------------
 1087|  8.79k|                    strm->msg = (z_const char *)"incorrect data check";
 1088|  8.79k|                    state->mode = BAD;
 1089|  8.79k|                    break;
 1090|  8.79k|                }
 1091|  72.1k|                INITBITS();
  ------------------
  |  |  351|  72.1k|    do { \
  |  |  352|  72.1k|        hold = 0; \
  |  |  353|  72.1k|        bits = 0; \
  |  |  354|  72.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (354:14): [Folded, False: 72.1k]
  |  |  ------------------
  ------------------
 1092|  72.1k|                Tracev((stderr, "inflate:   check matches trailer\n"));
 1093|  72.1k|            }
 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|  72.1k|            state->mode = DONE;
 1110|       |                /* fallthrough */
 1111|  72.1k|        case DONE:
  ------------------
  |  Branch (1111:9): [True: 13, False: 12.3M]
  ------------------
 1112|  72.1k|            ret = Z_STREAM_END;
  ------------------
  |  |  182|  72.1k|#define Z_STREAM_END    1
  ------------------
 1113|  72.1k|            goto inf_leave;
 1114|  29.3k|        case BAD:
  ------------------
  |  Branch (1114:9): [True: 29.3k, False: 12.3M]
  ------------------
 1115|  29.3k|            ret = Z_DATA_ERROR;
  ------------------
  |  |  186|  29.3k|#define Z_DATA_ERROR   (-3)
  ------------------
 1116|  29.3k|            goto inf_leave;
 1117|      0|        case MEM:
  ------------------
  |  Branch (1117:9): [True: 0, False: 12.3M]
  ------------------
 1118|      0|            return Z_MEM_ERROR;
  ------------------
  |  |  187|      0|#define Z_MEM_ERROR    (-4)
  ------------------
 1119|      0|        case SYNC:
  ------------------
  |  Branch (1119:9): [True: 0, False: 12.3M]
  ------------------
 1120|       |                /* fallthrough */
 1121|      0|        default:
  ------------------
  |  Branch (1121:9): [True: 0, False: 12.3M]
  ------------------
 1122|      0|            return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
 1123|  12.3M|        }
 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|   693k|  inf_leave:
 1132|   693k|    RESTORE();
  ------------------
  |  |  340|   693k|    do { \
  |  |  341|   693k|        strm->next_out = put; \
  |  |  342|   693k|        strm->avail_out = left; \
  |  |  343|   693k|        strm->next_in = next; \
  |  |  344|   693k|        strm->avail_in = have; \
  |  |  345|   693k|        state->hold = hold; \
  |  |  346|   693k|        state->bits = bits; \
  |  |  347|   693k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (347:14): [Folded, False: 693k]
  |  |  ------------------
  ------------------
 1133|   693k|    if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
  ------------------
  |  Branch (1133:9): [True: 557k, False: 135k]
  |  Branch (1133:26): [True: 15.2k, False: 120k]
  |  Branch (1133:52): [True: 12.9k, False: 2.30k]
  ------------------
 1134|  12.9k|            (state->mode < CHECK || flush != Z_FINISH)))
  ------------------
  |  |  176|  1.58k|#define Z_FINISH        4
  ------------------
  |  Branch (1134:14): [True: 11.3k, False: 1.58k]
  |  Branch (1134:37): [True: 1.58k, False: 0]
  ------------------
 1135|   570k|        if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
  ------------------
  |  Branch (1135:13): [True: 0, False: 570k]
  ------------------
 1136|      0|            state->mode = MEM;
 1137|      0|            return Z_MEM_ERROR;
  ------------------
  |  |  187|      0|#define Z_MEM_ERROR    (-4)
  ------------------
 1138|      0|        }
 1139|   693k|    in -= strm->avail_in;
 1140|   693k|    out -= strm->avail_out;
 1141|   693k|    strm->total_in += in;
 1142|   693k|    strm->total_out += out;
 1143|   693k|    state->total += out;
 1144|   693k|    if ((state->wrap & 4) && out)
  ------------------
  |  Branch (1144:9): [True: 693k, False: 0]
  |  Branch (1144:30): [True: 537k, False: 155k]
  ------------------
 1145|   537k|        strm->adler = state->check =
 1146|   537k|            UPDATE_CHECK(state->check, strm->next_out - out, out);
  ------------------
  |  |  305|   537k|#  define UPDATE_CHECK(check, buf, len) adler32(check, buf, len)
  |  |  ------------------
  |  |  |  |   34|   537k|#  define adler32               z_adler32
  |  |  ------------------
  ------------------
 1147|   693k|    strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
  ------------------
  |  Branch (1147:43): [True: 276k, False: 417k]
  ------------------
 1148|   693k|                      (state->mode == TYPE ? 128 : 0) +
  ------------------
  |  Branch (1148:24): [True: 511, False: 692k]
  ------------------
 1149|   693k|                      (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
  ------------------
  |  Branch (1149:24): [True: 0, False: 693k]
  |  Branch (1149:47): [True: 0, False: 693k]
  ------------------
 1150|   693k|    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
  ------------------
  |  |  176|   653k|#define Z_FINISH        4
  ------------------
                  if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
  ------------------
  |  |  181|  39.7k|#define Z_OK            0
  ------------------
  |  Branch (1150:11): [True: 358k, False: 334k]
  |  Branch (1150:22): [True: 39.7k, False: 319k]
  |  Branch (1150:35): [True: 0, False: 653k]
  |  Branch (1150:57): [True: 39.6k, False: 70]
  ------------------
 1151|  39.6k|        ret = Z_BUF_ERROR;
  ------------------
  |  |  188|  39.6k|#define Z_BUF_ERROR    (-5)
  ------------------
 1152|   693k|    return ret;
 1153|   693k|}
z_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: 15.6k, False: 113k]
  ------------------
 1158|  15.6k|        return Z_STREAM_ERROR;
  ------------------
  |  |  185|  15.6k|#define Z_STREAM_ERROR (-2)
  ------------------
 1159|   113k|    state = (struct inflate_state FAR *)strm->state;
 1160|   113k|    if (state->window != Z_NULL) ZFREE(strm, state->window);
  ------------------
  |  |  216|   113k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
                  if (state->window != Z_NULL) ZFREE(strm, state->window);
  ------------------
  |  |  254|  12.9k|#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  ------------------
  |  Branch (1160:9): [True: 12.9k, False: 100k]
  ------------------
 1161|   113k|    ZFREE(strm, strm->state);
  ------------------
  |  |  254|   113k|#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  ------------------
 1162|   113k|    strm->state = Z_NULL;
  ------------------
  |  |  216|   113k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
 1163|   113k|    Tracev((stderr, "inflate: end\n"));
 1164|   113k|    return Z_OK;
  ------------------
  |  |  181|   113k|#define Z_OK            0
  ------------------
 1165|   128k|}
z_inflateValidate:
 1385|   113k|int ZEXPORT inflateValidate(z_streamp strm, int check) {
 1386|   113k|    struct inflate_state FAR *state;
 1387|       |
 1388|   113k|    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
  ------------------
  |  |  185|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (1388:9): [True: 0, False: 113k]
  ------------------
 1389|   113k|    state = (struct inflate_state FAR *)strm->state;
 1390|   113k|    if (check && state->wrap)
  ------------------
  |  Branch (1390:9): [True: 113k, False: 0]
  |  Branch (1390:18): [True: 113k, False: 0]
  ------------------
 1391|   113k|        state->wrap |= 4;
 1392|      0|    else
 1393|      0|        state->wrap &= ~4;
 1394|   113k|    return Z_OK;
  ------------------
  |  |  181|   113k|#define Z_OK            0
  ------------------
 1395|   113k|}
inflate.c:inflateStateCheck:
   88|  1.27M|local int inflateStateCheck(z_streamp strm) {
   89|  1.27M|    struct inflate_state FAR *state;
   90|  1.27M|    if (strm == Z_NULL ||
  ------------------
  |  |  216|  2.55M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (90:9): [True: 0, False: 1.27M]
  ------------------
   91|  1.27M|        strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
  ------------------
  |  Branch (91:9): [True: 15.6k, False: 1.25M]
  |  Branch (91:42): [True: 0, False: 1.25M]
  ------------------
   92|  15.6k|        return 1;
   93|  1.25M|    state = (struct inflate_state FAR *)strm->state;
   94|  1.25M|    if (state == Z_NULL || state->strm != strm ||
  ------------------
  |  |  216|  2.51M|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (94:9): [True: 0, False: 1.25M]
  |  Branch (94:28): [True: 0, False: 1.25M]
  ------------------
   95|  1.25M|        state->mode < HEAD || state->mode > SYNC)
  ------------------
  |  Branch (95:9): [True: 0, False: 1.25M]
  |  Branch (95:31): [True: 0, False: 1.25M]
  ------------------
   96|      0|        return 1;
   97|  1.25M|    return 0;
   98|  1.25M|}
inflate.c:updatewindow:
  252|   570k|local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
  253|   570k|    struct inflate_state FAR *state;
  254|   570k|    unsigned dist;
  255|       |
  256|   570k|    state = (struct inflate_state FAR *)strm->state;
  257|       |
  258|       |    /* if it hasn't been done already, allocate space for the window */
  259|   570k|    if (state->window == Z_NULL) {
  ------------------
  |  |  216|   570k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (259:9): [True: 12.9k, False: 557k]
  ------------------
  260|  12.9k|        state->window = (unsigned char FAR *)
  261|  12.9k|                        ZALLOC(strm, 1U << state->wbits,
  ------------------
  |  |  253|  12.9k|           (*((strm)->zalloc))((strm)->opaque, (items), (size))
  ------------------
  262|  12.9k|                               sizeof(unsigned char));
  263|  12.9k|        if (state->window == Z_NULL) return 1;
  ------------------
  |  |  216|  12.9k|#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  ------------------
  |  Branch (263:13): [True: 0, False: 12.9k]
  ------------------
  264|  12.9k|    }
  265|       |
  266|       |    /* if window not in use yet, initialize */
  267|   570k|    if (state->wsize == 0) {
  ------------------
  |  Branch (267:9): [True: 12.9k, False: 557k]
  ------------------
  268|  12.9k|        state->wsize = 1U << state->wbits;
  269|  12.9k|        state->wnext = 0;
  270|  12.9k|        state->whave = 0;
  271|  12.9k|    }
  272|       |
  273|       |    /* copy state->wsize or less output bytes into the circular window */
  274|   570k|    if (copy >= state->wsize) {
  ------------------
  |  Branch (274:9): [True: 16.1k, False: 554k]
  ------------------
  275|  16.1k|        zmemcpy(state->window, end - state->wsize, state->wsize);
  ------------------
  |  |  216|  16.1k|#    define zmemcpy memcpy
  ------------------
  276|  16.1k|        state->wnext = 0;
  277|  16.1k|        state->whave = state->wsize;
  278|  16.1k|    }
  279|   554k|    else {
  280|   554k|        dist = state->wsize - state->wnext;
  281|   554k|        if (dist > copy) dist = copy;
  ------------------
  |  Branch (281:13): [True: 545k, False: 8.53k]
  ------------------
  282|   554k|        zmemcpy(state->window + state->wnext, end - copy, dist);
  ------------------
  |  |  216|   554k|#    define zmemcpy memcpy
  ------------------
  283|   554k|        copy -= dist;
  284|   554k|        if (copy) {
  ------------------
  |  Branch (284:13): [True: 4.55k, False: 549k]
  ------------------
  285|  4.55k|            zmemcpy(state->window, end - copy, copy);
  ------------------
  |  |  216|  4.55k|#    define zmemcpy memcpy
  ------------------
  286|  4.55k|            state->wnext = copy;
  287|  4.55k|            state->whave = state->wsize;
  288|  4.55k|        }
  289|   549k|        else {
  290|   549k|            state->wnext += dist;
  291|   549k|            if (state->wnext == state->wsize) state->wnext = 0;
  ------------------
  |  Branch (291:17): [True: 3.97k, False: 545k]
  ------------------
  292|   549k|            if (state->whave < state->wsize) state->whave += dist;
  ------------------
  |  Branch (292:17): [True: 481k, False: 68.6k]
  ------------------
  293|   549k|        }
  294|   554k|    }
  295|   570k|    return 0;
  296|   570k|}

z_inflate_table:
   48|  46.2k|                                unsigned FAR *bits, unsigned short FAR *work) {
   49|  46.2k|    unsigned len;               /* a code's length in bits */
   50|  46.2k|    unsigned sym;               /* index of code symbols */
   51|  46.2k|    unsigned min, max;          /* minimum and maximum code lengths */
   52|  46.2k|    unsigned root;              /* number of index bits for root table */
   53|  46.2k|    unsigned curr;              /* number of index bits for current table */
   54|  46.2k|    unsigned drop;              /* code bits to drop for sub-table */
   55|  46.2k|    int left;                   /* number of prefix codes available */
   56|  46.2k|    unsigned used;              /* code entries in table used */
   57|  46.2k|    unsigned huff;              /* Huffman code */
   58|  46.2k|    unsigned incr;              /* for incrementing code, index */
   59|  46.2k|    unsigned fill;              /* index for replicating entries */
   60|  46.2k|    unsigned low;               /* low bits for current root entry */
   61|  46.2k|    unsigned mask;              /* mask for low root bits */
   62|  46.2k|    code here;                  /* table entry for duplication */
   63|  46.2k|    code FAR *next;             /* next available space in table */
   64|  46.2k|    const unsigned short FAR *base = NULL;  /* base value table to use */
   65|  46.2k|    const unsigned short FAR *extra = NULL; /* extra bits table to use */
   66|  46.2k|    unsigned match = 0;         /* use base and extra for symbol >= match */
   67|  46.2k|    unsigned short count[MAXBITS+1];    /* number of codes of each length */
   68|  46.2k|    unsigned short offs[MAXBITS+1];     /* offsets in table for each length */
   69|  46.2k|    static const unsigned short lbase[31] = { /* Length codes 257..285 base */
   70|  46.2k|        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
   71|  46.2k|        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
   72|  46.2k|    static const unsigned short lext[31] = { /* Length codes 257..285 extra */
   73|  46.2k|        16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
   74|  46.2k|        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 75};
   75|  46.2k|    static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
   76|  46.2k|        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
   77|  46.2k|        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
   78|  46.2k|        8193, 12289, 16385, 24577, 0, 0};
   79|  46.2k|    static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
   80|  46.2k|        16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
   81|  46.2k|        23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
   82|  46.2k|        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|   786k|    for (len = 0; len <= MAXBITS; len++)
  ------------------
  |  |   23|   786k|#define MAXBITS 15
  ------------------
  |  Branch (116:19): [True: 740k, False: 46.2k]
  ------------------
  117|   740k|        count[len] = 0;
  118|  4.69M|    for (sym = 0; sym < codes; sym++)
  ------------------
  |  Branch (118:19): [True: 4.65M, False: 46.2k]
  ------------------
  119|  4.65M|        count[lens[sym]]++;
  120|       |
  121|       |    /* bound code lengths, force root to be within code lengths */
  122|  46.2k|    root = *bits;
  123|   481k|    for (max = MAXBITS; max >= 1; max--)
  ------------------
  |  |   23|  46.2k|#define MAXBITS 15
  ------------------
  |  Branch (123:25): [True: 481k, False: 405]
  ------------------
  124|   481k|        if (count[max] != 0) break;
  ------------------
  |  Branch (124:13): [True: 45.8k, False: 435k]
  ------------------
  125|  46.2k|    if (root > max) root = max;
  ------------------
  |  Branch (125:9): [True: 32.1k, False: 14.1k]
  ------------------
  126|  46.2k|    if (max == 0) {                     /* no symbols to code at all */
  ------------------
  |  Branch (126:9): [True: 405, False: 45.8k]
  ------------------
  127|    405|        here.op = (unsigned char)64;    /* invalid code marker */
  128|    405|        here.bits = (unsigned char)1;
  129|    405|        here.val = (unsigned short)0;
  130|    405|        *(*table)++ = here;             /* make a table to force an error */
  131|    405|        *(*table)++ = here;
  132|    405|        *bits = 1;
  133|    405|        return 0;     /* no symbols, but wait for decoding to report error */
  134|    405|    }
  135|  95.8k|    for (min = 1; min < max; min++)
  ------------------
  |  Branch (135:19): [True: 94.0k, False: 1.72k]
  ------------------
  136|  94.0k|        if (count[min] != 0) break;
  ------------------
  |  Branch (136:13): [True: 44.1k, False: 49.9k]
  ------------------
  137|  45.8k|    if (root < min) root = min;
  ------------------
  |  Branch (137:9): [True: 77, False: 45.7k]
  ------------------
  138|       |
  139|       |    /* check for an over-subscribed or incomplete set of lengths */
  140|  45.8k|    left = 1;
  141|   724k|    for (len = 1; len <= MAXBITS; len++) {
  ------------------
  |  |   23|   724k|#define MAXBITS 15
  ------------------
  |  Branch (141:19): [True: 679k, False: 45.1k]
  ------------------
  142|   679k|        left <<= 1;
  143|   679k|        left -= count[len];
  144|   679k|        if (left < 0) return -1;        /* over-subscribed */
  ------------------
  |  Branch (144:13): [True: 738, False: 678k]
  ------------------
  145|   679k|    }
  146|  45.1k|    if (left > 0 && (type == CODES || max != 1))
  ------------------
  |  Branch (146:9): [True: 2.32k, False: 42.7k]
  |  Branch (146:22): [True: 1.86k, False: 462]
  |  Branch (146:39): [True: 455, False: 7]
  ------------------
  147|  2.31k|        return -1;                      /* incomplete set */
  148|       |
  149|       |    /* generate offsets into symbol table for each length for sorting */
  150|  42.8k|    offs[1] = 0;
  151|   642k|    for (len = 1; len < MAXBITS; len++)
  ------------------
  |  |   23|   642k|#define MAXBITS 15
  ------------------
  |  Branch (151:19): [True: 599k, False: 42.8k]
  ------------------
  152|   599k|        offs[len + 1] = offs[len] + count[len];
  153|       |
  154|       |    /* sort symbols by length, by symbol order within each length */
  155|  4.53M|    for (sym = 0; sym < codes; sym++)
  ------------------
  |  Branch (155:19): [True: 4.48M, False: 42.8k]
  ------------------
  156|  4.48M|        if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
  ------------------
  |  Branch (156:13): [True: 1.69M, False: 2.79M]
  ------------------
  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|  42.8k|    switch (type) {
  ------------------
  |  Branch (190:13): [True: 42.8k, False: 0]
  ------------------
  191|  15.4k|    case CODES:
  ------------------
  |  Branch (191:5): [True: 15.4k, False: 27.3k]
  ------------------
  192|  15.4k|        match = 20;
  193|  15.4k|        break;
  194|  13.9k|    case LENS:
  ------------------
  |  Branch (194:5): [True: 13.9k, False: 28.8k]
  ------------------
  195|  13.9k|        base = lbase;
  196|  13.9k|        extra = lext;
  197|  13.9k|        match = 257;
  198|  13.9k|        break;
  199|  13.4k|    case DISTS:
  ------------------
  |  Branch (199:5): [True: 13.4k, False: 29.3k]
  ------------------
  200|  13.4k|        base = dbase;
  201|  13.4k|        extra = dext;
  202|  42.8k|    }
  203|       |
  204|       |    /* initialize state for loop */
  205|  42.8k|    huff = 0;                   /* starting code */
  206|  42.8k|    sym = 0;                    /* starting code symbol */
  207|  42.8k|    len = min;                  /* starting code length */
  208|  42.8k|    next = *table;              /* current table to fill in */
  209|  42.8k|    curr = root;                /* current table index bits */
  210|  42.8k|    drop = 0;                   /* current bits to drop from code for index */
  211|  42.8k|    low = (unsigned)(-1);       /* trigger new sub-table when len > root */
  212|  42.8k|    used = 1U << root;          /* use root table entries */
  213|  42.8k|    mask = used - 1;            /* mask for comparing low */
  214|       |
  215|       |    /* check available table space */
  216|  42.8k|    if ((type == LENS && used > ENOUGH_LENS) ||
  ------------------
  |  |   49|  13.9k|#define ENOUGH_LENS 852
  ------------------
  |  Branch (216:10): [True: 13.9k, False: 28.8k]
  |  Branch (216:26): [True: 0, False: 13.9k]
  ------------------
  217|  42.8k|        (type == DISTS && used > ENOUGH_DISTS))
  ------------------
  |  |   50|  13.4k|#define ENOUGH_DISTS 592
  ------------------
  |  Branch (217:10): [True: 13.4k, False: 29.3k]
  |  Branch (217:27): [True: 0, False: 13.4k]
  ------------------
  218|      0|        return 1;
  219|       |
  220|       |    /* process all codes and make table entries */
  221|  1.69M|    for (;;) {
  222|       |        /* create table entry */
  223|  1.69M|        here.bits = (unsigned char)(len - drop);
  224|  1.69M|        if (work[sym] + 1U < match) {
  ------------------
  |  Branch (224:13): [True: 1.40M, False: 289k]
  ------------------
  225|  1.40M|            here.op = (unsigned char)0;
  226|  1.40M|            here.val = work[sym];
  227|  1.40M|        }
  228|   289k|        else if (work[sym] >= match) {
  ------------------
  |  Branch (228:18): [True: 275k, False: 13.9k]
  ------------------
  229|   275k|            here.op = (unsigned char)(extra[work[sym] - match]);
  230|   275k|            here.val = base[work[sym] - match];
  231|   275k|        }
  232|  13.9k|        else {
  233|  13.9k|            here.op = (unsigned char)(32 + 64);         /* end of block */
  234|  13.9k|            here.val = 0;
  235|  13.9k|        }
  236|       |
  237|       |        /* replicate for those indices with low len bits equal to huff */
  238|  1.69M|        incr = 1U << (len - drop);
  239|  1.69M|        fill = 1U << curr;
  240|  1.69M|        min = fill;                 /* save offset to next table */
  241|  4.17M|        do {
  242|  4.17M|            fill -= incr;
  243|  4.17M|            next[(huff >> drop) + fill] = here;
  244|  4.17M|        } while (fill != 0);
  ------------------
  |  Branch (244:18): [True: 2.47M, False: 1.69M]
  ------------------
  245|       |
  246|       |        /* backwards increment the len-bit code huff */
  247|  1.69M|        incr = 1U << (len - 1);
  248|  3.34M|        while (huff & incr)
  ------------------
  |  Branch (248:16): [True: 1.65M, False: 1.69M]
  ------------------
  249|  1.65M|            incr >>= 1;
  250|  1.69M|        if (incr != 0) {
  ------------------
  |  Branch (250:13): [True: 1.65M, False: 42.7k]
  ------------------
  251|  1.65M|            huff &= incr - 1;
  252|  1.65M|            huff += incr;
  253|  1.65M|        }
  254|  42.7k|        else
  255|  42.7k|            huff = 0;
  256|       |
  257|       |        /* go to next symbol, update count, len */
  258|  1.69M|        sym++;
  259|  1.69M|        if (--(count[len]) == 0) {
  ------------------
  |  Branch (259:13): [True: 178k, False: 1.51M]
  ------------------
  260|   178k|            if (len == max) break;
  ------------------
  |  Branch (260:17): [True: 42.8k, False: 136k]
  ------------------
  261|   136k|            len = lens[work[sym]];
  262|   136k|        }
  263|       |
  264|       |        /* create new sub-table if needed */
  265|  1.65M|        if (len > root && (huff & mask) != low) {
  ------------------
  |  Branch (265:13): [True: 154k, False: 1.49M]
  |  Branch (265:27): [True: 52.4k, False: 101k]
  ------------------
  266|       |            /* if first time, transition to sub-tables */
  267|  52.4k|            if (drop == 0)
  ------------------
  |  Branch (267:17): [True: 7.00k, False: 45.4k]
  ------------------
  268|  7.00k|                drop = root;
  269|       |
  270|       |            /* increment past last table */
  271|  52.4k|            next += min;            /* here min is 1 << curr */
  272|       |
  273|       |            /* determine length of next table */
  274|  52.4k|            curr = len - drop;
  275|  52.4k|            left = (int)(1 << curr);
  276|  63.9k|            while (curr + drop < max) {
  ------------------
  |  Branch (276:20): [True: 54.6k, False: 9.23k]
  ------------------
  277|  54.6k|                left -= count[curr + drop];
  278|  54.6k|                if (left <= 0) break;
  ------------------
  |  Branch (278:21): [True: 43.2k, False: 11.4k]
  ------------------
  279|  11.4k|                curr++;
  280|  11.4k|                left <<= 1;
  281|  11.4k|            }
  282|       |
  283|       |            /* check for enough space */
  284|  52.4k|            used += 1U << curr;
  285|  52.4k|            if ((type == LENS && used > ENOUGH_LENS) ||
  ------------------
  |  |   49|  46.9k|#define ENOUGH_LENS 852
  ------------------
  |  Branch (285:18): [True: 46.9k, False: 5.54k]
  |  Branch (285:34): [True: 0, False: 46.9k]
  ------------------
  286|  52.4k|                (type == DISTS && used > ENOUGH_DISTS))
  ------------------
  |  |   50|  5.54k|#define ENOUGH_DISTS 592
  ------------------
  |  Branch (286:18): [True: 5.54k, False: 46.9k]
  |  Branch (286:35): [True: 0, False: 5.54k]
  ------------------
  287|      0|                return 1;
  288|       |
  289|       |            /* point entry in root table to sub-table */
  290|  52.4k|            low = huff & mask;
  291|  52.4k|            (*table)[low].op = (unsigned char)curr;
  292|  52.4k|            (*table)[low].bits = (unsigned char)root;
  293|  52.4k|            (*table)[low].val = (unsigned short)(next - *table);
  294|  52.4k|        }
  295|  1.65M|    }
  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|  42.8k|    if (huff != 0) {
  ------------------
  |  Branch (300:9): [True: 7, False: 42.7k]
  ------------------
  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|  42.8k|    *table += used;
  309|  42.8k|    *bits = root;
  310|  42.8k|    return 0;
  311|  42.8k|}
z_inflate_fixed:
  364|  86.8k|void inflate_fixed(struct inflate_state FAR *state) {
  365|       |#ifdef BUILDFIXED
  366|       |    z_once(&built, buildtables);
  367|       |#endif /* BUILDFIXED */
  368|  86.8k|    state->lencode = lenfix;
  369|  86.8k|    state->lenbits = 9;
  370|  86.8k|    state->distcode = distfix;
  371|  86.8k|    state->distbits = 5;
  372|  86.8k|}

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

tj3InitVersion:
  613|  60.6k|{
  614|  60.6k|  static const char FUNCTION_NAME[] = "tj3Init";
  615|  60.6k|  tjinstance *this = NULL;
  616|  60.6k|  tjhandle retval = NULL;
  617|       |
  618|  60.6k|  if (initType < 0 || initType >= TJ_NUMINIT || apiVersion < 1000000 ||
  ------------------
  |  |  139|   121k|#define TJ_NUMINIT  3
  ------------------
  |  Branch (618:7): [True: 0, False: 60.6k]
  |  Branch (618:23): [True: 0, False: 60.6k]
  |  Branch (618:49): [True: 0, False: 60.6k]
  ------------------
  619|  60.6k|      apiVersion > 999999999)
  ------------------
  |  Branch (619:7): [True: 0, False: 60.6k]
  ------------------
  620|  60.6k|    THROWG("Invalid argument", NULL);
  ------------------
  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  257|      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 */
  |  |  ------------------
  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  259|      0|}
  ------------------
  621|       |
  622|  60.6k|  if ((this = (tjinstance *)malloc(sizeof(tjinstance))) == NULL)
  ------------------
  |  Branch (622:7): [True: 0, False: 60.6k]
  ------------------
  623|  60.6k|    THROWG("Memory allocation failure", NULL);
  ------------------
  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  257|      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 */
  |  |  ------------------
  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  259|      0|}
  ------------------
  624|  60.6k|  memset(this, 0, sizeof(tjinstance));
  625|  60.6k|  SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
  ------------------
  |  |   42|  60.6k|#define SNPRINTF  snprintf
  ------------------
                SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
  ------------------
  |  |  792|  60.6k|#define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
  ------------------
  626|       |
  627|  60.6k|  this->quality = -1;
  628|  60.6k|  this->subsamp = TJSAMP_UNKNOWN;
  629|  60.6k|  this->jpegWidth = -1;
  630|  60.6k|  this->jpegHeight = -1;
  631|  60.6k|  this->precision = 8;
  632|  60.6k|  this->colorspace = TJCS_DEFAULT;
  633|  60.6k|  this->losslessPSV = 1;
  634|  60.6k|  this->xDensity = 1;
  635|  60.6k|  this->yDensity = 1;
  636|  60.6k|  this->scalingFactor = TJUNSCALED;
  637|  60.6k|  this->saveMarkers = 2;
  638|       |
  639|  60.6k|  this->apiVersion = apiVersion;
  640|  60.6k|  this->numSamp = apiVersion >= 3002000 ? TJ_NUMSAMP : 7;
  ------------------
  |  |  164|  7.57k|#define TJ_NUMSAMP  9
  ------------------
  |  Branch (640:19): [True: 7.57k, False: 53.0k]
  ------------------
  641|       |
  642|  60.6k|  switch (initType) {
  ------------------
  |  Branch (642:11): [True: 60.6k, False: 0]
  ------------------
  643|  60.6k|  case TJINIT_COMPRESS:  return _tjInitCompress(this);
  ------------------
  |  Branch (643:3): [True: 60.6k, False: 0]
  ------------------
  644|      0|  case TJINIT_DECOMPRESS:  return _tjInitDecompress(this);
  ------------------
  |  Branch (644:3): [True: 0, False: 60.6k]
  ------------------
  645|      0|  case TJINIT_TRANSFORM:
  ------------------
  |  Branch (645:3): [True: 0, False: 60.6k]
  ------------------
  646|      0|    retval = _tjInitCompress(this);
  647|      0|    if (!retval) return NULL;
  ------------------
  |  Branch (647:9): [True: 0, False: 0]
  ------------------
  648|      0|    retval = _tjInitDecompress(this);
  649|      0|    return retval;
  650|  60.6k|  }
  651|       |
  652|      0|bailout:
  653|      0|  return retval;
  654|  60.6k|}
tj3Init:
  658|  53.0k|{
  659|  53.0k|  return tj3InitVersion(initType, 3001000);
  660|  53.0k|}
tj3Destroy:
  665|  60.6k|{
  666|  60.6k|  tjinstance *this = (tjinstance *)handle;
  667|  60.6k|  j_compress_ptr cinfo = NULL;
  668|  60.6k|  j_decompress_ptr dinfo = NULL;
  669|       |
  670|  60.6k|  if (!this) return;
  ------------------
  |  Branch (670:7): [True: 0, False: 60.6k]
  ------------------
  671|       |
  672|  60.6k|  cinfo = &this->cinfo;  dinfo = &this->dinfo;
  673|  60.6k|  this->jerr.warning = FALSE;
  ------------------
  |  |  207|  60.6k|#define FALSE   0               /* values of boolean */
  ------------------
  674|  60.6k|  this->isInstanceError = FALSE;
  ------------------
  |  |  207|  60.6k|#define FALSE   0               /* values of boolean */
  ------------------
  675|       |
  676|       |  /* NOTE: jpeg_destroy_*() can never throw a libjpeg error in libjpeg-turbo's
  677|       |     implementation, so this is a belt-and-suspenders measure. */
  678|  60.6k|  if (setjmp(this->jerr.setjmp_buffer)) goto destroy_decompress;
  ------------------
  |  Branch (678:7): [True: 0, False: 60.6k]
  ------------------
  679|  60.6k|  if (this->init & COMPRESS) jpeg_destroy_compress(cinfo);
  ------------------
  |  Branch (679:7): [True: 60.6k, False: 0]
  ------------------
  680|  60.6k|destroy_decompress:
  681|  60.6k|  if (setjmp(this->jerr.setjmp_buffer)) goto bailout;
  ------------------
  |  Branch (681:7): [True: 0, False: 60.6k]
  ------------------
  682|  60.6k|  if (this->init & DECOMPRESS) jpeg_destroy_decompress(dinfo);
  ------------------
  |  Branch (682:7): [True: 0, False: 60.6k]
  ------------------
  683|  60.6k|bailout:
  684|  60.6k|  free(this->dstMgrs);
  685|  60.6k|  free(this->iccBuf);
  686|  60.6k|  free(this->decompICCBuf);
  687|  60.6k|  free(this);
  688|  60.6k|}
tj3Set:
  762|   528k|{
  763|   528k|  static const char FUNCTION_NAME[] = "tj3Set";
  764|   528k|  int retval = 0;
  765|       |
  766|   528k|  GET_TJINSTANCE(handle, -1);
  ------------------
  |  |  352|   528k|  tjinstance *this = (tjinstance *)handle; \
  |  |  353|   528k|  \
  |  |  354|   528k|  if (!this) { \
  |  |  ------------------
  |  |  |  Branch (354:7): [True: 0, False: 528k]
  |  |  ------------------
  |  |  355|      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 */
  |  |  ------------------
  |  |  356|      0|    return errorReturn; \
  |  |  357|      0|  } \
  |  |  358|   528k|  this->jerr.warning = FALSE; \
  |  |  ------------------
  |  |  |  |  207|   528k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  359|   528k|  this->isInstanceError = FALSE;
  |  |  ------------------
  |  |  |  |  207|   528k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  ------------------
  767|       |
  768|   528k|  switch (param) {
  769|      0|  case TJPARAM_STOPONWARNING:
  ------------------
  |  Branch (769:3): [True: 0, False: 528k]
  ------------------
  770|      0|    SET_BOOL_PARAM(jerr.stopOnWarning);
  ------------------
  |  |  754|      0|#define SET_BOOL_PARAM(field) { \
  |  |  755|      0|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (755:7): [True: 0, False: 0]
  |  |  |  Branch (755:20): [True: 0, False: 0]
  |  |  ------------------
  |  |  756|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  757|      0|  this->field = (boolean)value; \
  |  |  758|      0|}
  ------------------
  771|      0|    break;
  772|  53.0k|  case TJPARAM_BOTTOMUP:
  ------------------
  |  Branch (772:3): [True: 53.0k, False: 475k]
  ------------------
  773|  53.0k|    SET_BOOL_PARAM(bottomUp);
  ------------------
  |  |  754|  53.0k|#define SET_BOOL_PARAM(field) { \
  |  |  755|  53.0k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (755:7): [True: 0, False: 53.0k]
  |  |  |  Branch (755:20): [True: 0, False: 53.0k]
  |  |  ------------------
  |  |  756|  53.0k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  757|  53.0k|  this->field = (boolean)value; \
  |  |  758|  53.0k|}
  ------------------
  774|  53.0k|    break;
  775|  53.0k|  case TJPARAM_NOREALLOC:
  ------------------
  |  Branch (775:3): [True: 53.0k, False: 475k]
  ------------------
  776|  53.0k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (776:9): [True: 0, False: 53.0k]
  ------------------
  777|  53.0k|      THROW("TJPARAM_NOREALLOC is not applicable to decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  778|  53.0k|    SET_BOOL_PARAM(noRealloc);
  ------------------
  |  |  754|  53.0k|#define SET_BOOL_PARAM(field) { \
  |  |  755|  53.0k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (755:7): [True: 0, False: 53.0k]
  |  |  |  Branch (755:20): [True: 0, False: 53.0k]
  |  |  ------------------
  |  |  756|  53.0k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  757|  53.0k|  this->field = (boolean)value; \
  |  |  758|  53.0k|}
  ------------------
  779|  53.0k|    break;
  780|  25.4k|  case TJPARAM_QUALITY:
  ------------------
  |  Branch (780:3): [True: 25.4k, False: 502k]
  ------------------
  781|  25.4k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (781:9): [True: 0, False: 25.4k]
  ------------------
  782|  25.4k|      THROW("TJPARAM_QUALITY is not applicable to decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  783|  25.4k|    SET_PARAM(quality, 1, 100);
  ------------------
  |  |  748|  25.4k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|  25.4k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 25.4k]
  |  |  |  Branch (749:28): [True: 25.4k, Folded]
  |  |  |  Branch (749:44): [True: 0, False: 25.4k]
  |  |  ------------------
  |  |  750|  25.4k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|  25.4k|  this->field = value; \
  |  |  752|  25.4k|}
  ------------------
  784|  25.4k|    break;
  785|  25.4k|  case TJPARAM_SUBSAMP:
  ------------------
  |  Branch (785:3): [True: 25.4k, False: 502k]
  ------------------
  786|  25.4k|    SET_PARAM(subsamp, 0, this->numSamp - 1);
  ------------------
  |  |  748|  25.4k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|  25.4k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 25.4k]
  |  |  |  Branch (749:28): [True: 25.4k, False: 0]
  |  |  |  Branch (749:44): [True: 0, False: 25.4k]
  |  |  ------------------
  |  |  750|  25.4k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|  25.4k|  this->field = value; \
  |  |  752|  25.4k|}
  ------------------
  787|  25.4k|    break;
  788|      0|  case TJPARAM_JPEGWIDTH:
  ------------------
  |  Branch (788:3): [True: 0, False: 528k]
  ------------------
  789|      0|    if (!(this->init & DECOMPRESS))
  ------------------
  |  Branch (789:9): [True: 0, False: 0]
  ------------------
  790|      0|      THROW("TJPARAM_JPEGWIDTH is not applicable to compression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  791|      0|    THROW("TJPARAM_JPEGWIDTH is read-only in decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  792|      0|    break;
  793|      0|  case TJPARAM_JPEGHEIGHT:
  ------------------
  |  Branch (793:3): [True: 0, False: 528k]
  ------------------
  794|      0|    if (!(this->init & DECOMPRESS))
  ------------------
  |  Branch (794:9): [True: 0, False: 0]
  ------------------
  795|      0|      THROW("TJPARAM_JPEGHEIGHT is not applicable to compression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  796|      0|    THROW("TJPARAM_JPEGHEIGHT is read-only in decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  797|      0|    break;
  798|      0|  case TJPARAM_PRECISION:
  ------------------
  |  Branch (798:3): [True: 0, False: 528k]
  ------------------
  799|      0|    SET_PARAM(precision, 2, 16);
  ------------------
  |  |  748|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 0]
  |  |  |  Branch (749:28): [True: 0, Folded]
  |  |  |  Branch (749:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  750|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|      0|  this->field = value; \
  |  |  752|      0|}
  ------------------
  800|      0|    break;
  801|  53.0k|  case TJPARAM_COLORSPACE:
  ------------------
  |  Branch (801:3): [True: 53.0k, False: 475k]
  ------------------
  802|  53.0k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (802:9): [True: 0, False: 53.0k]
  ------------------
  803|  53.0k|      THROW("TJPARAM_COLORSPACE is read-only in decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  804|  53.0k|    SET_PARAM(colorspace, TJCS_DEFAULT, TJ_NUMCS - 1);
  ------------------
  |  |  748|  53.0k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|  53.0k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 53.0k]
  |  |  |  Branch (749:28): [True: 53.0k, Folded]
  |  |  |  Branch (749:44): [True: 0, False: 53.0k]
  |  |  ------------------
  |  |  750|  53.0k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|  53.0k|  this->field = value; \
  |  |  752|  53.0k|}
  ------------------
  805|  53.0k|    break;
  806|      0|  case TJPARAM_FASTUPSAMPLE:
  ------------------
  |  Branch (806:3): [True: 0, False: 528k]
  ------------------
  807|      0|    if (!(this->init & DECOMPRESS))
  ------------------
  |  Branch (807:9): [True: 0, False: 0]
  ------------------
  808|      0|      THROW("TJPARAM_FASTUPSAMPLE is not applicable to compression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  809|      0|    SET_BOOL_PARAM(fastUpsample);
  ------------------
  |  |  754|      0|#define SET_BOOL_PARAM(field) { \
  |  |  755|      0|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (755:7): [True: 0, False: 0]
  |  |  |  Branch (755:20): [True: 0, False: 0]
  |  |  ------------------
  |  |  756|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  757|      0|  this->field = (boolean)value; \
  |  |  758|      0|}
  ------------------
  810|      0|    break;
  811|  53.0k|  case TJPARAM_FASTDCT:
  ------------------
  |  Branch (811:3): [True: 53.0k, False: 475k]
  ------------------
  812|  53.0k|    SET_BOOL_PARAM(fastDCT);
  ------------------
  |  |  754|  53.0k|#define SET_BOOL_PARAM(field) { \
  |  |  755|  53.0k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (755:7): [True: 0, False: 53.0k]
  |  |  |  Branch (755:20): [True: 0, False: 53.0k]
  |  |  ------------------
  |  |  756|  53.0k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  757|  53.0k|  this->field = (boolean)value; \
  |  |  758|  53.0k|}
  ------------------
  813|  53.0k|    break;
  814|  53.0k|  case TJPARAM_OPTIMIZE:
  ------------------
  |  Branch (814:3): [True: 53.0k, False: 475k]
  ------------------
  815|  53.0k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (815:9): [True: 0, False: 53.0k]
  ------------------
  816|  53.0k|      THROW("TJPARAM_OPTIMIZE is not applicable to decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  817|  53.0k|    SET_BOOL_PARAM(optimize);
  ------------------
  |  |  754|  53.0k|#define SET_BOOL_PARAM(field) { \
  |  |  755|  53.0k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (755:7): [True: 0, False: 53.0k]
  |  |  |  Branch (755:20): [True: 0, False: 53.0k]
  |  |  ------------------
  |  |  756|  53.0k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  757|  53.0k|  this->field = (boolean)value; \
  |  |  758|  53.0k|}
  ------------------
  818|  53.0k|    break;
  819|  53.0k|  case TJPARAM_PROGRESSIVE:
  ------------------
  |  Branch (819:3): [True: 53.0k, False: 475k]
  ------------------
  820|  53.0k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (820:9): [True: 0, False: 53.0k]
  ------------------
  821|  53.0k|      THROW("TJPARAM_PROGRESSIVE is read-only in decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  822|  53.0k|    SET_BOOL_PARAM(progressive);
  ------------------
  |  |  754|  53.0k|#define SET_BOOL_PARAM(field) { \
  |  |  755|  53.0k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (755:7): [True: 0, False: 53.0k]
  |  |  |  Branch (755:20): [True: 0, False: 53.0k]
  |  |  ------------------
  |  |  756|  53.0k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  757|  53.0k|  this->field = (boolean)value; \
  |  |  758|  53.0k|}
  ------------------
  823|  53.0k|    break;
  824|      0|  case TJPARAM_SCANLIMIT:
  ------------------
  |  Branch (824:3): [True: 0, False: 528k]
  ------------------
  825|      0|    if (!(this->init & DECOMPRESS))
  ------------------
  |  Branch (825:9): [True: 0, False: 0]
  ------------------
  826|      0|      THROW("TJPARAM_SCANLIMIT is not applicable to compression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  827|      0|    SET_PARAM(scanLimit, 0, -1);
  ------------------
  |  |  748|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 0]
  |  |  |  Branch (749:28): [Folded, False: 0]
  |  |  |  Branch (749:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  750|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|      0|  this->field = value; \
  |  |  752|      0|}
  ------------------
  828|      0|    break;
  829|  53.0k|  case TJPARAM_ARITHMETIC:
  ------------------
  |  Branch (829:3): [True: 53.0k, False: 475k]
  ------------------
  830|  53.0k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (830:9): [True: 0, False: 53.0k]
  ------------------
  831|  53.0k|      THROW("TJPARAM_ARITHMETIC is read-only in decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  832|  53.0k|    SET_BOOL_PARAM(arithmetic);
  ------------------
  |  |  754|  53.0k|#define SET_BOOL_PARAM(field) { \
  |  |  755|  53.0k|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (755:7): [True: 0, False: 53.0k]
  |  |  |  Branch (755:20): [True: 0, False: 53.0k]
  |  |  ------------------
  |  |  756|  53.0k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  757|  53.0k|  this->field = (boolean)value; \
  |  |  758|  53.0k|}
  ------------------
  833|  53.0k|    break;
  834|      0|  case TJPARAM_LOSSLESS:
  ------------------
  |  Branch (834:3): [True: 0, False: 528k]
  ------------------
  835|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (835:9): [True: 0, False: 0]
  ------------------
  836|      0|      THROW("TJPARAM_LOSSLESS is read-only in decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  837|      0|    SET_BOOL_PARAM(lossless);
  ------------------
  |  |  754|      0|#define SET_BOOL_PARAM(field) { \
  |  |  755|      0|  if (value < 0 || value > 1) \
  |  |  ------------------
  |  |  |  Branch (755:7): [True: 0, False: 0]
  |  |  |  Branch (755:20): [True: 0, False: 0]
  |  |  ------------------
  |  |  756|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  757|      0|  this->field = (boolean)value; \
  |  |  758|      0|}
  ------------------
  838|      0|    break;
  839|      0|  case TJPARAM_LOSSLESSPSV:
  ------------------
  |  Branch (839:3): [True: 0, False: 528k]
  ------------------
  840|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (840:9): [True: 0, False: 0]
  ------------------
  841|      0|      THROW("TJPARAM_LOSSLESSPSV is read-only in decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  842|      0|    SET_PARAM(losslessPSV, 1, 7);
  ------------------
  |  |  748|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 0]
  |  |  |  Branch (749:28): [True: 0, Folded]
  |  |  |  Branch (749:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  750|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|      0|  this->field = value; \
  |  |  752|      0|}
  ------------------
  843|      0|    break;
  844|      0|  case TJPARAM_LOSSLESSPT:
  ------------------
  |  Branch (844:3): [True: 0, False: 528k]
  ------------------
  845|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (845:9): [True: 0, False: 0]
  ------------------
  846|      0|      THROW("TJPARAM_LOSSLESSPT is read-only in decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  847|      0|    SET_PARAM(losslessPt, 0, 15);
  ------------------
  |  |  748|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 0]
  |  |  |  Branch (749:28): [True: 0, Folded]
  |  |  |  Branch (749:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  750|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|      0|  this->field = value; \
  |  |  752|      0|}
  ------------------
  848|      0|    break;
  849|      0|  case TJPARAM_RESTARTBLOCKS:
  ------------------
  |  Branch (849:3): [True: 0, False: 528k]
  ------------------
  850|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (850:9): [True: 0, False: 0]
  ------------------
  851|      0|      THROW("TJPARAM_RESTARTBLOCKS is not applicable to decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  852|      0|    SET_PARAM(restartIntervalBlocks, 0, 65535);
  ------------------
  |  |  748|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 0]
  |  |  |  Branch (749:28): [True: 0, Folded]
  |  |  |  Branch (749:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  750|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|      0|  this->field = value; \
  |  |  752|      0|}
  ------------------
  853|      0|    if (value != 0) this->restartIntervalRows = 0;
  ------------------
  |  Branch (853:9): [True: 0, False: 0]
  ------------------
  854|      0|    break;
  855|  53.0k|  case TJPARAM_RESTARTROWS:
  ------------------
  |  Branch (855:3): [True: 53.0k, False: 475k]
  ------------------
  856|  53.0k|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (856:9): [True: 0, False: 53.0k]
  ------------------
  857|  53.0k|      THROW("TJPARAM_RESTARTROWS is not applicable to decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  858|  53.0k|    SET_PARAM(restartIntervalRows, 0, 65535);
  ------------------
  |  |  748|  53.0k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|  53.0k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 53.0k]
  |  |  |  Branch (749:28): [True: 53.0k, Folded]
  |  |  |  Branch (749:44): [True: 0, False: 53.0k]
  |  |  ------------------
  |  |  750|  53.0k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|  53.0k|  this->field = value; \
  |  |  752|  53.0k|}
  ------------------
  859|  53.0k|    if (value != 0) this->restartIntervalBlocks = 0;
  ------------------
  |  Branch (859:9): [True: 15.1k, False: 37.8k]
  ------------------
  860|  53.0k|    break;
  861|      0|  case TJPARAM_XDENSITY:
  ------------------
  |  Branch (861:3): [True: 0, False: 528k]
  ------------------
  862|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (862:9): [True: 0, False: 0]
  ------------------
  863|      0|      THROW("TJPARAM_XDENSITY is read-only in decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  864|      0|    SET_PARAM(xDensity, 1, 65535);
  ------------------
  |  |  748|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 0]
  |  |  |  Branch (749:28): [True: 0, Folded]
  |  |  |  Branch (749:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  750|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|      0|  this->field = value; \
  |  |  752|      0|}
  ------------------
  865|      0|    break;
  866|      0|  case TJPARAM_YDENSITY:
  ------------------
  |  Branch (866:3): [True: 0, False: 528k]
  ------------------
  867|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (867:9): [True: 0, False: 0]
  ------------------
  868|      0|      THROW("TJPARAM_YDENSITY is read-only in decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  869|      0|    SET_PARAM(yDensity, 1, 65535);
  ------------------
  |  |  748|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 0]
  |  |  |  Branch (749:28): [True: 0, Folded]
  |  |  |  Branch (749:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  750|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|      0|  this->field = value; \
  |  |  752|      0|}
  ------------------
  870|      0|    break;
  871|      0|  case TJPARAM_DENSITYUNITS:
  ------------------
  |  Branch (871:3): [True: 0, False: 528k]
  ------------------
  872|      0|    if (!(this->init & COMPRESS))
  ------------------
  |  Branch (872:9): [True: 0, False: 0]
  ------------------
  873|      0|      THROW("TJPARAM_DENSITYUNITS is read-only in decompression instances.");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  874|      0|    SET_PARAM(densityUnits, 0, 2);
  ------------------
  |  |  748|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 0]
  |  |  |  Branch (749:28): [True: 0, Folded]
  |  |  |  Branch (749:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  750|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|      0|  this->field = value; \
  |  |  752|      0|}
  ------------------
  875|      0|    break;
  876|      0|  case TJPARAM_MAXMEMORY:
  ------------------
  |  Branch (876:3): [True: 0, False: 528k]
  ------------------
  877|      0|    SET_PARAM(maxMemory, 0, (int)(min(LONG_MAX / 1048576L, (long)INT_MAX)));
  ------------------
  |  |  748|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 0]
  |  |  |  Branch (749:28): [Folded, False: 0]
  |  |  |  Branch (749:28): [True: 0, Folded]
  |  |  |  Branch (749:44): [True: 0, False: 0]
  |  |  |  Branch (749:52): [Folded, False: 0]
  |  |  ------------------
  |  |  750|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|      0|  this->field = value; \
  |  |  752|      0|}
  ------------------
  878|      0|    break;
  879|  53.0k|  case TJPARAM_MAXPIXELS:
  ------------------
  |  Branch (879:3): [True: 53.0k, False: 475k]
  ------------------
  880|  53.0k|    SET_PARAM(maxPixels, 0, -1);
  ------------------
  |  |  748|  53.0k|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|  53.0k|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 53.0k]
  |  |  |  Branch (749:28): [Folded, False: 53.0k]
  |  |  |  Branch (749:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  750|  53.0k|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|  53.0k|  this->field = value; \
  |  |  752|  53.0k|}
  ------------------
  881|  53.0k|    break;
  882|      0|  case TJPARAM_SAVEMARKERS:
  ------------------
  |  Branch (882:3): [True: 0, False: 528k]
  ------------------
  883|      0|    SET_PARAM(saveMarkers, 0, 4);
  ------------------
  |  |  748|      0|#define SET_PARAM(field, minValue, maxValue) { \
  |  |  749|      0|  if (value < minValue || (maxValue > 0 && value > maxValue)) \
  |  |  ------------------
  |  |  |  Branch (749:7): [True: 0, False: 0]
  |  |  |  Branch (749:28): [True: 0, Folded]
  |  |  |  Branch (749:44): [True: 0, False: 0]
  |  |  ------------------
  |  |  750|      0|    THROW("Parameter value out of range"); \
  |  |  ------------------
  |  |  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  |  |  282|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  |  |  259|      0|}
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  284|      0|}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  751|      0|  this->field = value; \
  |  |  752|      0|}
  ------------------
  884|      0|    break;
  885|      0|  default:
  ------------------
  |  Branch (885:3): [True: 0, False: 528k]
  ------------------
  886|      0|    THROW("Invalid parameter");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
  887|   528k|  }
  888|       |
  889|   528k|bailout:
  890|   528k|  return retval;
  891|   528k|}
tj3Get:
  896|  25.4k|{
  897|  25.4k|  tjinstance *this = (tjinstance *)handle;
  898|  25.4k|  if (!this) return -1;
  ------------------
  |  Branch (898:7): [True: 0, False: 25.4k]
  ------------------
  899|       |
  900|  25.4k|  switch (param) {
  ------------------
  |  Branch (900:11): [True: 25.4k, False: 0]
  ------------------
  901|      0|  case TJPARAM_STOPONWARNING:
  ------------------
  |  Branch (901:3): [True: 0, False: 25.4k]
  ------------------
  902|      0|    return this->jerr.stopOnWarning;
  903|      0|  case TJPARAM_BOTTOMUP:
  ------------------
  |  Branch (903:3): [True: 0, False: 25.4k]
  ------------------
  904|      0|    return this->bottomUp;
  905|  25.4k|  case TJPARAM_NOREALLOC:
  ------------------
  |  Branch (905:3): [True: 25.4k, False: 0]
  ------------------
  906|  25.4k|    return this->noRealloc;
  907|      0|  case TJPARAM_QUALITY:
  ------------------
  |  Branch (907:3): [True: 0, False: 25.4k]
  ------------------
  908|      0|    return this->quality;
  909|      0|  case TJPARAM_SUBSAMP:
  ------------------
  |  Branch (909:3): [True: 0, False: 25.4k]
  ------------------
  910|      0|    return this->subsamp;
  911|      0|  case TJPARAM_JPEGWIDTH:
  ------------------
  |  Branch (911:3): [True: 0, False: 25.4k]
  ------------------
  912|      0|    return this->jpegWidth;
  913|      0|  case TJPARAM_JPEGHEIGHT:
  ------------------
  |  Branch (913:3): [True: 0, False: 25.4k]
  ------------------
  914|      0|    return this->jpegHeight;
  915|      0|  case TJPARAM_PRECISION:
  ------------------
  |  Branch (915:3): [True: 0, False: 25.4k]
  ------------------
  916|      0|    return this->precision;
  917|      0|  case TJPARAM_COLORSPACE:
  ------------------
  |  Branch (917:3): [True: 0, False: 25.4k]
  ------------------
  918|      0|    return this->colorspace;
  919|      0|  case TJPARAM_FASTUPSAMPLE:
  ------------------
  |  Branch (919:3): [True: 0, False: 25.4k]
  ------------------
  920|      0|    return this->fastUpsample;
  921|      0|  case TJPARAM_FASTDCT:
  ------------------
  |  Branch (921:3): [True: 0, False: 25.4k]
  ------------------
  922|      0|    return this->fastDCT;
  923|      0|  case TJPARAM_OPTIMIZE:
  ------------------
  |  Branch (923:3): [True: 0, False: 25.4k]
  ------------------
  924|      0|    return this->optimize;
  925|      0|  case TJPARAM_PROGRESSIVE:
  ------------------
  |  Branch (925:3): [True: 0, False: 25.4k]
  ------------------
  926|      0|    return this->progressive;
  927|      0|  case TJPARAM_SCANLIMIT:
  ------------------
  |  Branch (927:3): [True: 0, False: 25.4k]
  ------------------
  928|      0|    return this->scanLimit;
  929|      0|  case TJPARAM_ARITHMETIC:
  ------------------
  |  Branch (929:3): [True: 0, False: 25.4k]
  ------------------
  930|      0|    return this->arithmetic;
  931|      0|  case TJPARAM_LOSSLESS:
  ------------------
  |  Branch (931:3): [True: 0, False: 25.4k]
  ------------------
  932|      0|    return this->lossless;
  933|      0|  case TJPARAM_LOSSLESSPSV:
  ------------------
  |  Branch (933:3): [True: 0, False: 25.4k]
  ------------------
  934|      0|    return this->losslessPSV;
  935|      0|  case TJPARAM_LOSSLESSPT:
  ------------------
  |  Branch (935:3): [True: 0, False: 25.4k]
  ------------------
  936|      0|    return this->losslessPt;
  937|      0|  case TJPARAM_RESTARTBLOCKS:
  ------------------
  |  Branch (937:3): [True: 0, False: 25.4k]
  ------------------
  938|      0|    return this->restartIntervalBlocks;
  939|      0|  case TJPARAM_RESTARTROWS:
  ------------------
  |  Branch (939:3): [True: 0, False: 25.4k]
  ------------------
  940|      0|    return this->restartIntervalRows;
  941|      0|  case TJPARAM_XDENSITY:
  ------------------
  |  Branch (941:3): [True: 0, False: 25.4k]
  ------------------
  942|      0|    return this->xDensity;
  943|      0|  case TJPARAM_YDENSITY:
  ------------------
  |  Branch (943:3): [True: 0, False: 25.4k]
  ------------------
  944|      0|    return this->yDensity;
  945|      0|  case TJPARAM_DENSITYUNITS:
  ------------------
  |  Branch (945:3): [True: 0, False: 25.4k]
  ------------------
  946|      0|    return this->densityUnits;
  947|      0|  case TJPARAM_MAXMEMORY:
  ------------------
  |  Branch (947:3): [True: 0, False: 25.4k]
  ------------------
  948|      0|    return this->maxMemory;
  949|      0|  case TJPARAM_MAXPIXELS:
  ------------------
  |  Branch (949:3): [True: 0, False: 25.4k]
  ------------------
  950|      0|    return this->maxPixels;
  951|      0|  case TJPARAM_SAVEMARKERS:
  ------------------
  |  Branch (951:3): [True: 0, False: 25.4k]
  ------------------
  952|      0|    return this->saveMarkers;
  953|  25.4k|  }
  954|       |
  955|      0|  return -1;
  956|  25.4k|}
tj3Alloc:
  966|  25.4k|{
  967|  25.4k|  return MALLOC(bytes);
  ------------------
  |  |  520|  25.4k|#define MALLOC(size)  malloc(size)
  ------------------
  968|  25.4k|}
tj3Free:
  979|  66.1k|{
  980|  66.1k|  free(buf);
  981|  66.1k|}
tj3JPEGBufSize:
  992|  25.4k|{
  993|  25.4k|  static const char FUNCTION_NAME[] = "tj3JPEGBufSize";
  994|  25.4k|  unsigned long long retval = 0;
  995|  25.4k|  int mcuw, mcuh, chromasf;
  996|       |
  997|  25.4k|  if (width < 1 || height < 1 || jpegSubsamp < TJSAMP_UNKNOWN ||
  ------------------
  |  Branch (997:7): [True: 0, False: 25.4k]
  |  Branch (997:20): [True: 0, False: 25.4k]
  |  Branch (997:34): [True: 0, False: 25.4k]
  ------------------
  998|  25.4k|      jpegSubsamp >= TJ_NUMSAMP)
  ------------------
  |  |  164|  25.4k|#define TJ_NUMSAMP  9
  ------------------
  |  Branch (998:7): [True: 0, False: 25.4k]
  ------------------
  999|  25.4k|    THROWG("Invalid argument", 0);
  ------------------
  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  257|      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 */
  |  |  ------------------
  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  259|      0|}
  ------------------
 1000|       |
 1001|  25.4k|  if (jpegSubsamp == TJSAMP_UNKNOWN)
  ------------------
  |  Branch (1001:7): [True: 0, False: 25.4k]
  ------------------
 1002|      0|    jpegSubsamp = TJSAMP_444;
 1003|       |
 1004|       |  /* This allows for rare corner cases in which a JPEG image can actually be
 1005|       |     larger than the uncompressed input (we wouldn't mention it if it hadn't
 1006|       |     happened before.) */
 1007|  25.4k|  mcuw = tjMCUWidth[jpegSubsamp];
 1008|  25.4k|  mcuh = tjMCUHeight[jpegSubsamp];
 1009|  25.4k|  chromasf = jpegSubsamp == TJSAMP_GRAY ? 0 : 4 * 64 / (mcuw * mcuh);
  ------------------
  |  Branch (1009:14): [True: 8.06k, False: 17.4k]
  ------------------
 1010|  25.4k|  retval = (unsigned long long)PAD(width, mcuw) * PAD(height, mcuh) *
  ------------------
  |  |   57|  25.4k|#define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
  ------------------
                retval = (unsigned long long)PAD(width, mcuw) * PAD(height, mcuh) *
  ------------------
  |  |   57|  25.4k|#define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
  ------------------
 1011|  25.4k|           (2ULL + chromasf) + 2048ULL;
 1012|       |#if ULLONG_MAX > ULONG_MAX
 1013|       |  if (retval > (unsigned long long)((unsigned long)-1))
 1014|       |    THROWG("Image is too large", 0);
 1015|       |#endif
 1016|       |
 1017|  25.4k|bailout:
 1018|  25.4k|  return (size_t)retval;
 1019|  25.4k|}
tj3SetICCProfile:
 1268|  22.5k|{
 1269|  22.5k|  static const char FUNCTION_NAME[] = "tj3SetICCProfile";
 1270|  22.5k|  int retval = 0;
 1271|       |
 1272|  22.5k|  GET_TJINSTANCE(handle, -1)
  ------------------
  |  |  352|  22.5k|  tjinstance *this = (tjinstance *)handle; \
  |  |  353|  22.5k|  \
  |  |  354|  22.5k|  if (!this) { \
  |  |  ------------------
  |  |  |  Branch (354:7): [True: 0, False: 22.5k]
  |  |  ------------------
  |  |  355|      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 */
  |  |  ------------------
  |  |  356|      0|    return errorReturn; \
  |  |  357|      0|  } \
  |  |  358|  22.5k|  this->jerr.warning = FALSE; \
  |  |  ------------------
  |  |  |  |  207|  22.5k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  |  |  359|  22.5k|  this->isInstanceError = FALSE;
  |  |  ------------------
  |  |  |  |  207|  22.5k|#define FALSE   0               /* values of boolean */
  |  |  ------------------
  ------------------
 1273|  22.5k|  if ((this->init & COMPRESS) == 0)
  ------------------
  |  Branch (1273:7): [True: 0, False: 22.5k]
  ------------------
 1274|  22.5k|    THROW("Instance has not been initialized for compression");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
 1275|       |
 1276|  22.5k|  if (iccBuf == this->iccBuf && iccSize == this->iccSize)
  ------------------
  |  Branch (1276:7): [True: 0, False: 22.5k]
  |  Branch (1276:33): [True: 0, False: 0]
  ------------------
 1277|      0|    return 0;
 1278|       |
 1279|  22.5k|  free(this->iccBuf);
 1280|  22.5k|  this->iccBuf = NULL;
 1281|  22.5k|  this->iccSize = 0;
 1282|  22.5k|  if (iccBuf && iccSize) {
  ------------------
  |  Branch (1282:7): [True: 22.5k, False: 0]
  |  Branch (1282:17): [True: 22.5k, False: 0]
  ------------------
 1283|  22.5k|    if ((this->iccBuf = (unsigned char *)malloc(iccSize)) == NULL)
  ------------------
  |  Branch (1283:9): [True: 0, False: 22.5k]
  ------------------
 1284|  22.5k|      THROW("Memory allocation failure");
  ------------------
  |  |  285|      0|#define THROW(m)  THROWRV(m, -1)
  |  |  ------------------
  |  |  |  |  281|      0|#define THROWRV(m, rv) { \
  |  |  |  |  282|      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 */
  |  |  |  |  ------------------
  |  |  |  |  283|      0|  this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      0|#define TRUE    1
  |  |  |  |  ------------------
  |  |  |  |                 this->isInstanceError = TRUE;  THROWG(m, rv) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  |  |  |  |  257|      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 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  |  |  |  |  259|      0|}
  |  |  |  |  ------------------
  |  |  |  |  284|      0|}
  |  |  ------------------
  ------------------
 1285|  22.5k|    memcpy(this->iccBuf, iccBuf, iccSize);
 1286|  22.5k|    this->iccSize = iccSize;
 1287|  22.5k|  }
 1288|       |
 1289|  22.5k|bailout:
 1290|  22.5k|  return retval;
 1291|  22.5k|}
turbojpeg.c:_tjInitCompress:
 1218|  60.6k|{
 1219|  60.6k|  static const char FUNCTION_NAME[] = "tj3Init";
 1220|  60.6k|  static unsigned char buffer[1];
 1221|  60.6k|  unsigned char *buf = buffer;
 1222|  60.6k|  size_t size = 1;
 1223|  60.6k|  tjhandle retval = (tjhandle)this;
 1224|       |
 1225|       |  /* This is also straight out of example.c */
 1226|  60.6k|  this->cinfo.err = jpeg_std_error(&this->jerr.pub);
 1227|  60.6k|  this->jerr.pub.error_exit = my_error_exit;
 1228|  60.6k|  this->jerr.pub.output_message = my_output_message;
 1229|  60.6k|  this->jerr.emit_message = this->jerr.pub.emit_message;
 1230|  60.6k|  this->jerr.pub.emit_message = my_emit_message;
 1231|  60.6k|  this->jerr.pub.addon_message_table = turbojpeg_message_table;
 1232|  60.6k|  this->jerr.pub.first_addon_message = JMSG_FIRSTADDONCODE;
 1233|  60.6k|  this->jerr.pub.last_addon_message = JMSG_LASTADDONCODE;
 1234|  60.6k|  this->jerr.tjHandle = (tjhandle)this;
 1235|       |
 1236|  60.6k|  if (setjmp(this->jerr.setjmp_buffer)) {
  ------------------
  |  Branch (1236:7): [True: 0, False: 60.6k]
  ------------------
 1237|       |    /* If we get here, the JPEG code has signaled an error. */
 1238|      0|    free(this);
 1239|      0|    retval = NULL;  goto bailout;
 1240|      0|  }
 1241|       |
 1242|  60.6k|  jpeg_create_compress(&this->cinfo);
  ------------------
  |  |  969|  60.6k|  jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
  |  |  ------------------
  |  |  |  |    4|  60.6k|#define JPEG_LIB_VERSION  62
  |  |  ------------------
  |  |  970|  60.6k|                      (size_t)sizeof(struct jpeg_compress_struct))
  ------------------
 1243|       |  /* Make an initial call so it will create the destination manager */
 1244|  60.6k|  jpeg_mem_dest_tj(&this->cinfo, &buf, &size, 0);
 1245|  60.6k|  this->dstMgrs = (struct jpeg_destination_mgr **)
 1246|  60.6k|    malloc(sizeof(struct jpeg_destination_mgr *));
 1247|  60.6k|  if (!this->dstMgrs)
  ------------------
  |  Branch (1247:7): [True: 0, False: 60.6k]
  ------------------
 1248|  60.6k|    THROWG("Memory allocation failure", NULL);
  ------------------
  |  |  256|      0|#define THROWG(m, rv) { \
  |  |  257|      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 */
  |  |  ------------------
  |  |  258|      0|  retval = rv;  goto bailout; \
  |  |  259|      0|}
  ------------------
 1249|  60.6k|  this->dstMgrs[0] = this->cinfo.dest;
 1250|  60.6k|  this->nDstMgrs = 1;
 1251|       |
 1252|  60.6k|  this->init |= COMPRESS;
 1253|       |
 1254|  60.6k|bailout:
 1255|  60.6k|  return retval;
 1256|  60.6k|}
turbojpeg.c:my_error_exit:
   81|  40.0k|{
   82|  40.0k|  my_error_ptr myerr = (my_error_ptr)cinfo->err;
   83|       |
   84|  40.0k|  (*cinfo->err->output_message) (cinfo);
   85|  40.0k|  longjmp(myerr->setjmp_buffer, 1);
   86|  40.0k|}
turbojpeg.c:my_output_message:
  151|  40.0k|{
  152|  40.0k|  my_error_ptr myerr = (my_error_ptr)cinfo->err;
  153|  40.0k|  tjinstance *this = (tjinstance *)myerr->tjHandle;
  154|       |
  155|  40.0k|  if (this) {
  ------------------
  |  Branch (155:7): [True: 40.0k, False: 0]
  ------------------
  156|  40.0k|    this->isInstanceError = TRUE;
  ------------------
  |  |  210|  40.0k|#define TRUE    1
  ------------------
  157|  40.0k|    (*cinfo->err->format_message) (cinfo, this->errStr);
  158|  40.0k|  } else
  159|      0|    (*cinfo->err->format_message) (cinfo, errStr);
  160|  40.0k|}
turbojpeg.c:my_emit_message:
   89|  41.4k|{
   90|  41.4k|  my_error_ptr myerr = (my_error_ptr)cinfo->err;
   91|       |
   92|  41.4k|  myerr->emit_message(cinfo, msg_level);
   93|  41.4k|  if (msg_level < 0) {
  ------------------
  |  Branch (93:7): [True: 0, False: 41.4k]
  ------------------
   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|  41.4k|}
turbojpeg.c:setCompDefaults:
  396|  25.4k|{
  397|  25.4k|  int colorspace = yuv ? TJCS_DEFAULT : this->colorspace;
  ------------------
  |  Branch (397:20): [True: 0, False: 25.4k]
  ------------------
  398|       |
  399|  25.4k|  this->cinfo.in_color_space = pf2cs[pixelFormat];
  400|  25.4k|  this->cinfo.input_components = tjPixelSize[pixelFormat];
  401|  25.4k|  jpeg_set_defaults(&this->cinfo);
  402|       |
  403|  25.4k|  this->cinfo.restart_interval = this->restartIntervalBlocks;
  404|  25.4k|  this->cinfo.restart_in_rows = this->restartIntervalRows;
  405|  25.4k|  this->cinfo.X_density = (UINT16)this->xDensity;
  406|  25.4k|  this->cinfo.Y_density = (UINT16)this->yDensity;
  407|  25.4k|  this->cinfo.density_unit = (UINT8)this->densityUnits;
  408|  25.4k|  this->cinfo.mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
  409|       |
  410|  25.4k|  if (this->lossless && !yuv) {
  ------------------
  |  Branch (410:7): [True: 0, False: 25.4k]
  |  Branch (410:25): [True: 0, False: 0]
  ------------------
  411|      0|#ifdef C_LOSSLESS_SUPPORTED
  412|      0|    jpeg_enable_lossless(&this->cinfo, this->losslessPSV, this->losslessPt);
  413|      0|#endif
  414|      0|    return;
  415|      0|  }
  416|       |
  417|  25.4k|  jpeg_set_quality(&this->cinfo, this->quality, TRUE);
  ------------------
  |  |  210|  25.4k|#define TRUE    1
  ------------------
  418|  25.4k|  this->cinfo.dct_method = this->fastDCT ? JDCT_FASTEST : JDCT_ISLOW;
  ------------------
  |  |  304|  3.42k|#define JDCT_FASTEST  JDCT_IFAST
  ------------------
  |  Branch (418:28): [True: 3.42k, False: 22.0k]
  ------------------
  419|       |
  420|  25.4k|  switch (colorspace) {
  421|  3.57k|  case TJCS_RGB:
  ------------------
  |  Branch (421:3): [True: 3.57k, False: 21.9k]
  ------------------
  422|  3.57k|    jpeg_set_colorspace(&this->cinfo, JCS_RGB);  break;
  423|  3.57k|  case TJCS_YCbCr:
  ------------------
  |  Branch (423:3): [True: 3.57k, False: 21.9k]
  ------------------
  424|  3.57k|    jpeg_set_colorspace(&this->cinfo, JCS_YCbCr);  break;
  425|  3.42k|  case TJCS_GRAY:
  ------------------
  |  Branch (425:3): [True: 3.42k, False: 22.0k]
  ------------------
  426|  3.42k|    jpeg_set_colorspace(&this->cinfo, JCS_GRAYSCALE);  break;
  427|      0|  case TJCS_CMYK:
  ------------------
  |  Branch (427:3): [True: 0, False: 25.4k]
  ------------------
  428|      0|    jpeg_set_colorspace(&this->cinfo, JCS_CMYK);  break;
  429|  3.42k|  case TJCS_YCCK:
  ------------------
  |  Branch (429:3): [True: 3.42k, False: 22.0k]
  ------------------
  430|  3.42k|    jpeg_set_colorspace(&this->cinfo, JCS_YCCK);  break;
  431|  11.4k|  default:
  ------------------
  |  Branch (431:3): [True: 11.4k, False: 13.9k]
  ------------------
  432|  11.4k|    if (this->subsamp == TJSAMP_GRAY)
  ------------------
  |  Branch (432:9): [True: 4.64k, False: 6.85k]
  ------------------
  433|  4.64k|      jpeg_set_colorspace(&this->cinfo, JCS_GRAYSCALE);
  434|  6.85k|    else if (pixelFormat == TJPF_CMYK)
  ------------------
  |  Branch (434:14): [True: 0, False: 6.85k]
  ------------------
  435|      0|      jpeg_set_colorspace(&this->cinfo, JCS_YCCK);
  436|  6.85k|    else
  437|  6.85k|      jpeg_set_colorspace(&this->cinfo, JCS_YCbCr);
  438|  25.4k|  }
  439|       |
  440|  25.4k|  if (this->cinfo.data_precision == 8)
  ------------------
  |  Branch (440:7): [True: 25.4k, False: 0]
  ------------------
  441|  25.4k|    this->cinfo.optimize_coding = this->optimize;
  442|  25.4k|#ifdef C_PROGRESSIVE_SUPPORTED
  443|  25.4k|  if (this->progressive) jpeg_simple_progression(&this->cinfo);
  ------------------
  |  Branch (443:7): [True: 6.99k, False: 18.4k]
  ------------------
  444|  25.4k|#endif
  445|  25.4k|  this->cinfo.arith_code = this->arithmetic;
  446|       |
  447|  25.4k|  this->cinfo.comp_info[0].h_samp_factor = tjMCUWidth[this->subsamp] / 8;
  448|  25.4k|  this->cinfo.comp_info[1].h_samp_factor = 1;
  449|  25.4k|  this->cinfo.comp_info[2].h_samp_factor = 1;
  450|  25.4k|  if (this->cinfo.num_components > 3)
  ------------------
  |  Branch (450:7): [True: 3.42k, False: 22.0k]
  ------------------
  451|  3.42k|    this->cinfo.comp_info[3].h_samp_factor = tjMCUWidth[this->subsamp] / 8;
  452|  25.4k|  this->cinfo.comp_info[0].v_samp_factor = tjMCUHeight[this->subsamp] / 8;
  453|  25.4k|  this->cinfo.comp_info[1].v_samp_factor = 1;
  454|  25.4k|  this->cinfo.comp_info[2].v_samp_factor = 1;
  455|  25.4k|  if (this->cinfo.num_components > 3)
  ------------------
  |  Branch (455:7): [True: 3.42k, False: 22.0k]
  ------------------
  456|  3.42k|    this->cinfo.comp_info[3].v_samp_factor = tjMCUHeight[this->subsamp] / 8;
  457|  25.4k|}

