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: 133, False: 203]
  ------------------
   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: 15, False: 321]
  |  Branch (62:29): [True: 0, False: 321]
  ------------------
   63|     15|    {
   64|     15|        ld->error = 1;
   65|     15|        return;
   66|     15|    }
   67|       |
   68|    321|    ld->buffer = _buffer;
   69|       |
   70|    321|    ld->buffer_size = buffer_size;
   71|    321|    ld->bytes_left  = buffer_size;
   72|       |
   73|    321|    if (ld->bytes_left >= 4)
  ------------------
  |  Branch (73:9): [True: 251, False: 70]
  ------------------
   74|    251|    {
   75|    251|        tmp = getdword((uint32_t*)ld->buffer);
   76|    251|        ld->bytes_left -= 4;
   77|    251|    } else {
   78|     70|        tmp = getdword_n((uint32_t*)ld->buffer, ld->bytes_left);
   79|     70|        ld->bytes_left = 0;
   80|     70|    }
   81|    321|    ld->bufa = tmp;
   82|       |
   83|    321|    if (ld->bytes_left >= 4)
  ------------------
  |  Branch (83:9): [True: 163, False: 158]
  ------------------
   84|    163|    {
   85|    163|        tmp = getdword((uint32_t*)ld->buffer + 1);
   86|    163|        ld->bytes_left -= 4;
   87|    163|    } else {
   88|    158|        tmp = getdword_n((uint32_t*)ld->buffer + 1, ld->bytes_left);
   89|    158|        ld->bytes_left = 0;
   90|    158|    }
   91|    321|    ld->bufb = tmp;
   92|       |
   93|    321|    ld->start = (uint32_t*)ld->buffer;
   94|    321|    ld->tail = ((uint32_t*)ld->buffer + 2);
   95|       |
   96|    321|    ld->bits_left = 32;
   97|       |
   98|    321|    ld->error = 0;
   99|    321|}
faad_endbits:
  102|    621|{
  103|    621|    (void)ld;
  104|    621|}
faad_get_processed_bits:
  107|    621|{
  108|    621|    return (uint32_t)(8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left));
  109|    621|}
faad_byte_align:
  112|    208|{
  113|    208|    int remainder = (32 - ld->bits_left) & 0x7;
  114|       |
  115|    208|    if (remainder)
  ------------------
  |  Branch (115:9): [True: 194, False: 14]
  ------------------
  116|    194|    {
  117|    194|        faad_flushbits(ld, 8 - remainder);
  118|    194|        return (uint8_t)(8 - remainder);
  119|    194|    }
  120|     14|    return 0;
  121|    208|}
faad_flushbits_ex:
  124|  3.55k|{
  125|  3.55k|    uint32_t tmp;
  126|       |
  127|  3.55k|    ld->bufa = ld->bufb;
  128|  3.55k|    if (ld->bytes_left >= 4)
  ------------------
  |  Branch (128:9): [True: 1.90k, False: 1.65k]
  ------------------
  129|  1.90k|    {
  130|  1.90k|        tmp = getdword(ld->tail);
  131|  1.90k|        ld->bytes_left -= 4;
  132|  1.90k|    } else {
  133|  1.65k|        tmp = getdword_n(ld->tail, ld->bytes_left);
  134|  1.65k|        ld->bytes_left = 0;
  135|  1.65k|    }
  136|  3.55k|    ld->bufb = tmp;
  137|  3.55k|    ld->tail++;
  138|  3.55k|    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.55k|}
