faad_fft_init:
   52|      2|{
   53|      2|#ifndef FAAD_DISABLE_DAB
   54|      2|    static const unsigned char logms[3] = { FFT_LOGM_5, FFT_LOGM_SHORT, FFT_LOGM_LONG };
  ------------------
  |  |   24|      2|#define FFT_LOGM_5     5  /* 32-sample FFT for 480 PFA */
  ------------------
                  static const unsigned char logms[3] = { FFT_LOGM_5, FFT_LOGM_SHORT, FFT_LOGM_LONG };
  ------------------
  |  |   26|      2|#define FFT_LOGM_SHORT 6  /* 256-sample short block MDCT, SBR QMF */
  ------------------
                  static const unsigned char logms[3] = { FFT_LOGM_5, FFT_LOGM_SHORT, FFT_LOGM_LONG };
  ------------------
  |  |   27|      2|#define FFT_LOGM_LONG  9  /* 2048-sample long block MDCT */
  ------------------
   55|      2|    int num_logms = 3;
   56|       |#else
   57|       |    static const unsigned char logms[2] = { FFT_LOGM_SHORT, FFT_LOGM_LONG };
   58|       |    int num_logms = 2;
   59|       |#endif
   60|      2|    int t;
   61|       |
   62|      8|    for (t = 0; t < num_logms; t++)
  ------------------
  |  Branch (62:17): [True: 6, False: 2]
  ------------------
   63|      6|    {
   64|      6|        int logm = logms[t];
   65|      6|        int size = 1 << logm;
   66|      6|        fftfloat *tw = twiddles + TW_OFFSET(logm);
  ------------------
  |  |   44|      6|#define TW_OFFSET(logm) (6 * ((logm) == FFT_LOGM_5 ? 0 : ((logm) == FFT_LOGM_SHORT ? TW_5 : (TW_5 + TW_SHORT))))
  |  |  ------------------
  |  |  |  |   24|      6|#define FFT_LOGM_5     5  /* 32-sample FFT for 480 PFA */
  |  |  ------------------
  |  |               #define TW_OFFSET(logm) (6 * ((logm) == FFT_LOGM_5 ? 0 : ((logm) == FFT_LOGM_SHORT ? TW_5 : (TW_5 + TW_SHORT))))
  |  |  ------------------
  |  |  |  |   26|      4|#define FFT_LOGM_SHORT 6  /* 256-sample short block MDCT, SBR QMF */
  |  |  ------------------
  |  |               #define TW_OFFSET(logm) (6 * ((logm) == FFT_LOGM_5 ? 0 : ((logm) == FFT_LOGM_SHORT ? TW_5 : (TW_5 + TW_SHORT))))
  |  |  ------------------
  |  |  |  |   36|      2|#define TW_5     (8 + 2)
  |  |  ------------------
  |  |               #define TW_OFFSET(logm) (6 * ((logm) == FFT_LOGM_5 ? 0 : ((logm) == FFT_LOGM_SHORT ? TW_5 : (TW_5 + TW_SHORT))))
  |  |  ------------------
  |  |  |  |   36|      2|#define TW_5     (8 + 2)
  |  |  ------------------
  |  |               #define TW_OFFSET(logm) (6 * ((logm) == FFT_LOGM_5 ? 0 : ((logm) == FFT_LOGM_SHORT ? TW_5 : (TW_5 + TW_SHORT))))
  |  |  ------------------
  |  |  |  |   40|      2|#define TW_SHORT (16 + 4 + 1)
  |  |  ------------------
  |  |  |  Branch (44:31): [True: 2, False: 4]
  |  |  |  Branch (44:59): [True: 2, False: 2]
  |  |  ------------------
  ------------------
   67|      6|        int n2, i;
   68|       |
   69|     24|        for (n2 = size >> 2; n2 >= 1; n2 >>= 2)
  ------------------
  |  Branch (69:30): [True: 18, False: 6]
  ------------------
   70|     18|        {
   71|       |            /* stage twiddle W_N^(j*size/(4*n2)) = exp(-2*pi*i*j/(4*n2)) */
   72|    420|            for (i = 0; i < n2; i++)
  ------------------
  |  Branch (72:25): [True: 402, False: 18]
  ------------------
   73|    402|            {
   74|    402|                int m;
   75|  1.60k|                for (m = 1; m <= 3; m++)
  ------------------
  |  Branch (75:29): [True: 1.20k, False: 402]
  ------------------
   76|  1.20k|                {
   77|  1.20k|                    double theta = 2.0 * M_PI_DOUBLE * (double)(m * i) / (double)(4 * n2);
  ------------------
  |  |   25|  1.20k|#define M_PI_DOUBLE 3.14159265358979323846
  ------------------
   78|  1.20k|                    *tw++ = (fftfloat)cos(theta);
   79|  1.20k|                    *tw++ = (fftfloat)-sin(theta);
   80|  1.20k|                }
   81|    402|            }
   82|     18|        }
   83|      6|    }
   84|      2|}

faad_get_sr_index:
   22|    335|{
   23|  2.94k|    for (int i = 0; i < 12; i++) {
  ------------------
  |  Branch (23:21): [True: 2.85k, False: 94]
  ------------------
   24|  2.85k|        if (asc_codec_sample_rates[i] == sample_rate) {
  ------------------
  |  Branch (24:13): [True: 241, False: 2.61k]
  ------------------
   25|    241|            return i;
   26|    241|        }
   27|  2.85k|    }
   28|     94|    return -1;
   29|    335|}
faad_asc_decode:
   89|  1.14k|{
   90|       |    /* asc_decode() is always called on a BitReader freshly bits_init()'d over
   91|       |     * exactly the ASC bytes (see faad_decoder_open()). */
   92|  1.14k|    bool frame_length;
   93|  1.14k|    faad_status status = parse_asc(bs->buffer, bs->len, asc, &frame_length);
   94|  1.14k|    if (status != FAAD_OK) return status;
  ------------------
  |  Branch (94:9): [True: 812, False: 335]
  ------------------
   95|       |
   96|    335|    if (frame_length) {
  ------------------
  |  Branch (96:9): [True: 194, False: 141]
  ------------------
   97|    194|#ifndef FAAD_DISABLE_DAB
   98|    194|        asc->frame_length_flag = true;
   99|       |#else
  100|       |        return FAAD_ERR_UNSUPPORTED;
  101|       |#endif
  102|    194|    }
  103|       |
  104|    335|    return FAAD_OK;
  105|  1.14k|}
asc.c:parse_asc:
   34|  1.14k|{
   35|  1.14k|    if (!buf || len < 2 || len > UINT32_MAX / 8) return FAAD_ERR_INVALID_ARGUMENT;
  ------------------
  |  Branch (35:9): [True: 0, False: 1.14k]
  |  Branch (35:17): [True: 0, False: 1.14k]
  |  Branch (35:28): [True: 0, False: 1.14k]
  ------------------
   36|  1.14k|    memset(asc, 0, sizeof(*asc));
   37|  1.14k|    asc_bitreader br = { buf, len * 8, 0 };
   38|  1.14k|    uint32_t aot = asc_br_get(&br, 5);
   39|  1.14k|    if (aot == 31) aot = 32 + asc_br_get(&br, 6);
  ------------------
  |  Branch (39:9): [True: 49, False: 1.09k]
  ------------------
   40|  1.14k|    uint32_t rate = asc_parse_sample_rate(&br);
   41|  1.14k|    uint32_t channels = asc_br_get(&br, 4);
   42|  1.14k|    uint32_t output_rate = rate * 2;
   43|  1.14k|    bool explicit_sbr = aot == 5 || aot == 29;
  ------------------
  |  Branch (43:25): [True: 210, False: 937]
  |  Branch (43:37): [True: 131, False: 806]
  ------------------
   44|  1.14k|    if (explicit_sbr) {
  ------------------
  |  Branch (44:9): [True: 341, False: 806]
  ------------------
   45|    341|        output_rate = asc_parse_sample_rate(&br);
   46|    341|        asc->is_sbr = true;
   47|    341|        asc->is_ps = aot == 29;
   48|    341|        aot = asc_br_get(&br, 5);
   49|    341|        if (aot == 31) aot = 32 + asc_br_get(&br, 6);
  ------------------
  |  Branch (49:13): [True: 42, False: 299]
  ------------------
   50|    341|    }
   51|  1.14k|    if (br.pos > br.len_bits || !rate || !output_rate || (channels > 7 && channels != 11 && channels != 12))
  ------------------
  |  Branch (51:9): [True: 21, False: 1.12k]
  |  Branch (51:33): [True: 6, False: 1.12k]
  |  Branch (51:42): [True: 6, False: 1.11k]
  |  Branch (51:59): [True: 170, False: 944]
  |  Branch (51:75): [True: 94, False: 76]
  |  Branch (51:93): [True: 52, False: 42]
  ------------------
   52|     85|        return FAAD_ERR_INVALID_ARGUMENT;
   53|  1.06k|    if (aot != 2) return FAAD_ERR_UNSUPPORTED;
  ------------------
  |  Branch (53:9): [True: 80, False: 982]
  ------------------
   54|    982|    if (explicit_sbr && output_rate != 2 * rate) return FAAD_ERR_UNSUPPORTED;
  ------------------
  |  Branch (54:9): [True: 256, False: 726]
  |  Branch (54:25): [True: 46, False: 210]
  ------------------
   55|    936|    *frame_length = asc_br_get(&br, 1) != 0;
   56|    936|    if (asc_br_get(&br, 1)) asc_skip_core_coder_delay(&br);
  ------------------
  |  Branch (56:9): [True: 393, False: 543]
  ------------------
   57|    936|    bool extension = asc_br_get(&br, 1) != 0;
   58|    936|    if (!channels) {
  ------------------
  |  Branch (58:9): [True: 550, False: 386]
  ------------------
   59|       |        /* Validate the ASC's PCE profile and sampling index; channel elements
   60|       |         * are mapped from its tags during packet decoding. */
   61|    550|        if (!asc_parse_pce(&br, &asc->pce)) return FAAD_ERR_INVALID_ARGUMENT;
  ------------------
  |  Branch (61:13): [True: 208, False: 342]
  ------------------
   62|    342|        if (asc->pce.profile != 1 || asc->pce.sr_index >= 12) return FAAD_ERR_UNSUPPORTED;
  ------------------
  |  Branch (62:13): [True: 179, False: 163]
  |  Branch (62:38): [True: 27, False: 136]
  ------------------
   63|       |        /* Per-channel state is sized for MAX_CHANNELS. */
   64|    136|        if (asc->pce.channels > MAX_CHANNELS) return FAAD_ERR_UNSUPPORTED;
  ------------------
  |  |    1|    136|#define MAX_CHANNELS 8
  ------------------
  |  Branch (64:13): [True: 35, False: 101]
  ------------------
   65|    136|    }
   66|    487|    if (extension) asc_br_get(&br, 1);
  ------------------
  |  Branch (66:9): [True: 201, False: 286]
  ------------------
   67|    487|    if (br.pos > br.len_bits) return FAAD_ERR_INVALID_ARGUMENT;
  ------------------
  |  Branch (67:9): [True: 2, False: 485]
  ------------------
   68|    485|    if (asc_br_remaining(&br) >= 11 && asc_br_get(&br, 11) == ASC_SYNC_EXTENSION_SBR) {
  ------------------
  |  Branch (68:9): [True: 402, False: 83]
  |  Branch (68:40): [True: 314, False: 88]
  ------------------
   69|    314|        uint32_t ext_aot = asc_br_get(&br, 5);
   70|    314|        if (ext_aot == 5 && asc_br_get(&br, 1)) {
  ------------------
  |  Branch (70:13): [True: 298, False: 16]
  |  Branch (70:29): [True: 294, False: 4]
  ------------------
   71|    294|            uint32_t ext_rate = asc_parse_sample_rate(&br);
   72|    294|            if (!ext_rate || br.pos > br.len_bits) return FAAD_ERR_INVALID_ARGUMENT;
  ------------------
  |  Branch (72:17): [True: 3, False: 291]
  |  Branch (72:30): [True: 26, False: 265]
  ------------------
   73|    265|            if (ext_rate != rate * 2) return FAAD_ERR_UNSUPPORTED;
  ------------------
  |  Branch (73:17): [True: 115, False: 150]
  ------------------
   74|    150|            asc->is_sbr = true;
   75|    150|            output_rate = ext_rate;
   76|    150|            if (asc_br_remaining(&br) >= 11 && asc_br_get(&br, 11) == ASC_SYNC_EXTENSION_PS)
  ------------------
  |  Branch (76:17): [True: 141, False: 9]
  |  Branch (76:48): [True: 47, False: 94]
  ------------------
   77|     47|                asc->is_ps = asc_br_get(&br, 1) != 0;
   78|    150|        }
   79|    314|    }
   80|    341|    if (br.pos > br.len_bits) return FAAD_ERR_INVALID_ARGUMENT;
  ------------------
  |  Branch (80:9): [True: 6, False: 335]
  ------------------
   81|    335|    asc->object_type = FAAD_OBJ_LC;
   82|    335|    asc->sample_rate = rate;
   83|    335|    asc->num_channels = channels;
   84|    335|    asc->sbr_sample_rate = output_rate;
   85|    335|    return FAAD_OK;
   86|    341|}

