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

faad_initbits:
   56|    319|{
   57|    319|    uint32_t tmp;
   58|       |
   59|    319|    if (ld == NULL)
  ------------------
  |  Branch (59:9): [True: 0, False: 319]
  ------------------
   60|      0|        return;
   61|       |
   62|    319|    if (buffer_size == 0 || _buffer == NULL)
  ------------------
  |  Branch (62:9): [True: 11, False: 308]
  |  Branch (62:29): [True: 0, False: 308]
  ------------------
   63|     11|    {
   64|     11|        ld->error = 1;
   65|     11|        return;
   66|     11|    }
   67|       |
   68|    308|    ld->buffer = _buffer;
   69|       |
   70|    308|    ld->buffer_size = buffer_size;
   71|    308|    ld->bytes_left  = buffer_size;
   72|       |
   73|    308|    if (ld->bytes_left >= 4)
  ------------------
  |  Branch (73:9): [True: 248, False: 60]
  ------------------
   74|    248|    {
   75|    248|        tmp = getdword((uint32_t*)ld->buffer);
   76|    248|        ld->bytes_left -= 4;
   77|    248|    } else {
   78|     60|        tmp = getdword_n((uint32_t*)ld->buffer, ld->bytes_left);
   79|     60|        ld->bytes_left = 0;
   80|     60|    }
   81|    308|    ld->bufa = tmp;
   82|       |
   83|    308|    if (ld->bytes_left >= 4)
  ------------------
  |  Branch (83:9): [True: 160, False: 148]
  ------------------
   84|    160|    {
   85|    160|        tmp = getdword((uint32_t*)ld->buffer + 1);
   86|    160|        ld->bytes_left -= 4;
   87|    160|    } else {
   88|    148|        tmp = getdword_n((uint32_t*)ld->buffer + 1, ld->bytes_left);
   89|    148|        ld->bytes_left = 0;
   90|    148|    }
   91|    308|    ld->bufb = tmp;
   92|       |
   93|    308|    ld->start = (uint32_t*)ld->buffer;
   94|    308|    ld->tail = ((uint32_t*)ld->buffer + 2);
   95|       |
   96|    308|    ld->bits_left = 32;
   97|       |
   98|    308|    ld->error = 0;
   99|    308|}
faad_endbits:
  102|    591|{
  103|    591|    (void)ld;
  104|    591|}
faad_get_processed_bits:
  107|    591|{
  108|    591|    return (uint32_t)(8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left));
  109|    591|}
faad_byte_align:
  112|    206|{
  113|    206|    int remainder = (32 - ld->bits_left) & 0x7;
  114|       |
  115|    206|    if (remainder)
  ------------------
  |  Branch (115:9): [True: 188, False: 18]
  ------------------
  116|    188|    {
  117|    188|        faad_flushbits(ld, 8 - remainder);
  118|    188|        return (uint8_t)(8 - remainder);
  119|    188|    }
  120|     18|    return 0;
  121|    206|}
faad_flushbits_ex:
  124|  3.60k|{
  125|  3.60k|    uint32_t tmp;
  126|       |
  127|  3.60k|    ld->bufa = ld->bufb;
  128|  3.60k|    if (ld->bytes_left >= 4)
  ------------------
  |  Branch (128:9): [True: 2.19k, False: 1.40k]
  ------------------
  129|  2.19k|    {
  130|  2.19k|        tmp = getdword(ld->tail);
  131|  2.19k|        ld->bytes_left -= 4;
  132|  2.19k|    } else {
  133|  1.40k|        tmp = getdword_n(ld->tail, ld->bytes_left);
  134|  1.40k|        ld->bytes_left = 0;
  135|  1.40k|    }
  136|  3.60k|    ld->bufb = tmp;
  137|  3.60k|    ld->tail++;
  138|  3.60k|    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.60k|}
bits.c:getdword_n:
   39|  1.61k|{
   40|  1.61k|    uint8_t* m8 = (uint8_t*)mem;
   41|  1.61k|    switch (n)
   42|  1.61k|    {
   43|     54|    case 3:
  ------------------
  |  Branch (43:5): [True: 54, False: 1.55k]
  ------------------
   44|     54|        return ((uint32_t)m8[2] << 8) | ((uint32_t)m8[1] << 16) | ((uint32_t)m8[0] << 24);
   45|     41|    case 2:
  ------------------
  |  Branch (45:5): [True: 41, False: 1.56k]
  ------------------
   46|     41|        return ((uint32_t)m8[1] << 16) | ((uint32_t)m8[0] << 24);
   47|     52|    case 1:
  ------------------
  |  Branch (47:5): [True: 52, False: 1.55k]
  ------------------
   48|     52|        return (uint32_t)m8[0] << 24;
   49|  1.46k|    default:
  ------------------
  |  Branch (49:5): [True: 1.46k, False: 147]
  ------------------
   50|  1.46k|        return 0;
   51|  1.61k|    }
   52|  1.61k|}

bits.c:getdword:
   97|  2.60k|{
   98|  2.60k|    uint8_t* m8 = (uint8_t*)mem;
   99|  2.60k|    return (uint32_t)m8[3] | ((uint32_t)m8[2] << 8) | ((uint32_t)m8[1] << 16) | ((uint32_t)m8[0] << 24);
  100|  2.60k|}