bits.c:getdword_n:
   39|  1.87k|{
   40|  1.87k|    uint8_t* m8 = (uint8_t*)mem;
   41|  1.87k|    switch (n)
   42|  1.87k|    {
   43|     54|    case 3:
  ------------------
  |  Branch (43:5): [True: 54, False: 1.82k]
  ------------------
   44|     54|        return ((uint32_t)m8[2] << 8) | ((uint32_t)m8[1] << 16) | ((uint32_t)m8[0] << 24);
   45|     48|    case 2:
  ------------------
  |  Branch (45:5): [True: 48, False: 1.83k]
  ------------------
   46|     48|        return ((uint32_t)m8[1] << 16) | ((uint32_t)m8[0] << 24);
   47|     57|    case 1:
  ------------------
  |  Branch (47:5): [True: 57, False: 1.82k]
  ------------------
   48|     57|        return (uint32_t)m8[0] << 24;
   49|  1.72k|    default:
  ------------------
  |  Branch (49:5): [True: 1.72k, False: 159]
  ------------------
   50|  1.72k|        return 0;
   51|  1.87k|    }
   52|  1.87k|}

bits.c:getdword:
   97|  2.31k|{
   98|  2.31k|    uint8_t* m8 = (uint8_t*)mem;
   99|  2.31k|    return (uint32_t)m8[3] | ((uint32_t)m8[2] << 8) | ((uint32_t)m8[1] << 16) | ((uint32_t)m8[0] << 24);
  100|  2.31k|}
bits.c:faad_flushbits:
  116|    194|{
  117|       |    /* do nothing if error */
  118|    194|    if (ld->error != 0)
  ------------------
  |  Branch (118:9): [True: 0, False: 194]
  ------------------
  119|      0|        return;
  120|       |
  121|    194|    if (bits < ld->bits_left)
  ------------------
  |  Branch (121:9): [True: 116, False: 78]
  ------------------
  122|    116|    {
  123|    116|        ld->bits_left -= bits;
  124|    116|    } else {
  125|     78|        faad_flushbits_ex(ld, bits);
  126|     78|    }
  127|    194|}
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.33k, False: 83]
  ------------------
  105|  1.33k|    {
  106|       |        //return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits];
  107|  1.33k|        return (ld->bufa << (32 - ld->bits_left)) >> (32 - bits);
  108|  1.33k|    }
  109|       |
  110|     83|    bits -= ld->bits_left;
  111|       |    //return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits));
  112|     83|    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.32k, False: 88]
  ------------------
  122|  1.32k|    {
  123|  1.32k|        ld->bits_left -= bits;
  124|  1.32k|    } else {
  125|     88|        faad_flushbits_ex(ld, bits);
  126|     88|    }
  127|  1.41k|}
mp4.c:faad_get1bit:
  149|     16|{
  150|     16|    uint8_t r;
  151|       |
  152|     16|    if (ld->bits_left > 0)
  ------------------
  |  Branch (152:9): [True: 16, False: 0]
  ------------------
  153|     16|    {
  154|     16|        ld->bits_left--;
  155|     16|        r = (uint8_t)((ld->bufa >> ld->bits_left) & 1);
  156|     16|        return r;
  157|     16|    }
  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|     16|}
syntax.c:faad_get1bit:
  149|  4.60k|{
  150|  4.60k|    uint8_t r;
  151|       |
  152|  4.60k|    if (ld->bits_left > 0)
  ------------------
  |  Branch (152:9): [True: 4.59k, False: 11]
  ------------------
  153|  4.59k|    {
  154|  4.59k|        ld->bits_left--;
  155|  4.59k|        r = (uint8_t)((ld->bufa >> ld->bits_left) & 1);
  156|  4.59k|        return r;
  157|  4.59k|    }
  158|       |
  159|       |    /* bits_left == 0 */
  160|       |#if 0
  161|       |    r = (uint8_t)(ld->bufb >> 31);
  162|       |    faad_flushbits_ex(ld, 1);
  163|       |#else
  164|     11|    r = (uint8_t)faad_getbits(ld, 1);
  165|     11|#endif
  166|     11|    return r;
  167|  4.60k|}