faad_bits_init:
   19|  1.14k|{
   20|  1.14k|    bs->buffer = buffer;
   21|  1.14k|    bs->len = len;
   22|  1.14k|    bs->byte_pos = 0;
   23|  1.14k|    bs->bit_pos = 0;
   24|       |    bs->overread = false;
   25|  1.14k|}

faad_layout_update:
  148|    241|{
  149|    241|    struct faad_layout *L = &dec->layout;
  150|    241|    uint32_t cfg = dec->asc.num_channels;
  151|    241|    if (cfg) {
  ------------------
  |  Branch (151:9): [True: 196, False: 45]
  ------------------
  152|    196|        if (cfg == L->cfg && L->n) return;
  ------------------
  |  Branch (152:13): [True: 0, False: 196]
  |  Branch (152:30): [True: 0, False: 0]
  ------------------
  153|    196|        if (cfg < CFG_COUNT) {
  ------------------
  |  Branch (153:13): [True: 196, False: 0]
  ------------------
  154|    196|            uint32_t n = 0;
  155|    912|            while (n < 5 && config_elements[cfg][n] != 0xff) n++;
  ------------------
  |  Branch (155:20): [True: 829, False: 83]
  |  Branch (155:29): [True: 716, False: 113]
  ------------------
  156|    196|            layout_build(dec, config_elements[cfg], n, false);
  157|    196|        } else {
  158|      0|            memset(L, 0, sizeof(*L));
  159|      0|        }
  160|    196|    } else {
  161|     45|        if (L->cfg) memset(L, 0, sizeof(*L)); /* a new layout starts, with no PCM in it yet */
  ------------------
  |  Branch (161:13): [True: 0, False: 45]
  ------------------
  162|     45|        if (!L->frozen && dec->asc.pce.n_el)
  ------------------
  |  Branch (162:13): [True: 45, False: 0]
  |  Branch (162:27): [True: 45, False: 0]
  ------------------
  163|     45|            layout_build(dec, dec->asc.pce.el, dec->asc.pce.n_el, true);
  164|     45|    }
  165|    241|    L->cfg = (uint8_t)cfg;
  166|    241|}
faad_config_init:
  446|  2.29k|{
  447|  2.29k|    if (!config || caller_size < CONFIG_BASELINE_SIZE) {
  ------------------
  |  |   27|  2.29k|#define CONFIG_BASELINE_SIZE ((uint32_t)FAAD_CONFIG_BASELINE)
  ------------------
  |  Branch (447:9): [True: 0, False: 2.29k]
  |  Branch (447:20): [True: 0, False: 2.29k]
  ------------------
  448|      0|        return FAAD_ERR_INVALID_ARGUMENT;
  449|      0|    }
  450|  2.29k|    faad_config tmp;
  451|  2.29k|    uint32_t n = caller_size < sizeof(tmp) ? caller_size : (uint32_t)sizeof(tmp);
  ------------------
  |  Branch (451:18): [True: 0, False: 2.29k]
  ------------------
  452|  2.29k|    memset(&tmp, 0, sizeof(tmp));
  453|  2.29k|    tmp.struct_size = n;
  454|  2.29k|    tmp.stream_format = FAAD_STREAM_ADTS;
  455|  2.29k|    tmp.output_format = FAAD_OUTPUT_16BIT;
  456|  2.29k|    tmp.downmix_mode = FAAD_DOWNMIX_NONE;
  457|  2.29k|    memcpy(config, &tmp, n);
  458|  2.29k|    return FAAD_OK;
  459|  2.29k|}
faad_init_global_tables:
  662|  1.14k|{
  663|       |    static faac_once_t once = FAAC_ONCE_INIT;
  664|  1.14k|    faac_once_run(&once, faad_init_global_tables_impl);
  665|  1.14k|}
faad_ensure_sbr:
  754|    145|{
  755|    145|    if (alloc_optional(dec, (void **)&dec->sbr, sizeof(SBRChannel[MAX_CHANNELS])) != FAAD_OK
  ------------------
  |  Branch (755:9): [True: 0, False: 145]
  ------------------
  756|    145|        || alloc_optional(dec, (void **)&dec->sbr_el, sizeof(SBRElement[MAX_CHANNELS])) != FAAD_OK
  ------------------
  |  Branch (756:12): [True: 0, False: 145]
  ------------------
  757|    145|        || alloc_optional(dec, (void **)&dec->sbr_scratch.y,
  ------------------
  |  Branch (757:12): [True: 0, False: 145]
  ------------------
  758|    145|                          sizeof(float[SBR_MAX_BANDS][SBR_BUF_SLOTS][2])) != FAAD_OK)
  759|      0|        return FAAD_ERR_NO_MEMORY;
  760|    145|    dec->sbr_scratch.x_low = dec->sbr_scratch.y;
  761|    145|    return FAAD_OK;
  762|    145|}
faad_ensure_ps:
  766|     44|{
  767|     44|    return alloc_optional(dec, (void **)&dec->ps, sizeof(PSState));
  768|     44|}
faad_decoder_open:
  783|  1.14k|{
  784|  1.14k|    if (!out) return FAAD_ERR_INVALID_ARGUMENT;
  ------------------
  |  Branch (784:9): [True: 0, False: 1.14k]
  ------------------
  785|  1.14k|    *out = NULL;
  786|  1.14k|    faad_config resolved;
  787|  1.14k|    if (resolve_config(config, &resolved) != FAAD_OK
  ------------------
  |  Branch (787:9): [True: 0, False: 1.14k]
  ------------------
  788|  1.14k|        || ((asc_buf == NULL) != (asc_len == 0))
  ------------------
  |  Branch (788:12): [True: 0, False: 1.14k]
  ------------------
  789|  1.14k|        || (resolved.stream_format == FAAD_STREAM_RAW && !asc_len))
  ------------------
  |  Branch (789:13): [True: 1.14k, False: 0]
  |  Branch (789:58): [True: 0, False: 1.14k]
  ------------------
  790|      0|        return FAAD_ERR_INVALID_ARGUMENT;
  791|  1.14k|    faad_init_global_tables();
  792|  1.14k|    faad_decoder *dec = AllocMemory(sizeof(*dec));
  ------------------
  |  |   41|  1.14k|#define AllocMemory(size) malloc(size)
  ------------------
  793|  1.14k|    if (!dec) return FAAD_ERR_NO_MEMORY;
  ------------------
  |  Branch (793:9): [True: 0, False: 1.14k]
  ------------------
  794|  1.14k|    memset(dec, 0, sizeof(*dec));
  795|  1.14k|    dec->allocated_bytes = sizeof(*dec);
  796|  1.14k|    dec->largest_allocation = sizeof(*dec);
  797|  1.14k|    ALLOC_PART(spec, sizeof(float[MAX_CHANNELS][FRAME_LEN_LONG]));
  ------------------
  |  |  772|  1.14k|#define ALLOC_PART(field, size) do { \
  |  |  773|  1.14k|    dec->field = AllocMemory(size); \
  |  |  ------------------
  |  |  |  |   41|  1.14k|#define AllocMemory(size) malloc(size)
  |  |  ------------------
  |  |  774|  1.14k|    if (!dec->field) { free_split_state(dec); return FAAD_ERR_NO_MEMORY; } \
  |  |  ------------------
  |  |  |  Branch (774:9): [True: 0, False: 1.14k]
  |  |  ------------------
  |  |  775|  1.14k|    memset(dec->field, 0, size); \
  |  |  776|  1.14k|    dec->allocated_bytes += (size); \
  |  |  777|  1.14k|    if ((size) > dec->largest_allocation) dec->largest_allocation = (size); \
  |  |  ------------------
  |  |  |  Branch (777:9): [True: 1.14k, False: 0]
  |  |  ------------------
  |  |  778|  1.14k|} while (0)
  |  |  ------------------
  |  |  |  Branch (778:10): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
  798|  1.14k|    ALLOC_PART(overlap, sizeof(float[MAX_CHANNELS][FRAME_LEN_LONG]));
  ------------------
  |  |  772|  1.14k|#define ALLOC_PART(field, size) do { \
  |  |  773|  1.14k|    dec->field = AllocMemory(size); \
  |  |  ------------------
  |  |  |  |   41|  1.14k|#define AllocMemory(size) malloc(size)
  |  |  ------------------
  |  |  774|  1.14k|    if (!dec->field) { free_split_state(dec); return FAAD_ERR_NO_MEMORY; } \
  |  |  ------------------
  |  |  |  Branch (774:9): [True: 0, False: 1.14k]
  |  |  ------------------
  |  |  775|  1.14k|    memset(dec->field, 0, size); \
  |  |  776|  1.14k|    dec->allocated_bytes += (size); \
  |  |  777|  1.14k|    if ((size) > dec->largest_allocation) dec->largest_allocation = (size); \
  |  |  ------------------
  |  |  |  Branch (777:9): [True: 0, False: 1.14k]
  |  |  ------------------
  |  |  778|  1.14k|} while (0)
  |  |  ------------------
  |  |  |  Branch (778:10): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
  799|  1.14k|    ALLOC_PART(prev_spec, sizeof(float[MAX_CHANNELS][FRAME_LEN_LONG]));
  ------------------
  |  |  772|  1.14k|#define ALLOC_PART(field, size) do { \
  |  |  773|  1.14k|    dec->field = AllocMemory(size); \
  |  |  ------------------
  |  |  |  |   41|  1.14k|#define AllocMemory(size) malloc(size)
  |  |  ------------------
  |  |  774|  1.14k|    if (!dec->field) { free_split_state(dec); return FAAD_ERR_NO_MEMORY; } \
  |  |  ------------------
  |  |  |  Branch (774:9): [True: 0, False: 1.14k]
  |  |  ------------------
  |  |  775|  1.14k|    memset(dec->field, 0, size); \
  |  |  776|  1.14k|    dec->allocated_bytes += (size); \
  |  |  777|  1.14k|    if ((size) > dec->largest_allocation) dec->largest_allocation = (size); \
  |  |  ------------------
  |  |  |  Branch (777:9): [True: 0, False: 1.14k]
  |  |  ------------------
  |  |  778|  1.14k|} while (0)
  |  |  ------------------
  |  |  |  Branch (778:10): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
  800|  1.14k|    ALLOC_PART(pcm, sizeof(float[MAX_CHANNELS * FRAME_SAMPLES_MAX]));
  ------------------
  |  |  772|  1.14k|#define ALLOC_PART(field, size) do { \
  |  |  773|  1.14k|    dec->field = AllocMemory(size); \
  |  |  ------------------
  |  |  |  |   41|  1.14k|#define AllocMemory(size) malloc(size)
  |  |  ------------------
  |  |  774|  1.14k|    if (!dec->field) { free_split_state(dec); return FAAD_ERR_NO_MEMORY; } \
  |  |  ------------------
  |  |  |  Branch (774:9): [True: 0, False: 1.14k]
  |  |  ------------------
  |  |  775|  1.14k|    memset(dec->field, 0, size); \
  |  |  776|  1.14k|    dec->allocated_bytes += (size); \
  |  |  777|  1.14k|    if ((size) > dec->largest_allocation) dec->largest_allocation = (size); \
  |  |  ------------------
  |  |  |  Branch (777:9): [True: 1.14k, False: 0]
  |  |  ------------------
  |  |  778|  1.14k|} while (0)
  |  |  ------------------
  |  |  |  Branch (778:10): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
  801|  1.14k|#if !defined(FAAD_DISABLE_SBR) && MAX_CHANNELS >= 2
  802|       |    /* Core PCM is packed into the first half until every IMDCT finishes. */
  803|  1.14k|    dec->scratch = (FrameScratch *)(dec->pcm + MAX_CHANNELS * FRAME_LEN_LONG);
  ------------------
  |  |    1|  1.14k|#define MAX_CHANNELS 8
  ------------------
                  dec->scratch = (FrameScratch *)(dec->pcm + MAX_CHANNELS * FRAME_LEN_LONG);
  ------------------
  |  |   98|  1.14k|#define FRAME_LEN_LONG 1024
  ------------------
  804|       |#else
  805|       |    ALLOC_PART(scratch, sizeof(FrameScratch));
  806|       |#endif
  807|  1.14k|    faad_status st = init_decoder(dec, &resolved, asc_buf, asc_len, out);
  808|  1.14k|    if (st != FAAD_OK) { free_split_state(dec); return st; }
  ------------------
  |  Branch (808:9): [True: 906, False: 241]
  ------------------
  809|    241|#ifndef FAAD_DISABLE_SBR
  810|    241|    if (dec->asc.is_sbr && faad_ensure_sbr(dec) != FAAD_OK) st = FAAD_ERR_NO_MEMORY;
  ------------------
  |  Branch (810:9): [True: 145, False: 96]
  |  Branch (810:28): [True: 0, False: 145]
  ------------------
  811|    241|#ifndef FAAD_DISABLE_PS
  812|    241|    if (st == FAAD_OK && dec->asc.is_ps && faad_ensure_ps(dec) != FAAD_OK)
  ------------------
  |  Branch (812:9): [True: 241, False: 0]
  |  Branch (812:26): [True: 44, False: 197]
  |  Branch (812:44): [True: 0, False: 44]
  ------------------
  813|      0|        st = FAAD_ERR_NO_MEMORY;
  814|    241|#endif
  815|    241|#endif
  816|    241|    if (st != FAAD_OK) { *out = NULL; free_split_state(dec); }
  ------------------
  |  Branch (816:9): [True: 0, False: 241]
  ------------------
  817|    241|    return st;
  818|  1.14k|}
