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

faad_initbits:
   56|    336|{
   57|    336|    uint32_t tmp;
   58|       |
   59|    336|    if (ld == NULL)
  ------------------
  |  Branch (59:9): [True: 0, False: 336]
  ------------------
   60|      0|        return;
   61|       |
   62|    336|    if (buffer_size == 0 || _buffer == NULL)
  ------------------
  |  Branch (62:9): [True: 16, False: 320]
  |  Branch (62:29): [True: 0, False: 320]
  ------------------
   63|     16|    {
   64|     16|        ld->error = 1;
   65|     16|        return;
   66|     16|    }
   67|       |
   68|    320|    ld->buffer = _buffer;
   69|       |
   70|    320|    ld->buffer_size = buffer_size;
   71|    320|    ld->bytes_left  = buffer_size;
   72|       |
   73|    320|    if (ld->bytes_left >= 4)
  ------------------
  |  Branch (73:9): [True: 257, False: 63]
  ------------------
   74|    257|    {
   75|    257|        tmp = getdword((uint32_t*)ld->buffer);
   76|    257|        ld->bytes_left -= 4;
   77|    257|    } else {
   78|     63|        tmp = getdword_n((uint32_t*)ld->buffer, ld->bytes_left);
   79|     63|        ld->bytes_left = 0;
   80|     63|    }
   81|    320|    ld->bufa = tmp;
   82|       |
   83|    320|    if (ld->bytes_left >= 4)
  ------------------
  |  Branch (83:9): [True: 164, False: 156]
  ------------------
   84|    164|    {
   85|    164|        tmp = getdword((uint32_t*)ld->buffer + 1);
   86|    164|        ld->bytes_left -= 4;
   87|    164|    } else {
   88|    156|        tmp = getdword_n((uint32_t*)ld->buffer + 1, ld->bytes_left);
   89|    156|        ld->bytes_left = 0;
   90|    156|    }
   91|    320|    ld->bufb = tmp;
   92|       |
   93|    320|    ld->start = (uint32_t*)ld->buffer;
   94|    320|    ld->tail = ((uint32_t*)ld->buffer + 2);
   95|       |
   96|    320|    ld->bits_left = 32;
   97|       |
   98|    320|    ld->error = 0;
   99|    320|}
faad_endbits:
  102|    615|{
  103|    615|    (void)ld;
  104|    615|}
faad_get_processed_bits:
  107|    615|{
  108|    615|    return (uint32_t)(8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left));
  109|    615|}
faad_byte_align:
  112|    208|{
  113|    208|    int remainder = (32 - ld->bits_left) & 0x7;
  114|       |
  115|    208|    if (remainder)
  ------------------
  |  Branch (115:9): [True: 189, False: 19]
  ------------------
  116|    189|    {
  117|    189|        faad_flushbits(ld, 8 - remainder);
  118|    189|        return (uint8_t)(8 - remainder);
  119|    189|    }
  120|     19|    return 0;
  121|    208|}
faad_flushbits_ex:
  124|  3.93k|{
  125|  3.93k|    uint32_t tmp;
  126|       |
  127|  3.93k|    ld->bufa = ld->bufb;
  128|  3.93k|    if (ld->bytes_left >= 4)
  ------------------
  |  Branch (128:9): [True: 2.41k, False: 1.52k]
  ------------------
  129|  2.41k|    {
  130|  2.41k|        tmp = getdword(ld->tail);
  131|  2.41k|        ld->bytes_left -= 4;
  132|  2.41k|    } else {
  133|  1.52k|        tmp = getdword_n(ld->tail, ld->bytes_left);
  134|  1.52k|        ld->bytes_left = 0;
  135|  1.52k|    }
  136|  3.93k|    ld->bufb = tmp;
  137|  3.93k|    ld->tail++;
  138|  3.93k|    ld->bits_left += (32 - bits);
  139|       |    //ld->bytes_left -= 4;
  140|       |//    if (ld->bytes_left == 0)
  141|       |//        ld->no_more_reading = 1;
  142|       |//    if (ld->bytes_left < 0)
  143|       |//        ld->error = 1;
  144|  3.93k|}
bits.c:getdword_n:
   39|  1.74k|{
   40|  1.74k|    uint8_t* m8 = (uint8_t*)mem;
   41|  1.74k|    switch (n)
   42|  1.74k|    {
   43|     50|    case 3:
  ------------------
  |  Branch (43:5): [True: 50, False: 1.69k]
  ------------------
   44|     50|        return ((uint32_t)m8[2] << 8) | ((uint32_t)m8[1] << 16) | ((uint32_t)m8[0] << 24);
   45|     42|    case 2:
  ------------------
  |  Branch (45:5): [True: 42, False: 1.69k]
  ------------------
   46|     42|        return ((uint32_t)m8[1] << 16) | ((uint32_t)m8[0] << 24);
   47|     58|    case 1:
  ------------------
  |  Branch (47:5): [True: 58, False: 1.68k]
  ------------------
   48|     58|        return (uint32_t)m8[0] << 24;
   49|  1.59k|    default:
  ------------------
  |  Branch (49:5): [True: 1.59k, False: 150]
  ------------------
   50|  1.59k|        return 0;
   51|  1.74k|    }
   52|  1.74k|}