syntax.c:faad_getbits:
  131|  16.0k|{
  132|  16.0k|    uint32_t ret;
  133|       |
  134|  16.0k|    if (n == 0)
  ------------------
  |  Branch (134:9): [True: 0, False: 16.0k]
  ------------------
  135|      0|        return 0;
  136|       |
  137|  16.0k|    ret = faad_showbits(ld, n);
  138|  16.0k|    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.0k|    return ret;
  146|  16.0k|}
syntax.c:faad_showbits:
  103|  16.0k|{
  104|  16.0k|    if (bits <= ld->bits_left)
  ------------------
  |  Branch (104:9): [True: 15.4k, False: 681]
  ------------------
  105|  15.4k|    {
  106|       |        //return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits];
  107|  15.4k|        return (ld->bufa << (32 - ld->bits_left)) >> (32 - bits);
  108|  15.4k|    }
  109|       |
  110|    681|    bits -= ld->bits_left;
  111|       |    //return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits));
  112|    681|    return ((ld->bufa & ((1u<<ld->bits_left)-1)) << bits) | (ld->bufb >> (32 - bits));
  113|  16.0k|}
syntax.c:faad_flushbits:
  116|  16.0k|{
  117|       |    /* do nothing if error */
  118|  16.0k|    if (ld->error != 0)
  ------------------
  |  Branch (118:9): [True: 0, False: 16.0k]
  ------------------
  119|      0|        return;
  120|       |
  121|  16.0k|    if (bits < ld->bits_left)
  ------------------
  |  Branch (121:9): [True: 12.6k, False: 3.38k]
  ------------------
  122|  12.6k|    {
  123|  12.6k|        ld->bits_left -= bits;
  124|  12.6k|    } else {
  125|  3.38k|        faad_flushbits_ex(ld, bits);
  126|  3.38k|    }
  127|  16.0k|}

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

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