faad_decoder_close:
  873|    241|{
  874|    241|    if (!decoder) return FAAD_ERR_INVALID_ARGUMENT;
  ------------------
  |  Branch (874:9): [True: 0, False: 241]
  ------------------
  875|    241|    faad_decoder *dec = *decoder;
  876|    241|    if (!dec) return FAAD_OK;
  ------------------
  |  Branch (876:9): [True: 0, False: 241]
  ------------------
  877|    241|    *decoder = NULL;
  878|       |#ifdef FAAD_STATS
  879|       |    faad_print_stats();
  880|       |    if (g_faadStats.dumpFile) fclose(g_faadStats.dumpFile);
  881|       |    g_faadStats.dumpFile = NULL;
  882|       |    g_faadStats.dumpOpenTried = false;
  883|       |#endif
  884|    241|    free_split_state(dec);
  885|    241|    return FAAD_OK;
  886|    241|}
faad_decoder_get_info:
  889|    241|{
  890|    241|    if (!decoder || !out_info || out_info->struct_size < STREAM_INFO_BASELINE_SIZE)
  ------------------
  |  |   29|    241|#define STREAM_INFO_BASELINE_SIZE ((uint32_t)FAAD_STREAM_INFO_BASELINE)
  ------------------
  |  Branch (890:9): [True: 0, False: 241]
  |  Branch (890:21): [True: 0, False: 241]
  |  Branch (890:34): [True: 0, False: 241]
  ------------------
  891|      0|        return FAAD_ERR_INVALID_ARGUMENT;
  892|    241|    faad_stream_info info;
  893|    241|    memset(&info, 0, sizeof(info));
  894|    241|    info.struct_size = bounded_size(out_info->struct_size, sizeof(info));
  895|    241|    info.max_output_bytes = decoder->max_output_bytes;
  896|    241|    if (decoder->format_known) info.flags |= FAAD_STREAM_FORMAT_KNOWN;
  ------------------
  |  Branch (896:9): [True: 241, False: 0]
  ------------------
  897|    241|#ifndef FAAD_DISABLE_DRC
  898|    241|    info.drc_ref_level = -0.25f * (float)decoder->drc.ref;
  899|    241|    if (decoder->drc.ref_present) info.flags |= FAAD_STREAM_DRC_REF_LEVEL;
  ------------------
  |  Branch (899:9): [True: 0, False: 241]
  ------------------
  900|    241|#endif
  901|    241|    if (!(info.flags & FAAD_STREAM_FORMAT_KNOWN)) {
  ------------------
  |  Branch (901:9): [True: 0, False: 241]
  ------------------
  902|      0|        memcpy(out_info, &info, info.struct_size);
  903|      0|        return FAAD_OK;
  904|      0|    }
  905|    241|    bool sbr = decoder->asc.is_sbr || decoder->sbr_seen;
  ------------------
  |  Branch (905:16): [True: 145, False: 96]
  |  Branch (905:39): [True: 0, False: 96]
  ------------------
  906|    241|    info.sample_rate = decoder->core_sample_rate;
  907|    241|    uint32_t core_samples = FRAME_IS_960(decoder) ? 960 : 1024;
  ------------------
  |  |  265|    241|#define FRAME_IS_960(dec) ((dec)->asc.frame_length_flag)
  |  |  ------------------
  |  |  |  Branch (265:27): [True: 144, False: 97]
  |  |  ------------------
  ------------------
  908|    241|    info.frame_samples = core_samples;
  909|    241|#ifndef FAAD_DISABLE_SBR
  910|    241|    if (sbr) { info.sample_rate *= 2; info.frame_samples = core_samples * 2; }
  ------------------
  |  Branch (910:9): [True: 145, False: 96]
  ------------------
  911|    241|#endif
  912|    241|    info.channels = decoder->num_channels;
  913|    241|#ifndef FAAD_DISABLE_PS
  914|    241|    if (decoder->ps_seen && info.channels == 1) info.channels = 2;
  ------------------
  |  Branch (914:9): [True: 44, False: 197]
  |  Branch (914:29): [True: 3, False: 41]
  ------------------
  915|    241|#endif
  916|    241|    info.channels = downmix_out_chs(decoder->config.downmix_mode, info.channels);
  917|    241|    info.object_type = (decoder->asc.is_ps || decoder->ps_seen) ? FAAD_OBJ_HE_AAC_V2
  ------------------
  |  Branch (917:25): [True: 44, False: 197]
  |  Branch (917:47): [True: 0, False: 197]
  ------------------
  918|    241|        : sbr ? FAAD_OBJ_HE_AAC_V1 : FAAD_OBJ_LC;
  ------------------
  |  Branch (918:11): [True: 101, False: 96]
  ------------------
  919|    241|#ifndef FAAD_DISABLE_SBR
  920|    241|    info.decoder_delay = sbr ? 2 * FAAD_SBR_CORE_DELAY : 0;
  ------------------
  |  |  558|    145|#define FAAD_SBR_CORE_DELAY 481u
  ------------------
  |  Branch (920:26): [True: 145, False: 96]
  ------------------
  921|    241|#endif
  922|    241|    info.channel_mask = channel_mask(decoder, info.channels);
  923|    241|    if (decoder->pcm_emitted) {
  ------------------
  |  Branch (923:9): [True: 0, False: 241]
  ------------------
  924|      0|        info.sample_rate = decoder->emitted_format.sample_rate;
  925|      0|        info.channels = decoder->emitted_format.channels;
  926|      0|        info.frame_samples = decoder->emitted_format.frame_samples;
  927|      0|        info.channel_mask = decoder->emitted_format.channel_mask;
  928|      0|        info.decoder_delay = decoder->emitted_format.decoder_delay;
  929|      0|    }
  930|    241|    memcpy(out_info, &info, info.struct_size);
  931|       |
  932|    241|    return FAAD_OK;
  933|    241|}
decoder.c:layout_build:
  104|    241|{
  105|    241|    static const uint16_t speakers[4][2] = { { SPK_FC, SPK_FRONT }, { 0, SPK_SIDE }, { SPK_BC, SPK_BACK }, { SPK_LFE, 0 } };
  106|    241|    struct faad_layout *L = &dec->layout;
  107|    241|    uint16_t spk[MAX_CHANNELS];
  108|    241|    uint32_t mask = 0, ch = 0, front_pairs = 0, back_pairs = 0, side = 0, front_total = 0;
  109|    241|    memset(L, 0, sizeof(*L));
  110|    241|    L->lfe = 0xff;
  111|  1.10k|    for (uint32_t i = 0; i < n; i++) {
  ------------------
  |  Branch (111:26): [True: 865, False: 241]
  ------------------
  112|    865|        side += el[i] >> 5 == ASC_PCE_SIDE;
  113|    865|        back_pairs += el[i] >> 4 == (ASC_PCE_BACK << 1 | 1);
  114|    865|        front_total += el[i] >> 4 == (ASC_PCE_FRONT << 1 | 1);
  115|    865|    }
  116|    241|    bool rear_pairs = back_pairs == 2 && !side;
  ------------------
  |  Branch (116:23): [True: 9, False: 232]
  |  Branch (116:42): [True: 9, False: 0]
  ------------------
  117|  1.03k|    for (uint32_t i = 0; i < n; i++) {
  ------------------
  |  Branch (117:26): [True: 820, False: 212]
  ------------------
  118|    820|        uint32_t cat = el[i] >> 5, pair = el[i] >> 4 & 1, bits = speakers[cat][pair];
  119|    820|        if (cat == ASC_PCE_FRONT && pair) {
  ------------------
  |  Branch (119:13): [True: 416, False: 404]
  |  Branch (119:37): [True: 217, False: 199]
  ------------------
  120|       |            /* Front pairs are listed from the centre outward: with two, the inner one is FLC/FRC. */
  121|    217|            if (front_total > 2) bits = 0;
  ------------------
  |  Branch (121:17): [True: 2, False: 215]
  ------------------
  122|    215|            else if (front_total == 2 && !front_pairs++) bits = SPK_FLC | SPK_FRC;
  ------------------
  |  Branch (122:22): [True: 22, False: 193]
  |  Branch (122:42): [True: 11, False: 11]
  ------------------
  123|    217|        }
  124|    820|        if (rear_pairs && cat == ASC_PCE_BACK && pair && !(mask & SPK_SIDE)) bits = SPK_SIDE;
  ------------------
  |  Branch (124:13): [True: 31, False: 789]
  |  Branch (124:27): [True: 20, False: 11]
  |  Branch (124:50): [True: 16, False: 4]
  |  Branch (124:58): [True: 8, False: 8]
  ------------------
  125|    820|        if (!bits || (mask & bits) || ch + 1 + pair > MAX_CHANNELS) return;
  ------------------
  |  |    1|    796|#define MAX_CHANNELS 8
  ------------------
  |  Branch (125:13): [True: 12, False: 808]
  |  Branch (125:22): [True: 12, False: 796]
  |  Branch (125:39): [True: 0, False: 796]
  ------------------
  126|    796|        mask |= bits;
  127|    796|        L->el_key[i] = (uint8_t)((cat == ASC_PCE_LFE ? ID_LFE : pair) << 4 | (el[i] & 0xf));
  ------------------
  |  |  113|    122|#define ID_LFE 0x3
  ------------------
  |  Branch (127:35): [True: 122, False: 674]
  ------------------
  128|       |        /* Tags select the elements, so two of one kind cannot share one. */
  129|    855|        for (uint32_t j = 0; by_tag && j < i; j++)
  ------------------
  |  Branch (129:30): [True: 139, False: 716]
  |  Branch (129:40): [True: 64, False: 75]
  ------------------
  130|     64|            if (L->el_key[j] == L->el_key[i]) return;
  ------------------
  |  Branch (130:17): [True: 5, False: 59]
  ------------------
  131|    791|        L->el_slot[i] = (uint8_t)ch;
  132|    791|        spk[ch] = (uint16_t)(bits & (0u - bits));
  133|    791|        if (pair) spk[ch + 1] = (uint16_t)(bits & (bits - 1));
  ------------------
  |  Branch (133:13): [True: 397, False: 394]
  ------------------
  134|    791|        ch += 1 + pair;
  135|    791|    }
  136|    212|    if (!ch) return;
  ------------------
  |  Branch (136:9): [True: 0, False: 212]
  ------------------
  137|  1.34k|    for (uint32_t i = 0; i < ch; i++) {
  ------------------
  |  Branch (137:26): [True: 1.13k, False: 212]
  ------------------
  138|  1.13k|        uint32_t rank = faac_popcount32(mask & (spk[i] - 1u)); /* speakers before this one */
  139|  1.13k|        L->map[rank] = (uint8_t)i;
  140|  1.13k|        if (spk[i] == SPK_LFE) L->lfe = (uint8_t)i;
  ------------------
  |  Branch (140:13): [True: 119, False: 1.01k]
  ------------------
  141|  1.13k|    }
  142|    212|    L->mask = (uint16_t)mask;
  143|    212|    L->n = (uint8_t)ch;
  144|    212|    L->n_el = by_tag ? (uint8_t)n : 0;
  ------------------
  |  Branch (144:15): [True: 16, False: 196]
  ------------------
  145|    212|}
