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

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

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

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

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

NeAACDecAudioSpecificConfig:
  123|    335|{
  124|       |    return AudioSpecificConfig2(pBuffer, buffer_size, mp4ASC, NULL, 0);
  125|    335|}
AudioSpecificConfigFromBitfile:
  130|    319|{
  131|    319|    int8_t result = 0;
  132|    319|    uint32_t startpos = faad_get_processed_bits(ld);
  133|    319|#ifdef SBR_DEC
  134|    319|    int8_t bits_to_decode = 0;
  135|    319|#endif
  136|       |
  137|    319|    if (mp4ASC == NULL)
  ------------------
  |  Branch (137:9): [True: 0, False: 319]
  ------------------
  138|      0|        return -8;
  139|       |
  140|    319|    memset(mp4ASC, 0, sizeof(mp4AudioSpecificConfig));
  141|       |
  142|    319|    mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(ld, 5
  143|    319|        DEBUGVAR(1,1,"parse_audio_decoder_specific_info(): ObjectTypeIndex"));
  144|       |
  145|    319|    mp4ASC->samplingFrequencyIndex = (uint8_t)faad_getbits(ld, 4
  146|    319|        DEBUGVAR(1,2,"parse_audio_decoder_specific_info(): SamplingFrequencyIndex"));
  147|    319|	if(mp4ASC->samplingFrequencyIndex==0x0f)
  ------------------
  |  Branch (147:5): [True: 3, False: 316]
  ------------------
  148|      3|		faad_getbits(ld, 24);
  149|       |
  150|    319|    mp4ASC->channelsConfiguration = (uint8_t)faad_getbits(ld, 4
  151|    319|        DEBUGVAR(1,3,"parse_audio_decoder_specific_info(): ChannelsConfiguration"));
  152|       |
  153|    319|    mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex);
  154|       |
  155|    319|    if (ObjectTypesTable[mp4ASC->objectTypeIndex] != 1)
  ------------------
  |  Branch (155:9): [True: 20, False: 299]
  ------------------
  156|     20|    {
  157|     20|        return -1;
  158|     20|    }
  159|       |
  160|    299|    if (mp4ASC->samplingFrequency == 0)
  ------------------
  |  Branch (160:9): [True: 1, False: 298]
  ------------------
  161|      1|    {
  162|      1|        return -2;
  163|      1|    }
  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: 15, False: 280]
  ------------------
  173|     15|    {
  174|       |        /* upMatrix to 2 channels for implicit signalling of PS */
  175|     15|        mp4ASC->channelsConfiguration = 2;
  176|     15|    }
  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: 52, False: 243]
  |  Branch (181:41): [True: 22, False: 221]
  ------------------
  182|     74|    {
  183|     74|        uint8_t tmp;
  184|       |
  185|     74|        mp4ASC->sbr_present_flag = 1;
  186|     74|        tmp = (uint8_t)faad_getbits(ld, 4
  187|     74|            DEBUGVAR(1,5,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
  188|       |        /* check for downsampled SBR */
  189|     74|        if (tmp == mp4ASC->samplingFrequencyIndex)
  ------------------
  |  Branch (189:13): [True: 3, False: 71]
  ------------------
  190|      3|            mp4ASC->downSampledSBR = 1;
  191|     74|        mp4ASC->samplingFrequencyIndex = tmp;
  192|     74|        if (mp4ASC->samplingFrequencyIndex == 15)
  ------------------
  |  Branch (192:13): [True: 13, False: 61]
  ------------------
  193|     13|        {
  194|     13|            mp4ASC->samplingFrequency = (uint32_t)faad_getbits(ld, 24
  195|     13|                DEBUGVAR(1,6,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
  196|     61|        } else {
  197|     61|            mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex);
  198|     61|        }
  199|     74|        mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(ld, 5
  200|     74|            DEBUGVAR(1,7,"parse_audio_decoder_specific_info(): ObjectTypeIndex"));
  201|     74|    }
  202|    295|#endif
  203|       |
  204|       |    /* get GASpecificConfig */
  205|    295|    if (mp4ASC->objectTypeIndex == 1 || mp4ASC->objectTypeIndex == 2 ||
  ------------------
  |  Branch (205:9): [True: 76, False: 219]
  |  Branch (205:41): [True: 40, False: 179]
  ------------------
  206|    179|        mp4ASC->objectTypeIndex == 3 || mp4ASC->objectTypeIndex == 4 ||
  ------------------
  |  Branch (206:9): [True: 7, False: 172]
  |  Branch (206:41): [True: 61, False: 111]
  ------------------
  207|    111|        mp4ASC->objectTypeIndex == 6 || mp4ASC->objectTypeIndex == 7)
  ------------------
  |  Branch (207:9): [True: 5, False: 106]
  |  Branch (207:41): [True: 3, False: 103]
  ------------------
  208|    192|    {
  209|    192|        result = GASpecificConfig(ld, mp4ASC, pce);
  210|       |
  211|    192|#ifdef ERROR_RESILIENCE
  212|    192|    } else if (mp4ASC->objectTypeIndex >= ER_OBJECT_START) { /* ER */
  ------------------
  |  |   71|    103|#define ER_OBJECT_START 17
  ------------------
  |  Branch (212:16): [True: 77, False: 26]
  ------------------
  213|     77|        result = GASpecificConfig(ld, mp4ASC, pce);
  214|     77|        mp4ASC->epConfig = (uint8_t)faad_getbits(ld, 2
  215|     77|            DEBUGVAR(1,143,"parse_audio_decoder_specific_info(): epConfig"));
  216|       |
  217|     77|        if (mp4ASC->epConfig != 0)
  ------------------
  |  Branch (217:13): [True: 6, False: 71]
  ------------------
  218|      6|            result = -5;
  219|     77|#endif
  220|       |
  221|     77|    } else {
  222|     26|        result = -4;
  223|     26|    }
  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: 172, False: 120]
  ------------------
  239|    172|    {
  240|    172|        int16_t syncExtensionType = (int16_t)faad_getbits(ld, 11
  241|    172|            DEBUGVAR(1,9,"parse_audio_decoder_specific_info(): syncExtensionType"));
  242|       |
  243|    172|        if (syncExtensionType == 0x2b7)
  ------------------
  |  Branch (243:13): [True: 23, False: 149]
  ------------------
  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: 15, False: 8]
  ------------------
  249|     15|            {
  250|     15|                mp4ASC->sbr_present_flag = (uint8_t)faad_get1bit(ld
  251|     15|                    DEBUGVAR(1,11,"parse_audio_decoder_specific_info(): sbr_present_flag"));
  252|       |
  253|     15|                if (mp4ASC->sbr_present_flag)
  ------------------
  |  Branch (253:21): [True: 14, False: 1]
  ------------------
  254|     14|                {
  255|     14|                    uint8_t tmp;
  256|       |
  257|       |					/* Don't set OT to SBR until checked that it is actually there */
  258|     14|					mp4ASC->objectTypeIndex = tmp_OTi;
  259|       |
  260|     14|                    tmp = (uint8_t)faad_getbits(ld, 4
  261|     14|                        DEBUGVAR(1,12,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
  262|       |
  263|       |                    /* check for downsampled SBR */
  264|     14|                    if (tmp == mp4ASC->samplingFrequencyIndex)
  ------------------
  |  Branch (264:25): [True: 2, False: 12]
  ------------------
  265|      2|                        mp4ASC->downSampledSBR = 1;
  266|     14|                    mp4ASC->samplingFrequencyIndex = tmp;
  267|       |
  268|     14|                    if (mp4ASC->samplingFrequencyIndex == 15)
  ------------------
  |  Branch (268:25): [True: 4, False: 10]
  ------------------
  269|      4|                    {
  270|      4|                        mp4ASC->samplingFrequency = (uint32_t)faad_getbits(ld, 24
  271|      4|                            DEBUGVAR(1,13,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
  272|     10|                    } else {
  273|     10|                        mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex);
  274|     10|                    }
  275|     14|                }
  276|     15|            }
  277|     23|        }
  278|    172|    }
  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: 212, False: 83]
  ------------------
  283|    212|    {
  284|    212|        if (mp4ASC->samplingFrequency <= 24000)
  ------------------
  |  Branch (284:13): [True: 94, False: 118]
  ------------------
  285|     94|        {
  286|     94|            mp4ASC->samplingFrequency *= 2;
  287|     94|            mp4ASC->forceUpSampling = 1;
  288|    118|        } else /* > 24000*/ {
  289|    118|            mp4ASC->downSampledSBR = 1;
  290|    118|        }
  291|    212|    }
  292|    295|#endif
  293|       |
  294|    295|    faad_endbits(ld);
  295|       |
  296|    295|    return result;
  297|    298|}
AudioSpecificConfig2:
  304|    335|{
  305|    335|    uint8_t ret = 0;
  306|    335|    bitfile ld;
  307|    335|    faad_initbits(&ld, pBuffer, buffer_size);
  308|    335|    if (ld.error != 0)
  ------------------
  |  Branch (308:9): [True: 16, False: 319]
  ------------------
  309|     16|        return -7;
  310|    319|    ret = AudioSpecificConfigFromBitfile(&ld, mp4ASC, pce, buffer_size, short_form);
  311|    319|    faad_endbits(&ld);
  312|    319|    return ret;
  313|    335|}

GASpecificConfig:
  111|    269|{
  112|    269|    program_config pce;
  113|       |
  114|       |    /* 1024 or 960 */
  115|    269|    mp4ASC->frameLengthFlag = faad_get1bit(ld
  116|    269|        DEBUGVAR(1,138,"GASpecificConfig(): FrameLengthFlag"));
  117|       |#ifndef ALLOW_SMALL_FRAMELENGTH
  118|       |    if (mp4ASC->frameLengthFlag == 1)
  119|       |        return -3;
  120|       |#endif
  121|       |
  122|    269|    mp4ASC->dependsOnCoreCoder = faad_get1bit(ld
  123|    269|        DEBUGVAR(1,139,"GASpecificConfig(): DependsOnCoreCoder"));
  124|    269|    if (mp4ASC->dependsOnCoreCoder == 1)
  ------------------
  |  Branch (124:9): [True: 42, False: 227]
  ------------------
  125|     42|    {
  126|     42|        mp4ASC->coreCoderDelay = (uint16_t)faad_getbits(ld, 14
  127|     42|            DEBUGVAR(1,140,"GASpecificConfig(): CoreCoderDelay"));
  128|     42|    }
  129|       |
  130|    269|    mp4ASC->extensionFlag = faad_get1bit(ld DEBUGVAR(1,141,"GASpecificConfig(): ExtensionFlag"));
  131|    269|    if (mp4ASC->channelsConfiguration == 0)
  ------------------
  |  Branch (131:9): [True: 206, False: 63]
  ------------------
  132|    206|    {
  133|    206|        if (program_config_element(&pce, ld))
  ------------------
  |  Branch (133:13): [True: 5, False: 201]
  ------------------
  134|      5|            return -3;
  135|       |        //mp4ASC->channelsConfiguration = pce.channels;
  136|       |
  137|    201|        if (pce_out != NULL)
  ------------------
  |  Branch (137:13): [True: 0, False: 201]
  ------------------
  138|      0|            memcpy(pce_out, &pce, sizeof(program_config));
  139|       |
  140|       |        /*
  141|       |        if (pce.num_valid_cc_elements)
  142|       |            return -3;
  143|       |        */
  144|    201|    }
  145|       |
  146|    264|#ifdef ERROR_RESILIENCE
  147|    264|    if (mp4ASC->extensionFlag == 1)
  ------------------
  |  Branch (147:9): [True: 61, False: 203]
  ------------------
  148|     61|    {
  149|       |        /* Error resilience not supported yet */
  150|     61|        if (mp4ASC->objectTypeIndex >= ER_OBJECT_START)
  ------------------
  |  |   71|     61|#define ER_OBJECT_START 17
  ------------------
  |  Branch (150:13): [True: 25, False: 36]
  ------------------
  151|     25|        {
  152|     25|            mp4ASC->aacSectionDataResilienceFlag = faad_get1bit(ld
  153|     25|                DEBUGVAR(1,144,"GASpecificConfig(): aacSectionDataResilienceFlag"));
  154|     25|            mp4ASC->aacScalefactorDataResilienceFlag = faad_get1bit(ld
  155|     25|                DEBUGVAR(1,145,"GASpecificConfig(): aacScalefactorDataResilienceFlag"));
  156|     25|            mp4ASC->aacSpectralDataResilienceFlag = faad_get1bit(ld
  157|     25|                DEBUGVAR(1,146,"GASpecificConfig(): aacSpectralDataResilienceFlag"));
  158|     25|        }
  159|       |        /* 1 bit: extensionFlag3 */
  160|     61|        faad_getbits(ld, 1);
  161|     61|	}
  162|    264|#endif
  163|       |
  164|    264|    return 0;
  165|    269|}
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: 32, False: 174]
  ------------------
  205|     32|    {
  206|     32|        pce->mono_mixdown_element_number = (uint8_t)faad_getbits(ld, 4
  207|     32|            DEBUGVAR(1,20,"program_config_element(): mono_mixdown_element_number"));
  208|     32|    }
  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: 44, False: 162]
  ------------------
  213|     44|    {
  214|     44|        pce->stereo_mixdown_element_number = (uint8_t)faad_getbits(ld, 4
  215|     44|            DEBUGVAR(1,22,"program_config_element(): stereo_mixdown_element_number"));
  216|     44|    }
  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: 43, False: 163]
  ------------------
  221|     43|    {
  222|     43|        pce->matrix_mixdown_idx = (uint8_t)faad_getbits(ld, 2
  223|     43|            DEBUGVAR(1,24,"program_config_element(): matrix_mixdown_idx"));
  224|     43|        pce->pseudo_surround_enable = faad_get1bit(ld
  225|     43|            DEBUGVAR(1,25,"program_config_element(): pseudo_surround_enable"));
  226|     43|    }
  227|       |
  228|    981|    for (i = 0; i < pce->num_front_channel_elements; i++)
  ------------------
  |  Branch (228:17): [True: 775, False: 206]
  ------------------
  229|    775|    {
  230|    775|        pce->front_element_is_cpe[i] = faad_get1bit(ld
  231|    775|            DEBUGVAR(1,26,"program_config_element(): front_element_is_cpe"));
  232|    775|        pce->front_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  233|    775|            DEBUGVAR(1,27,"program_config_element(): front_element_tag_select"));
  234|       |
  235|    775|        if (pce->front_element_is_cpe[i] & 1)
  ------------------
  |  Branch (235:13): [True: 193, False: 582]
  ------------------
  236|    193|        {
  237|    193|            pce->cpe_channel[pce->front_element_tag_select[i]] = pce->channels;
  238|    193|            pce->num_front_channels += 2;
  239|    193|            pce->channels += 2;
  240|    582|        } else {
  241|    582|            pce->sce_channel[pce->front_element_tag_select[i]] = pce->channels;
  242|    582|            pce->num_front_channels++;
  243|    582|            pce->channels++;
  244|    582|        }
  245|    775|    }
  246|       |
  247|    955|    for (i = 0; i < pce->num_side_channel_elements; i++)
  ------------------
  |  Branch (247:17): [True: 749, False: 206]
  ------------------
  248|    749|    {
  249|    749|        pce->side_element_is_cpe[i] = faad_get1bit(ld
  250|    749|            DEBUGVAR(1,28,"program_config_element(): side_element_is_cpe"));
  251|    749|        pce->side_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  252|    749|            DEBUGVAR(1,29,"program_config_element(): side_element_tag_select"));
  253|       |
  254|    749|        if (pce->side_element_is_cpe[i] & 1)
  ------------------
  |  Branch (254:13): [True: 121, False: 628]
  ------------------
  255|    121|        {
  256|    121|            pce->cpe_channel[pce->side_element_tag_select[i]] = pce->channels;
  257|    121|            pce->num_side_channels += 2;
  258|    121|            pce->channels += 2;
  259|    628|        } else {
  260|    628|            pce->sce_channel[pce->side_element_tag_select[i]] = pce->channels;
  261|    628|            pce->num_side_channels++;
  262|    628|            pce->channels++;
  263|    628|        }
  264|    749|    }
  265|       |
  266|    976|    for (i = 0; i < pce->num_back_channel_elements; i++)
  ------------------
  |  Branch (266:17): [True: 770, False: 206]
  ------------------
  267|    770|    {
  268|    770|        pce->back_element_is_cpe[i] = faad_get1bit(ld
  269|    770|            DEBUGVAR(1,30,"program_config_element(): back_element_is_cpe"));
  270|    770|        pce->back_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  271|    770|            DEBUGVAR(1,31,"program_config_element(): back_element_tag_select"));
  272|       |
  273|    770|        if (pce->back_element_is_cpe[i] & 1)
  ------------------
  |  Branch (273:13): [True: 116, False: 654]
  ------------------
  274|    116|        {
  275|    116|            pce->cpe_channel[pce->back_element_tag_select[i]] = pce->channels;
  276|    116|            pce->channels += 2;
  277|    116|            pce->num_back_channels += 2;
  278|    654|        } else {
  279|    654|            pce->sce_channel[pce->back_element_tag_select[i]] = pce->channels;
  280|    654|            pce->num_back_channels++;
  281|    654|            pce->channels++;
  282|    654|        }
  283|    770|    }
  284|       |
  285|    376|    for (i = 0; i < pce->num_lfe_channel_elements; i++)
  ------------------
  |  Branch (285:17): [True: 170, False: 206]
  ------------------
  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|    453|    for (i = 0; i < pce->num_assoc_data_elements; i++)
  ------------------
  |  Branch (295:17): [True: 247, False: 206]
  ------------------
  296|    247|        pce->assoc_data_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  297|    247|        DEBUGVAR(1,33,"program_config_element(): assoc_data_element_tag_select"));
  298|       |
  299|    729|    for (i = 0; i < pce->num_valid_cc_elements; i++)
  ------------------
  |  Branch (299:17): [True: 523, False: 206]
  ------------------
  300|    523|    {
  301|    523|        pce->cc_element_is_ind_sw[i] = faad_get1bit(ld
  302|    523|            DEBUGVAR(1,34,"program_config_element(): cc_element_is_ind_sw"));
  303|    523|        pce->valid_cc_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
  304|    523|            DEBUGVAR(1,35,"program_config_element(): valid_cc_element_tag_select"));
  305|    523|    }
  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.5k|    for (i = 0; i < pce->comment_field_bytes; i++)
  ------------------
  |  Branch (312:17): [True: 10.3k, False: 206]
  ------------------
  313|  10.3k|    {
  314|  10.3k|        pce->comment_field_data[i] = (uint8_t)faad_getbits(ld, 8
  315|  10.3k|            DEBUGVAR(1,37,"program_config_element(): comment_field_data"));
  316|  10.3k|    }
  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: 5, False: 201]
  ------------------
  320|      5|        return 22;
  321|       |
  322|    201|    return 0;
  323|    206|}