bits.c:getdword:
   97|  2.83k|{
   98|  2.83k|    uint8_t* m8 = (uint8_t*)mem;
   99|  2.83k|    return (uint32_t)m8[3] | ((uint32_t)m8[2] << 8) | ((uint32_t)m8[1] << 16) | ((uint32_t)m8[0] << 24);
  100|  2.83k|}
bits.c:faad_flushbits:
  116|    189|{
  117|       |    /* do nothing if error */
  118|    189|    if (ld->error != 0)
  ------------------
  |  Branch (118:9): [True: 0, False: 189]
  ------------------
  119|      0|        return;
  120|       |
  121|    189|    if (bits < ld->bits_left)
  ------------------
  |  Branch (121:9): [True: 111, False: 78]
  ------------------
  122|    111|    {
  123|    111|        ld->bits_left -= bits;
  124|    111|    } else {
  125|     78|        faad_flushbits_ex(ld, bits);
  126|     78|    }
  127|    189|}
mp4.c:faad_getbits:
  131|  1.41k|{
  132|  1.41k|    uint32_t ret;
  133|       |
  134|  1.41k|    if (n == 0)
  ------------------
  |  Branch (134:9): [True: 0, False: 1.41k]
  ------------------
  135|      0|        return 0;
  136|       |
  137|  1.41k|    ret = faad_showbits(ld, n);
  138|  1.41k|    faad_flushbits(ld, n);
  139|       |
  140|       |#ifdef ANALYSIS
  141|       |    if (print)
  142|       |        fprintf(stdout, "%4d %2d bits, val: %4d, variable: %d %s\n", dbg_count++, n, ret, var, dbg);
  143|       |#endif
  144|       |
  145|  1.41k|    return ret;
  146|  1.41k|}
mp4.c:faad_showbits:
  103|  1.41k|{
  104|  1.41k|    if (bits <= ld->bits_left)
  ------------------
  |  Branch (104:9): [True: 1.34k, False: 78]
  ------------------
  105|  1.34k|    {
  106|       |        //return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits];
  107|  1.34k|        return (ld->bufa << (32 - ld->bits_left)) >> (32 - bits);
  108|  1.34k|    }
  109|       |
  110|     78|    bits -= ld->bits_left;
  111|       |    //return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits));
  112|     78|    return ((ld->bufa & ((1u<<ld->bits_left)-1)) << bits) | (ld->bufb >> (32 - bits));
  113|  1.41k|}
mp4.c:faad_flushbits:
  116|  1.41k|{
  117|       |    /* do nothing if error */
  118|  1.41k|    if (ld->error != 0)
  ------------------
  |  Branch (118:9): [True: 0, False: 1.41k]
  ------------------
  119|      0|        return;
  120|       |
  121|  1.41k|    if (bits < ld->bits_left)
  ------------------
  |  Branch (121:9): [True: 1.33k, False: 87]
  ------------------
  122|  1.33k|    {
  123|  1.33k|        ld->bits_left -= bits;
  124|  1.33k|    } else {
  125|     87|        faad_flushbits_ex(ld, bits);
  126|     87|    }
  127|  1.41k|}
mp4.c:faad_get1bit:
  149|     17|{
  150|     17|    uint8_t r;
  151|       |
  152|     17|    if (ld->bits_left > 0)
  ------------------
  |  Branch (152:9): [True: 17, False: 0]
  ------------------
  153|     17|    {
  154|     17|        ld->bits_left--;
  155|     17|        r = (uint8_t)((ld->bufa >> ld->bits_left) & 1);
  156|     17|        return r;
  157|     17|    }
  158|       |
  159|       |    /* bits_left == 0 */
  160|       |#if 0
  161|       |    r = (uint8_t)(ld->bufb >> 31);
  162|       |    faad_flushbits_ex(ld, 1);
  163|       |#else
  164|      0|    r = (uint8_t)faad_getbits(ld, 1);
  165|      0|#endif
  166|      0|    return r;
  167|     17|}
syntax.c:faad_get1bit:
  149|  4.93k|{
  150|  4.93k|    uint8_t r;
  151|       |
  152|  4.93k|    if (ld->bits_left > 0)
  ------------------
  |  Branch (152:9): [True: 4.92k, False: 9]
  ------------------
  153|  4.92k|    {
  154|  4.92k|        ld->bits_left--;
  155|  4.92k|        r = (uint8_t)((ld->bufa >> ld->bits_left) & 1);
  156|  4.92k|        return r;
  157|  4.92k|    }
  158|       |
  159|       |    /* bits_left == 0 */
  160|       |#if 0
  161|       |    r = (uint8_t)(ld->bufb >> 31);
  162|       |    faad_flushbits_ex(ld, 1);
  163|       |#else
  164|      9|    r = (uint8_t)faad_getbits(ld, 1);
  165|      9|#endif
  166|      9|    return r;
  167|  4.93k|}