decoder.c:bounded_size:
   37|    241|{
   38|    241|    return caller_size < library_size ? caller_size : (uint32_t)library_size;
  ------------------
  |  Branch (38:12): [True: 0, False: 241]
  ------------------
   39|    241|}
decoder.c:faad_init_global_tables_impl:
  637|      1|{
  638|      1|    extern void init_dequant_tables(void);
  639|      1|    extern void init_huffman_luts(void);
  640|      1|    extern void init_windows(void);
  641|      1|#ifndef FAAD_DISABLE_SBR
  642|      1|    extern void init_qmf_twiddles(void);
  643|      1|#endif
  644|      1|    extern void init_is_tables(void);
  645|      1|#ifndef FAAD_DISABLE_PS
  646|      1|    extern void init_ps_tables(void);
  647|      1|#endif
  648|       |
  649|      1|    init_dequant_tables();
  ------------------
  |  |   45|      1|#define init_dequant_tables faad_init_dequant_tables
  ------------------
  650|      1|    init_huffman_luts();
  ------------------
  |  |   46|      1|#define init_huffman_luts faad_init_huffman_luts
  ------------------
  651|      1|    init_windows();
  ------------------
  |  |   50|      1|#define init_windows faad_init_windows
  ------------------
  652|      1|#ifndef FAAD_DISABLE_SBR
  653|      1|    init_qmf_twiddles();
  ------------------
  |  |   49|      1|#define init_qmf_twiddles faad_init_qmf_twiddles
  ------------------
  654|      1|#endif
  655|      1|    init_is_tables();
  ------------------
  |  |   47|      1|#define init_is_tables faad_init_is_tables
  ------------------
  656|      1|#ifndef FAAD_DISABLE_PS
  657|      1|    init_ps_tables();
  ------------------
  |  |   48|      1|#define init_ps_tables faad_init_ps_tables
  ------------------
  658|      1|#endif
  659|      1|}
decoder.c:alloc_optional:
  743|    479|{
  744|    479|    if (*ptr) return FAAD_OK;
  ------------------
  |  Branch (744:9): [True: 0, False: 479]
  ------------------
  745|    479|    *ptr = AllocMemory(size);
  ------------------
  |  |   41|    479|#define AllocMemory(size) malloc(size)
  ------------------
  746|    479|    if (!*ptr) return FAAD_ERR_NO_MEMORY;
  ------------------
  |  Branch (746:9): [True: 0, False: 479]
  ------------------
  747|    479|    memset(*ptr, 0, size);
  748|    479|    dec->allocated_bytes += size;
  749|    479|    if (size > dec->largest_allocation) dec->largest_allocation = size;
  ------------------
  |  Branch (749:9): [True: 145, False: 334]
  ------------------
  750|    479|    return FAAD_OK;
  751|    479|}
decoder.c:resolve_config:
  607|  1.14k|{
  608|  1.14k|    faad_config_init(resolved, sizeof(*resolved));
  609|  1.14k|    if (!cfg) return FAAD_OK;
  ------------------
  |  Branch (609:9): [True: 0, False: 1.14k]
  ------------------
  610|  1.14k|    if (cfg->struct_size < CONFIG_BASELINE_SIZE) return FAAD_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   27|  1.14k|#define CONFIG_BASELINE_SIZE ((uint32_t)FAAD_CONFIG_BASELINE)
  ------------------
  |  Branch (610:9): [True: 0, False: 1.14k]
  ------------------
  611|       |    /* Absent or partially supplied fields keep defaults.
  612|       |     * Never memcpy a partially supplied scalar or read beyond the caller. */
  613|  1.14k|#define COPY_CONFIG_FIELD(field) \
  614|  1.14k|    if (cfg->struct_size >= offsetof(faad_config, field) + sizeof(cfg->field)) \
  615|  1.14k|        resolved->field = cfg->field
  616|  1.14k|    COPY_CONFIG_FIELD(stream_format);
  ------------------
  |  |  614|  1.14k|    if (cfg->struct_size >= offsetof(faad_config, field) + sizeof(cfg->field)) \
  |  |  ------------------
  |  |  |  Branch (614:9): [True: 1.14k, False: 0]
  |  |  ------------------
  |  |  615|  1.14k|        resolved->field = cfg->field
  ------------------
  617|  1.14k|    COPY_CONFIG_FIELD(output_format);
  ------------------
  |  |  614|  1.14k|    if (cfg->struct_size >= offsetof(faad_config, field) + sizeof(cfg->field)) \
  |  |  ------------------
  |  |  |  Branch (614:9): [True: 1.14k, False: 0]
  |  |  ------------------
  |  |  615|  1.14k|        resolved->field = cfg->field
  ------------------
  618|  1.14k|    COPY_CONFIG_FIELD(downmix_mode);
  ------------------
  |  |  614|  1.14k|    if (cfg->struct_size >= offsetof(faad_config, field) + sizeof(cfg->field)) \
  |  |  ------------------
  |  |  |  Branch (614:9): [True: 1.14k, False: 0]
  |  |  ------------------
  |  |  615|  1.14k|        resolved->field = cfg->field
  ------------------
  619|  1.14k|#ifndef FAAD_DISABLE_DRC
  620|  1.14k|    COPY_CONFIG_FIELD(drc_cut);
  ------------------
  |  |  614|  1.14k|    if (cfg->struct_size >= offsetof(faad_config, field) + sizeof(cfg->field)) \
  |  |  ------------------
  |  |  |  Branch (614:9): [True: 1.14k, False: 0]
  |  |  ------------------
  |  |  615|  1.14k|        resolved->field = cfg->field
  ------------------
  621|  1.14k|    COPY_CONFIG_FIELD(drc_boost);
  ------------------
  |  |  614|  1.14k|    if (cfg->struct_size >= offsetof(faad_config, field) + sizeof(cfg->field)) \
  |  |  ------------------
  |  |  |  Branch (614:9): [True: 1.14k, False: 0]
  |  |  ------------------
  |  |  615|  1.14k|        resolved->field = cfg->field
  ------------------
  622|  1.14k|    COPY_CONFIG_FIELD(drc_target_level);
  ------------------
  |  |  614|  1.14k|    if (cfg->struct_size >= offsetof(faad_config, field) + sizeof(cfg->field)) \
  |  |  ------------------
  |  |  |  Branch (614:9): [True: 1.14k, False: 0]
  |  |  ------------------
  |  |  615|  1.14k|        resolved->field = cfg->field
  ------------------
  623|  1.14k|    if (resolved->drc_cut > 127 || resolved->drc_boost > 127
  ------------------
  |  Branch (623:9): [True: 0, False: 1.14k]
  |  Branch (623:36): [True: 0, False: 1.14k]
  ------------------
  624|  1.14k|        || (resolved->drc_target_level != 0.0f
  ------------------
  |  Branch (624:13): [True: 1.14k, False: 0]
  ------------------
  625|  1.14k|            && !(resolved->drc_target_level >= -31.75f && resolved->drc_target_level <= -10.0f)))
  ------------------
  |  Branch (625:18): [True: 1.14k, False: 0]
  |  Branch (625:59): [True: 1.14k, False: 0]
  ------------------
  626|      0|        return FAAD_ERR_INVALID_ARGUMENT;
  627|  1.14k|    resolved->drc_target_level = roundf(4.0f * resolved->drc_target_level) / 4.0f;
  628|  1.14k|#endif
  629|  1.14k|#undef COPY_CONFIG_FIELD
  630|  1.14k|    return (resolved->stream_format == FAAD_STREAM_RAW || resolved->stream_format == FAAD_STREAM_ADTS)
  ------------------
  |  Branch (630:13): [True: 1.14k, False: 0]
  |  Branch (630:59): [True: 0, False: 0]
  ------------------
  631|  1.14k|        && (resolved->output_format == FAAD_OUTPUT_16BIT || resolved->output_format == FAAD_OUTPUT_24BIT
  ------------------
  |  Branch (631:13): [True: 1.14k, False: 0]
  |  Branch (631:61): [True: 0, False: 0]
  ------------------
  632|      0|            || resolved->output_format == FAAD_OUTPUT_24IN32 || resolved->output_format == FAAD_OUTPUT_FLOAT)
  ------------------
  |  Branch (632:16): [True: 0, False: 0]
  |  Branch (632:65): [True: 0, False: 0]
  ------------------
  633|  1.14k|        && downmix_mode_is_valid(resolved->downmix_mode) ? FAAD_OK : FAAD_ERR_INVALID_ARGUMENT;
  ------------------
  |  Branch (633:12): [True: 1.14k, False: 0]
  ------------------
  634|  1.14k|}
decoder.c:downmix_mode_is_valid:
  209|  1.14k|{
  210|  1.14k|    uint32_t n = faac_popcount32((uint32_t)mode);
  211|  1.14k|    return mode == FAAD_DOWNMIX_NONE || (!((uint32_t)mode >> POS_COUNT) && n <= 8);
  ------------------
  |  Branch (211:12): [True: 1.14k, False: 0]
  |  Branch (211:42): [True: 0, False: 0]
  |  Branch (211:76): [True: 0, False: 0]
  ------------------
  212|  1.14k|}