bits.c:faad_flushbits:
  116|    188|{
  117|       |    /* do nothing if error */
  118|    188|    if (ld->error != 0)
  ------------------
  |  Branch (118:9): [True: 0, False: 188]
  ------------------
  119|      0|        return;
  120|       |
  121|    188|    if (bits < ld->bits_left)
  ------------------
  |  Branch (121:9): [True: 113, False: 75]
  ------------------
  122|    113|    {
  123|    113|        ld->bits_left -= bits;
  124|    113|    } else {
  125|     75|        faad_flushbits_ex(ld, bits);
  126|     75|    }
  127|    188|}
mp4.c:faad_getbits:
  131|  1.39k|{
  132|  1.39k|    uint32_t ret;
  133|       |
  134|  1.39k|    if (n == 0)
  ------------------
  |  Branch (134:9): [True: 0, False: 1.39k]
  ------------------
  135|      0|        return 0;
  136|       |
  137|  1.39k|    ret = faad_showbits(ld, n);
  138|  1.39k|    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.39k|    return ret;
  146|  1.39k|}
mp4.c:faad_showbits:
  103|  1.39k|{
  104|  1.39k|    if (bits <= ld->bits_left)
  ------------------
  |  Branch (104:9): [True: 1.29k, False: 97]
  ------------------
  105|  1.29k|    {
  106|       |        //return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits];
  107|  1.29k|        return (ld->bufa << (32 - ld->bits_left)) >> (32 - bits);
  108|  1.29k|    }
  109|       |
  110|     97|    bits -= ld->bits_left;
  111|       |    //return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits));
  112|     97|    return ((ld->bufa & ((1u<<ld->bits_left)-1)) << bits) | (ld->bufb >> (32 - bits));
  113|  1.39k|}
mp4.c:faad_flushbits:
  116|  1.39k|{
  117|       |    /* do nothing if error */
  118|  1.39k|    if (ld->error != 0)
  ------------------
  |  Branch (118:9): [True: 0, False: 1.39k]
  ------------------
  119|      0|        return;
  120|       |
  121|  1.39k|    if (bits < ld->bits_left)
  ------------------
  |  Branch (121:9): [True: 1.28k, False: 105]
  ------------------
  122|  1.28k|    {
  123|  1.28k|        ld->bits_left -= bits;
  124|  1.28k|    } else {
  125|    105|        faad_flushbits_ex(ld, bits);
  126|    105|    }
  127|  1.39k|}
mp4.c:faad_get1bit:
  149|     19|{
  150|     19|    uint8_t r;
  151|       |
  152|     19|    if (ld->bits_left > 0)
  ------------------
  |  Branch (152:9): [True: 19, False: 0]
  ------------------
  153|     19|    {
  154|     19|        ld->bits_left--;
  155|     19|        r = (uint8_t)((ld->bufa >> ld->bits_left) & 1);
  156|     19|        return r;
  157|     19|    }
  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|     19|}
syntax.c:faad_get1bit:
  149|  4.95k|{
  150|  4.95k|    uint8_t r;
  151|       |
  152|  4.95k|    if (ld->bits_left > 0)
  ------------------
  |  Branch (152:9): [True: 4.94k, False: 12]
  ------------------
  153|  4.94k|    {
  154|  4.94k|        ld->bits_left--;
  155|  4.94k|        r = (uint8_t)((ld->bufa >> ld->bits_left) & 1);
  156|  4.94k|        return r;
  157|  4.94k|    }
  158|       |
  159|       |    /* bits_left == 0 */
  160|       |#if 0
  161|       |    r = (uint8_t)(ld->bufb >> 31);
  162|       |    faad_flushbits_ex(ld, 1);
  163|       |#else
  164|     12|    r = (uint8_t)faad_getbits(ld, 1);
  165|     12|#endif
  166|     12|    return r;
  167|  4.95k|}
syntax.c:faad_getbits:
  131|  16.3k|{
  132|  16.3k|    uint32_t ret;
  133|       |
  134|  16.3k|    if (n == 0)
  ------------------
  |  Branch (134:9): [True: 0, False: 16.3k]
  ------------------
  135|      0|        return 0;
  136|       |
  137|  16.3k|    ret = faad_showbits(ld, n);
  138|  16.3k|    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|  16.3k|    return ret;
  146|  16.3k|}
syntax.c:faad_showbits:
  103|  16.3k|{
  104|  16.3k|    if (bits <= ld->bits_left)
  ------------------
  |  Branch (104:9): [True: 15.6k, False: 734]
  ------------------
  105|  15.6k|    {
  106|       |        //return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits];
  107|  15.6k|        return (ld->bufa << (32 - ld->bits_left)) >> (32 - bits);
  108|  15.6k|    }
  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|  16.3k|}
syntax.c:faad_flushbits:
  116|  16.3k|{
  117|       |    /* do nothing if error */
  118|  16.3k|    if (ld->error != 0)
  ------------------
  |  Branch (118:9): [True: 0, False: 16.3k]
  ------------------
  119|      0|        return;
  120|       |
  121|  16.3k|    if (bits < ld->bits_left)
  ------------------
  |  Branch (121:9): [True: 12.9k, False: 3.42k]
  ------------------
  122|  12.9k|    {
  123|  12.9k|        ld->bits_left -= bits;
  124|  12.9k|    } else {
  125|  3.42k|        faad_flushbits_ex(ld, bits);
  126|  3.42k|    }
  127|  16.3k|}

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

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

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

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