syntax.c:faad_getbits:
  131|  17.6k|{
  132|  17.6k|    uint32_t ret;
  133|       |
  134|  17.6k|    if (n == 0)
  ------------------
  |  Branch (134:9): [True: 0, False: 17.6k]
  ------------------
  135|      0|        return 0;
  136|       |
  137|  17.6k|    ret = faad_showbits(ld, n);
  138|  17.6k|    faad_flushbits(ld, n);
  139|       |
  140|       |#ifdef ANALYSIS
  141|       |    if (print)
  142|       |        fprintf(stdout, "%4d %2d bits, val: %4d, variable: %d %s\n", dbg_count++, n, ret, var, dbg);
  143|       |#endif
  144|       |
  145|  17.6k|    return ret;
  146|  17.6k|}
syntax.c:faad_showbits:
  103|  17.6k|{
  104|  17.6k|    if (bits <= ld->bits_left)
  ------------------
  |  Branch (104:9): [True: 16.9k, False: 734]
  ------------------
  105|  16.9k|    {
  106|       |        //return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits];
  107|  16.9k|        return (ld->bufa << (32 - ld->bits_left)) >> (32 - bits);
  108|  16.9k|    }
  109|       |
  110|    734|    bits -= ld->bits_left;
  111|       |    //return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits));
  112|    734|    return ((ld->bufa & ((1u<<ld->bits_left)-1)) << bits) | (ld->bufb >> (32 - bits));
  113|  17.6k|}
syntax.c:faad_flushbits:
  116|  17.6k|{
  117|       |    /* do nothing if error */
  118|  17.6k|    if (ld->error != 0)
  ------------------
  |  Branch (118:9): [True: 0, False: 17.6k]
  ------------------
  119|      0|        return;
  120|       |
  121|  17.6k|    if (bits < ld->bits_left)
  ------------------
  |  Branch (121:9): [True: 13.9k, False: 3.76k]
  ------------------
  122|  13.9k|    {
  123|  13.9k|        ld->bits_left -= bits;
  124|  13.9k|    } else {
  125|  3.76k|        faad_flushbits_ex(ld, bits);
  126|  3.76k|    }
  127|  17.6k|}

get_sample_rate:
   60|    391|{
   61|    391|    static const uint32_t sample_rates[] =
   62|    391|    {
   63|    391|        96000, 88200, 64000, 48000, 44100, 32000,
   64|    391|        24000, 22050, 16000, 12000, 11025, 8000
   65|    391|    };
   66|       |
   67|    391|    if (sr_index < 12)
  ------------------
  |  Branch (67:9): [True: 372, False: 19]
  ------------------
   68|    372|        return sample_rates[sr_index];
   69|       |
   70|     19|    return 0;
   71|    391|}

NeAACDecGetVersion:
   73|    336|{
   74|    336|    static char *libfaadName = PACKAGE_VERSION;
   75|    336|    static char *libCopyright =
   76|    336|        " Copyright 2002-2004: Ahead Software AG\n"
   77|    336|	" http://www.audiocoding.com\n"
   78|    336|	" bug tracking: https://sourceforge.net/p/faac/bugs/\n";
   79|       |
   80|    336|    if (faad_id_string)
  ------------------
  |  Branch (80:9): [True: 336, False: 0]
  ------------------
   81|    336|        *faad_id_string = libfaadName;
   82|       |
   83|    336|    if (faad_copyright_string)
  ------------------
  |  Branch (83:9): [True: 336, False: 0]
  ------------------
   84|    336|        *faad_copyright_string = libCopyright;
   85|       |
   86|    336|    return 0;
   87|    336|}
NeAACDecGetErrorMessage:
   90|    336|{
   91|    336|    if (errcode >= NUM_ERROR_MESSAGES)
  ------------------
  |  |   38|    336|#define NUM_ERROR_MESSAGES 34
  ------------------
  |  Branch (91:9): [True: 200, False: 136]
  ------------------
   92|    200|        return NULL;
   93|    136|    return err_msg[errcode];
   94|    336|}
NeAACDecGetCapabilities:
   97|    336|{
   98|    336|    uint32_t cap = 0;
   99|       |
  100|       |    /* can't do without it */
  101|    336|    cap += LC_DEC_CAP;
  ------------------
  |  |  106|    336|#define LC_DEC_CAP           (1<<0) /* Can decode LC */
  ------------------
  102|       |
  103|    336|#ifdef MAIN_DEC
  104|    336|    cap += MAIN_DEC_CAP;
  ------------------
  |  |  107|    336|#define MAIN_DEC_CAP         (1<<1) /* Can decode MAIN */
  ------------------
  105|    336|#endif
  106|    336|#ifdef LTP_DEC
  107|    336|    cap += LTP_DEC_CAP;
  ------------------
  |  |  108|    336|#define LTP_DEC_CAP          (1<<2) /* Can decode LTP */
  ------------------
  108|    336|#endif
  109|    336|#ifdef LD_DEC
  110|    336|    cap += LD_DEC_CAP;
  ------------------
  |  |  109|    336|#define LD_DEC_CAP           (1<<3) /* Can decode LD */
  ------------------
  111|    336|#endif
  112|    336|#ifdef ERROR_RESILIENCE
  113|    336|    cap += ERROR_RESILIENCE_CAP;
  ------------------
  |  |  110|    336|#define ERROR_RESILIENCE_CAP (1<<4) /* Can decode ER */
  ------------------
  114|    336|#endif
  115|       |#ifdef FIXED_POINT
  116|       |    cap += FIXED_POINT_CAP;
  117|       |#endif
  118|       |
  119|    336|    return cap;
  120|    336|}