decoder.c:free_split_state:
  711|  1.14k|{
  712|  1.14k|    if (!dec) return;
  ------------------
  |  Branch (712:9): [True: 0, False: 1.14k]
  ------------------
  713|  1.14k|#define FREE_PART(field) do { if (dec->field) FreeMemory(dec->field); } while (0)
  714|  1.14k|#if MAX_CHANNELS >= 3
  715|  1.14k|    while (dec->coupling) {
  ------------------
  |  Branch (715:12): [True: 0, False: 1.14k]
  ------------------
  716|      0|        CouplingChannel *next = dec->coupling->next;
  717|      0|        if (dec->coupling->overlap) FreeMemory(dec->coupling->overlap);
  ------------------
  |  |   44|      0|#define FreeMemory(block) free(block)
  ------------------
  |  Branch (717:13): [True: 0, False: 0]
  ------------------
  718|      0|        FreeMemory(dec->coupling);
  ------------------
  |  |   44|      0|#define FreeMemory(block) free(block)
  ------------------
  719|      0|        dec->coupling = next;
  720|      0|    }
  721|  1.14k|#endif
  722|  1.14k|    FREE_PART(spec);
  ------------------
  |  |  713|  1.14k|#define FREE_PART(field) do { if (dec->field) FreeMemory(dec->field); } while (0)
  |  |  ------------------
  |  |  |  |   44|  1.14k|#define FreeMemory(block) free(block)
  |  |  ------------------
  |  |  |  Branch (713:35): [True: 1.14k, False: 0]
  |  |  |  Branch (713:80): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
  723|  1.14k|    FREE_PART(overlap);
  ------------------
  |  |  713|  1.14k|#define FREE_PART(field) do { if (dec->field) FreeMemory(dec->field); } while (0)
  |  |  ------------------
  |  |  |  |   44|  1.14k|#define FreeMemory(block) free(block)
  |  |  ------------------
  |  |  |  Branch (713:35): [True: 1.14k, False: 0]
  |  |  |  Branch (713:80): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
  724|  1.14k|    FREE_PART(prev_spec);
  ------------------
  |  |  713|  1.14k|#define FREE_PART(field) do { if (dec->field) FreeMemory(dec->field); } while (0)
  |  |  ------------------
  |  |  |  |   44|  1.14k|#define FreeMemory(block) free(block)
  |  |  ------------------
  |  |  |  Branch (713:35): [True: 1.14k, False: 0]
  |  |  |  Branch (713:80): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
  725|  1.14k|#ifndef FAAD_DISABLE_SBR
  726|  1.14k|    FREE_PART(sbr);
  ------------------
  |  |  713|  1.14k|#define FREE_PART(field) do { if (dec->field) FreeMemory(dec->field); } while (0)
  |  |  ------------------
  |  |  |  |   44|    145|#define FreeMemory(block) free(block)
  |  |  ------------------
  |  |  |  Branch (713:35): [True: 145, False: 1.00k]
  |  |  |  Branch (713:80): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
  727|  1.14k|    FREE_PART(sbr_el);
  ------------------
  |  |  713|  1.14k|#define FREE_PART(field) do { if (dec->field) FreeMemory(dec->field); } while (0)
  |  |  ------------------
  |  |  |  |   44|    145|#define FreeMemory(block) free(block)
  |  |  ------------------
  |  |  |  Branch (713:35): [True: 145, False: 1.00k]
  |  |  |  Branch (713:80): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
  728|  1.14k|    FREE_PART(sbr_scratch.y);
  ------------------
  |  |  713|  1.14k|#define FREE_PART(field) do { if (dec->field) FreeMemory(dec->field); } while (0)
  |  |  ------------------
  |  |  |  |   44|    145|#define FreeMemory(block) free(block)
  |  |  ------------------
  |  |  |  Branch (713:35): [True: 145, False: 1.00k]
  |  |  |  Branch (713:80): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
  729|  1.14k|#endif
  730|  1.14k|#ifndef FAAD_DISABLE_PS
  731|  1.14k|    FREE_PART(ps);
  ------------------
  |  |  713|  1.14k|#define FREE_PART(field) do { if (dec->field) FreeMemory(dec->field); } while (0)
  |  |  ------------------
  |  |  |  |   44|     44|#define FreeMemory(block) free(block)
  |  |  ------------------
  |  |  |  Branch (713:35): [True: 44, False: 1.10k]
  |  |  |  Branch (713:80): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
  732|  1.14k|#endif
  733|       |#if defined(FAAD_DISABLE_SBR) || MAX_CHANNELS < 2
  734|       |    FREE_PART(scratch);
  735|       |#endif
  736|  1.14k|    FREE_PART(pcm);
  ------------------
  |  |  713|  1.14k|#define FREE_PART(field) do { if (dec->field) FreeMemory(dec->field); } while (0)
  |  |  ------------------
  |  |  |  |   44|  1.14k|#define FreeMemory(block) free(block)
  |  |  ------------------
  |  |  |  Branch (713:35): [True: 1.14k, False: 0]
  |  |  |  Branch (713:80): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
  737|  1.14k|    FreeMemory(dec);
  ------------------
  |  |   44|  1.14k|#define FreeMemory(block) free(block)
  ------------------
  738|  1.14k|#undef FREE_PART
  739|  1.14k|}
decoder.c:init_decoder:
  670|  1.14k|{
  671|  1.14k|    dec->config = *resolved;
  672|       |
  673|  1.14k|    dec->pns_seed = 0x12345678;
  674|       |
  675|  1.14k|    if (asc_buf && asc_len > 0) {
  ------------------
  |  Branch (675:9): [True: 1.14k, False: 0]
  |  Branch (675:20): [True: 1.14k, False: 0]
  ------------------
  676|  1.14k|        BitReader bs;
  677|  1.14k|        bits_init(&bs, asc_buf, asc_len);
  ------------------
  |  |   28|  1.14k|#define bits_init faad_bits_init
  ------------------
  678|  1.14k|        faad_status st = asc_decode(&bs, &dec->asc);
  ------------------
  |  |   24|  1.14k|#define asc_decode faad_asc_decode
  ------------------
  679|  1.14k|        if (st != FAAD_OK) return st;
  ------------------
  |  Branch (679:13): [True: 812, False: 335]
  ------------------
  680|       |
  681|    335|        dec->num_channels = asc_channels(&dec->asc);
  682|    335|        if (dec->num_channels > MAX_CHANNELS) return FAAD_ERR_UNSUPPORTED;
  ------------------
  |  |    1|    335|#define MAX_CHANNELS 8
  ------------------
  |  Branch (682:13): [True: 0, False: 335]
  ------------------
  683|    335|        dec->core_sample_rate = dec->asc.sample_rate ? dec->asc.sample_rate : 44100;
  ------------------
  |  Branch (683:33): [True: 335, False: 0]
  ------------------
  684|    335|        if (get_sr_index(dec->core_sample_rate) < 0) return FAAD_ERR_UNSUPPORTED;
  ------------------
  |  |   43|    335|#define get_sr_index faad_get_sr_index
  ------------------
  |  Branch (684:13): [True: 94, False: 241]
  ------------------
  685|    241|        dec->sample_rate = dec->asc.is_sbr ? dec->asc.sbr_sample_rate : dec->core_sample_rate;
  ------------------
  |  Branch (685:28): [True: 145, False: 96]
  ------------------
  686|    241|        uint32_t core_samples = FRAME_IS_960(dec) ? 960 : 1024;
  ------------------
  |  |  265|    241|#define FRAME_IS_960(dec) ((dec)->asc.frame_length_flag)
  |  |  ------------------
  |  |  |  Branch (265:27): [True: 144, False: 97]
  |  |  ------------------
  ------------------
  687|    241|        dec->frame_samples = dec->asc.is_sbr ? (core_samples * 2) : core_samples;
  ------------------
  |  Branch (687:30): [True: 145, False: 96]
  ------------------
  688|    241|        dec->asc_parsed = true;
  689|    241|        faad_layout_update(dec);
  690|    241|        dec->format_known = dec->asc.num_channels != 0 || dec->asc.pce.channels != 0;
  ------------------
  |  Branch (690:29): [True: 196, False: 45]
  |  Branch (690:59): [True: 45, False: 0]
  ------------------
  691|    241|        dec->sbr_seen = dec->asc.is_sbr;
  692|    241|        dec->ps_seen = dec->asc.is_ps;
  693|    241|    } else {
  694|      0|        dec->num_channels = MAX_CHANNELS < 2 ? 1 : 2;
  ------------------
  |  |    1|      0|#define MAX_CHANNELS 8
  ------------------
  |  Branch (694:29): [Folded, False: 0]
  ------------------
  695|      0|        dec->sample_rate = 44100;
  696|      0|        dec->core_sample_rate = 44100;
  697|      0|        dec->frame_samples = 1024;
  698|      0|    }
  699|    241|    dec->core_channels = dec->num_channels;
  700|    241|    dec->max_output_bytes = output_capacity(dec);
  701|       |
  702|       |#ifdef FAAD_STATS
  703|       |    if (g_faadStats.dumpFile) fclose(g_faadStats.dumpFile);
  704|       |    memset(&g_faadStats, 0, sizeof(g_faadStats));
  705|       |#endif
  706|    241|    *out_dec = dec;
  707|    241|    return FAAD_OK;
  708|  1.14k|}
decoder.c:output_capacity:
  467|    241|{
  468|    241|    uint32_t channels = MAX_CHANNELS;
  ------------------
  |  |    1|    241|#define MAX_CHANNELS 8
  ------------------
  469|    241|    if (dec->config.stream_format == FAAD_STREAM_RAW && dec->asc_parsed && (dec->asc.num_channels || dec->asc.pce.channels))
  ------------------
  |  Branch (469:9): [True: 241, False: 0]
  |  Branch (469:57): [True: 241, False: 0]
  |  Branch (469:77): [True: 196, False: 45]
  |  Branch (469:102): [True: 45, False: 0]
  ------------------
  470|    241|        channels = asc_channels(&dec->asc);
  471|    241|#ifndef FAAD_DISABLE_PS
  472|    241|    if (channels < 2) channels = 2;
  ------------------
  |  Branch (472:9): [True: 17, False: 224]
  ------------------
  473|    241|#endif
  474|    241|    channels = downmix_out_chs(dec->config.downmix_mode, channels);
  475|    241|    uint32_t samples = FRAME_IS_960(dec) ? 960 : 1024;
  ------------------
  |  |  265|    241|#define FRAME_IS_960(dec) ((dec)->asc.frame_length_flag)
  |  |  ------------------
  |  |  |  Branch (265:27): [True: 144, False: 97]
  |  |  ------------------
  ------------------
  476|    241|#ifndef FAAD_DISABLE_SBR
  477|    241|    samples *= 2;
  478|    241|#endif
  479|    241|    return samples * channels * output_sample_bytes(dec->config.output_format);
  480|    241|}
decoder.c:downmix_out_chs:
  216|    482|{
  217|    482|    uint32_t n = faac_popcount32((uint32_t)mode);
  218|    482|    return mode != FAAD_DOWNMIX_NONE && channels > n ? n : channels;
  ------------------
  |  Branch (218:12): [True: 0, False: 482]
  |  Branch (218:41): [True: 0, False: 0]
  ------------------
  219|    482|}
decoder.c:channel_mask:
  483|    241|{
  484|    241|    if (channels < dec->num_channels) /* mixed: the stream is in the target layout */
  ------------------
  |  Branch (484:9): [True: 0, False: 241]
  ------------------
  485|      0|        return (uint32_t)dec->config.downmix_mode;
  486|    241|    static const uint32_t masks[] = { 0, SPK_FC, SPK_FRONT };
  487|    241|    return channels <= 2 ? masks[channels] : faad_layout_mask(dec, channels);
  ------------------
  |  Branch (487:12): [True: 47, False: 194]
  ------------------
  488|    241|}
decoder.c:output_sample_bytes:
  462|    241|{
  463|    241|    return f == FAAD_OUTPUT_16BIT ? 2 : f == FAAD_OUTPUT_24BIT ? 3 : 4;
  ------------------
  |  Branch (463:12): [True: 241, False: 0]
  |  Branch (463:41): [True: 0, False: 0]
  ------------------
  464|    241|}
decoder.c:config_channels:
   48|    467|{
   49|    467|    return channel_config == CFG_7_1 || channel_config == CFG_7_1_SIDE_BACK ? 8
  ------------------
  |  Branch (49:12): [True: 19, False: 448]
  |  Branch (49:41): [True: 43, False: 405]
  ------------------
   50|    467|        : channel_config == CFG_6_1 ? 7
  ------------------
  |  Branch (50:11): [True: 120, False: 285]
  ------------------
   51|    405|        : (channel_config >= CFG_MONO && channel_config <= CFG_5_1)
  ------------------
  |  Branch (51:12): [True: 285, False: 0]
  |  Branch (51:42): [True: 285, False: 0]
  ------------------
   52|    285|        ? channel_config : (MAX_CHANNELS < 2 ? 1 : 2);
  ------------------
  |  |    1|      0|#define MAX_CHANNELS 8
  ------------------
  |  Branch (52:29): [Folded, False: 0]
  ------------------
   53|    467|}