GASpecificConfig:
  111|    270|{
  112|    270|    program_config pce;
  113|       |
  114|       |    /* 1024 or 960 */
  115|    270|    mp4ASC->frameLengthFlag = faad_get1bit(ld
  116|    270|        DEBUGVAR(1,138,"GASpecificConfig(): FrameLengthFlag"));
  117|       |#ifndef ALLOW_SMALL_FRAMELENGTH
  118|       |    if (mp4ASC->frameLengthFlag == 1)
  119|       |        return -3;
  120|       |#endif
  121|       |
  122|    270|    mp4ASC->dependsOnCoreCoder = faad_get1bit(ld
  123|    270|        DEBUGVAR(1,139,"GASpecificConfig(): DependsOnCoreCoder"));
  124|    270|    if (mp4ASC->dependsOnCoreCoder == 1)
  ------------------
  |  Branch (124:9): [True: 42, False: 228]
  ------------------
  125|     42|    {
  126|     42|        mp4ASC->coreCoderDelay = (uint16_t)faad_getbits(ld, 14
  127|     42|            DEBUGVAR(1,140,"GASpecificConfig(): CoreCoderDelay"));
  128|     42|    }
  129|       |
  130|    270|    mp4ASC->extensionFlag = faad_get1bit(ld DEBUGVAR(1,141,"GASpecificConfig(): ExtensionFlag"));
  131|    270|    if (mp4ASC->channelsConfiguration == 0)
  ------------------
  |  Branch (131:9): [True: 208, False: 62]
  ------------------
  132|    208|    {
  133|    208|        if (program_config_element(&pce, ld))
  ------------------
  |  Branch (133:13): [True: 5, False: 203]
  ------------------
  134|      5|            return -3;
  135|       |        //mp4ASC->channelsConfiguration = pce.channels;
  136|       |
  137|    203|        if (pce_out != NULL)
  ------------------
  |  Branch (137:13): [True: 0, False: 203]
  ------------------
  138|      0|            memcpy(pce_out, &pce, sizeof(program_config));
  139|       |
  140|       |        /*
  141|       |        if (pce.num_valid_cc_elements)
  142|       |            return -3;
  143|       |        */
  144|    203|    }
  145|       |
  146|    265|#ifdef ERROR_RESILIENCE
  147|    265|    if (mp4ASC->extensionFlag == 1)
  ------------------
  |  Branch (147:9): [True: 77, False: 188]
  ------------------
  148|     77|    {
  149|       |        /* Error resilience not supported yet */
  150|     77|        if (mp4ASC->objectTypeIndex >= ER_OBJECT_START)
  ------------------
  |  |   71|     77|#define ER_OBJECT_START 17
  ------------------
  |  Branch (150:13): [True: 23, False: 54]
  ------------------
  151|     23|        {
  152|     23|            mp4ASC->aacSectionDataResilienceFlag = faad_get1bit(ld
  153|     23|                DEBUGVAR(1,144,"GASpecificConfig(): aacSectionDataResilienceFlag"));
  154|     23|            mp4ASC->aacScalefactorDataResilienceFlag = faad_get1bit(ld
  155|     23|                DEBUGVAR(1,145,"GASpecificConfig(): aacScalefactorDataResilienceFlag"));
  156|     23|            mp4ASC->aacSpectralDataResilienceFlag = faad_get1bit(ld
  157|     23|                DEBUGVAR(1,146,"GASpecificConfig(): aacSpectralDataResilienceFlag"));
  158|     23|        }
  159|       |        /* 1 bit: extensionFlag3 */
  160|     77|        faad_getbits(ld, 1);
  161|     77|	}
  162|    265|#endif
  163|       |
  164|    265|    return 0;
  165|    270|}
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: 59, False: 149]
  ------------------
  205|     59|    {
  206|     59|        pce->mono_mixdown_element_number = (uint8_t)faad_getbits(ld, 4
  207|     59|            DEBUGVAR(1,20,"program_config_element(): mono_mixdown_element_number"));
  208|     59|    }
  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: 48, False: 160]
  ------------------
  213|     48|    {
  214|     48|        pce->stereo_mixdown_element_number = (uint8_t)faad_getbits(ld, 4
  215|     48|            DEBUGVAR(1,22,"program_config_element(): stereo_mixdown_element_number"));
  216|     48|    }
  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: 65, False: 143]
  ------------------
  221|     65|    {
  222|     65|        pce->matrix_mixdown_idx = (uint8_t)faad_getbits(ld, 2
  223|     65|            DEBUGVAR(1,24,"program_config_element(): matrix_mixdown_idx"));
  224|     65|        pce->pseudo_surround_enable = faad_get1bit(ld
  225|     65|            DEBUGVAR(1,25,"program_config_element(): pseudo_surround_enable"));
  226|     65|    }
  227|       |
  228|    932|    for (i = 0; i < pce->num_front_channel_elements; i++)
  ------------------
  |  Branch (228:17): [True: 724, False: 208]
  ------------------
  229|    724|    {
  230|    724|        pce->front_element_is_cpe[i] = faad_get1bit(ld
  231|    724|            DEBUGVAR(1,26,"program_config_element(): front_element_is_cpe"));
  232|    724|        pce->front_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  233|    724|            DEBUGVAR(1,27,"program_config_element(): front_element_tag_select"));
  234|       |
  235|    724|        if (pce->front_element_is_cpe[i] & 1)
  ------------------
  |  Branch (235:13): [True: 228, False: 496]
  ------------------
  236|    228|        {
  237|    228|            pce->cpe_channel[pce->front_element_tag_select[i]] = pce->channels;
  238|    228|            pce->num_front_channels += 2;
  239|    228|            pce->channels += 2;
  240|    496|        } else {
  241|    496|            pce->sce_channel[pce->front_element_tag_select[i]] = pce->channels;
  242|    496|            pce->num_front_channels++;
  243|    496|            pce->channels++;
  244|    496|        }
  245|    724|    }
  246|       |
  247|    990|    for (i = 0; i < pce->num_side_channel_elements; i++)
  ------------------
  |  Branch (247:17): [True: 782, False: 208]
  ------------------
  248|    782|    {
  249|    782|        pce->side_element_is_cpe[i] = faad_get1bit(ld
  250|    782|            DEBUGVAR(1,28,"program_config_element(): side_element_is_cpe"));
  251|    782|        pce->side_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  252|    782|            DEBUGVAR(1,29,"program_config_element(): side_element_tag_select"));
  253|       |
  254|    782|        if (pce->side_element_is_cpe[i] & 1)
  ------------------
  |  Branch (254:13): [True: 125, False: 657]
  ------------------
  255|    125|        {
  256|    125|            pce->cpe_channel[pce->side_element_tag_select[i]] = pce->channels;
  257|    125|            pce->num_side_channels += 2;
  258|    125|            pce->channels += 2;
  259|    657|        } else {
  260|    657|            pce->sce_channel[pce->side_element_tag_select[i]] = pce->channels;
  261|    657|            pce->num_side_channels++;
  262|    657|            pce->channels++;
  263|    657|        }
  264|    782|    }
  265|       |
  266|  1.15k|    for (i = 0; i < pce->num_back_channel_elements; i++)
  ------------------
  |  Branch (266:17): [True: 942, False: 208]
  ------------------
  267|    942|    {
  268|    942|        pce->back_element_is_cpe[i] = faad_get1bit(ld
  269|    942|            DEBUGVAR(1,30,"program_config_element(): back_element_is_cpe"));
  270|    942|        pce->back_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  271|    942|            DEBUGVAR(1,31,"program_config_element(): back_element_tag_select"));
  272|       |
  273|    942|        if (pce->back_element_is_cpe[i] & 1)
  ------------------
  |  Branch (273:13): [True: 191, False: 751]
  ------------------
  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|    751|        } else {
  279|    751|            pce->sce_channel[pce->back_element_tag_select[i]] = pce->channels;
  280|    751|            pce->num_back_channels++;
  281|    751|            pce->channels++;
  282|    751|        }
  283|    942|    }
  284|       |
  285|    378|    for (i = 0; i < pce->num_lfe_channel_elements; i++)
  ------------------
  |  Branch (285:17): [True: 170, False: 208]
  ------------------
  286|    170|    {
  287|    170|        pce->lfe_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  288|    170|            DEBUGVAR(1,32,"program_config_element(): lfe_element_tag_select"));
  289|       |
  290|    170|        pce->sce_channel[pce->lfe_element_tag_select[i]] = pce->channels;
  291|    170|        pce->num_lfe_channels++;
  292|    170|        pce->channels++;
  293|    170|    }
  294|       |
  295|    506|    for (i = 0; i < pce->num_assoc_data_elements; i++)
  ------------------
  |  Branch (295:17): [True: 298, False: 208]
  ------------------
  296|    298|        pce->assoc_data_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  297|    298|        DEBUGVAR(1,33,"program_config_element(): assoc_data_element_tag_select"));
  298|       |
  299|    797|    for (i = 0; i < pce->num_valid_cc_elements; i++)
  ------------------
  |  Branch (299:17): [True: 589, False: 208]
  ------------------
  300|    589|    {
  301|    589|        pce->cc_element_is_ind_sw[i] = faad_get1bit(ld
  302|    589|            DEBUGVAR(1,34,"program_config_element(): cc_element_is_ind_sw"));
  303|    589|        pce->valid_cc_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  304|    589|            DEBUGVAR(1,35,"program_config_element(): valid_cc_element_tag_select"));
  305|    589|    }
  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|  10.4k|    for (i = 0; i < pce->comment_field_bytes; i++)
  ------------------
  |  Branch (312:17): [True: 10.1k, False: 208]
  ------------------
  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|    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: 5, False: 203]
  ------------------
  320|      5|        return 22;
  321|       |
  322|    203|    return 0;
  323|    208|}