NeAACDecAudioSpecificConfig:
  123|    336|{
  124|       |    return AudioSpecificConfig2(pBuffer, buffer_size, mp4ASC, NULL, 0);
  125|    336|}
AudioSpecificConfigFromBitfile:
  130|    320|{
  131|    320|    int8_t result = 0;
  132|    320|    uint32_t startpos = faad_get_processed_bits(ld);
  133|    320|#ifdef SBR_DEC
  134|    320|    int8_t bits_to_decode = 0;
  135|    320|#endif
  136|       |
  137|    320|    if (mp4ASC == NULL)
  ------------------
  |  Branch (137:9): [True: 0, False: 320]
  ------------------
  138|      0|        return -8;
  139|       |
  140|    320|    memset(mp4ASC, 0, sizeof(mp4AudioSpecificConfig));
  141|       |
  142|    320|    mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(ld, 5
  143|    320|        DEBUGVAR(1,1,"parse_audio_decoder_specific_info(): ObjectTypeIndex"));
  144|       |
  145|    320|    mp4ASC->samplingFrequencyIndex = (uint8_t)faad_getbits(ld, 4
  146|    320|        DEBUGVAR(1,2,"parse_audio_decoder_specific_info(): SamplingFrequencyIndex"));
  147|    320|	if(mp4ASC->samplingFrequencyIndex==0x0f)
  ------------------
  |  Branch (147:5): [True: 1, False: 319]
  ------------------
  148|      1|		faad_getbits(ld, 24);
  149|       |
  150|    320|    mp4ASC->channelsConfiguration = (uint8_t)faad_getbits(ld, 4
  151|    320|        DEBUGVAR(1,3,"parse_audio_decoder_specific_info(): ChannelsConfiguration"));
  152|       |
  153|    320|    mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex);
  154|       |
  155|    320|    if (ObjectTypesTable[mp4ASC->objectTypeIndex] != 1)
  ------------------
  |  Branch (155:9): [True: 20, False: 300]
  ------------------
  156|     20|    {
  157|     20|        return -1;
  158|     20|    }
  159|       |
  160|    300|    if (mp4ASC->samplingFrequency == 0)
  ------------------
  |  Branch (160:9): [True: 2, False: 298]
  ------------------
  161|      2|    {
  162|      2|        return -2;
  163|      2|    }
  164|       |
  165|    298|    if (mp4ASC->channelsConfiguration > 7)
  ------------------
  |  Branch (165:9): [True: 3, False: 295]
  ------------------
  166|      3|    {
  167|      3|        return -3;
  168|      3|    }
  169|       |
  170|    295|#if (defined(PS_DEC) || defined(DRM_PS))
  171|       |    /* check if we have a mono file */
  172|    295|    if (mp4ASC->channelsConfiguration == 1)
  ------------------
  |  Branch (172:9): [True: 14, False: 281]
  ------------------
  173|     14|    {
  174|       |        /* upMatrix to 2 channels for implicit signalling of PS */
  175|     14|        mp4ASC->channelsConfiguration = 2;
  176|     14|    }
  177|    295|#endif
  178|       |
  179|    295|#ifdef SBR_DEC
  180|    295|    mp4ASC->sbr_present_flag = -1;
  181|    295|    if (mp4ASC->objectTypeIndex == 5 || mp4ASC->objectTypeIndex == 29)
  ------------------
  |  Branch (181:9): [True: 61, False: 234]
  |  Branch (181:41): [True: 9, False: 225]
  ------------------
  182|     70|    {
  183|     70|        uint8_t tmp;
  184|       |
  185|     70|        mp4ASC->sbr_present_flag = 1;
  186|     70|        tmp = (uint8_t)faad_getbits(ld, 4
  187|     70|            DEBUGVAR(1,5,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
  188|       |        /* check for downsampled SBR */
  189|     70|        if (tmp == mp4ASC->samplingFrequencyIndex)
  ------------------
  |  Branch (189:13): [True: 4, False: 66]
  ------------------
  190|      4|            mp4ASC->downSampledSBR = 1;
  191|     70|        mp4ASC->samplingFrequencyIndex = tmp;
  192|     70|        if (mp4ASC->samplingFrequencyIndex == 15)
  ------------------
  |  Branch (192:13): [True: 12, False: 58]
  ------------------
  193|     12|        {
  194|     12|            mp4ASC->samplingFrequency = (uint32_t)faad_getbits(ld, 24
  195|     12|                DEBUGVAR(1,6,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
  196|     58|        } else {
  197|     58|            mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex);
  198|     58|        }
  199|     70|        mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(ld, 5
  200|     70|            DEBUGVAR(1,7,"parse_audio_decoder_specific_info(): ObjectTypeIndex"));
  201|     70|    }
  202|    295|#endif
  203|       |
  204|       |    /* get GASpecificConfig */
  205|    295|    if (mp4ASC->objectTypeIndex == 1 || mp4ASC->objectTypeIndex == 2 ||
  ------------------
  |  Branch (205:9): [True: 84, False: 211]
  |  Branch (205:41): [True: 29, False: 182]
  ------------------
  206|    182|        mp4ASC->objectTypeIndex == 3 || mp4ASC->objectTypeIndex == 4 ||
  ------------------
  |  Branch (206:9): [True: 3, False: 179]
  |  Branch (206:41): [True: 56, False: 123]
  ------------------
  207|    123|        mp4ASC->objectTypeIndex == 6 || mp4ASC->objectTypeIndex == 7)
  ------------------
  |  Branch (207:9): [True: 2, False: 121]
  |  Branch (207:41): [True: 4, False: 117]
  ------------------
  208|    178|    {
  209|    178|        result = GASpecificConfig(ld, mp4ASC, pce);
  210|       |
  211|    178|#ifdef ERROR_RESILIENCE
  212|    178|    } else if (mp4ASC->objectTypeIndex >= ER_OBJECT_START) { /* ER */
  ------------------
  |  |   71|    117|#define ER_OBJECT_START 17
  ------------------
  |  Branch (212:16): [True: 95, False: 22]
  ------------------
  213|     95|        result = GASpecificConfig(ld, mp4ASC, pce);
  214|     95|        mp4ASC->epConfig = (uint8_t)faad_getbits(ld, 2
  215|     95|            DEBUGVAR(1,143,"parse_audio_decoder_specific_info(): epConfig"));
  216|       |
  217|     95|        if (mp4ASC->epConfig != 0)
  ------------------
  |  Branch (217:13): [True: 22, False: 73]
  ------------------
  218|     22|            result = -5;
  219|     95|#endif
  220|       |
  221|     95|    } else {
  222|     22|        result = -4;
  223|     22|    }
  224|       |
  225|       |#ifdef SSR_DEC
  226|       |    /* shorter frames not allowed for SSR */
  227|       |    if ((mp4ASC->objectTypeIndex == 4) && mp4ASC->frameLengthFlag)
  228|       |        return -6;
  229|       |#endif
  230|       |
  231|       |
  232|    295|#ifdef SBR_DEC
  233|    295|    if(short_form)
  ------------------
  |  Branch (233:8): [True: 0, False: 295]
  ------------------
  234|      0|        bits_to_decode = 0;
  235|    295|    else
  236|    295|		bits_to_decode = (int8_t)(buffer_size*8 + faad_get_processed_bits(ld) - startpos);
  237|       |
  238|    295|    if ((mp4ASC->objectTypeIndex != 5 && mp4ASC->objectTypeIndex != 29) && (bits_to_decode >= 16))
  ------------------
  |  Branch (238:10): [True: 294, False: 1]
  |  Branch (238:42): [True: 292, False: 2]
  |  Branch (238:76): [True: 167, False: 125]
  ------------------
  239|    167|    {
  240|    167|        int16_t syncExtensionType = (int16_t)faad_getbits(ld, 11
  241|    167|            DEBUGVAR(1,9,"parse_audio_decoder_specific_info(): syncExtensionType"));
  242|       |
  243|    167|        if (syncExtensionType == 0x2b7)
  ------------------
  |  Branch (243:13): [True: 25, False: 142]
  ------------------
  244|     25|        {
  245|     25|            uint8_t tmp_OTi = (uint8_t)faad_getbits(ld, 5
  246|     25|                DEBUGVAR(1,10,"parse_audio_decoder_specific_info(): extensionAudioObjectType"));
  247|       |
  248|     25|            if (tmp_OTi == 5)
  ------------------
  |  Branch (248:17): [True: 17, False: 8]
  ------------------
  249|     17|            {
  250|     17|                mp4ASC->sbr_present_flag = (uint8_t)faad_get1bit(ld
  251|     17|                    DEBUGVAR(1,11,"parse_audio_decoder_specific_info(): sbr_present_flag"));
  252|       |
  253|     17|                if (mp4ASC->sbr_present_flag)
  ------------------
  |  Branch (253:21): [True: 16, False: 1]
  ------------------
  254|     16|                {
  255|     16|                    uint8_t tmp;
  256|       |
  257|       |					/* Don't set OT to SBR until checked that it is actually there */
  258|     16|					mp4ASC->objectTypeIndex = tmp_OTi;
  259|       |
  260|     16|                    tmp = (uint8_t)faad_getbits(ld, 4
  261|     16|                        DEBUGVAR(1,12,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
  262|       |
  263|       |                    /* check for downsampled SBR */
  264|     16|                    if (tmp == mp4ASC->samplingFrequencyIndex)
  ------------------
  |  Branch (264:25): [True: 4, False: 12]
  ------------------
  265|      4|                        mp4ASC->downSampledSBR = 1;
  266|     16|                    mp4ASC->samplingFrequencyIndex = tmp;
  267|       |
  268|     16|                    if (mp4ASC->samplingFrequencyIndex == 15)
  ------------------
  |  Branch (268:25): [True: 3, False: 13]
  ------------------
  269|      3|                    {
  270|      3|                        mp4ASC->samplingFrequency = (uint32_t)faad_getbits(ld, 24
  271|      3|                            DEBUGVAR(1,13,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
  272|     13|                    } else {
  273|     13|                        mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex);
  274|     13|                    }
  275|     16|                }
  276|     17|            }
  277|     25|        }
  278|    167|    }
  279|       |
  280|       |    /* no SBR signalled, this could mean either implicit signalling or no SBR in this file */
  281|       |    /* MPEG specification states: assume SBR on files with samplerate <= 24000 Hz */
  282|    295|    if (mp4ASC->sbr_present_flag == (char)-1) /* cannot be -1 on systems with unsigned char */
  ------------------
  |  Branch (282:9): [True: 214, False: 81]
  ------------------
  283|    214|    {
  284|    214|        if (mp4ASC->samplingFrequency <= 24000)
  ------------------
  |  Branch (284:13): [True: 94, False: 120]
  ------------------
  285|     94|        {
  286|     94|            mp4ASC->samplingFrequency *= 2;
  287|     94|            mp4ASC->forceUpSampling = 1;
  288|    120|        } else /* > 24000*/ {
  289|    120|            mp4ASC->downSampledSBR = 1;
  290|    120|        }
  291|    214|    }
  292|    295|#endif
  293|       |
  294|    295|    faad_endbits(ld);
  295|       |
  296|    295|    return result;
  297|    298|}
AudioSpecificConfig2:
  304|    336|{
  305|    336|    uint8_t ret = 0;
  306|    336|    bitfile ld;
  307|    336|    faad_initbits(&ld, pBuffer, buffer_size);
  308|    336|    if (ld.error != 0)
  ------------------
  |  Branch (308:9): [True: 16, False: 320]
  ------------------
  309|     16|        return -7;
  310|    320|    ret = AudioSpecificConfigFromBitfile(&ld, mp4ASC, pce, buffer_size, short_form);
  311|    320|    faad_endbits(&ld);
  312|    320|    return ret;
  313|    336|}

GASpecificConfig:
  111|    273|{
  112|    273|    program_config pce;
  113|       |
  114|       |    /* 1024 or 960 */
  115|    273|    mp4ASC->frameLengthFlag = faad_get1bit(ld
  116|    273|        DEBUGVAR(1,138,"GASpecificConfig(): FrameLengthFlag"));
  117|       |#ifndef ALLOW_SMALL_FRAMELENGTH
  118|       |    if (mp4ASC->frameLengthFlag == 1)
  119|       |        return -3;
  120|       |#endif
  121|       |
  122|    273|    mp4ASC->dependsOnCoreCoder = faad_get1bit(ld
  123|    273|        DEBUGVAR(1,139,"GASpecificConfig(): DependsOnCoreCoder"));
  124|    273|    if (mp4ASC->dependsOnCoreCoder == 1)
  ------------------
  |  Branch (124:9): [True: 57, False: 216]
  ------------------
  125|     57|    {
  126|     57|        mp4ASC->coreCoderDelay = (uint16_t)faad_getbits(ld, 14
  127|     57|            DEBUGVAR(1,140,"GASpecificConfig(): CoreCoderDelay"));
  128|     57|    }
  129|       |
  130|    273|    mp4ASC->extensionFlag = faad_get1bit(ld DEBUGVAR(1,141,"GASpecificConfig(): ExtensionFlag"));
  131|    273|    if (mp4ASC->channelsConfiguration == 0)
  ------------------
  |  Branch (131:9): [True: 208, False: 65]
  ------------------
  132|    208|    {
  133|    208|        if (program_config_element(&pce, ld))
  ------------------
  |  Branch (133:13): [True: 9, False: 199]
  ------------------
  134|      9|            return -3;
  135|       |        //mp4ASC->channelsConfiguration = pce.channels;
  136|       |
  137|    199|        if (pce_out != NULL)
  ------------------
  |  Branch (137:13): [True: 0, False: 199]
  ------------------
  138|      0|            memcpy(pce_out, &pce, sizeof(program_config));
  139|       |
  140|       |        /*
  141|       |        if (pce.num_valid_cc_elements)
  142|       |            return -3;
  143|       |        */
  144|    199|    }
  145|       |
  146|    264|#ifdef ERROR_RESILIENCE
  147|    264|    if (mp4ASC->extensionFlag == 1)
  ------------------
  |  Branch (147:9): [True: 64, False: 200]
  ------------------
  148|     64|    {
  149|       |        /* Error resilience not supported yet */
  150|     64|        if (mp4ASC->objectTypeIndex >= ER_OBJECT_START)
  ------------------
  |  |   71|     64|#define ER_OBJECT_START 17
  ------------------
  |  Branch (150:13): [True: 36, False: 28]
  ------------------
  151|     36|        {
  152|     36|            mp4ASC->aacSectionDataResilienceFlag = faad_get1bit(ld
  153|     36|                DEBUGVAR(1,144,"GASpecificConfig(): aacSectionDataResilienceFlag"));
  154|     36|            mp4ASC->aacScalefactorDataResilienceFlag = faad_get1bit(ld
  155|     36|                DEBUGVAR(1,145,"GASpecificConfig(): aacScalefactorDataResilienceFlag"));
  156|     36|            mp4ASC->aacSpectralDataResilienceFlag = faad_get1bit(ld
  157|     36|                DEBUGVAR(1,146,"GASpecificConfig(): aacSpectralDataResilienceFlag"));
  158|     36|        }
  159|       |        /* 1 bit: extensionFlag3 */
  160|     64|        faad_getbits(ld, 1);
  161|     64|	}
  162|    264|#endif
  163|       |
  164|    264|    return 0;
  165|    273|}
syntax.c:program_config_element:
  175|    208|{
  176|    208|    uint8_t i;
  177|       |
  178|    208|    memset(pce, 0, sizeof(program_config));
  179|       |
  180|    208|    pce->channels = 0;
  181|       |
  182|    208|    pce->element_instance_tag = (uint8_t)faad_getbits(ld, 4
  183|    208|        DEBUGVAR(1,10,"program_config_element(): element_instance_tag"));
  184|       |
  185|    208|    pce->object_type = (uint8_t)faad_getbits(ld, 2
  186|    208|        DEBUGVAR(1,11,"program_config_element(): object_type"));
  187|    208|    pce->sf_index = (uint8_t)faad_getbits(ld, 4
  188|    208|        DEBUGVAR(1,12,"program_config_element(): sf_index"));
  189|    208|    pce->num_front_channel_elements = (uint8_t)faad_getbits(ld, 4
  190|    208|        DEBUGVAR(1,13,"program_config_element(): num_front_channel_elements"));
  191|    208|    pce->num_side_channel_elements = (uint8_t)faad_getbits(ld, 4
  192|    208|        DEBUGVAR(1,14,"program_config_element(): num_side_channel_elements"));
  193|    208|    pce->num_back_channel_elements = (uint8_t)faad_getbits(ld, 4
  194|    208|        DEBUGVAR(1,15,"program_config_element(): num_back_channel_elements"));
  195|    208|    pce->num_lfe_channel_elements = (uint8_t)faad_getbits(ld, 2
  196|    208|        DEBUGVAR(1,16,"program_config_element(): num_lfe_channel_elements"));
  197|    208|    pce->num_assoc_data_elements = (uint8_t)faad_getbits(ld, 3
  198|    208|        DEBUGVAR(1,17,"program_config_element(): num_assoc_data_elements"));
  199|    208|    pce->num_valid_cc_elements = (uint8_t)faad_getbits(ld, 4
  200|    208|        DEBUGVAR(1,18,"program_config_element(): num_valid_cc_elements"));
  201|       |
  202|    208|    pce->mono_mixdown_present = faad_get1bit(ld
  203|    208|        DEBUGVAR(1,19,"program_config_element(): mono_mixdown_present"));
  204|    208|    if (pce->mono_mixdown_present == 1)
  ------------------
  |  Branch (204:9): [True: 41, False: 167]
  ------------------
  205|     41|    {
  206|     41|        pce->mono_mixdown_element_number = (uint8_t)faad_getbits(ld, 4
  207|     41|            DEBUGVAR(1,20,"program_config_element(): mono_mixdown_element_number"));
  208|     41|    }
  209|       |
  210|    208|    pce->stereo_mixdown_present = faad_get1bit(ld
  211|    208|        DEBUGVAR(1,21,"program_config_element(): stereo_mixdown_present"));
  212|    208|    if (pce->stereo_mixdown_present == 1)
  ------------------
  |  Branch (212:9): [True: 55, False: 153]
  ------------------
  213|     55|    {
  214|     55|        pce->stereo_mixdown_element_number = (uint8_t)faad_getbits(ld, 4
  215|     55|            DEBUGVAR(1,22,"program_config_element(): stereo_mixdown_element_number"));
  216|     55|    }
  217|       |
  218|    208|    pce->matrix_mixdown_idx_present = faad_get1bit(ld
  219|    208|        DEBUGVAR(1,23,"program_config_element(): matrix_mixdown_idx_present"));
  220|    208|    if (pce->matrix_mixdown_idx_present == 1)
  ------------------
  |  Branch (220:9): [True: 53, False: 155]
  ------------------
  221|     53|    {
  222|     53|        pce->matrix_mixdown_idx = (uint8_t)faad_getbits(ld, 2
  223|     53|            DEBUGVAR(1,24,"program_config_element(): matrix_mixdown_idx"));
  224|     53|        pce->pseudo_surround_enable = faad_get1bit(ld
  225|     53|            DEBUGVAR(1,25,"program_config_element(): pseudo_surround_enable"));
  226|     53|    }
  227|       |
  228|  1.04k|    for (i = 0; i < pce->num_front_channel_elements; i++)
  ------------------
  |  Branch (228:17): [True: 833, False: 208]
  ------------------
  229|    833|    {
  230|    833|        pce->front_element_is_cpe[i] = faad_get1bit(ld
  231|    833|            DEBUGVAR(1,26,"program_config_element(): front_element_is_cpe"));
  232|    833|        pce->front_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  233|    833|            DEBUGVAR(1,27,"program_config_element(): front_element_tag_select"));
  234|       |
  235|    833|        if (pce->front_element_is_cpe[i] & 1)
  ------------------
  |  Branch (235:13): [True: 283, False: 550]
  ------------------
  236|    283|        {
  237|    283|            pce->cpe_channel[pce->front_element_tag_select[i]] = pce->channels;
  238|    283|            pce->num_front_channels += 2;
  239|    283|            pce->channels += 2;
  240|    550|        } else {
  241|    550|            pce->sce_channel[pce->front_element_tag_select[i]] = pce->channels;
  242|    550|            pce->num_front_channels++;
  243|    550|            pce->channels++;
  244|    550|        }
  245|    833|    }
  246|       |
  247|  1.15k|    for (i = 0; i < pce->num_side_channel_elements; i++)
  ------------------
  |  Branch (247:17): [True: 942, False: 208]
  ------------------
  248|    942|    {
  249|    942|        pce->side_element_is_cpe[i] = faad_get1bit(ld
  250|    942|            DEBUGVAR(1,28,"program_config_element(): side_element_is_cpe"));
  251|    942|        pce->side_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  252|    942|            DEBUGVAR(1,29,"program_config_element(): side_element_tag_select"));
  253|       |
  254|    942|        if (pce->side_element_is_cpe[i] & 1)
  ------------------
  |  Branch (254:13): [True: 169, False: 773]
  ------------------
  255|    169|        {
  256|    169|            pce->cpe_channel[pce->side_element_tag_select[i]] = pce->channels;
  257|    169|            pce->num_side_channels += 2;
  258|    169|            pce->channels += 2;
  259|    773|        } else {
  260|    773|            pce->sce_channel[pce->side_element_tag_select[i]] = pce->channels;
  261|    773|            pce->num_side_channels++;
  262|    773|            pce->channels++;
  263|    773|        }
  264|    942|    }
  265|       |
  266|  1.07k|    for (i = 0; i < pce->num_back_channel_elements; i++)
  ------------------
  |  Branch (266:17): [True: 870, False: 208]
  ------------------
  267|    870|    {
  268|    870|        pce->back_element_is_cpe[i] = faad_get1bit(ld
  269|    870|            DEBUGVAR(1,30,"program_config_element(): back_element_is_cpe"));
  270|    870|        pce->back_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  271|    870|            DEBUGVAR(1,31,"program_config_element(): back_element_tag_select"));
  272|       |
  273|    870|        if (pce->back_element_is_cpe[i] & 1)
  ------------------
  |  Branch (273:13): [True: 191, False: 679]
  ------------------
  274|    191|        {
  275|    191|            pce->cpe_channel[pce->back_element_tag_select[i]] = pce->channels;
  276|    191|            pce->channels += 2;
  277|    191|            pce->num_back_channels += 2;
  278|    679|        } else {
  279|    679|            pce->sce_channel[pce->back_element_tag_select[i]] = pce->channels;
  280|    679|            pce->num_back_channels++;
  281|    679|            pce->channels++;
  282|    679|        }
  283|    870|    }
  284|       |
  285|    402|    for (i = 0; i < pce->num_lfe_channel_elements; i++)
  ------------------
  |  Branch (285:17): [True: 194, False: 208]
  ------------------
  286|    194|    {
  287|    194|        pce->lfe_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  288|    194|            DEBUGVAR(1,32,"program_config_element(): lfe_element_tag_select"));
  289|       |
  290|    194|        pce->sce_channel[pce->lfe_element_tag_select[i]] = pce->channels;
  291|    194|        pce->num_lfe_channels++;
  292|    194|        pce->channels++;
  293|    194|    }
  294|       |
  295|    515|    for (i = 0; i < pce->num_assoc_data_elements; i++)
  ------------------
  |  Branch (295:17): [True: 307, False: 208]
  ------------------
  296|    307|        pce->assoc_data_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  297|    307|        DEBUGVAR(1,33,"program_config_element(): assoc_data_element_tag_select"));
  298|       |
  299|    890|    for (i = 0; i < pce->num_valid_cc_elements; i++)
  ------------------
  |  Branch (299:17): [True: 682, False: 208]
  ------------------
  300|    682|    {
  301|    682|        pce->cc_element_is_ind_sw[i] = faad_get1bit(ld
  302|    682|            DEBUGVAR(1,34,"program_config_element(): cc_element_is_ind_sw"));
  303|    682|        pce->valid_cc_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  304|    682|            DEBUGVAR(1,35,"program_config_element(): valid_cc_element_tag_select"));
  305|    682|    }
  306|       |
  307|    208|    faad_byte_align(ld);
  308|       |
  309|    208|    pce->comment_field_bytes = (uint8_t)faad_getbits(ld, 8
  310|    208|        DEBUGVAR(1,36,"program_config_element(): comment_field_bytes"));
  311|       |
  312|  11.7k|    for (i = 0; i < pce->comment_field_bytes; i++)
  ------------------
  |  Branch (312:17): [True: 11.5k, False: 208]
  ------------------
  313|  11.5k|    {
  314|  11.5k|        pce->comment_field_data[i] = (uint8_t)faad_getbits(ld, 8
  315|  11.5k|            DEBUGVAR(1,37,"program_config_element(): comment_field_data"));
  316|  11.5k|    }
  317|    208|    pce->comment_field_data[i] = 0;
  318|       |
  319|    208|    if (pce->channels > MAX_CHANNELS)
  ------------------
  |  |   43|    208|#define MAX_CHANNELS        64
  ------------------
  |  Branch (319:9): [True: 9, False: 199]
  ------------------
  320|      9|        return 22;
  321|       |
  322|    199|    return 0;
  323|    208|}