decoder.c:asc_channels:
   56|    576|{
   57|    576|    return asc->pce.channels ? asc->pce.channels : config_channels(asc->num_channels);
  ------------------
  |  Branch (57:12): [True: 109, False: 467]
  ------------------
   58|    576|}

decoder.c:faad_layout_mask:
  530|    194|{
  531|    194|    return dec->layout.n == num_chs ? dec->layout.mask : 0;
  ------------------
  |  Branch (531:12): [True: 170, False: 24]
  ------------------
  532|    194|}

faad_init_dequant_tables:
   25|      1|{
   26|    129|    for (int i = 0; i < POW_4_3_LUT_SIZE; i++) {
  ------------------
  |  |   20|    129|#define POW_4_3_LUT_SIZE 128
  ------------------
  |  Branch (26:21): [True: 128, False: 1]
  ------------------
   27|    128|        pow_4_3_lut[i] = powf((float)i, 4.0f / 3.0f);
   28|    128|    }
   29|    257|    for (int i = 0; i < 256; i++) {
  ------------------
  |  Branch (29:21): [True: 256, False: 1]
  ------------------
   30|    256|        sf_scale_lut[i] = powf(2.0f, 0.25f * (i - 100));
   31|    256|    }
   32|      1|}
faad_init_huffman_luts:
  304|      1|{
  305|      1|    int n_sub = 0, n_entries = 0;
  306|      1|    const HuffDesc *tab = huff_desc;
  307|     13|    for (int book = 1; book <= 12; book++) {
  ------------------
  |  Branch (307:24): [True: 12, False: 1]
  ------------------
  308|     12|        int n = huffbook_sizes[book];
  309|     12|        uint32_t code = 0;
  310|     12|        int prev_len = 0;
  311|     12|        HuffEntry *lut = huff_lut[book - 1];
  312|     12|        memset(lut, 0, sizeof(huff_lut[0]));
  313|       |
  314|       |        /* short codes fill their share of the first level; each longer
  315|       |         * code's prefix gets a subtree as deep as its longest code */
  316|  1.37k|        for (int i = 0; i < n; i++) {
  ------------------
  |  Branch (316:25): [True: 1.36k, False: 12]
  ------------------
  317|  1.36k|            int len = (int)tab[i].len;
  318|  1.36k|            code = (code + (i != 0)) << (len - prev_len);
  319|  1.36k|            prev_len = len;
  320|  1.36k|            if (len == 0) continue;
  ------------------
  |  Branch (320:17): [True: 0, False: 1.36k]
  ------------------
  321|  1.36k|            if (len <= HUFF_LUT_BITS) {
  ------------------
  |  |  284|  1.36k|#define HUFF_LUT_BITS 8
  ------------------
  |  Branch (321:17): [True: 508, False: 854]
  ------------------
  322|    508|                uint32_t start = code << (HUFF_LUT_BITS - len);
  ------------------
  |  |  284|    508|#define HUFF_LUT_BITS 8
  ------------------
  323|  3.38k|                for (uint32_t k = 0; k < (1U << (HUFF_LUT_BITS - len)); k++)
  ------------------
  |  |  284|  3.38k|#define HUFF_LUT_BITS 8
  ------------------
  |  Branch (323:38): [True: 2.87k, False: 508]
  ------------------
  324|  2.87k|                    lut[start + k] = (HuffEntry)(len | (huff_tuple(book, tab[i].sym) << 4));
  325|    854|            } else {
  326|    854|                uint32_t prefix = code >> (len - HUFF_LUT_BITS);
  ------------------
  |  |  284|    854|#define HUFF_LUT_BITS 8
  ------------------
  327|    854|                if (lut[prefix] == 0) {
  ------------------
  |  Branch (327:21): [True: 198, False: 656]
  ------------------
  328|    198|                    lut[prefix] = (HuffEntry)(n_sub << 4);
  329|    198|                    huff_subtree[n_sub].depth = 0;
  330|    198|                    n_sub++;
  331|    198|                }
  332|    854|                int t = lut[prefix] >> 4;
  333|    854|                if (len - HUFF_LUT_BITS > huff_subtree[t].depth) huff_subtree[t].depth = (uint8_t)(len - HUFF_LUT_BITS);
  ------------------
  |  |  284|    854|#define HUFF_LUT_BITS 8
  ------------------
                              if (len - HUFF_LUT_BITS > huff_subtree[t].depth) huff_subtree[t].depth = (uint8_t)(len - HUFF_LUT_BITS);
  ------------------
  |  |  284|    234|#define HUFF_LUT_BITS 8
  ------------------
  |  Branch (333:21): [True: 234, False: 620]
  ------------------
  334|    854|            }
  335|  1.36k|        }
  336|     12|        code = 0;
  337|     12|        prev_len = 0;
  338|  1.37k|        for (int i = 0; i < n; i++) {
  ------------------
  |  Branch (338:25): [True: 1.36k, False: 12]
  ------------------
  339|  1.36k|            int len = (int)tab[i].len;
  340|  1.36k|            code = (code + (i != 0)) << (len - prev_len);
  341|  1.36k|            prev_len = len;
  342|  1.36k|            if (len <= HUFF_LUT_BITS) continue;
  ------------------
  |  |  284|  1.36k|#define HUFF_LUT_BITS 8
  ------------------
  |  Branch (342:17): [True: 508, False: 854]
  ------------------
  343|    854|            uint32_t prefix = code >> (len - HUFF_LUT_BITS);
  ------------------
  |  |  284|    854|#define HUFF_LUT_BITS 8
  ------------------
  344|    854|            int t = lut[prefix] >> 4;
  345|    854|            if (!(huff_subtree[t].depth & 0x80)) {
  ------------------
  |  Branch (345:17): [True: 197, False: 657]
  ------------------
  346|       |                /* first code of this subtree: allocate it */
  347|    197|                huff_subtree[t].start = (uint16_t)n_entries;
  348|    197|                n_entries += 1 << huff_subtree[t].depth;
  349|    197|                memset(huff_sub + huff_subtree[t].start, 0, sizeof(HuffEntry) << huff_subtree[t].depth);
  350|    197|                huff_subtree[t].depth |= 0x80;
  351|    197|            }
  352|    854|            int depth = huff_subtree[t].depth & 0x7F;
  353|    854|            int rest = len - HUFF_LUT_BITS;
  ------------------
  |  |  284|    854|#define HUFF_LUT_BITS 8
  ------------------
  354|    854|            uint32_t tail = code & ((1U << rest) - 1);
  355|    854|            uint32_t start = huff_subtree[t].start + (tail << (depth - rest));
  356|  4.06k|            for (uint32_t k = 0; k < (1U << (depth - rest)); k++)
  ------------------
  |  Branch (356:34): [True: 3.20k, False: 854]
  ------------------
  357|  3.20k|                huff_sub[start + k] = (HuffEntry)(rest | (huff_tuple(book, tab[i].sym) << 4));
  358|    854|        }
  359|     12|        tab += n;
  360|     12|    }
  361|    199|    for (int t = 0; t < n_sub; t++) huff_subtree[t].depth &= 0x7F;
  ------------------
  |  Branch (361:21): [True: 198, False: 1]
  ------------------
  362|      1|}
huffman.c:huff_tuple:
  294|  6.08k|{
  295|  6.08k|    if (book == 12) return (uint32_t)sym;
  ------------------
  |  Branch (295:9): [True: 2.31k, False: 3.76k]
  ------------------
  296|  3.76k|    if (book <= 4) { /* v w x y, base 3 */
  ------------------
  |  Branch (296:9): [True: 1.37k, False: 2.38k]
  ------------------
  297|  1.37k|        return (uint32_t)((sym / 27) | ((sym / 9 % 3) << 2) | ((sym / 3 % 3) << 4) | ((sym % 3) << 6));
  298|  1.37k|    }
  299|  2.38k|    int base = book_base[book];
  300|  2.38k|    return (uint32_t)((sym / base) | ((sym % base) << 6));
  301|  3.76k|}

faad_init_windows:
   77|      1|{
   78|      1|    fft_init();
   79|       |
   80|  1.02k|    for (int i = 0; i < 1024; i++) {
  ------------------
  |  Branch (80:21): [True: 1.02k, False: 1]
  ------------------
   81|  1.02k|        sine_window_2048[i] = sinf((float)M_PI * (i + 0.5f) / 2048.0f);
   82|  1.02k|    }
   83|    129|    for (int i = 0; i < 128; i++) {
  ------------------
  |  Branch (83:21): [True: 128, False: 1]
  ------------------
   84|    128|        sine_window_256[i] = sinf((float)M_PI * (i + 0.5f) / 256.0f);
   85|    128|    }
   86|      1|#ifndef FAAD_DISABLE_DAB
   87|    961|    for (int i = 0; i < 960; i++) {
  ------------------
  |  Branch (87:21): [True: 960, False: 1]
  ------------------
   88|    960|        sine_window_1920[i] = sinf((float)M_PI * (i + 0.5f) / 1920.0f);
   89|    960|    }
   90|    121|    for (int i = 0; i < 120; i++) {
  ------------------
  |  Branch (90:21): [True: 120, False: 1]
  ------------------
   91|    120|        sine_window_240[i] = sinf((float)M_PI * (i + 0.5f) / 240.0f);
   92|    120|    }
   93|      1|#endif
   94|       |
   95|      1|    kbd_window(kbd_window_2048, 1024, 4.0);
   96|      1|    kbd_window(kbd_window_256, 128, 6.0);
   97|      1|#ifndef FAAD_DISABLE_DAB
   98|      1|    kbd_window(kbd_window_1920, 960, 4.0);
   99|      1|    kbd_window(kbd_window_240, 120, 6.0);
  100|      1|#endif
  101|       |
  102|    513|    for (int k = 0; k < 512; k++) {
  ------------------
  |  Branch (102:21): [True: 512, False: 1]
  ------------------
  103|    512|        double ang = -M_PI * (k + 0.125) / 1024.0;
  104|    512|        dct4_cos_1024[k] = (float)cos(ang);
  105|    512|        dct4_sin_1024[k] = (float)sin(ang);
  106|    512|    }
  107|     65|    for (int k = 0; k < 64; k++) {
  ------------------
  |  Branch (107:21): [True: 64, False: 1]
  ------------------
  108|     64|        double ang = -M_PI * (k + 0.125) / 128.0;
  109|     64|        dct4_cos_128[k] = (float)cos(ang);
  110|     64|        dct4_sin_128[k] = (float)sin(ang);
  111|     64|    }
  112|      1|#ifndef FAAD_DISABLE_DAB
  113|    481|    for (int k = 0; k < 480; k++) {
  ------------------
  |  Branch (113:21): [True: 480, False: 1]
  ------------------
  114|    480|        double ang = -M_PI * (k + 0.125) / 960.0;
  115|    480|        dct4_cos_960[k] = (float)cos(ang);
  116|    480|        dct4_sin_960[k] = (float)sin(ang);
  117|    480|    }
  118|     61|    for (int k = 0; k < 60; k++) {
  ------------------
  |  Branch (118:21): [True: 60, False: 1]
  ------------------
  119|       |        double ang = -M_PI * (k + 0.125) / 120.0;
  120|     60|        dct4_cos_120[k] = (float)cos(ang);
  121|     60|        dct4_sin_120[k] = (float)sin(ang);
  122|     60|    }
  123|      1|#endif
  124|      1|}
imdct.c:kbd_window:
   63|      4|{
   64|      4|    double sum = 0.0, run = 0.0;
   65|  2.24k|    for (int i = 0; i <= n; i++) {
  ------------------
  |  Branch (65:21): [True: 2.23k, False: 4]
  ------------------
   66|  2.23k|        double v = (2.0 * i / n) - 1.0;
   67|  2.23k|        sum += bessel_i0(M_PI * alpha * sqrt(1.0 - v * v));
   68|  2.23k|    }
   69|  2.23k|    for (int i = 0; i < n; i++) {
  ------------------
  |  Branch (69:21): [True: 2.23k, False: 4]
  ------------------
   70|  2.23k|        double v = (2.0 * i / n) - 1.0;
   71|       |        run += bessel_i0(M_PI * alpha * sqrt(1.0 - v * v));
   72|  2.23k|        w[i] = (float)sqrt(run / sum);
   73|  2.23k|    }
   74|      4|}
imdct.c:bessel_i0:
   50|  4.46k|{
   51|  4.46k|    double sum = 1.0, term = 1.0, q = x * x / 4.0;
   52|   108k|    for (int k = 1; k < 60; k++) {
  ------------------
  |  Branch (52:21): [True: 108k, False: 0]
  ------------------
   53|   108k|        term *= q / ((double)k * k);
   54|   108k|        sum += term;
   55|   108k|        if (term < sum * 1e-17) break;
  ------------------
  |  Branch (55:13): [True: 4.46k, False: 104k]
  ------------------
   56|   108k|    }
   57|  4.46k|    return sum;
   58|  4.46k|}

faad_init_ps_tables:
   96|      1|{
   97|      1|    static const double links[3] = { 0.43, 0.75, 0.347 };
   98|      1|    const double gain = 0.39;
   99|       |
  100|      1|    ps_init_split_filters();
  101|       |
  102|      3|    for (int is34 = 0; is34 < 2; is34++) {
  ------------------
  |  Branch (102:24): [True: 2, False: 1]
  ------------------
  103|     82|        for (int k = 0; k < ps_nr_allpass[is34]; k++) {
  ------------------
  |  Branch (103:25): [True: 80, False: 2]
  ------------------
  104|     80|            double fc;
  105|     80|            if (!is34) fc = (k < 10) ? ps_f_center_20[k] / 8.0 : k - 6.5;
  ------------------
  |  Branch (105:17): [True: 30, False: 50]
  |  Branch (105:29): [True: 10, False: 20]
  ------------------
  106|     50|            else       fc = (k < 32) ? ps_f_center_34[k] / 24.0 : k - 26.5;
  ------------------
  |  Branch (106:29): [True: 32, False: 18]
  ------------------
  107|    320|            for (int m = 0; m < 3; m++) {
  ------------------
  |  Branch (107:29): [True: 240, False: 80]
  ------------------
  108|    240|                double th = -M_PI * links[m] * fc;
  109|    240|                ps_q_fract[is34][k][m][0] = (float)cos(th);
  110|    240|                ps_q_fract[is34][k][m][1] = (float)sin(th);
  111|    240|            }
  112|     80|            double th = -M_PI * gain * fc;
  113|     80|            ps_phi_fract[is34][k][0] = (float)cos(th);
  114|     80|            ps_phi_fract[is34][k][1] = (float)sin(th);
  115|     80|        }
  116|      2|    }
  117|       |
  118|       |    /* Mixing matrices (§8.6.4.6.2 type A, §8.6.4.6.3 type B) for every IID/ICC index. */
  119|     47|    for (int i = 0; i < 46; i++) {
  ------------------
  |  Branch (119:21): [True: 46, False: 1]
  ------------------
  120|     46|        double db = (i < 15) ? ps_iid_db_default[i] : ps_iid_db_fine[i - 15];
  ------------------
  |  Branch (120:21): [True: 15, False: 31]
  ------------------
  121|     46|        double c = pow(10.0, db / 20.0);
  122|     46|        double c1 = sqrt(2.0) / sqrt(1.0 + c * c);
  123|     46|        double c2 = c * c1;
  124|    414|        for (int icc = 0; icc < 8; icc++) {
  ------------------
  |  Branch (124:27): [True: 368, False: 46]
  ------------------
  125|    368|            double alpha = 0.5 * acos(ps_icc_invq[icc]);
  126|    368|            double beta = alpha * (c1 - c2) / sqrt(2.0);
  127|    368|            ps_HA[i][icc][0] = (float)(c2 * cos(beta + alpha));
  128|    368|            ps_HA[i][icc][1] = (float)(c1 * cos(beta - alpha));
  129|    368|            ps_HA[i][icc][2] = (float)(c2 * sin(beta + alpha));
  130|    368|            ps_HA[i][icc][3] = (float)(c1 * sin(beta - alpha));
  131|       |
  132|    368|            double rho = ps_icc_invq[icc] > 0.05 ? ps_icc_invq[icc] : 0.05;
  ------------------
  |  Branch (132:26): [True: 230, False: 138]
  ------------------
  133|    368|            double a = 0.5 * atan2(2.0 * c * rho, c * c - 1.0);
  134|    368|            double mu = c + 1.0 / c;
  135|    368|            mu = sqrt(1.0 + (4.0 * rho * rho - 4.0) / (mu * mu));
  136|    368|            double gamma = atan(sqrt((1.0 - mu) / (1.0 + mu)));
  137|    368|            if (a < 0) a += M_PI / 2;
  ------------------
  |  Branch (137:17): [True: 0, False: 368]
  ------------------
  138|    368|            ps_HB[i][icc][0] = (float)( sqrt(2.0) * cos(a) * cos(gamma));
  139|    368|            ps_HB[i][icc][1] = (float)( sqrt(2.0) * sin(a) * cos(gamma));
  140|    368|            ps_HB[i][icc][2] = (float)(-sqrt(2.0) * sin(a) * sin(gamma));
  141|    368|            ps_HB[i][icc][3] = (float)( sqrt(2.0) * cos(a) * sin(gamma));
  142|    368|        }
  143|     46|    }
  144|      1|    ps_init_band_maps();
  145|      1|}
ps.c:ps_init_split_filters:
   79|      1|{
   80|      1|    static const struct { float (*coef)[7][2]; const float *proto; uint8_t Q; } split[4] = {
   81|      1|        { ps_split8_g0, ps_g0_q8, 8 }, { ps_split12_g0, ps_g0_q12, 12 },
   82|      1|        { ps_split8_g1, ps_g1_q8, 8 }, { ps_split4_g2, ps_g2_q4, 4 },
   83|      1|    };
   84|      5|    for (int i = 0; i < 4; i++) {
  ------------------
  |  Branch (84:21): [True: 4, False: 1]
  ------------------
   85|     36|        for (int q = 0; q < split[i].Q; q++) {
  ------------------
  |  Branch (85:25): [True: 32, False: 4]
  ------------------
   86|    256|            for (int n = 0; n < 7; n++) {
  ------------------
  |  Branch (86:29): [True: 224, False: 32]
  ------------------
   87|       |                double phase = -2.0 * M_PI * (q + 0.5) * (n - 6) / split[i].Q;
   88|    224|                split[i].coef[q][n][0] = (float)(split[i].proto[n] * cos(phase));
   89|    224|                split[i].coef[q][n][1] = (float)(split[i].proto[n] * sin(phase));
   90|    224|            }
   91|     32|        }
   92|      4|    }
   93|      1|}
ps.c:ps_init_band_maps:
  573|      1|{
  574|      1|    float c20[PS_NR_PAR], c34[PS_NR_PAR];
  575|      1|    ps_layout_centers(false, c20);
  576|       |    ps_layout_centers(true, c34);
  577|      1|    ps_build_band_map(ps_map_34_20, c34, 34, c20, 20);
  578|      1|    ps_build_band_map(ps_map_20_34, c20, 20, c34, 34);
  579|      1|}
ps.c:ps_layout_centers:
  537|      2|{
  538|      2|    const int8_t *k_to_b = is34 ? ps_k_to_b_34 : ps_k_to_b_20;
  ------------------
  |  Branch (538:28): [True: 1, False: 1]
  ------------------
  539|      2|    int count[PS_NR_PAR] = { 0 };
  540|     56|    for (int b = 0; b < ps_nr_par_bands[is34]; b++) center[b] = 0.0f;
  ------------------
  |  Branch (540:21): [True: 54, False: 2]
  ------------------
  541|    164|    for (int k = 0; k < ps_nr_bands[is34]; k++) {
  ------------------
  |  Branch (541:21): [True: 162, False: 2]
  ------------------
  542|    162|        float f = !is34 ? ((k < 10) ? ps_f_center_20[k] / 8.0f : k - 6.5f)
  ------------------
  |  Branch (542:19): [True: 71, False: 91]
  |  Branch (542:28): [True: 10, False: 61]
  ------------------
  543|    162|                        : ((k < 32) ? ps_f_center_34[k] / 24.0f : k - 26.5f);
  ------------------
  |  Branch (543:28): [True: 32, False: 59]
  ------------------
  544|    162|        center[k_to_b[k]] += fabsf(f);
  545|    162|        count[k_to_b[k]]++;
  546|    162|    }
  547|     56|    for (int b = 0; b < ps_nr_par_bands[is34]; b++) center[b] /= (float)count[b];
  ------------------
  |  Branch (547:21): [True: 54, False: 2]
  ------------------
  548|      2|}
ps.c:ps_build_band_map:
  551|      2|{
  552|     56|    for (int j = 0; j < n_dst; j++) {
  ------------------
  |  Branch (552:21): [True: 54, False: 2]
  ------------------
  553|     54|        float lo = j ? 0.5f * (dst[j - 1] + dst[j]) : 0.0f;
  ------------------
  |  Branch (553:20): [True: 52, False: 2]
  ------------------
  554|     54|        float hi = (j + 1 < n_dst) ? 0.5f * (dst[j] + dst[j + 1]) : 1e9f;
  ------------------
  |  Branch (554:20): [True: 52, False: 2]
  ------------------
  555|     54|        int first = -1, count = 0;
  556|  1.41k|        for (int i = 0; i < n_src; i++) {
  ------------------
  |  Branch (556:25): [True: 1.36k, False: 54]
  ------------------
  557|  1.36k|            if (src[i] < lo || src[i] >= hi) continue;
  ------------------
  |  Branch (557:17): [True: 654, False: 706]
  |  Branch (557:32): [True: 652, False: 54]
  ------------------
  558|     54|            if (first < 0) first = i;
  ------------------
  |  Branch (558:17): [True: 40, False: 14]
  ------------------
  559|     54|            count++;
  560|     54|        }
  561|     54|        if (count == 0) {
  ------------------
  |  Branch (561:13): [True: 14, False: 40]
  ------------------
  562|     14|            first = 0;
  563|    280|            for (int i = 1; i < n_src; i++)
  ------------------
  |  Branch (563:29): [True: 266, False: 14]
  ------------------
  564|    266|                if (fabsf(src[i] - dst[j]) < fabsf(src[first] - dst[j])) first = i;
  ------------------
  |  Branch (564:21): [True: 162, False: 104]
  ------------------
  565|     14|            count = 1;
  566|     14|        }
  567|     54|        map[j].first = (uint8_t)first;
  568|     54|        map[j].count = (uint8_t)count;
  569|     54|    }
  570|      2|}

faad_init_qmf_twiddles:
   44|      1|{
   45|      1|    fft_init();
   46|    641|    for (int n = 0; n < 640; n++)
  ------------------
  |  Branch (46:21): [True: 640, False: 1]
  ------------------
   47|    640|        qmf_win[n] = n < 384 ? qmf_c[n] : (n == 384 || n == 512 ? -qmf_c[640 - n] : qmf_c[640 - n]);
  ------------------
  |  Branch (47:22): [True: 384, False: 256]
  |  Branch (47:44): [True: 1, False: 255]
  |  Branch (47:56): [True: 1, False: 254]
  ------------------
   48|     65|    for (int n = 0; n < 64; n++) {
  ------------------
  |  Branch (48:21): [True: 64, False: 1]
  ------------------
   49|     64|        ana_pre_c[n] = (float)cos(M_PI * n / 64.0);
   50|     64|        ana_pre_s[n] = (float)sin(M_PI * n / 64.0);
   51|     64|    }
   52|     33|    for (int k = 0; k < 32; k++) {
  ------------------
  |  Branch (52:21): [True: 32, False: 1]
  ------------------
   53|     32|        ana_post_c[k] = (float)cos(-0.5 * M_PI * (k + 0.5) / 64.0);
   54|     32|        ana_post_s[k] = (float)sin(-0.5 * M_PI * (k + 0.5) / 64.0);
   55|     32|    }
   56|     33|    for (int n = 0; n < 32; n++) {
  ------------------
  |  Branch (56:21): [True: 32, False: 1]
  ------------------
   57|     32|        double a = -M_PI * (n + 0.125) / 64.0, b = a + 2.0 * M_PI * n / 64.0;
   58|     32|        syn_rot_c[n] = (float)cos(a);
   59|     32|        syn_rot_s[n] = (float)sin(a);
   60|     32|        syn_a_c[n] = (float)(cos(a) / 128.0);
   61|     32|        syn_a_s[n] = (float)(sin(a) / 128.0);
   62|     32|        syn_b_c[n] = (float)(cos(b) / 128.0);
   63|     32|        syn_b_s[n] = (float)(sin(b) / 128.0);
   64|     32|    }
   65|      1|}

faad_init_is_tables:
   23|      1|{
   24|    258|    for (int p = -IS_POS_RANGE; p <= IS_POS_RANGE; p++) {
  ------------------
  |  |   19|      1|#define IS_POS_RANGE 128
  ------------------
                  for (int p = -IS_POS_RANGE; p <= IS_POS_RANGE; p++) {
  ------------------
  |  |   19|    258|#define IS_POS_RANGE 128
  ------------------
  |  Branch (24:33): [True: 257, False: 1]
  ------------------
   25|    257|        is_scale_lut[p + IS_POS_RANGE] = powf(0.5f, 0.25f * (float)p);
  ------------------
  |  |   19|    257|#define IS_POS_RANGE 128
  ------------------
   26|    257|    }
   27|      1|}

LLVMFuzzerTestOneInput:
   36|  1.16k|int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
   37|  1.16k|  long sink = 0;
   38|       |
   39|  1.16k|  if (size < 1) return 0;
  ------------------
  |  Branch (39:7): [True: 0, False: 1.16k]
  ------------------
   40|  1.16k|  unsigned char error_code = *(data++);
   41|  1.16k|  size -= 1;
   42|       |
   43|  1.16k|  char* error_message = NeAACDecGetErrorMessage(error_code);
   44|  1.16k|  if (error_message) sink += strlen(error_message);
  ------------------
  |  Branch (44:7): [True: 352, False: 808]
  ------------------
   45|       |
   46|  1.16k|  char* id = NULL;
   47|  1.16k|  char* copyright = NULL;
   48|  1.16k|  sink += NeAACDecGetVersion(&id, &copyright);
   49|  1.16k|  sink += strlen(id);
   50|  1.16k|  sink += strlen(copyright);
   51|       |
   52|  1.16k|  sink += (long)NeAACDecGetCapabilities();
   53|       |
   54|  1.16k|  unsigned char* non_const_data = (unsigned char *)malloc(size);
   55|  1.16k|  memcpy(non_const_data, data, size);
   56|  1.16k|  mp4AudioSpecificConfig mp4ASC;
   57|       |
   58|  1.16k|  NeAACDecAudioSpecificConfig(non_const_data, (unsigned long) size, &mp4ASC);
   59|  1.16k|  free(non_const_data);
   60|       |
   61|  1.16k|  return (sink < 0) ? sink : 0;
  ------------------
  |  Branch (61:10): [True: 0, False: 1.16k]
  ------------------
   62|  1.16k|}

NeAACDecGetErrorMessage:
  131|  1.16k|{
  132|  1.16k|    if (errcode >= sizeof(err_msg) / sizeof(err_msg[0]))
  ------------------
  |  Branch (132:9): [True: 808, False: 352]
  ------------------
  133|    808|        return NULL;
  134|    352|    return err_msg[errcode];
  135|  1.16k|}
NeAACDecGetCapabilities:
  138|  1.16k|{
  139|  1.16k|    return LC_DEC_CAP;
  ------------------
  |  |  106|  1.16k|#define LC_DEC_CAP           (1<<0) /* Can decode LC */
  ------------------
  140|  1.16k|}
NeAACDecGetVersion:
  143|  1.16k|{
  144|  1.16k|    static char id[] = FAAD2_VERSION;
  145|  1.16k|    static char copy[] = "Code from FAAD2 is copyright (c) Nero AG, www.nero.com";
  146|  1.16k|    if (faad_id_string)
  ------------------
  |  Branch (146:9): [True: 1.16k, False: 0]
  ------------------
  147|  1.16k|        *faad_id_string = id;
  148|  1.16k|    if (faad_copyright_string)
  ------------------
  |  Branch (148:9): [True: 1.16k, False: 0]
  ------------------
  149|  1.16k|        *faad_copyright_string = copy;
  150|  1.16k|    return 0;
  151|  1.16k|}
NeAACDecAudioSpecificConfig:
  575|  1.16k|{
  576|  1.16k|    faad_decoder *d = NULL;
  577|  1.16k|    faad_stream_info info = { .struct_size = sizeof(info) };
  578|  1.16k|    unsigned i;
  579|       |
  580|  1.16k|    if (!pBuffer || size < 2 || !asc)
  ------------------
  |  Branch (580:9): [True: 0, False: 1.16k]
  |  Branch (580:21): [True: 13, False: 1.14k]
  |  Branch (580:33): [True: 0, False: 1.14k]
  ------------------
  581|     13|        return -1;
  582|  1.14k|    memset(asc, 0, sizeof(*asc));
  583|  1.14k|    if (shim_open_dec(NULL, FAAD_STREAM_RAW, T_I16, pBuffer, (uint32_t)size, &d) != FAAD_OK)
  ------------------
  |  Branch (583:9): [True: 906, False: 241]
  ------------------
  584|    906|        return -1;
  585|    241|    if (faad_decoder_get_info(d, &info) != FAAD_OK || !(info.flags & FAAD_STREAM_FORMAT_KNOWN)) {
  ------------------
  |  Branch (585:9): [True: 0, False: 241]
  |  Branch (585:55): [True: 0, False: 241]
  ------------------
  586|      0|        faad_decoder_close(&d);
  587|      0|        return -1;
  588|      0|    }
  589|    241|    faad_decoder_close(&d);
  590|       |
  591|       |    /* FAAD2 reported the object type the ASC starts with when SBR is signalled
  592|       |     * explicitly (AOT 5 or 29 is wrapped around an AAC-LC core, so 2), and 5
  593|       |     * when the SBR or PS extension follows an AOT 2 core. */
  594|    241|    {
  595|    241|        unsigned first = pBuffer[0] >> 3;
  596|    241|        int hev2 = info.object_type == FAAD_OBJ_HE_AAC_V2;
  597|    241|        asc->objectTypeIndex = (unsigned char)((first == 5 || first == 29) ? LC :
  ------------------
  |  |   76|     36|#define LC         2
  ------------------
  |  Branch (597:49): [True: 24, False: 217]
  |  Branch (597:63): [True: 12, False: 205]
  ------------------
  598|    241|                               hev2 ? HE_AAC : info.object_type);
  ------------------
  |  |   79|     33|#define HE_AAC     5
  ------------------
  |  Branch (598:32): [True: 33, False: 172]
  ------------------
  599|    241|        asc->sbr_present_flag = info.object_type != FAAD_OBJ_LC ? 1 : -1;
  ------------------
  |  Branch (599:33): [True: 145, False: 96]
  ------------------
  600|    241|        asc->ps_present_flag = hev2 ? 1 : -1;
  ------------------
  |  Branch (600:32): [True: 44, False: 197]
  ------------------
  601|    241|    }
  602|    241|    asc->samplingFrequency = info.sample_rate;
  603|       |    /* The channel configuration index, which is 7 for 7.1. */
  604|    241|    asc->channelsConfiguration = (unsigned char)(info.object_type == FAAD_OBJ_HE_AAC_V2 ? 1 :
  ------------------
  |  Branch (604:50): [True: 44, False: 197]
  ------------------
  605|    241|                                                 info.channels == 8 ? 7 : info.channels);
  ------------------
  |  Branch (605:50): [True: 32, False: 165]
  ------------------
  606|       |    /* FAAD2 2.11.3 upmixed mono to stereo in the ASC too (implicit PS). */
  607|    241|    if (asc->channelsConfiguration == 1)
  ------------------
  |  Branch (607:9): [True: 58, False: 183]
  ------------------
  608|     58|        asc->channelsConfiguration = 2;
  609|    241|    asc->frameLengthFlag = (info.frame_samples % 960) == 0 && (info.frame_samples % 1024) != 0;
  ------------------
  |  Branch (609:28): [True: 144, False: 97]
  |  Branch (609:63): [True: 144, False: 0]
  ------------------
  610|    241|    {
  611|    241|        unsigned long core = asc->sbr_present_flag > 0 ? info.sample_rate / 2 : info.sample_rate;
  ------------------
  |  Branch (611:30): [True: 145, False: 96]
  ------------------
  612|  1.72k|        for (i = 0; i < 12; i++)
  ------------------
  |  Branch (612:21): [True: 1.72k, False: 0]
  ------------------
  613|  1.72k|            if (sr_table[i] == core)
  ------------------
  |  Branch (613:17): [True: 241, False: 1.48k]
  ------------------
  614|    241|                break;
  615|    241|        asc->samplingFrequencyIndex = (unsigned char)(i < 12 ? i : 15);
  ------------------
  |  Branch (615:55): [True: 241, False: 0]
  ------------------
  616|    241|    }
  617|       |    /* Without SBR signalling FAAD2 assumed implicit SBR: upsampled output at or
  618|       |     * below 24 kHz, and SBR at the core rate above it. */
  619|    241|    if (asc->sbr_present_flag < 0) {
  ------------------
  |  Branch (619:9): [True: 96, False: 145]
  ------------------
  620|     96|        if (implicit_sbr(&info)) {
  ------------------
  |  Branch (620:13): [True: 51, False: 45]
  ------------------
  621|     51|            asc->samplingFrequency *= 2;
  622|     51|            asc->forceUpSampling = 1;
  623|     51|        } else if (info.sample_rate > 24000) {
  ------------------
  |  Branch (623:20): [True: 45, False: 0]
  ------------------
  624|     45|            asc->downSampledSBR = 1;
  625|     45|        }
  626|     96|    }
  627|    241|    return 0;
  628|    241|}
shim.c:shim_open_dec:
  346|  1.14k|{
  347|  1.14k|    faad_config cfg;
  348|  1.14k|    faad_status st = faad_config_init(&cfg, sizeof(cfg));
  349|  1.14k|    if (st != FAAD_OK)
  ------------------
  |  Branch (349:9): [True: 0, False: 1.14k]
  ------------------
  350|      0|        return st;
  351|  1.14k|    (void)s;
  352|  1.14k|    cfg.stream_format = stream;
  353|  1.14k|    cfg.output_format = faad3_format(type);
  354|       |    /* FAAD2 applies the full compression and normalises to -20 dBFS. */
  355|  1.14k|    cfg.drc_cut = 127;
  356|  1.14k|    cfg.drc_boost = 127;
  357|  1.14k|    cfg.drc_target_level = DRC_TARGET_DB;
  ------------------
  |  |   43|  1.14k|#define DRC_TARGET_DB (-20.0f)
  ------------------
  358|  1.14k|    return faad_decoder_open(&cfg, asc, asc_len, dec);
  359|  1.14k|}
shim.c:faad3_format:
  340|  1.14k|{
  341|  1.14k|    return t == T_I16 ? FAAD_OUTPUT_16BIT : t == T_I32 ? FAAD_OUTPUT_24IN32 : FAAD_OUTPUT_FLOAT;
  ------------------
  |  Branch (341:12): [True: 1.14k, False: 0]
  |  Branch (341:45): [True: 0, False: 0]
  ------------------
  342|  1.14k|}
shim.c:implicit_sbr:
  305|     96|{
  306|     96|    return info->object_type == FAAD_OBJ_LC && info->sample_rate > 0 && info->sample_rate <= 24000;
  ------------------
  |  Branch (306:12): [True: 96, False: 0]
  |  Branch (306:48): [True: 96, False: 0]
  |  Branch (306:73): [True: 51, False: 45]
  ------------------
  307|     96|}

