ldaclib.c:alloc_bits_ldac:
  674|     44|{
  675|     44|    int nbits_avail, nbits_side = 0, nbits_spec = 0;
  676|     44|    int nbits_ab = p_ab->nbits_ab;
  677|       |
  678|     44|    nbits_side = encode_side_info_ldac(p_ab);
  679|     44|    p_ab->nbits_avail = nbits_avail = nbits_ab - nbits_side;
  680|       |
  681|     44|    nbits_spec = encode_audio_block_a_ldac(p_ab, p_ab->nqus);
  682|       |
  683|     44|    if (nbits_spec > nbits_avail) {
  ------------------
  |  Branch (683:9): [True: 44, False: 0]
  ------------------
  684|     44|        if (p_ab->grad_mode == LDAC_MODE_0) {
  ------------------
  |  |  150|     44|#define LDAC_MODE_0            0
  ------------------
  |  Branch (684:13): [True: 44, False: 0]
  ------------------
  685|     44|            decrease_offset_low_ldac(p_ab, LDAC_UPPER_NOISE_LEVEL, &nbits_spec);
  ------------------
  |  |  669|     44|#define LDAC_UPPER_NOISE_LEVEL 20
  ------------------
  686|       |
  687|     44|            decrease_offset_high_ldac(p_ab, &nbits_spec);
  688|       |
  689|     44|            decrease_offset_low_ldac(p_ab, LDAC_MAXGRADOS, &nbits_spec);
  ------------------
  |  |  106|     44|#define LDAC_MAXGRADOS        31
  ------------------
  690|     44|        }
  691|      0|        else {
  692|      0|            decrease_offset_low_ldac(p_ab, LDAC_MAXGRADOS, &nbits_spec);
  ------------------
  |  |  106|      0|#define LDAC_MAXGRADOS        31
  ------------------
  693|      0|        }
  694|       |
  695|     44|        while ((nbits_spec > nbits_avail) && (p_ab->nbands > LDAC_BAND_OFFSET)) {
  ------------------
  |  |  102|      0|#define LDAC_BAND_OFFSET       2
  ------------------
  |  Branch (695:16): [True: 0, False: 44]
  |  Branch (695:46): [True: 0, False: 0]
  ------------------
  696|      0|            p_ab->nbands--;
  697|      0|            p_ab->nqus = ga_nqus_ldac[p_ab->nbands];
  698|       |
  699|      0|            nbits_side = encode_side_info_ldac(p_ab);
  700|      0|            p_ab->nbits_avail = nbits_avail = nbits_ab - nbits_side;
  701|       |
  702|      0|            nbits_spec = encode_audio_block_a_ldac(p_ab, p_ab->nqus);
  703|      0|        }
  704|     44|    }
  705|       |
  706|     44|    if (nbits_spec < nbits_avail) {
  ------------------
  |  Branch (706:9): [True: 44, False: 0]
  ------------------
  707|     44|        if (p_ab->grad_mode == LDAC_MODE_0) {
  ------------------
  |  |  150|     44|#define LDAC_MODE_0            0
  ------------------
  |  Branch (707:13): [True: 44, False: 0]
  ------------------
  708|     44|            increase_offset_low_ldac(p_ab, &nbits_spec);
  709|       |
  710|     44|            increase_qu_low_0_ldac(p_ab, &nbits_spec);
  711|     44|        }    
  712|      0|        else {
  713|      0|            increase_offset_low_ldac(p_ab, &nbits_spec);
  714|       |
  715|      0|            increase_qu_low_ldac(p_ab, &nbits_spec);
  716|      0|        }
  717|     44|    }
  718|       |
  719|     44|    p_ab->nadjqus = 0;
  720|     44|    adjust_remain_bits_ldac(p_ab, &nbits_spec, &p_ab->nadjqus);
  721|       |
  722|     44|    if (nbits_spec > nbits_avail) {
  ------------------
  |  Branch (722:9): [True: 0, False: 44]
  ------------------
  723|      0|        *p_ab->p_error_code = LDAC_ERR_BIT_ALLOCATION;
  ------------------
  |  |  109|      0|#define LDAC_ERR_BIT_ALLOCATION             5
  ------------------
  724|      0|        return LDAC_FALSE;
  ------------------
  |  |  147|      0|#define LDAC_FALSE             0
  ------------------
  725|      0|    }
  726|     44|    p_ab->nbits_spec = nbits_spec;
  727|     44|    p_ab->nbits_used = nbits_spec + nbits_side;
  728|       |
  729|       |
  730|     44|    return LDAC_TRUE;
  ------------------
  |  |  146|     44|#define LDAC_TRUE              1
  ------------------
  731|     44|}
ldaclib.c:encode_audio_block_a_ldac:
   27|    660|{
   28|    660|    AC *p_ac;
   29|    660|    int ich, iqu;
   30|    660|    int nchs = p_ab->blk_nchs;
   31|    660|    int tmp, nbits = 0;
   32|    660|    int idsp, idwl1, idwl2;
   33|    660|    int grad_mode = p_ab->grad_mode;
   34|    660|    int grad_qu_l = p_ab->grad_qu_l;
   35|    660|    int grad_qu_h = p_ab->grad_qu_h;
   36|    660|    int grad_os_l = p_ab->grad_os_l;
   37|    660|    int grad_os_h = p_ab->grad_os_h;
   38|    660|    int *p_grad = p_ab->a_grad;
   39|    660|    int *p_idsf, *p_addwl, *p_idwl1, *p_idwl2;
   40|    660|    const unsigned char *p_t;
   41|       |
   42|       |    /* Calculate Gradient Curve */
   43|    660|    tmp = grad_qu_h - grad_qu_l;
   44|       |
   45|  21.7k|    for (iqu = 0; iqu < grad_qu_h; iqu++) {
  ------------------
  |  Branch (45:19): [True: 21.1k, False: 660]
  ------------------
   46|  21.1k|        p_grad[iqu] = -grad_os_l;
   47|  21.1k|    }
   48|    660|    for (iqu = grad_qu_h; iqu < hqu; iqu++) {
  ------------------
  |  Branch (48:27): [True: 0, False: 660]
  ------------------
   49|      0|        p_grad[iqu] = -grad_os_h;
   50|      0|    }
   51|       |
   52|    660|    if (tmp > 0) {
  ------------------
  |  Branch (52:9): [True: 660, False: 0]
  ------------------
   53|    660|        p_t = gaa_resamp_grad_ldac[tmp-1];
   54|       |
   55|    660|        tmp = grad_os_h - grad_os_l;
   56|    660|        if (tmp > 0) {
  ------------------
  |  Branch (56:13): [True: 660, False: 0]
  ------------------
   57|    660|            tmp = tmp-1;
   58|  10.5k|            for (iqu = grad_qu_l; iqu < grad_qu_h; iqu++) {
  ------------------
  |  Branch (58:35): [True: 9.90k, False: 660]
  ------------------
   59|  9.90k|                p_grad[iqu] -= ((*p_t++ * tmp) >> 8) + 1;
   60|  9.90k|            }
   61|    660|        }
   62|      0|        else if (tmp < 0) {
  ------------------
  |  Branch (62:18): [True: 0, False: 0]
  ------------------
   63|      0|            tmp = -tmp-1;
   64|      0|            for (iqu = grad_qu_l; iqu < grad_qu_h; iqu++) {
  ------------------
  |  Branch (64:35): [True: 0, False: 0]
  ------------------
   65|      0|                p_grad[iqu] += ((*p_t++ * tmp) >> 8) + 1;
   66|      0|            }
   67|      0|        }
   68|    660|    }
   69|       |
   70|       |    /* Calculate Bits */
   71|  1.32k|    for (ich = 0; ich < nchs; ich++) {
  ------------------
  |  Branch (71:19): [True: 660, False: 660]
  ------------------
   72|    660|        p_ac = p_ab->ap_ac[ich];
   73|    660|	p_idsf = p_ac->a_idsf;
   74|    660|	p_addwl = p_ac->a_addwl;
   75|    660|	p_idwl1 = p_ac->a_idwl1;
   76|    660|	p_idwl2 = p_ac->a_idwl2;
   77|       |
   78|    660|        if (grad_mode == LDAC_MODE_0) { 
  ------------------
  |  |  150|    660|#define LDAC_MODE_0            0
  ------------------
  |  Branch (78:13): [True: 660, False: 0]
  ------------------
   79|  17.8k|            for (iqu = 0; iqu < hqu; iqu++) {
  ------------------
  |  Branch (79:27): [True: 17.1k, False: 660]
  ------------------
   80|  17.1k|                idwl1 = p_idsf[iqu] + p_grad[iqu];
   81|  17.1k|                if (idwl1 < LDAC_MINIDWL1) {
  ------------------
  |  |  129|  17.1k|#define LDAC_MINIDWL1          1
  ------------------
  |  Branch (81:21): [True: 198, False: 16.9k]
  ------------------
   82|    198|                    idwl1 = LDAC_MINIDWL1;
  ------------------
  |  |  129|    198|#define LDAC_MINIDWL1          1
  ------------------
   83|    198|                }
   84|  17.1k|                idwl2 = 0;
   85|  17.1k|                if (idwl1 > LDAC_MAXIDWL1) {
  ------------------
  |  |  130|  17.1k|#define LDAC_MAXIDWL1         15
  ------------------
  |  Branch (85:21): [True: 880, False: 16.2k]
  ------------------
   86|    880|                    idwl2 = idwl1 - LDAC_MAXIDWL1;
  ------------------
  |  |  130|    880|#define LDAC_MAXIDWL1         15
  ------------------
   87|    880|                    if (idwl2 > LDAC_MAXIDWL2) {
  ------------------
  |  |  131|    880|#define LDAC_MAXIDWL2         15
  ------------------
  |  Branch (87:25): [True: 0, False: 880]
  ------------------
   88|      0|                        idwl2 = LDAC_MAXIDWL2;
  ------------------
  |  |  131|      0|#define LDAC_MAXIDWL2         15
  ------------------
   89|      0|                    }
   90|    880|                    idwl1 = LDAC_MAXIDWL1;
  ------------------
  |  |  130|    880|#define LDAC_MAXIDWL1         15
  ------------------
   91|    880|                }
   92|  17.1k|                p_idwl1[iqu] = idwl1;
   93|  17.1k|                p_idwl2[iqu] = idwl2;
   94|  17.1k|                idsp = ga_idsp_ldac[iqu];
   95|  17.1k|                nbits += gaa_ndim_wls_ldac[idsp][idwl1] + ga_wl_ldac[idwl2] * ga_nsps_ldac[iqu];
   96|  17.1k|            }
   97|    660|        }
   98|      0|        else if (grad_mode == LDAC_MODE_1) {
  ------------------
  |  |  151|      0|#define LDAC_MODE_1            1
  ------------------
  |  Branch (98:18): [True: 0, False: 0]
  ------------------
   99|      0|            for (iqu = 0; iqu < hqu; iqu++) {
  ------------------
  |  Branch (99:27): [True: 0, False: 0]
  ------------------
  100|      0|                idwl1 = p_idsf[iqu] + p_grad[iqu] + p_addwl[iqu];
  101|      0|                if (idwl1 > 0) {
  ------------------
  |  Branch (101:21): [True: 0, False: 0]
  ------------------
  102|      0|                    idwl1 = idwl1 >> 1;
  103|      0|                }
  104|      0|                if (idwl1 < LDAC_MINIDWL1) {
  ------------------
  |  |  129|      0|#define LDAC_MINIDWL1          1
  ------------------
  |  Branch (104:21): [True: 0, False: 0]
  ------------------
  105|      0|                    idwl1 = LDAC_MINIDWL1;
  ------------------
  |  |  129|      0|#define LDAC_MINIDWL1          1
  ------------------
  106|      0|                }
  107|      0|                idwl2 = 0;
  108|      0|                if (idwl1 > LDAC_MAXIDWL1) {
  ------------------
  |  |  130|      0|#define LDAC_MAXIDWL1         15
  ------------------
  |  Branch (108:21): [True: 0, False: 0]
  ------------------
  109|      0|                    idwl2 = idwl1 - LDAC_MAXIDWL1;
  ------------------
  |  |  130|      0|#define LDAC_MAXIDWL1         15
  ------------------
  110|      0|                    if (idwl2 > LDAC_MAXIDWL2) {
  ------------------
  |  |  131|      0|#define LDAC_MAXIDWL2         15
  ------------------
  |  Branch (110:25): [True: 0, False: 0]
  ------------------
  111|      0|                        idwl2 = LDAC_MAXIDWL2;
  ------------------
  |  |  131|      0|#define LDAC_MAXIDWL2         15
  ------------------
  112|      0|                    }
  113|      0|                    idwl1 = LDAC_MAXIDWL1;
  ------------------
  |  |  130|      0|#define LDAC_MAXIDWL1         15
  ------------------
  114|      0|                }
  115|      0|                p_idwl1[iqu] = idwl1;
  116|      0|                p_idwl2[iqu] = idwl2;
  117|      0|                idsp = ga_idsp_ldac[iqu];
  118|      0|                nbits += gaa_ndim_wls_ldac[idsp][idwl1] + ga_wl_ldac[idwl2] * ga_nsps_ldac[iqu];
  119|      0|            }
  120|      0|        }
  121|      0|        else if (grad_mode == LDAC_MODE_2) {
  ------------------
  |  |  152|      0|#define LDAC_MODE_2            2
  ------------------
  |  Branch (121:18): [True: 0, False: 0]
  ------------------
  122|      0|            for (iqu = 0; iqu < hqu; iqu++) {
  ------------------
  |  Branch (122:27): [True: 0, False: 0]
  ------------------
  123|      0|                idwl1 = p_idsf[iqu] + p_grad[iqu] + p_addwl[iqu];
  124|      0|                if (idwl1 > 0) {
  ------------------
  |  Branch (124:21): [True: 0, False: 0]
  ------------------
  125|      0|                    idwl1 = (idwl1*3) >> 3;
  126|      0|                }
  127|      0|                if (idwl1 < LDAC_MINIDWL1) {
  ------------------
  |  |  129|      0|#define LDAC_MINIDWL1          1
  ------------------
  |  Branch (127:21): [True: 0, False: 0]
  ------------------
  128|      0|                    idwl1 = LDAC_MINIDWL1;
  ------------------
  |  |  129|      0|#define LDAC_MINIDWL1          1
  ------------------
  129|      0|                }
  130|      0|                idwl2 = 0;
  131|      0|                if (idwl1 > LDAC_MAXIDWL1) {
  ------------------
  |  |  130|      0|#define LDAC_MAXIDWL1         15
  ------------------
  |  Branch (131:21): [True: 0, False: 0]
  ------------------
  132|      0|                    idwl2 = idwl1 - LDAC_MAXIDWL1;
  ------------------
  |  |  130|      0|#define LDAC_MAXIDWL1         15
  ------------------
  133|      0|                    if (idwl2 > LDAC_MAXIDWL2) {
  ------------------
  |  |  131|      0|#define LDAC_MAXIDWL2         15
  ------------------
  |  Branch (133:25): [True: 0, False: 0]
  ------------------
  134|      0|                        idwl2 = LDAC_MAXIDWL2;
  ------------------
  |  |  131|      0|#define LDAC_MAXIDWL2         15
  ------------------
  135|      0|                    }
  136|      0|                    idwl1 = LDAC_MAXIDWL1;
  ------------------
  |  |  130|      0|#define LDAC_MAXIDWL1         15
  ------------------
  137|      0|                }
  138|      0|                p_idwl1[iqu] = idwl1;
  139|      0|                p_idwl2[iqu] = idwl2;
  140|      0|                idsp = ga_idsp_ldac[iqu];
  141|      0|                nbits += gaa_ndim_wls_ldac[idsp][idwl1] + ga_wl_ldac[idwl2] * ga_nsps_ldac[iqu];
  142|      0|            }
  143|      0|        }
  144|      0|        else if (grad_mode == LDAC_MODE_3) {
  ------------------
  |  |  153|      0|#define LDAC_MODE_3            3
  ------------------
  |  Branch (144:18): [True: 0, False: 0]
  ------------------
  145|      0|            for (iqu = 0; iqu < hqu; iqu++) {
  ------------------
  |  Branch (145:27): [True: 0, False: 0]
  ------------------
  146|      0|                idwl1 = p_idsf[iqu] + p_grad[iqu] + p_addwl[iqu];
  147|      0|                if (idwl1 > 0) {
  ------------------
  |  Branch (147:21): [True: 0, False: 0]
  ------------------
  148|      0|                    idwl1 = idwl1 >> 2;
  149|      0|                }
  150|      0|                if (idwl1 < LDAC_MINIDWL1) {
  ------------------
  |  |  129|      0|#define LDAC_MINIDWL1          1
  ------------------
  |  Branch (150:21): [True: 0, False: 0]
  ------------------
  151|      0|                    idwl1 = LDAC_MINIDWL1;
  ------------------
  |  |  129|      0|#define LDAC_MINIDWL1          1
  ------------------
  152|      0|                }
  153|      0|                idwl2 = 0;
  154|      0|                if (idwl1 > LDAC_MAXIDWL1) {
  ------------------
  |  |  130|      0|#define LDAC_MAXIDWL1         15
  ------------------
  |  Branch (154:21): [True: 0, False: 0]
  ------------------
  155|      0|                    idwl2 = idwl1 - LDAC_MAXIDWL1;
  ------------------
  |  |  130|      0|#define LDAC_MAXIDWL1         15
  ------------------
  156|      0|                    if (idwl2 > LDAC_MAXIDWL2) {
  ------------------
  |  |  131|      0|#define LDAC_MAXIDWL2         15
  ------------------
  |  Branch (156:25): [True: 0, False: 0]
  ------------------
  157|      0|                        idwl2 = LDAC_MAXIDWL2;
  ------------------
  |  |  131|      0|#define LDAC_MAXIDWL2         15
  ------------------
  158|      0|                    }
  159|      0|                    idwl1 = LDAC_MAXIDWL1;
  ------------------
  |  |  130|      0|#define LDAC_MAXIDWL1         15
  ------------------
  160|      0|                }
  161|      0|                p_idwl1[iqu] = idwl1;
  162|      0|                p_idwl2[iqu] = idwl2;
  163|      0|                idsp = ga_idsp_ldac[iqu];
  164|      0|                nbits += gaa_ndim_wls_ldac[idsp][idwl1] + ga_wl_ldac[idwl2] * ga_nsps_ldac[iqu];
  165|      0|            }
  166|      0|        }
  167|    660|    }
  168|       |
  169|    660|    return nbits;
  170|    660|}
ldaclib.c:decrease_offset_low_ldac:
  224|     88|{
  225|     88|    int ncalls = 0;
  226|     88|    int nqus = p_ab->nqus;
  227|     88|    int grad_os_l = p_ab->grad_os_l;
  228|     88|    int nbits_avail = p_ab->nbits_avail;
  229|     88|    int step = limit - grad_os_l;
  230|     88|    int a_checked[LDAC_MAXGRADOS+1];
  231|       |
  232|     88|    if (*p_nbits_spec > nbits_avail) {
  ------------------
  |  Branch (232:9): [True: 44, False: 44]
  ------------------
  233|     44|        memset(a_checked, 0, (LDAC_MAXGRADOS+1)*sizeof(int));
  ------------------
  |  |  106|     44|#define LDAC_MAXGRADOS        31
  ------------------
  234|       |
  235|    220|        while (grad_os_l < limit) {
  ------------------
  |  Branch (235:16): [True: 220, False: 0]
  ------------------
  236|    220|            if (step > 1) {
  ------------------
  |  Branch (236:17): [True: 176, False: 44]
  ------------------
  237|    176|                step = (step+1)/2;
  238|    176|            }
  239|       |
  240|    220|            if (*p_nbits_spec < nbits_avail) {
  ------------------
  |  Branch (240:17): [True: 44, False: 176]
  ------------------
  241|     44|                grad_os_l -= step;
  242|     44|                if (grad_os_l < 0) {
  ------------------
  |  Branch (242:21): [True: 0, False: 44]
  ------------------
  243|      0|                    grad_os_l += step;
  244|      0|                    break;
  245|      0|                }
  246|     44|                else if (a_checked[grad_os_l]) {
  ------------------
  |  Branch (246:26): [True: 0, False: 44]
  ------------------
  247|      0|                    grad_os_l += step;
  248|      0|                    break;
  249|      0|                }
  250|     44|            }
  251|    176|            else if (*p_nbits_spec > nbits_avail) {
  ------------------
  |  Branch (251:22): [True: 176, False: 0]
  ------------------
  252|    176|                grad_os_l += step;
  253|    176|                if (grad_os_l > LDAC_MAXGRADOS) {
  ------------------
  |  |  106|    176|#define LDAC_MAXGRADOS        31
  ------------------
  |  Branch (253:21): [True: 0, False: 176]
  ------------------
  254|      0|                    grad_os_l -= step;
  255|      0|                    break;
  256|      0|                }
  257|    176|                else if (a_checked[grad_os_l]) {
  ------------------
  |  Branch (257:26): [True: 44, False: 132]
  ------------------
  258|     44|                    grad_os_l -= step;
  259|     44|                    break;
  260|     44|                }
  261|    176|            }
  262|      0|            else {
  263|      0|                break;
  264|      0|            }
  265|       |
  266|    176|            p_ab->grad_os_l = grad_os_l;
  267|    176|            *p_nbits_spec = encode_audio_block_a_ldac(p_ab, nqus);
  268|    176|            a_checked[grad_os_l] = *p_nbits_spec;
  269|    176|            ncalls++;
  270|    176|        }
  271|       |
  272|     88|        while ((*p_nbits_spec > nbits_avail) && (grad_os_l < limit)) {
  ------------------
  |  Branch (272:16): [True: 44, False: 44]
  |  Branch (272:49): [True: 44, False: 0]
  ------------------
  273|     44|            p_ab->grad_os_l = ++grad_os_l;
  274|     44|            *p_nbits_spec = encode_audio_block_a_ldac(p_ab, nqus);
  275|     44|            ncalls++;
  276|     44|        }
  277|     44|    }
  278|       |
  279|     88|    return ncalls;
  280|     88|}
ldaclib.c:decrease_offset_high_ldac:
  288|     44|{
  289|     44|    int ncalls = 0;
  290|     44|    int nqus = p_ab->nqus;
  291|     44|    int grad_os_h = p_ab->grad_os_h;
  292|     44|    int nbits_avail = p_ab->nbits_avail;
  293|     44|    int step = LDAC_MAXGRADOS - grad_os_h;
  ------------------
  |  |  106|     44|#define LDAC_MAXGRADOS        31
  ------------------
  294|     44|    int a_checked[LDAC_MAXGRADOS+1];
  295|       |
  296|     44|    if (*p_nbits_spec > nbits_avail) {
  ------------------
  |  Branch (296:9): [True: 0, False: 44]
  ------------------
  297|      0|        memset(a_checked, 0, (LDAC_MAXGRADOS+1)*sizeof(int));
  ------------------
  |  |  106|      0|#define LDAC_MAXGRADOS        31
  ------------------
  298|       |
  299|      0|        while (grad_os_h < LDAC_MAXGRADOS) {
  ------------------
  |  |  106|      0|#define LDAC_MAXGRADOS        31
  ------------------
  |  Branch (299:16): [True: 0, False: 0]
  ------------------
  300|      0|            if (step > 1) {
  ------------------
  |  Branch (300:17): [True: 0, False: 0]
  ------------------
  301|      0|                step = (step+1)/2;
  302|      0|            }
  303|       |
  304|      0|            if (*p_nbits_spec < nbits_avail) {
  ------------------
  |  Branch (304:17): [True: 0, False: 0]
  ------------------
  305|      0|                grad_os_h -= step;
  306|      0|                if (grad_os_h < 0) {
  ------------------
  |  Branch (306:21): [True: 0, False: 0]
  ------------------
  307|      0|                    grad_os_h += step;
  308|      0|                    break;
  309|      0|                }
  310|      0|                else if (a_checked[grad_os_h]) {
  ------------------
  |  Branch (310:26): [True: 0, False: 0]
  ------------------
  311|      0|                    grad_os_h += step;
  312|      0|                    break;
  313|      0|                }
  314|      0|            }
  315|      0|            else if (*p_nbits_spec > nbits_avail) {
  ------------------
  |  Branch (315:22): [True: 0, False: 0]
  ------------------
  316|      0|                grad_os_h += step;
  317|      0|                if (grad_os_h > LDAC_MAXGRADOS) {
  ------------------
  |  |  106|      0|#define LDAC_MAXGRADOS        31
  ------------------
  |  Branch (317:21): [True: 0, False: 0]
  ------------------
  318|      0|                    grad_os_h -= step;
  319|      0|                    break;
  320|      0|                }
  321|      0|                else if (a_checked[grad_os_h]) {
  ------------------
  |  Branch (321:26): [True: 0, False: 0]
  ------------------
  322|      0|                    grad_os_h -= step;
  323|      0|                    break;
  324|      0|                }
  325|      0|            }
  326|      0|            else {
  327|      0|                break;
  328|      0|            }
  329|       |
  330|      0|            p_ab->grad_os_h = grad_os_h;
  331|      0|            *p_nbits_spec = encode_audio_block_a_ldac(p_ab, nqus);
  332|      0|            a_checked[grad_os_h] = *p_nbits_spec;
  333|      0|            ncalls++;
  334|      0|        }
  335|       |
  336|      0|        while ((*p_nbits_spec > nbits_avail) && (grad_os_h < LDAC_MAXGRADOS)) {
  ------------------
  |  |  106|      0|#define LDAC_MAXGRADOS        31
  ------------------
  |  Branch (336:16): [True: 0, False: 0]
  |  Branch (336:49): [True: 0, False: 0]
  ------------------
  337|      0|            p_ab->grad_os_h = ++grad_os_h;
  338|      0|            *p_nbits_spec = encode_audio_block_a_ldac(p_ab, nqus);
  339|      0|            ncalls++;
  340|      0|        }
  341|      0|    }
  342|       |
  343|     44|    return ncalls;
  344|     44|}
ldaclib.c:increase_offset_low_ldac:
  352|     44|{
  353|     44|    int ncalls = 0;
  354|     44|    int nqus = p_ab->nqus;
  355|     44|    int grad_os_l = p_ab->grad_os_l;
  356|     44|    int nbits_avail = p_ab->nbits_avail;
  357|     44|    int step = grad_os_l;
  358|     44|    int a_checked[LDAC_MAXGRADOS+1];
  359|       |
  360|     44|    memset(a_checked, 0, (LDAC_MAXGRADOS+1)*sizeof(int));
  ------------------
  |  |  106|     44|#define LDAC_MAXGRADOS        31
  ------------------
  361|       |
  362|    264|    while (grad_os_l > 0) {
  ------------------
  |  Branch (362:12): [True: 264, False: 0]
  ------------------
  363|    264|        if (step > 1) {
  ------------------
  |  Branch (363:13): [True: 220, False: 44]
  ------------------
  364|    220|            step = (step+1)/2;
  365|    220|        }
  366|       |
  367|    264|        if (*p_nbits_spec < nbits_avail) {
  ------------------
  |  Branch (367:13): [True: 132, False: 132]
  ------------------
  368|    132|            grad_os_l -= step;
  369|    132|            if (grad_os_l < 0) {
  ------------------
  |  Branch (369:17): [True: 0, False: 132]
  ------------------
  370|      0|                grad_os_l += step;
  371|      0|                break;
  372|      0|            }
  373|    132|            else if (a_checked[grad_os_l]) {
  ------------------
  |  Branch (373:22): [True: 44, False: 88]
  ------------------
  374|     44|                grad_os_l += step;
  375|     44|                break;
  376|     44|            }
  377|    132|        }
  378|    132|        else if (*p_nbits_spec > nbits_avail) {
  ------------------
  |  Branch (378:18): [True: 132, False: 0]
  ------------------
  379|    132|            grad_os_l += step;
  380|    132|            if (grad_os_l > LDAC_MAXGRADOS) {
  ------------------
  |  |  106|    132|#define LDAC_MAXGRADOS        31
  ------------------
  |  Branch (380:17): [True: 0, False: 132]
  ------------------
  381|      0|                grad_os_l -= step;
  382|      0|                break;
  383|      0|            }
  384|    132|            else if (a_checked[grad_os_l]) {
  ------------------
  |  Branch (384:22): [True: 0, False: 132]
  ------------------
  385|      0|                grad_os_l -= step;
  386|      0|                break;
  387|      0|            }
  388|    132|        }
  389|      0|        else {
  390|      0|            break;
  391|      0|        }
  392|       |
  393|    220|        p_ab->grad_os_l = grad_os_l;
  394|    220|        *p_nbits_spec = encode_audio_block_a_ldac(p_ab, nqus);
  395|    220|        a_checked[grad_os_l] = *p_nbits_spec;
  396|    220|        ncalls++;
  397|    220|    }
  398|       |
  399|     44|    while ((*p_nbits_spec > nbits_avail) && (grad_os_l < LDAC_MAXGRADOS)) {
  ------------------
  |  |  106|      0|#define LDAC_MAXGRADOS        31
  ------------------
  |  Branch (399:12): [True: 0, False: 44]
  |  Branch (399:45): [True: 0, False: 0]
  ------------------
  400|      0|        p_ab->grad_os_l = ++grad_os_l;
  401|      0|        *p_nbits_spec = encode_audio_block_a_ldac(p_ab, nqus);
  402|      0|        ncalls++;
  403|      0|    }
  404|       |
  405|     44|    return ncalls;
  406|     44|}
ldaclib.c:increase_qu_low_0_ldac:
  478|     44|{
  479|     44|    int ncalls = 0;
  480|     44|    int nqus = p_ab->nqus;
  481|     44|    int grad_qu_l = p_ab->grad_qu_l;
  482|     44|    int grad_qu_h = p_ab->grad_qu_h;
  483|     44|    int nbits_avail = p_ab->nbits_avail;
  484|     44|    int step = grad_qu_h - grad_qu_l;
  485|     44|    int a_checked[LDAC_MAXGRADQU+1];
  486|       |
  487|     44|    memset(a_checked, 0, (LDAC_MAXGRADQU+1)*sizeof(int));
  ------------------
  |  |   85|     44|#define LDAC_MAXGRADQU        50
  ------------------
  488|       |
  489|    220|    while ((grad_qu_l > 0) && (grad_qu_l < grad_qu_h)) {
  ------------------
  |  Branch (489:12): [True: 220, False: 0]
  |  Branch (489:31): [True: 220, False: 0]
  ------------------
  490|    220|        if (step > 1) {
  ------------------
  |  Branch (490:13): [True: 176, False: 44]
  ------------------
  491|    176|            step = step/2;
  492|    176|        }
  493|       |
  494|    220|        if (*p_nbits_spec < nbits_avail) {
  ------------------
  |  Branch (494:13): [True: 88, False: 132]
  ------------------
  495|     88|            grad_qu_l += step;
  496|     88|            if (grad_qu_l >= grad_qu_h) {
  ------------------
  |  Branch (496:17): [True: 0, False: 88]
  ------------------
  497|      0|                grad_qu_l -= step;
  498|      0|                break;
  499|      0|            }
  500|     88|            else if (a_checked[grad_qu_l]) {
  ------------------
  |  Branch (500:22): [True: 44, False: 44]
  ------------------
  501|     44|                grad_qu_l -= step;
  502|     44|                break;
  503|     44|            }
  504|     88|        }
  505|    132|        else if (*p_nbits_spec > nbits_avail) {
  ------------------
  |  Branch (505:18): [True: 132, False: 0]
  ------------------
  506|    132|            grad_qu_l -= step;
  507|    132|            if (grad_qu_l < 0) {
  ------------------
  |  Branch (507:17): [True: 0, False: 132]
  ------------------
  508|      0|                grad_qu_l += step;
  509|      0|                break;
  510|      0|            }
  511|    132|            else if (a_checked[grad_qu_l]) {
  ------------------
  |  Branch (511:22): [True: 0, False: 132]
  ------------------
  512|      0|                grad_qu_l += step;
  513|      0|                break;
  514|      0|            }
  515|    132|        }
  516|      0|        else {
  517|      0|            break;
  518|      0|        }
  519|       |
  520|    176|        p_ab->grad_qu_l = grad_qu_l;
  521|    176|        *p_nbits_spec = encode_audio_block_a_ldac(p_ab, nqus);
  522|    176|        a_checked[grad_qu_l] = *p_nbits_spec;
  523|    176|        ncalls++;
  524|    176|    }
  525|       |
  526|     44|    while ((*p_nbits_spec > nbits_avail) && (grad_qu_l > 0)) {
  ------------------
  |  Branch (526:12): [True: 0, False: 44]
  |  Branch (526:45): [True: 0, False: 0]
  ------------------
  527|      0|        p_ab->grad_qu_l = --grad_qu_l;
  528|      0|        *p_nbits_spec = encode_audio_block_a_ldac(p_ab, nqus);
  529|      0|        ncalls++;
  530|      0|    }
  531|       |
  532|     44|    return ncalls;
  533|     44|}
ldaclib.c:adjust_remain_bits_ldac:
  542|     44|{
  543|     44|    int ich, iqu;
  544|     44|    int ncalls = 0;
  545|     44|    int nbits_fix, nbits_spec;
  546|     44|    int nbits_avail = p_ab->nbits_avail;
  547|     44|    int idsp, idwl1, idwl2, tmp;
  548|     44|    int step = LDAC_MAXNADJQUS>>1;
  ------------------
  |  |  112|     44|#define LDAC_MAXNADJQUS       32
  ------------------
  549|     44|    int nadjqus = LDAC_MAXNADJQUS>>1;
  ------------------
  |  |  112|     44|#define LDAC_MAXNADJQUS       32
  ------------------
  550|     44|    int nchs = p_ab->blk_nchs;
  551|     44|    int nqus = min_ldac(LDAC_MAXNADJQUS, p_ab->nqus);
  ------------------
  |  |  275|     44|#define min_ldac(a, b) (((a)<(b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (275:25): [True: 0, False: 44]
  |  |  ------------------
  ------------------
  552|     44|    int grad_mode = p_ab->grad_mode;
  553|     44|    int *p_grad = p_ab->a_grad;
  554|     44|    int *p_idsf, *p_addwl, *p_idwl1, *p_idwl2, *p_tmp;
  555|     44|    AC *p_ac;
  556|       |
  557|     44|    nbits_fix = 0;
  558|     88|    for (ich = 0; ich < nchs; ich++){
  ------------------
  |  Branch (558:19): [True: 44, False: 44]
  ------------------
  559|     44|        p_ac = p_ab->ap_ac[ich];
  560|     44|        p_idsf = p_ac->a_idsf;
  561|     44|        p_addwl = p_ac->a_addwl;
  562|     44|        p_idwl1 = p_ac->a_idwl1;
  563|     44|        p_idwl2 = p_ac->a_idwl2;
  564|     44|        p_tmp = p_ac->a_tmp;
  565|       |
  566|     44|        if (grad_mode == LDAC_MODE_0) {
  ------------------
  |  |  150|     44|#define LDAC_MODE_0            0
  ------------------
  |  Branch (566:13): [True: 44, False: 0]
  ------------------
  567|  1.18k|            for (iqu = 0; iqu < nqus; iqu++) {
  ------------------
  |  Branch (567:27): [True: 1.14k, False: 44]
  ------------------
  568|  1.14k|		idwl1 = p_idwl1[iqu];
  569|  1.14k|		idwl2 = p_idwl2[iqu];
  570|  1.14k|                idsp = ga_idsp_ldac[iqu];
  571|  1.14k|                nbits_fix += gaa_ndim_wls_ldac[idsp][idwl1] + ga_wl_ldac[idwl2] * ga_nsps_ldac[iqu];
  572|  1.14k|                tmp = p_idsf[iqu] + p_grad[iqu];
  573|  1.14k|                if (tmp < LDAC_MINIDWL1) {
  ------------------
  |  |  129|  1.14k|#define LDAC_MINIDWL1          1
  ------------------
  |  Branch (573:21): [True: 0, False: 1.14k]
  ------------------
  574|      0|                    tmp = LDAC_MINIDWL1;
  ------------------
  |  |  129|      0|#define LDAC_MINIDWL1          1
  ------------------
  575|      0|                }
  576|  1.14k|                p_tmp[iqu] = tmp;
  577|  1.14k|            }
  578|     44|        }
  579|      0|        else if (grad_mode == LDAC_MODE_1) {
  ------------------
  |  |  151|      0|#define LDAC_MODE_1            1
  ------------------
  |  Branch (579:18): [True: 0, False: 0]
  ------------------
  580|      0|            for (iqu = 0; iqu < nqus; iqu++) {
  ------------------
  |  Branch (580:27): [True: 0, False: 0]
  ------------------
  581|      0|		idwl1 = p_idwl1[iqu];
  582|      0|		idwl2 = p_idwl2[iqu];
  583|      0|                idsp = ga_idsp_ldac[iqu];
  584|      0|                nbits_fix += gaa_ndim_wls_ldac[idsp][idwl1] + ga_wl_ldac[idwl2] * ga_nsps_ldac[iqu];
  585|      0|                tmp = p_idsf[iqu] + p_grad[iqu] + p_addwl[iqu];
  586|      0|                if (tmp > 0) {
  ------------------
  |  Branch (586:21): [True: 0, False: 0]
  ------------------
  587|      0|                    tmp = tmp >> 1;
  588|      0|                }
  589|      0|                if (tmp < LDAC_MINIDWL1) {
  ------------------
  |  |  129|      0|#define LDAC_MINIDWL1          1
  ------------------
  |  Branch (589:21): [True: 0, False: 0]
  ------------------
  590|      0|                    tmp = LDAC_MINIDWL1;
  ------------------
  |  |  129|      0|#define LDAC_MINIDWL1          1
  ------------------
  591|      0|                }
  592|      0|                p_tmp[iqu] = tmp;
  593|      0|            }
  594|      0|        }
  595|      0|        else if (grad_mode == LDAC_MODE_2) {
  ------------------
  |  |  152|      0|#define LDAC_MODE_2            2
  ------------------
  |  Branch (595:18): [True: 0, False: 0]
  ------------------
  596|      0|            for (iqu = 0; iqu < nqus; iqu++) {
  ------------------
  |  Branch (596:27): [True: 0, False: 0]
  ------------------
  597|      0|		idwl1 = p_idwl1[iqu];
  598|      0|		idwl2 = p_idwl2[iqu];
  599|      0|                idsp = ga_idsp_ldac[iqu];
  600|      0|                nbits_fix += gaa_ndim_wls_ldac[idsp][idwl1] + ga_wl_ldac[idwl2] * ga_nsps_ldac[iqu];
  601|      0|                tmp = p_idsf[iqu] + p_grad[iqu] + p_addwl[iqu];
  602|      0|                if (tmp > 0) {
  ------------------
  |  Branch (602:21): [True: 0, False: 0]
  ------------------
  603|      0|                    tmp = (tmp*3) >> 3;
  604|      0|                }
  605|      0|                if (tmp < LDAC_MINIDWL1) {
  ------------------
  |  |  129|      0|#define LDAC_MINIDWL1          1
  ------------------
  |  Branch (605:21): [True: 0, False: 0]
  ------------------
  606|      0|                    tmp = LDAC_MINIDWL1;
  ------------------
  |  |  129|      0|#define LDAC_MINIDWL1          1
  ------------------
  607|      0|                }
  608|      0|                p_tmp[iqu] = tmp;
  609|      0|            }
  610|      0|        }
  611|      0|        else if (grad_mode == LDAC_MODE_3) {
  ------------------
  |  |  153|      0|#define LDAC_MODE_3            3
  ------------------
  |  Branch (611:18): [True: 0, False: 0]
  ------------------
  612|      0|            for (iqu = 0; iqu < nqus; iqu++) {
  ------------------
  |  Branch (612:27): [True: 0, False: 0]
  ------------------
  613|      0|		idwl1 = p_idwl1[iqu];
  614|      0|		idwl2 = p_idwl2[iqu];
  615|      0|                idsp = ga_idsp_ldac[iqu];
  616|      0|                nbits_fix += gaa_ndim_wls_ldac[idsp][idwl1] + ga_wl_ldac[idwl2] * ga_nsps_ldac[iqu];
  617|      0|                tmp = p_idsf[iqu] + p_grad[iqu] + p_addwl[iqu];
  618|      0|                if (tmp > 0) {
  ------------------
  |  Branch (618:21): [True: 0, False: 0]
  ------------------
  619|      0|                    tmp = tmp >> 2;
  620|      0|                }
  621|      0|                if (tmp < LDAC_MINIDWL1) {
  ------------------
  |  |  129|      0|#define LDAC_MINIDWL1          1
  ------------------
  |  Branch (621:21): [True: 0, False: 0]
  ------------------
  622|      0|                    tmp = LDAC_MINIDWL1;
  ------------------
  |  |  129|      0|#define LDAC_MINIDWL1          1
  ------------------
  623|      0|                }
  624|      0|                p_tmp[iqu] = tmp;
  625|      0|            }
  626|      0|        }
  627|     44|    }
  628|       |
  629|     44|    nbits_fix = *p_nbits_spec - nbits_fix;
  630|     44|    nbits_spec = nbits_fix + encode_audio_block_b_ldac(p_ab, nadjqus);
  631|     44|    ncalls++;
  632|       |
  633|    220|    while (step > 1) {
  ------------------
  |  Branch (633:12): [True: 176, False: 44]
  ------------------
  634|    176|        step >>= 1;
  635|       |
  636|    176|        if (nbits_spec < nbits_avail) {
  ------------------
  |  Branch (636:13): [True: 88, False: 88]
  ------------------
  637|     88|            nadjqus += step;
  638|     88|            if (nadjqus > p_ab->nqus) {
  ------------------
  |  Branch (638:17): [True: 0, False: 88]
  ------------------
  639|      0|                nadjqus = p_ab->nqus;
  640|      0|            }
  641|     88|        }
  642|     88|        else if (nbits_spec > nbits_avail) {
  ------------------
  |  Branch (642:18): [True: 88, False: 0]
  ------------------
  643|     88|            nadjqus -= step; 
  644|     88|        }
  645|      0|        else {
  646|      0|            if (nadjqus > p_ab->nqus) {
  ------------------
  |  Branch (646:17): [True: 0, False: 0]
  ------------------
  647|      0|                nadjqus = p_ab->nqus;
  648|      0|            }
  649|      0|            break;
  650|      0|        }
  651|    176|        nbits_spec = nbits_fix + encode_audio_block_b_ldac(p_ab, nadjqus);
  652|    176|        ncalls++;
  653|    176|    }
  654|       |
  655|     44|    if (nbits_spec > nbits_avail) {
  ------------------
  |  Branch (655:9): [True: 0, False: 44]
  ------------------
  656|      0|        nadjqus--;
  657|      0|        nbits_spec = nbits_fix + encode_audio_block_b_ldac(p_ab, nadjqus);
  658|      0|        ncalls++;
  659|      0|    }
  660|     44|    *p_nadjqus = nadjqus;
  661|     44|    *p_nbits_spec = nbits_spec;
  662|       |
  663|     44|    return ncalls;
  664|     44|}
ldaclib.c:encode_audio_block_b_ldac:
  178|    220|{
  179|    220|    AC *p_ac;
  180|    220|    int ich, iqu;
  181|    220|    int nchs = p_ab->blk_nchs;
  182|    220|    int nqus = min_ldac(LDAC_MAXNADJQUS, p_ab->nqus);
  ------------------
  |  |  275|    220|#define min_ldac(a, b) (((a)<(b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (275:25): [True: 0, False: 220]
  |  |  ------------------
  ------------------
  183|    220|    int nbits = 0;
  184|    220|    int idsp, idwl1, idwl2;
  185|    220|    int *p_idwl1, *p_idwl2, *p_tmp;
  186|       |
  187|       |    /* Calculate Bits */
  188|    440|    for (ich = 0; ich < nchs; ich++) {
  ------------------
  |  Branch (188:19): [True: 220, False: 220]
  ------------------
  189|    220|        p_ac = p_ab->ap_ac[ich]; 
  190|    220|	p_idwl1 = p_ac->a_idwl1;
  191|    220|	p_idwl2 = p_ac->a_idwl2;
  192|    220|	p_tmp = p_ac->a_tmp;
  193|       |
  194|  5.94k|        for (iqu = 0; iqu < nqus; iqu++) {
  ------------------
  |  Branch (194:23): [True: 5.72k, False: 220]
  ------------------
  195|  5.72k|            idwl1 = p_tmp[iqu];
  196|  5.72k|            if (iqu < nadjqus) {
  ------------------
  |  Branch (196:17): [True: 2.28k, False: 3.43k]
  ------------------
  197|  2.28k|                idwl1++;
  198|  2.28k|            }
  199|  5.72k|            idwl2 = 0;
  200|  5.72k|            if (idwl1 > LDAC_MAXIDWL1) {
  ------------------
  |  |  130|  5.72k|#define LDAC_MAXIDWL1         15
  ------------------
  |  Branch (200:17): [True: 0, False: 5.72k]
  ------------------
  201|      0|                idwl2 = idwl1 - LDAC_MAXIDWL1;
  ------------------
  |  |  130|      0|#define LDAC_MAXIDWL1         15
  ------------------
  202|      0|                if (idwl2 > LDAC_MAXIDWL2) {
  ------------------
  |  |  131|      0|#define LDAC_MAXIDWL2         15
  ------------------
  |  Branch (202:21): [True: 0, False: 0]
  ------------------
  203|      0|                    idwl2 = LDAC_MAXIDWL2;
  ------------------
  |  |  131|      0|#define LDAC_MAXIDWL2         15
  ------------------
  204|      0|                }
  205|      0|                idwl1 = LDAC_MAXIDWL1;
  ------------------
  |  |  130|      0|#define LDAC_MAXIDWL1         15
  ------------------
  206|      0|            }
  207|  5.72k|            p_idwl1[iqu] = idwl1;
  208|  5.72k|            p_idwl2[iqu] = idwl2;
  209|  5.72k|            idsp = ga_idsp_ldac[iqu];
  210|  5.72k|            nbits += gaa_ndim_wls_ldac[idsp][idwl1] + ga_wl_ldac[idwl2] * ga_nsps_ldac[iqu];
  211|  5.72k|        }
  212|    220|    }
  213|       |
  214|    220|    return nbits;
  215|    220|}

ldaclib.c:encode_side_info_ldac:
  261|     44|{
  262|     44|    AC *p_ac;
  263|     44|    int ich;
  264|     44|    int nchs = p_ab->blk_nchs;
  265|     44|    int nbits, nbits_band, nbits_grad, nbits_scfc = 0;
  266|       |
  267|     44|    p_ab->nbits_band = nbits_band = encode_band_info_ldac(p_ab);
  268|     44|    p_ab->nbits_grad = nbits_grad = encode_gradient_ldac(p_ab);
  269|     88|    for (ich = 0; ich < nchs; ich++) {
  ------------------
  |  Branch (269:19): [True: 44, False: 44]
  ------------------
  270|     44|        p_ac = p_ab->ap_ac[ich];
  271|     44|        nbits_scfc += encode_scale_factor_ldac(p_ac);
  272|     44|        calc_add_word_length_ldac(p_ac);
  273|     44|    }
  274|     44|    p_ab->nbits_scfc = nbits_scfc;
  275|       |
  276|     44|    nbits = nbits_band + nbits_grad + nbits_scfc;
  277|       |
  278|     44|    return nbits;
  279|     44|}
ldaclib.c:encode_band_info_ldac:
   24|     44|{
   25|     44|    int	nbits;
   26|       |
   27|     44|    nbits = LDAC_NBANDBITS + LDAC_FLAGBITS;
  ------------------
  |  |  101|     44|#define LDAC_NBANDBITS         4
  ------------------
                  nbits = LDAC_NBANDBITS + LDAC_FLAGBITS;
  ------------------
  |  |  145|     44|#define LDAC_FLAGBITS          1
  ------------------
   28|       |
   29|     44|    return nbits;
   30|     44|}
ldaclib.c:encode_gradient_ldac:
   37|     44|{
   38|     44|    int	nbits;
   39|       |
   40|     44|    if (p_ab->grad_mode == LDAC_MODE_0) {
  ------------------
  |  |  150|     44|#define LDAC_MODE_0            0
  ------------------
  |  Branch (40:9): [True: 44, False: 0]
  ------------------
   41|     44|        nbits = LDAC_GRADMODEBITS + LDAC_GRADQU0BITS*2 + LDAC_GRADOSBITS*2 + LDAC_NADJQUBITS;
  ------------------
  |  |  104|     44|#define LDAC_GRADMODEBITS      2
  ------------------
                      nbits = LDAC_GRADMODEBITS + LDAC_GRADQU0BITS*2 + LDAC_GRADOSBITS*2 + LDAC_NADJQUBITS;
  ------------------
  |  |  108|     44|#define LDAC_GRADQU0BITS       6
  ------------------
                      nbits = LDAC_GRADMODEBITS + LDAC_GRADQU0BITS*2 + LDAC_GRADOSBITS*2 + LDAC_NADJQUBITS;
  ------------------
  |  |  105|     44|#define LDAC_GRADOSBITS        5
  ------------------
                      nbits = LDAC_GRADMODEBITS + LDAC_GRADQU0BITS*2 + LDAC_GRADOSBITS*2 + LDAC_NADJQUBITS;
  ------------------
  |  |  111|     44|#define LDAC_NADJQUBITS        5
  ------------------
   42|     44|    }
   43|      0|    else {
   44|      0|        nbits = LDAC_GRADMODEBITS + LDAC_GRADQU1BITS + LDAC_GRADOSBITS + LDAC_NADJQUBITS;
  ------------------
  |  |  104|      0|#define LDAC_GRADMODEBITS      2
  ------------------
                      nbits = LDAC_GRADMODEBITS + LDAC_GRADQU1BITS + LDAC_GRADOSBITS + LDAC_NADJQUBITS;
  ------------------
  |  |  109|      0|#define LDAC_GRADQU1BITS       5
  ------------------
                      nbits = LDAC_GRADMODEBITS + LDAC_GRADQU1BITS + LDAC_GRADOSBITS + LDAC_NADJQUBITS;
  ------------------
  |  |  105|      0|#define LDAC_GRADOSBITS        5
  ------------------
                      nbits = LDAC_GRADMODEBITS + LDAC_GRADQU1BITS + LDAC_GRADOSBITS + LDAC_NADJQUBITS;
  ------------------
  |  |  111|      0|#define LDAC_NADJQUBITS        5
  ------------------
   45|      0|    }
   46|       |
   47|     44|    return nbits;
   48|     44|}
ldaclib.c:encode_scale_factor_ldac:
  231|     44|{
  232|     44|    SFCINF a_sfcinf[LDAC_NSFCMODE];
  233|     44|    SFCINF *p_sfcinf;
  234|     44|    int nbits, sfc_mode;
  235|     44|    int a_nbits[LDAC_NSFCMODE];
  236|       |
  237|     44|    if (p_ac->ich == 0) {
  ------------------
  |  Branch (237:9): [True: 44, False: 0]
  ------------------
  238|     44|        a_nbits[LDAC_MODE_0] = encode_scale_factor_0_ldac(p_ac, a_sfcinf+LDAC_MODE_0);
  ------------------
  |  |  150|     44|#define LDAC_MODE_0            0
  ------------------
                      a_nbits[LDAC_MODE_0] = encode_scale_factor_0_ldac(p_ac, a_sfcinf+LDAC_MODE_0);
  ------------------
  |  |  150|     44|#define LDAC_MODE_0            0
  ------------------
  239|     44|        a_nbits[LDAC_MODE_1] = encode_scale_factor_1_ldac(p_ac, a_sfcinf+LDAC_MODE_1);
  ------------------
  |  |  151|     44|#define LDAC_MODE_1            1
  ------------------
                      a_nbits[LDAC_MODE_1] = encode_scale_factor_1_ldac(p_ac, a_sfcinf+LDAC_MODE_1);
  ------------------
  |  |  151|     44|#define LDAC_MODE_1            1
  ------------------
  240|     44|    }
  241|      0|    else {
  242|      0|        a_nbits[LDAC_MODE_0] = encode_scale_factor_0_ldac(p_ac, a_sfcinf+LDAC_MODE_0);
  ------------------
  |  |  150|      0|#define LDAC_MODE_0            0
  ------------------
                      a_nbits[LDAC_MODE_0] = encode_scale_factor_0_ldac(p_ac, a_sfcinf+LDAC_MODE_0);
  ------------------
  |  |  150|      0|#define LDAC_MODE_0            0
  ------------------
  243|      0|        a_nbits[LDAC_MODE_1] = encode_scale_factor_2_ldac(p_ac, a_sfcinf+LDAC_MODE_1);
  ------------------
  |  |  151|      0|#define LDAC_MODE_1            1
  ------------------
                      a_nbits[LDAC_MODE_1] = encode_scale_factor_2_ldac(p_ac, a_sfcinf+LDAC_MODE_1);
  ------------------
  |  |  151|      0|#define LDAC_MODE_1            1
  ------------------
  244|      0|    }
  245|       |
  246|     44|    p_ac->sfc_mode = sfc_mode = get_minimum_id_ldac(a_nbits, LDAC_MODE_1+1);
  ------------------
  |  |  151|     44|#define LDAC_MODE_1            1
  ------------------
  247|     44|    p_sfcinf = a_sfcinf + sfc_mode;
  248|     44|    p_ac->sfc_bitlen = p_sfcinf->bitlen;
  249|     44|    p_ac->sfc_offset = p_sfcinf->offset;
  250|     44|    p_ac->sfc_weight = p_sfcinf->weight;
  251|     44|    nbits = a_nbits[sfc_mode] + LDAC_SFCMODEBITS;
  ------------------
  |  |  116|     44|#define LDAC_SFCMODEBITS       1
  ------------------
  252|       |
  253|     44|    return nbits;
  254|     44|}
ldaclib.c:encode_scale_factor_0_ldac:
   89|     44|{
   90|     44|    HCENC *p_hcsf;
   91|     44|    int iqu, iwt;
   92|     44|    int nqus = p_ac->p_ab->nqus;
   93|     44|    int nbits = LDAC_MAXBITNUM;
  ------------------
  |  |  142|     44|#define LDAC_MAXBITNUM      8192
  ------------------
   94|     44|    int bitlen, vmin, vmax, val0, val1;
   95|     44|    int *p_idsf = p_ac->a_idsf;
   96|     44|    int *p_idsf_dif = p_ac->a_tmp;
   97|     44|    const unsigned char *p_tbl;
   98|       |
   99|    396|    for (iwt = 0; iwt < LDAC_NSFCWTBL; iwt++) {
  ------------------
  |  |  119|    396|#define LDAC_NSFCWTBL          8
  ------------------
  |  Branch (99:19): [True: 352, False: 44]
  ------------------
  100|    352|        p_tbl = gaa_sfcwgt_ldac[iwt];
  101|    352|        vmin = vmax = val0 = p_idsf[0] + p_tbl[0];
  102|  9.15k|        for (iqu = 1; iqu < nqus; iqu++) {
  ------------------
  |  Branch (102:23): [True: 8.80k, False: 352]
  ------------------
  103|  8.80k|            val1 = p_idsf[iqu] + p_tbl[iqu];
  104|  8.80k|            if (vmin > val1) {
  ------------------
  |  Branch (104:17): [True: 66, False: 8.73k]
  ------------------
  105|     66|                vmin = val1;
  106|     66|            }
  107|  8.80k|            if (vmax < val1) {
  ------------------
  |  Branch (107:17): [True: 2.81k, False: 5.98k]
  ------------------
  108|  2.81k|                vmax = val1;
  109|  2.81k|            }
  110|  8.80k|            p_idsf_dif[iqu] = val1 - val0;
  111|  8.80k|            val0 = val1;
  112|  8.80k|        }
  113|       |
  114|    352|        val1 = bitlen = sa_bitlen_maxdif_0_ldac[(vmax-vmin)>>1];
  115|    352|        p_hcsf = ga_hcenc_sf0_ldac + (bitlen-LDAC_MINSFCBLEN_0);
  ------------------
  |  |  121|    352|#define LDAC_MINSFCBLEN_0      3
  ------------------
  116|  9.15k|        for (iqu = 1; iqu < nqus; iqu++) {
  ------------------
  |  Branch (116:23): [True: 8.80k, False: 352]
  ------------------
  117|  8.80k|            val0 = p_idsf_dif[iqu] & p_hcsf->mask;
  118|  8.80k|            val1 += hc_len_ldac(p_hcsf->p_tbl+val0);
  ------------------
  |  |  279|  8.80k|#define hc_len_ldac(p)  ((p)->len)
  ------------------
  119|  8.80k|        }
  120|       |
  121|    352|        if (nbits > val1) {
  ------------------
  |  Branch (121:13): [True: 110, False: 242]
  ------------------
  122|    110|            p_sfcinf->bitlen = bitlen;
  123|    110|            p_sfcinf->offset = vmin;
  124|    110|            p_sfcinf->weight = iwt;
  125|    110|            nbits = val1;
  126|    110|        }
  127|    352|    }
  128|     44|    nbits += LDAC_SFCBLENBITS + LDAC_IDSFBITS + LDAC_SFCWTBLBITS;
  ------------------
  |  |  120|     44|#define LDAC_SFCBLENBITS       2
  ------------------
                  nbits += LDAC_SFCBLENBITS + LDAC_IDSFBITS + LDAC_SFCWTBLBITS;
  ------------------
  |  |  114|     44|#define LDAC_IDSFBITS          5
  ------------------
                  nbits += LDAC_SFCBLENBITS + LDAC_IDSFBITS + LDAC_SFCWTBLBITS;
  ------------------
  |  |  118|     44|#define LDAC_SFCWTBLBITS       3
  ------------------
  129|       |
  130|     44|    return nbits;
  131|     44|}
ldaclib.c:encode_scale_factor_1_ldac:
  143|     44|{
  144|     44|    int iqu, iwt;
  145|     44|    int nqus = p_ac->p_ab->nqus;
  146|     44|    int nbits = LDAC_MAXBITNUM;
  ------------------
  |  |  142|     44|#define LDAC_MAXBITNUM      8192
  ------------------
  147|     44|    int bitlen, vmin, vmax, val;
  148|     44|    int *p_idsf = p_ac->a_idsf;
  149|     44|    const unsigned char *p_tbl;
  150|       |
  151|    396|    for (iwt = 0; iwt < LDAC_NSFCWTBL; iwt++) {
  ------------------
  |  |  119|    396|#define LDAC_NSFCWTBL          8
  ------------------
  |  Branch (151:19): [True: 352, False: 44]
  ------------------
  152|    352|        p_tbl = gaa_sfcwgt_ldac[iwt];
  153|    352|        vmin = vmax = p_idsf[0] + p_tbl[0];
  154|  9.15k|        for (iqu = 1; iqu < nqus; iqu++) {
  ------------------
  |  Branch (154:23): [True: 8.80k, False: 352]
  ------------------
  155|  8.80k|            val = p_idsf[iqu] + p_tbl[iqu];
  156|  8.80k|            if (vmin > val) {
  ------------------
  |  Branch (156:17): [True: 66, False: 8.73k]
  ------------------
  157|     66|                vmin = val;
  158|     66|            }
  159|  8.80k|            if (vmax < val) {
  ------------------
  |  Branch (159:17): [True: 2.81k, False: 5.98k]
  ------------------
  160|  2.81k|                vmax = val;
  161|  2.81k|            }
  162|  8.80k|        }
  163|       |
  164|    352|        bitlen = sa_bitlen_maxdif_1_ldac[(vmax-vmin)>>1];
  165|    352|        if (bitlen > 4) {
  ------------------
  |  Branch (165:13): [True: 0, False: 352]
  ------------------
  166|      0|            val = LDAC_SFCBLENBITS;
  ------------------
  |  |  120|      0|#define LDAC_SFCBLENBITS       2
  ------------------
  167|      0|        }
  168|    352|        else {
  169|    352|            val = LDAC_SFCBLENBITS + LDAC_IDSFBITS + LDAC_SFCWTBLBITS;
  ------------------
  |  |  120|    352|#define LDAC_SFCBLENBITS       2
  ------------------
                          val = LDAC_SFCBLENBITS + LDAC_IDSFBITS + LDAC_SFCWTBLBITS;
  ------------------
  |  |  114|    352|#define LDAC_IDSFBITS          5
  ------------------
                          val = LDAC_SFCBLENBITS + LDAC_IDSFBITS + LDAC_SFCWTBLBITS;
  ------------------
  |  |  118|    352|#define LDAC_SFCWTBLBITS       3
  ------------------
  170|    352|        }
  171|    352|        val += bitlen * nqus;
  172|       |
  173|    352|        if (nbits > val) {
  ------------------
  |  Branch (173:13): [True: 44, False: 308]
  ------------------
  174|     44|            p_sfcinf->bitlen = bitlen;
  175|     44|            p_sfcinf->offset = vmin;
  176|     44|            p_sfcinf->weight = iwt;
  177|     44|            nbits = val;
  178|     44|        }
  179|    352|    }
  180|       |
  181|     44|    return nbits;
  182|     44|}
ldaclib.c:get_minimum_id_ldac:
   56|     44|{
   57|     44|    int i;
   58|     44|    int id, nbits;
   59|       |
   60|     44|    id = 0;
   61|     44|    nbits = p_nbits[0];
   62|       |
   63|     88|    for (i = 1; i < n; i++) {
  ------------------
  |  Branch (63:17): [True: 44, False: 44]
  ------------------
   64|     44|        if (nbits > p_nbits[i]) {
  ------------------
  |  Branch (64:13): [True: 0, False: 44]
  ------------------
   65|      0|            id = i;
   66|      0|            nbits = p_nbits[i];
   67|      0|        }
   68|     44|    }
   69|       |
   70|     44|    return id;
   71|     44|}
ldaclib.c:calc_add_word_length_ldac:
  286|     44|{
  287|     44|    int iqu;
  288|     44|    int nqus = p_ac->p_ab->nqus;
  289|     44|    int dif;
  290|     44|    int *p_idsf = p_ac->a_idsf;
  291|     44|    int *p_addwl = p_ac->a_addwl;
  292|       |
  293|     44|    clear_data_ldac(p_addwl, LDAC_MAXNQUS*sizeof(int));
  ------------------
  |  |   61|     44|#define clear_data_ldac(p, n)      memset((p), 0, (n))
  ------------------
  294|       |
  295|     44|    if (p_ac->p_ab->grad_mode != LDAC_MODE_0) {
  ------------------
  |  |  150|     44|#define LDAC_MODE_0            0
  ------------------
  |  Branch (295:9): [True: 0, False: 44]
  ------------------
  296|      0|        for (iqu = 1; iqu < nqus; iqu++) {
  ------------------
  |  Branch (296:23): [True: 0, False: 0]
  ------------------
  297|      0|            dif = p_idsf[iqu] - p_idsf[iqu-1];
  298|       |
  299|      0|            if (dif > 0) {
  ------------------
  |  Branch (299:17): [True: 0, False: 0]
  ------------------
  300|      0|                if (dif > 5) {
  ------------------
  |  Branch (300:21): [True: 0, False: 0]
  ------------------
  301|      0|                    p_addwl[iqu] += 5;
  302|      0|                }
  303|      0|                else if (dif > 4) {
  ------------------
  |  Branch (303:26): [True: 0, False: 0]
  ------------------
  304|      0|                    p_addwl[iqu] += 4;
  305|      0|                }
  306|      0|                else if (dif > 3) {
  ------------------
  |  Branch (306:26): [True: 0, False: 0]
  ------------------
  307|      0|                    p_addwl[iqu] += 3;
  308|      0|                }
  309|      0|                else if (dif > 2) {
  ------------------
  |  Branch (309:26): [True: 0, False: 0]
  ------------------
  310|      0|                    p_addwl[iqu] += 2;
  311|      0|                }
  312|      0|                else if (dif > 1) {
  ------------------
  |  Branch (312:26): [True: 0, False: 0]
  ------------------
  313|      0|                    p_addwl[iqu] += 1;
  314|      0|                }
  315|      0|            }
  316|      0|            else {
  317|      0|                if (dif < -5) {
  ------------------
  |  Branch (317:21): [True: 0, False: 0]
  ------------------
  318|      0|                    p_addwl[iqu-1] += 5;
  319|      0|                }
  320|      0|                else if (dif < -4) {
  ------------------
  |  Branch (320:26): [True: 0, False: 0]
  ------------------
  321|      0|                    p_addwl[iqu-1] += 4;
  322|      0|                }
  323|      0|                else if (dif < -3) {
  ------------------
  |  Branch (323:26): [True: 0, False: 0]
  ------------------
  324|      0|                    p_addwl[iqu-1] += 3;
  325|      0|                }
  326|      0|                else if (dif < -2) {
  ------------------
  |  Branch (326:26): [True: 0, False: 0]
  ------------------
  327|      0|                    p_addwl[iqu-1] += 2;
  328|      0|                }
  329|      0|                else if (dif < -1) {
  ------------------
  |  Branch (329:26): [True: 0, False: 0]
  ------------------
  330|      0|                    p_addwl[iqu-1] += 1;
  331|      0|                }
  332|      0|            }
  333|      0|        }
  334|      0|    }
  335|       |
  336|     44|    return;
  337|     44|}

ldaclib.c:init_encode_ldac:
   65|     22|{
   66|     22|    LDAC_RESULT result = LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
   67|     22|    CFG *p_cfg = &p_sfinfo->cfg;
   68|     22|    AB *p_ab;
   69|     22|    int ibk, ich;
   70|     22|    int blk_type, blk_nchs;
   71|     22|    int ch_offset = 0;
   72|     22|    int chconfig_id = p_cfg->chconfig_id;
   73|     22|    int nbks = gaa_block_setting_ldac[chconfig_id][1];
   74|       |
   75|     22|    if (alloc_encode_ldac(p_sfinfo) == LDAC_E_FAIL) {
  ------------------
  |  |   38|     22|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  |  Branch (75:9): [True: 0, False: 22]
  ------------------
   76|      0|        p_sfinfo->error_code = LDAC_ERR_ALLOC_MEMORY;
  ------------------
  |  |  130|      0|#define LDAC_ERR_ALLOC_MEMORY             300
  ------------------
   77|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
   78|      0|    }
   79|       |
   80|     22|    p_sfinfo->error_code = LDAC_ERR_NONE;
  ------------------
  |  |  103|     22|#define LDAC_ERR_NONE                       0
  ------------------
   81|     22|    p_cfg->frame_status = LDAC_FRMSTAT_LEV_0;
  ------------------
  |  |   59|     22|#define LDAC_FRMSTAT_LEV_0     0
  ------------------
   82|       |
   83|       |    /* Set AB information */
   84|     22|    p_ab = p_sfinfo->p_ab;
   85|     66|    for (ibk = 0; ibk < nbks; ibk++){
  ------------------
  |  Branch (85:19): [True: 44, False: 22]
  ------------------
   86|     44|        p_ab->blk_type = blk_type = gaa_block_setting_ldac[chconfig_id][ibk+2];
   87|     44|        p_ab->blk_nchs = blk_nchs = get_block_nchs_ldac(blk_type);
   88|     44|        p_ab->p_smplrate_id = &p_cfg->smplrate_id;
   89|     44|        p_ab->p_error_code = &p_sfinfo->error_code;
   90|       |
   91|       |        /* Set AC Information */
   92|     88|        for (ich = 0; ich < blk_nchs; ich++) {
  ------------------
  |  Branch (92:23): [True: 44, False: 44]
  ------------------
   93|     44|            p_ab->ap_ac[ich] = p_sfinfo->ap_ac[ch_offset++];
   94|     44|            p_ab->ap_ac[ich]->p_ab = p_ab;
   95|     44|            p_ab->ap_ac[ich]->ich = ich;
   96|     44|            p_ab->ap_ac[ich]->frmana_cnt = 0;
   97|     44|        }
   98|       |
   99|     44|        p_ab++;
  100|     44|    }
  101|       |
  102|     22|    calc_initial_bits_ldac(p_sfinfo);
  103|       |
  104|     22|    return result;
  105|     22|}
ldaclib.c:alloc_encode_ldac:
   24|     22|{
   25|     22|    LDAC_RESULT result = LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
   26|     22|    CFG *p_cfg = &p_sfinfo->cfg;
   27|     22|    int ich;
   28|     22|    int nchs = p_cfg->ch;
   29|     22|    int nbks = gaa_block_setting_ldac[p_cfg->chconfig_id][1];
   30|       |
   31|       |    /* Allocate AC */
   32|     66|    for (ich = 0; ich < nchs; ich++) {
  ------------------
  |  Branch (32:19): [True: 44, False: 22]
  ------------------
   33|     44|        p_sfinfo->ap_ac[ich] = (AC *)calloc_ldac(p_sfinfo, 1, sizeof(AC));
   34|     44|        if (p_sfinfo->ap_ac[ich] != (AC *)NULL) {
  ------------------
  |  Branch (34:13): [True: 44, False: 0]
  ------------------
   35|     44|            p_sfinfo->ap_ac[ich]->p_acsub = (ACSUB *)calloc_ldac(p_sfinfo, 1, sizeof(ACSUB));
   36|     44|            if (p_sfinfo->ap_ac[ich]->p_acsub == (ACSUB *)NULL) {
  ------------------
  |  Branch (36:17): [True: 0, False: 44]
  ------------------
   37|      0|                result = LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
   38|      0|                break;
   39|      0|            }
   40|     44|        }
   41|      0|        else {
   42|      0|            result = LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
   43|      0|            break;
   44|      0|        }
   45|     44|    }
   46|       |
   47|     22|    if (result != LDAC_S_OK) {
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  |  Branch (47:9): [True: 0, False: 22]
  ------------------
   48|      0|        return result;
   49|      0|    }
   50|       |
   51|       |    /* Allocate AB */
   52|     22|    p_sfinfo->p_ab = (AB *)calloc_ldac(p_sfinfo, nbks, sizeof(AB));
   53|     22|    if (p_sfinfo->p_ab == (AB *)NULL) {
  ------------------
  |  Branch (53:9): [True: 0, False: 22]
  ------------------
   54|      0|        result = LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
   55|      0|    }
   56|       |
   57|     22|    return result;
   58|     22|}
ldaclib.c:calc_initial_bits_ldac:
  112|     22|{
  113|     22|    CFG *p_cfg = &p_sfinfo->cfg;
  114|     22|    AB *p_ab = p_sfinfo->p_ab;
  115|     22|    int ibk;
  116|     22|    int blk_type;
  117|     22|    int nbits_ab, nbits_ac;
  118|     22|    int chconfig_id = p_cfg->chconfig_id;
  119|     22|    int nbks = gaa_block_setting_ldac[chconfig_id][1];
  120|       |
  121|     22|    nbits_ac = p_cfg->frame_length * LDAC_BYTESIZE / p_cfg->ch;
  ------------------
  |  |  141|     22|#define LDAC_BYTESIZE          8
  ------------------
  122|       |
  123|     66|    for (ibk = 0; ibk < nbks; ibk++){
  ------------------
  |  Branch (123:19): [True: 44, False: 22]
  ------------------
  124|     44|        blk_type = gaa_block_setting_ldac[chconfig_id][ibk+2];
  125|       |
  126|     44|        if (blk_type == LDAC_BLKID_STEREO){
  ------------------
  |  |   98|     44|#define LDAC_BLKID_STEREO      1
  ------------------
  |  Branch (126:13): [True: 0, False: 44]
  ------------------
  127|      0|            nbits_ab = (nbits_ac * 2 / LDAC_BYTESIZE) * LDAC_BYTESIZE;
  ------------------
  |  |  141|      0|#define LDAC_BYTESIZE          8
  ------------------
                          nbits_ab = (nbits_ac * 2 / LDAC_BYTESIZE) * LDAC_BYTESIZE;
  ------------------
  |  |  141|      0|#define LDAC_BYTESIZE          8
  ------------------
  128|      0|        }
  129|     44|        else{
  130|     44|            nbits_ab = (nbits_ac / LDAC_BYTESIZE) * LDAC_BYTESIZE;
  ------------------
  |  |  141|     44|#define LDAC_BYTESIZE          8
  ------------------
                          nbits_ab = (nbits_ac / LDAC_BYTESIZE) * LDAC_BYTESIZE;
  ------------------
  |  |  141|     44|#define LDAC_BYTESIZE          8
  ------------------
  131|     44|        }
  132|     44|        p_ab->nbits_ab = nbits_ab;
  133|       |
  134|     44|        p_ab++;
  135|     44|    }
  136|       |
  137|     22|    return;
  138|     22|}
ldaclib.c:free_encode_ldac:
  145|     22|{
  146|     22|    int ich;
  147|     22|    int nchs = p_sfinfo->cfg.ch;
  148|       |
  149|       |    /* Free AB */
  150|     22|    if (p_sfinfo->p_ab != (AB *)NULL) {
  ------------------
  |  Branch (150:9): [True: 22, False: 0]
  ------------------
  151|     22|        free(p_sfinfo->p_ab);
  152|     22|        p_sfinfo->p_ab = (AB *)NULL;
  153|     22|    }
  154|       |
  155|       |    /* Free AC */
  156|     66|    for (ich = 0; ich < nchs; ich++) {
  ------------------
  |  Branch (156:19): [True: 44, False: 22]
  ------------------
  157|     44|        if (p_sfinfo->ap_ac[ich] != (AC *)NULL) {
  ------------------
  |  Branch (157:13): [True: 44, False: 0]
  ------------------
  158|     44|            if (p_sfinfo->ap_ac[ich]->p_acsub != (ACSUB *)NULL) {
  ------------------
  |  Branch (158:17): [True: 44, False: 0]
  ------------------
  159|     44|                free(p_sfinfo->ap_ac[ich]->p_acsub);
  160|     44|                p_sfinfo->ap_ac[ich]->p_acsub = (ACSUB *)NULL;
  161|     44|            }
  162|     44|            free(p_sfinfo->ap_ac[ich]);
  163|     44|            p_sfinfo->ap_ac[ich] = (AC *)NULL;
  164|     44|        }
  165|     44|    }
  166|       |
  167|     22|    return;
  168|     22|}
ldaclib.c:encode_ldac:
  213|     22|{
  214|     22|    AB *p_ab = p_sfinfo->p_ab;
  215|     22|    int ibk;
  216|     22|    int nbks = gaa_block_setting_ldac[p_sfinfo->cfg.chconfig_id][1];
  217|       |
  218|     66|    for (ibk = 0; ibk < nbks; ibk++){
  ------------------
  |  Branch (218:19): [True: 44, False: 22]
  ------------------
  219|     44|        p_ab->nbands = nbands;
  220|     44|        p_ab->nqus = ga_nqus_ldac[nbands];
  221|     44|        p_ab->grad_mode = grad_mode;
  222|     44|        p_ab->grad_qu_l = grad_qu_l;
  223|     44|        p_ab->grad_qu_h = grad_qu_h;
  224|     44|        p_ab->grad_os_l = grad_os_l;
  225|     44|        p_ab->grad_os_h = grad_os_h;
  226|     44|        p_ab->abc_status = abc_status;
  227|       |
  228|     44|        if (!encode_audio_block_ldac(p_ab)) {
  ------------------
  |  Branch (228:13): [True: 0, False: 44]
  ------------------
  229|      0|            return LDAC_ERR_NON_FATAL_ENCODE;
  ------------------
  |  |  113|      0|#define LDAC_ERR_NON_FATAL_ENCODE         132
  ------------------
  230|      0|        }
  231|       |
  232|     44|        p_ab++;
  233|     44|    }
  234|       |
  235|     22|    return LDAC_ERR_NONE;
  ------------------
  |  |  103|     22|#define LDAC_ERR_NONE                       0
  ------------------
  236|     22|}
ldaclib.c:encode_audio_block_ldac:
  175|     44|{
  176|     44|    AC *p_ac;
  177|     44|    int ich;
  178|     44|    int nchs = p_ab->blk_nchs;
  179|       |
  180|     88|    for (ich = 0; ich < nchs; ich++) {
  ------------------
  |  Branch (180:19): [True: 44, False: 44]
  ------------------
  181|     44|        p_ac = p_ab->ap_ac[ich];
  182|       |
  183|     44|        norm_spectrum_ldac(p_ac);
  184|     44|    }
  185|       |
  186|     44|    if (!alloc_bits_ldac(p_ab)) {
  ------------------
  |  Branch (186:9): [True: 0, False: 44]
  ------------------
  187|      0|        return LDAC_FALSE;
  ------------------
  |  |  147|      0|#define LDAC_FALSE             0
  ------------------
  188|      0|    }
  189|       |
  190|     88|    for (ich = 0; ich < nchs; ich++) {
  ------------------
  |  Branch (190:19): [True: 44, False: 44]
  ------------------
  191|     44|        p_ac = p_ab->ap_ac[ich];
  192|       |
  193|     44|        quant_spectrum_ldac(p_ac);
  194|       |
  195|     44|        quant_residual_ldac(p_ac);
  196|     44|    }
  197|       |
  198|     44|    return LDAC_TRUE;
  ------------------
  |  |  146|     44|#define LDAC_TRUE              1
  ------------------
  199|     44|}

ldacBT_get_version:
   25|     22|{
   26|     22|    return ((LDACBT_LIB_VER_MAJOR)<<16)|((LDACBT_LIB_VER_MINOR)<<8)|(LDACBT_LIB_VER_BRANCH);
  ------------------
  |  |   21|     22|#define LDACBT_LIB_VER_MAJOR   2
  ------------------
                  return ((LDACBT_LIB_VER_MAJOR)<<16)|((LDACBT_LIB_VER_MINOR)<<8)|(LDACBT_LIB_VER_BRANCH);
  ------------------
  |  |   22|     22|#define LDACBT_LIB_VER_MINOR   0
  ------------------
                  return ((LDACBT_LIB_VER_MAJOR)<<16)|((LDACBT_LIB_VER_MINOR)<<8)|(LDACBT_LIB_VER_BRANCH);
  ------------------
  |  |   23|     22|#define LDACBT_LIB_VER_BRANCH  2
  ------------------
   27|     22|}
ldacBT_get_handle:
   31|     22|{
   32|     22|    HANDLE_LDAC_BT hLdacBT;
   33|     22|    hLdacBT = (HANDLE_LDAC_BT)malloc( sizeof(STRUCT_LDACBT_HANDLE) );
   34|     22|    if( hLdacBT == NULL ){ return NULL; }
  ------------------
  |  Branch (34:9): [True: 0, False: 22]
  ------------------
   35|       |
   36|       |    /* Get ldaclib Handler */
   37|     22|    if( (hLdacBT->hLDAC = ldaclib_get_handle()) == NULL ){
  ------------------
  |  Branch (37:9): [True: 0, False: 22]
  ------------------
   38|      0|        ldacBT_free_handle( hLdacBT );
   39|      0|        return NULL;
   40|      0|    }
   41|       |
   42|     22|    ldacBT_param_clear( hLdacBT );
   43|     22|    return hLdacBT;
   44|     22|}
ldacBT_free_handle:
   48|     22|{
   49|     22|    if( hLdacBT == NULL ){ return; }
  ------------------
  |  Branch (49:9): [True: 0, False: 22]
  ------------------
   50|       |
   51|     22|    if( hLdacBT->hLDAC != NULL ){
  ------------------
  |  Branch (51:9): [True: 22, False: 0]
  ------------------
   52|       |        /* close ldaclib handle */
   53|     22|        if( hLdacBT->proc_mode == LDACBT_PROCMODE_ENCODE ){
  ------------------
  |  Branch (53:13): [True: 0, False: 22]
  ------------------
   54|      0|            ldaclib_free_encode( hLdacBT->hLDAC );
   55|      0|        }
   56|       |        /* free ldaclib handle */
   57|     22|        ldaclib_free_handle( hLdacBT->hLDAC );
   58|     22|        hLdacBT->hLDAC = NULL;
   59|     22|    }
   60|       |    /* free ldacbt handle */
   61|     22|    free( hLdacBT );
   62|     22|}
ldacBT_close_handle:
   66|     44|{
   67|     44|    if( hLdacBT == NULL ){ return; }
  ------------------
  |  Branch (67:9): [True: 0, False: 44]
  ------------------
   68|       |
   69|     44|    if( hLdacBT->hLDAC != NULL ){
  ------------------
  |  Branch (69:9): [True: 44, False: 0]
  ------------------
   70|       |        /* close ldaclib handle */
   71|     44|        if( hLdacBT->proc_mode == LDACBT_PROCMODE_ENCODE ){
  ------------------
  |  Branch (71:13): [True: 22, False: 22]
  ------------------
   72|     22|            ldaclib_free_encode( hLdacBT->hLDAC );
   73|     22|        }
   74|       |        /* clear error code */
   75|     44|        ldaclib_clear_error_code(hLdacBT->hLDAC);
   76|     44|        ldaclib_clear_internal_error_code(hLdacBT->hLDAC);
   77|     44|    }
   78|       |    /* clear ldacbt handle */
   79|     44|    ldacBT_param_clear( hLdacBT );
   80|     44|}
ldacBT_get_sampling_freq:
  102|     22|{
  103|     22|    if( hLdacBT == NULL ){
  ------------------
  |  Branch (103:9): [True: 0, False: 22]
  ------------------
  104|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  105|      0|    }
  106|     22|    if( hLdacBT->proc_mode != LDACBT_PROCMODE_ENCODE )
  ------------------
  |  Branch (106:9): [True: 0, False: 22]
  ------------------
  107|      0|    {
  108|      0|        hLdacBT->error_code_api = LDACBT_ERR_HANDLE_NOT_INIT;
  ------------------
  |  |  447|      0|#define LDACBT_ERR_HANDLE_NOT_INIT          1000
  ------------------
  109|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  110|      0|    }
  111|     22|    return hLdacBT->pcm.sf;
  112|     22|}
ldacBT_get_bitrate:
  116|     22|{
  117|     22|    if( hLdacBT == NULL ){
  ------------------
  |  Branch (117:9): [True: 0, False: 22]
  ------------------
  118|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  119|      0|    }
  120|     22|    if( hLdacBT->proc_mode != LDACBT_PROCMODE_ENCODE )
  ------------------
  |  Branch (120:9): [True: 0, False: 22]
  ------------------
  121|      0|    {
  122|      0|        hLdacBT->error_code_api = LDACBT_ERR_HANDLE_NOT_INIT;
  ------------------
  |  |  447|      0|#define LDACBT_ERR_HANDLE_NOT_INIT          1000
  ------------------
  123|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  124|      0|    }
  125|     22|    return hLdacBT->bitrate;
  126|     22|}
ldacBT_init_handle_encode:
  131|     22|{
  132|     22|    LDAC_RESULT result;
  133|     22|    int sfid, frame_samples, cci;
  134|     22|    int nbasebands, grad_mode, grad_qu_l, grad_qu_h, grad_ofst_l, grad_ofst_h, abc_flag;
  135|     22|    P_LDACBT_CONFIG pCfg;
  136|     22|    const int a_cci_nch[] = { 1, 2, 2 };
  137|       |
  138|       |    /* check arguments */
  139|     22|    if( hLdacBT == NULL ){ return LDACBT_E_FAIL; }
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  |  Branch (139:9): [True: 0, False: 22]
  ------------------
  140|     22|    if( (hLdacBT->error_code_api = ldacBT_assert_mtu( mtu )) != LDACBT_ERR_NONE ){
  ------------------
  |  |  380|     22|#define LDACBT_ERR_NONE                     0
  ------------------
  |  Branch (140:9): [True: 0, False: 22]
  ------------------
  141|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  142|      0|    }
  143|     22|    if( (hLdacBT->error_code_api = ldacBT_assert_eqmid( eqmid )) != LDACBT_ERR_NONE ){
  ------------------
  |  |  380|     22|#define LDACBT_ERR_NONE                     0
  ------------------
  |  Branch (143:9): [True: 0, False: 22]
  ------------------
  144|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  145|      0|    }
  146|     22|    if( (hLdacBT->error_code_api = ldacBT_assert_cm( cm )) != LDACBT_ERR_NONE ){
  ------------------
  |  |  380|     22|#define LDACBT_ERR_NONE                     0
  ------------------
  |  Branch (146:9): [True: 0, False: 22]
  ------------------
  147|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  148|      0|    }
  149|     22|    if( (hLdacBT->error_code_api = ldacBT_assert_sample_format( fmt )) != LDACBT_ERR_NONE ){
  ------------------
  |  |  380|     22|#define LDACBT_ERR_NONE                     0
  ------------------
  |  Branch (149:9): [True: 0, False: 22]
  ------------------
  150|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  151|      0|    }
  152|     22|    if( (hLdacBT->error_code_api = ldacBT_assert_pcm_sampling_freq( sf )) != LDACBT_ERR_NONE ){
  ------------------
  |  |  380|     22|#define LDACBT_ERR_NONE                     0
  ------------------
  |  Branch (152:9): [True: 0, False: 22]
  ------------------
  153|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  154|      0|    }
  155|       |
  156|     22|    ldacBT_close_handle( hLdacBT );
  157|       |
  158|       |    /* initialize handle for encode processing */
  159|     22|    hLdacBT->proc_mode = LDACBT_PROCMODE_ENCODE;
  160|     22|    hLdacBT->flg_encode_flushed = FALSE;
  ------------------
  |  |   73|     22|#define FALSE  0
  ------------------
  161|       |
  162|       |    /* transport setting */
  163|       |    /* The ldac frame header is REQUIRED for A2DP streaming. */
  164|     22|    hLdacBT->transport = TRUE;
  ------------------
  |  |   76|     22|#define TRUE   1
  ------------------
  165|     22|    hLdacBT->tx.mtu = mtu;
  166|     22|    hLdacBT->tx.pkt_hdr_sz = LDACBT_TX_HEADER_SIZE;
  ------------------
  |  |   54|     22|#define LDACBT_TX_HEADER_SIZE 18
  ------------------
  167|     22|    hLdacBT->tx.tx_size = LDACBT_MTU_REQUIRED;
  ------------------
  |  |   56|     22|#define LDACBT_MTU_REQUIRED  679
  ------------------
  168|     22|    hLdacBT->tx.pkt_type = _2_DH5;
  169|       |    /* - BT TRANS HEADER etc */
  170|     22|    hLdacBT->tx.tx_size -= hLdacBT->tx.pkt_hdr_sz;
  171|     22|    if( hLdacBT->tx.tx_size > (hLdacBT->tx.mtu - hLdacBT->tx.pkt_hdr_sz) ){
  ------------------
  |  Branch (171:9): [True: 0, False: 22]
  ------------------
  172|       |        /* never happen, mtu must be larger than LDACBT_MTU_REQUIRED(2DH5) */
  173|      0|        hLdacBT->tx.tx_size = (hLdacBT->tx.mtu - hLdacBT->tx.pkt_hdr_sz);
  174|      0|    }
  175|       |
  176|       |    /* channel configration */
  177|     22|    cci = ldacBT_cm_to_cci(cm);
  178|     22|    hLdacBT->cm = cm;
  179|     22|    hLdacBT->cci = cci;
  180|       |    /* input pcm configuration */
  181|     22|    hLdacBT->pcm.ch = a_cci_nch[cci];
  182|     22|    hLdacBT->pcm.sf = sf;
  183|     22|    hLdacBT->pcm.fmt = fmt;
  184|     22|    switch(hLdacBT->pcm.fmt){
  185|     22|      case LDACBT_SMPL_FMT_S16:
  ------------------
  |  Branch (185:7): [True: 22, False: 0]
  ------------------
  186|     22|        hLdacBT->pcm.wl = 2;
  187|     22|        break;
  188|      0|      case LDACBT_SMPL_FMT_S24:
  ------------------
  |  Branch (188:7): [True: 0, False: 22]
  ------------------
  189|      0|        hLdacBT->pcm.wl = 3;
  190|      0|        break;
  191|      0|      case LDACBT_SMPL_FMT_S32:
  ------------------
  |  Branch (191:7): [True: 0, False: 22]
  ------------------
  192|      0|      case LDACBT_SMPL_FMT_F32:
  ------------------
  |  Branch (192:7): [True: 0, False: 22]
  ------------------
  193|      0|        hLdacBT->pcm.wl = 4;
  194|      0|        break;
  195|      0|      default:
  ------------------
  |  Branch (195:7): [True: 0, False: 22]
  ------------------
  196|       |        // must be rejected by ldacBT_assert_sample_format()
  197|      0|        hLdacBT->pcm.wl = 4;
  198|      0|        break;
  199|     22|    }
  200|       |
  201|       |    /* initilize ldac encode */
  202|       |    /* Get sampling frequency index */
  203|     22|    result = ldaclib_get_sampling_rate_index( hLdacBT->pcm.sf, &sfid );
  204|     22|    if( LDAC_FAILED ( result ) ){
  ------------------
  |  |   42|     22|#define LDAC_FAILED(result)    ((LDAC_RESULT)(result)<0)
  |  |  ------------------
  |  |  |  Branch (42:32): [True: 0, False: 22]
  |  |  ------------------
  ------------------
  205|      0|        hLdacBT->error_code_api = LDACBT_ERR_ILL_SAMPLING_FREQ;
  ------------------
  |  |  449|      0|#define LDACBT_ERR_ILL_SAMPLING_FREQ        1025
  ------------------
  206|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  207|      0|    }
  208|     22|    hLdacBT->sfid = sfid;
  209|       |
  210|       |    /* Get number of frame samples */
  211|     22|    result = ldaclib_get_frame_samples(sfid, &frame_samples);
  212|     22|    if (LDAC_FAILED(result)) {
  ------------------
  |  |   42|     22|#define LDAC_FAILED(result)    ((LDAC_RESULT)(result)<0)
  |  |  ------------------
  |  |  |  Branch (42:32): [True: 0, False: 22]
  |  |  ------------------
  ------------------
  213|      0|        hLdacBT->error_code_api = LDACBT_ERR_ILL_SAMPLING_FREQ;
  ------------------
  |  |  449|      0|#define LDACBT_ERR_ILL_SAMPLING_FREQ        1025
  ------------------
  214|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  215|      0|    }
  216|     22|    hLdacBT->frm_samples = frame_samples;
  217|       |
  218|       |
  219|       |    /* Set Parameters by Encode Quality Mode Index */
  220|     22|    hLdacBT->eqmid = eqmid;
  221|       |    /* get frame_length of EQMID */
  222|     22|    pCfg = ldacBT_get_config( hLdacBT->eqmid, hLdacBT->tx.pkt_type );
  223|       |    /* set frame_length */
  224|     22|    hLdacBT->frmlen_tx = hLdacBT->pcm.ch * pCfg->frmlen_1ch;
  225|     22|    hLdacBT->frmlen = hLdacBT->frmlen_tx;
  226|     22|    if (hLdacBT->transport) {
  ------------------
  |  Branch (226:9): [True: 22, False: 0]
  ------------------
  227|       |        /* Adjust frame_length for Transport Header Data */
  228|     22|        hLdacBT->frmlen -= LDACBT_FRMHDRBYTES;
  ------------------
  |  |   43|     22|#define LDACBT_FRMHDRBYTES LDAC_FRMHDRBYTES
  |  |  ------------------
  |  |  |  |   29|     22|#define LDAC_FRMHDRBYTES   3
  |  |  ------------------
  ------------------
  229|     22|    }
  230|       |
  231|       |    /* Calculate how many LDAC frames fit into payload packet */
  232|     22|    hLdacBT->tx.nfrm_in_pkt = hLdacBT->tx.tx_size / hLdacBT->frmlen_tx;
  233|       |    
  234|       |    
  235|       |    /* Get ldac encode setting */
  236|     22|    result = ldaclib_get_encode_setting( pCfg->frmlen_1ch, sfid, &nbasebands, &grad_mode,
  237|     22|                     &grad_qu_l, &grad_qu_h, &grad_ofst_l, &grad_ofst_h, &abc_flag);
  238|     22|    if (LDAC_FAILED(result)) {
  ------------------
  |  |   42|     22|#define LDAC_FAILED(result)    ((LDAC_RESULT)(result)<0)
  |  |  ------------------
  |  |  |  Branch (42:32): [True: 0, False: 22]
  |  |  ------------------
  ------------------
  239|      0|        hLdacBT->error_code_api = LDACBT_ERR_ILL_PARAM;
  ------------------
  |  |  414|      0|#define LDACBT_ERR_ILL_PARAM                518
  ------------------
  240|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  241|      0|    }
  242|       |
  243|       |    /* Set Configuration Information */
  244|     22|    result = ldaclib_set_config_info( hLdacBT->hLDAC, hLdacBT->sfid, hLdacBT->cci,
  245|     22|                                      hLdacBT->frmlen, hLdacBT->frm_status);
  246|     22|    if (LDAC_FAILED(result)) {
  ------------------
  |  |   42|     22|#define LDAC_FAILED(result)    ((LDAC_RESULT)(result)<0)
  |  |  ------------------
  |  |  |  Branch (42:32): [True: 0, False: 22]
  |  |  ------------------
  ------------------
  247|      0|        hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE;
  ------------------
  |  |   81|      0|#define LDACBT_GET_LDACLIB_ERROR_CODE   9999
  ------------------
  248|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  249|      0|    }
  250|     22|    else if (result != LDAC_S_OK) {
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  |  Branch (250:14): [True: 0, False: 22]
  ------------------
  251|      0|        hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE;
  ------------------
  |  |   81|      0|#define LDACBT_GET_LDACLIB_ERROR_CODE   9999
  ------------------
  252|      0|    }
  253|       |
  254|       |    /* Set Encoding Information */
  255|     22|    result = ldaclib_set_encode_info(hLdacBT->hLDAC, nbasebands, grad_mode,
  256|     22|                                     grad_qu_l, grad_qu_h, grad_ofst_l, grad_ofst_h, abc_flag);
  257|     22|    if (LDAC_FAILED(result)) {
  ------------------
  |  |   42|     22|#define LDAC_FAILED(result)    ((LDAC_RESULT)(result)<0)
  |  |  ------------------
  |  |  |  Branch (42:32): [True: 0, False: 22]
  |  |  ------------------
  ------------------
  258|      0|        hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE;
  ------------------
  |  |   81|      0|#define LDACBT_GET_LDACLIB_ERROR_CODE   9999
  ------------------
  259|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  260|      0|    }
  261|     22|    else if (result != LDAC_S_OK) {
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  |  Branch (261:14): [True: 0, False: 22]
  ------------------
  262|      0|        hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE;
  ------------------
  |  |   81|      0|#define LDACBT_GET_LDACLIB_ERROR_CODE   9999
  ------------------
  263|      0|    }
  264|       |
  265|       |    /* Initialize ldaclib for Encoding */
  266|     22|    result = ldaclib_init_encode(hLdacBT->hLDAC);
  267|     22|    if (LDAC_FAILED(result)) {
  ------------------
  |  |   42|     22|#define LDAC_FAILED(result)    ((LDAC_RESULT)(result)<0)
  |  |  ------------------
  |  |  |  Branch (42:32): [True: 0, False: 22]
  |  |  ------------------
  ------------------
  268|      0|        hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE;
  ------------------
  |  |   81|      0|#define LDACBT_GET_LDACLIB_ERROR_CODE   9999
  ------------------
  269|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  270|      0|    }
  271|     22|    else if (result != LDAC_S_OK) {
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  |  Branch (271:14): [True: 0, False: 22]
  ------------------
  272|      0|        hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE;
  ------------------
  |  |   81|      0|#define LDACBT_GET_LDACLIB_ERROR_CODE   9999
  ------------------
  273|      0|    }
  274|       |
  275|       |    /* reset target eqmid as current setting */
  276|     22|    hLdacBT->tgt_eqmid = hLdacBT->eqmid;
  277|     22|    hLdacBT->tgt_nfrm_in_pkt = hLdacBT->tx.nfrm_in_pkt;
  278|     22|    hLdacBT->tgt_frmlen = hLdacBT->frmlen;
  279|     22|    hLdacBT->stat_alter_op = LDACBT_ALTER_OP__NON;
  ------------------
  |  |   60|     22|#define LDACBT_ALTER_OP__NON 0
  ------------------
  280|       |
  281|       |    /* get bitrate */
  282|     22|    hLdacBT->bitrate = ldacBT_frmlen_to_bitrate( hLdacBT->frmlen, hLdacBT->transport,
  283|     22|                                                 hLdacBT->pcm.sf, hLdacBT->frm_samples );
  284|       |
  285|     22|    return (hLdacBT->error_code_api==LDACBT_ERR_NONE?LDACBT_S_OK:LDACBT_E_FAIL);
  ------------------
  |  |  380|     22|#define LDACBT_ERR_NONE                     0
  ------------------
                  return (hLdacBT->error_code_api==LDACBT_ERR_NONE?LDACBT_S_OK:LDACBT_E_FAIL);
  ------------------
  |  |   67|     22|#define LDACBT_S_OK (0)
  ------------------
                  return (hLdacBT->error_code_api==LDACBT_ERR_NONE?LDACBT_S_OK:LDACBT_E_FAIL);
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  |  Branch (285:13): [True: 22, False: 0]
  ------------------
  286|     22|}
ldacBT_encode:
  349|     22|{
  350|     22|    LDAC_RESULT result;
  351|     22|    LDACBT_SMPL_FMT_T fmt;
  352|     22|    LDACBT_TRANSPORT_FRM_BUF *ptfbuf;
  353|     22|    LDACBT_PCM_RING_BUF *ppcmring;
  354|     22|    P_LDACBT_CONFIG pCfg;
  355|     22|    int frmlen, frmlen_wrote, frmlen_adj;
  356|     22|    int frm_status, flg_Do_Encode;
  357|     22|    int nFrmToPkt, ch, wl;
  358|     22|    unsigned char *p_ldac_transport_frame;
  359|     22|    unsigned char a_frm_header[LDACBT_FRMHDRBYTES + 2];
  360|     22|    if( hLdacBT == NULL ){
  ------------------
  |  Branch (360:9): [True: 0, False: 22]
  ------------------
  361|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  362|      0|    }
  363|     22|    if( hLdacBT->hLDAC == NULL ){
  ------------------
  |  Branch (363:9): [True: 0, False: 22]
  ------------------
  364|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  365|      0|    }
  366|     22|    if( hLdacBT->proc_mode != LDACBT_PROCMODE_ENCODE ){
  ------------------
  |  Branch (366:9): [True: 0, False: 22]
  ------------------
  367|      0|        hLdacBT->error_code_api = LDACBT_ERR_HANDLE_NOT_INIT;
  ------------------
  |  |  447|      0|#define LDACBT_ERR_HANDLE_NOT_INIT          1000
  ------------------
  368|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  369|      0|    }
  370|       |    /* Clear Error Codes */
  371|     22|    hLdacBT->error_code_api = LDACBT_ERR_NONE;
  ------------------
  |  |  380|     22|#define LDACBT_ERR_NONE                     0
  ------------------
  372|     22|    ldaclib_clear_error_code( hLdacBT->hLDAC );
  373|     22|    ldaclib_clear_internal_error_code( hLdacBT->hLDAC );
  374|       |
  375|     22|    if( ( pcm_used == NULL) ||
  ------------------
  |  Branch (375:9): [True: 0, False: 22]
  ------------------
  376|     22|        ( p_stream == NULL ) ||
  ------------------
  |  Branch (376:9): [True: 0, False: 22]
  ------------------
  377|     22|        ( stream_sz == NULL ) ||
  ------------------
  |  Branch (377:9): [True: 0, False: 22]
  ------------------
  378|     22|        ( frame_num == NULL )
  ------------------
  |  Branch (378:9): [True: 0, False: 22]
  ------------------
  379|     22|        ){
  380|      0|            hLdacBT->error_code_api = LDACBT_ERR_ILL_PARAM;
  ------------------
  |  |  414|      0|#define LDACBT_ERR_ILL_PARAM                518
  ------------------
  381|      0|            return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  382|      0|    }
  383|       |    /* reset parameters */
  384|     22|    *pcm_used = 0;
  385|     22|    *stream_sz = 0;
  386|     22|    *frame_num = 0;
  387|     22|    flg_Do_Encode = 0;
  388|     22|    fmt = hLdacBT->pcm.fmt;
  389|     22|    ch = hLdacBT->pcm.ch;
  390|     22|    wl = hLdacBT->pcm.wl;
  391|     22|    ptfbuf = &hLdacBT->ldac_trns_frm_buf;
  392|     22|    ppcmring = &hLdacBT->pcmring;
  393|       |
  394|       |    /* update input pcm data */
  395|     22|    if( p_pcm != NULL ){
  ------------------
  |  Branch (395:9): [True: 22, False: 0]
  ------------------
  396|     22|        int nByteCpy, sz;
  397|     22|        nByteCpy = LDACBT_ENC_LSU * wl * ch;
  ------------------
  |  |   93|     22|#define LDACBT_ENC_LSU 128
  ------------------
  398|     22|        sz = ppcmring->nsmpl * wl * ch + nByteCpy;
  399|     22|        if( sz < LDACBT_ENC_PCM_BUF_SZ ){
  ------------------
  |  |   47|     22|#define LDACBT_ENC_PCM_BUF_SZ 6144 
  ------------------
  |  Branch (399:13): [True: 22, False: 0]
  ------------------
  400|     22|            copy_data_ldac( p_pcm, ppcmring->buf + ppcmring->wp, nByteCpy );
  ------------------
  |  |   74|     22|#define copy_data_ldac(p1, p2, n)  memcpy((p2), (p1), (n))
  ------------------
  401|     22|            ppcmring->wp += nByteCpy;
  402|     22|            if( ppcmring->wp >= LDACBT_ENC_PCM_BUF_SZ ){
  ------------------
  |  |   47|     22|#define LDACBT_ENC_PCM_BUF_SZ 6144 
  ------------------
  |  Branch (402:17): [True: 0, False: 22]
  ------------------
  403|      0|                ppcmring->wp = 0;
  404|      0|            }
  405|     22|            ppcmring->nsmpl += LDACBT_ENC_LSU;
  ------------------
  |  |   93|     22|#define LDACBT_ENC_LSU 128
  ------------------
  406|     22|            *pcm_used = nByteCpy;
  407|     22|        }else{
  408|       |            /* Not enough space to copy.
  409|       |             * This will happen when the last encode process failed.
  410|       |             */
  411|      0|            *pcm_used = 0;
  412|      0|        }
  413|       |
  414|     22|        if( ppcmring->nsmpl >= hLdacBT->frm_samples )
  ------------------
  |  Branch (414:13): [True: 22, False: 0]
  ------------------
  415|     22|        {
  416|     22|            flg_Do_Encode = 1;
  417|     22|        }
  418|     22|    }else{
  419|      0|        if (hLdacBT->flg_encode_flushed != TRUE){
  ------------------
  |  |   76|      0|#define TRUE   1
  ------------------
  |  Branch (419:13): [True: 0, False: 0]
  ------------------
  420|      0|            flg_Do_Encode = 1;
  421|      0|        }
  422|      0|    }
  423|       |
  424|     22|    if( !flg_Do_Encode ){
  ------------------
  |  Branch (424:9): [True: 0, False: 22]
  ------------------
  425|       |        /* nothing to do */
  426|      0|        return LDACBT_S_OK;
  ------------------
  |  |   67|      0|#define LDACBT_S_OK (0)
  ------------------
  427|      0|    }
  428|       |
  429|       |    /* update frame_length if needed */
  430|     22|    if( (hLdacBT->tgt_eqmid != UNSET) && (hLdacBT->tgt_eqmid != hLdacBT->eqmid) ){
  ------------------
  |  |   79|     22|#define UNSET -1
  ------------------
  |  Branch (430:9): [True: 22, False: 0]
  |  Branch (430:42): [True: 0, False: 22]
  ------------------
  431|      0|        if( ptfbuf->nfrm_in == 0 ){
  ------------------
  |  Branch (431:13): [True: 0, False: 0]
  ------------------
  432|      0|            ldacBT_update_frmlen( hLdacBT, hLdacBT->tgt_frmlen );
  433|      0|            hLdacBT->stat_alter_op = LDACBT_ALTER_OP__NON;
  ------------------
  |  |   60|      0|#define LDACBT_ALTER_OP__NON 0
  ------------------
  434|      0|        }
  435|      0|        else if( hLdacBT->tgt_nfrm_in_pkt > hLdacBT->tx.nfrm_in_pkt ){
  ------------------
  |  Branch (435:18): [True: 0, False: 0]
  ------------------
  436|       |            /* for better connectivity, apply ASAP */
  437|      0|            if( !hLdacBT->stat_alter_op ){
  ------------------
  |  Branch (437:17): [True: 0, False: 0]
  ------------------
  438|      0|                nFrmToPkt = hLdacBT->tgt_nfrm_in_pkt - ptfbuf->nfrm_in;
  439|      0|                if( nFrmToPkt > 0 ){
  ------------------
  |  Branch (439:21): [True: 0, False: 0]
  ------------------
  440|      0|                    pCfg = ldacBT_get_config(LDACBT_EQMID_END, hLdacBT->tx.pkt_type);
  441|      0|                    if( pCfg != NULL ){
  ------------------
  |  Branch (441:25): [True: 0, False: 0]
  ------------------
  442|      0|                        do{
  443|      0|                            frmlen_adj = (hLdacBT->tx.tx_size - ptfbuf->used) / nFrmToPkt;
  444|      0|                            if( frmlen_adj > hLdacBT->tgt_frmlen ) {
  ------------------
  |  Branch (444:33): [True: 0, False: 0]
  ------------------
  445|      0|                                frmlen_adj = hLdacBT->tgt_frmlen;
  446|      0|                            }
  447|      0|                            frmlen_adj -= LDACBT_FRMHDRBYTES;
  ------------------
  |  |   43|      0|#define LDACBT_FRMHDRBYTES LDAC_FRMHDRBYTES
  |  |  ------------------
  |  |  |  |   29|      0|#define LDAC_FRMHDRBYTES   3
  |  |  ------------------
  ------------------
  448|      0|                            if( frmlen_adj >= pCfg->frmlen ){
  ------------------
  |  Branch (448:33): [True: 0, False: 0]
  ------------------
  449|      0|                                if( ldacBT_update_frmlen( hLdacBT, frmlen_adj ) == LDACBT_S_OK ){
  ------------------
  |  |   67|      0|#define LDACBT_S_OK (0)
  ------------------
  |  Branch (449:37): [True: 0, False: 0]
  ------------------
  450|      0|                                    hLdacBT->stat_alter_op = LDACBT_ALTER_OP__ACTIVE;
  ------------------
  |  |   61|      0|#define LDACBT_ALTER_OP__ACTIVE 1
  ------------------
  451|      0|                                    break;
  452|      0|                                }
  453|      0|                            }
  454|      0|                        }while( --nFrmToPkt > 0 );
  ------------------
  |  Branch (454:33): [True: 0, False: 0]
  ------------------
  455|      0|                    }
  456|      0|                    if( !hLdacBT->stat_alter_op ){
  ------------------
  |  Branch (456:25): [True: 0, False: 0]
  ------------------
  457|       |                        /* force to flash streams */
  458|      0|                        hLdacBT->stat_alter_op = LDACBT_ALTER_OP__FLASH;
  ------------------
  |  |   63|      0|#define LDACBT_ALTER_OP__FLASH 9
  ------------------
  459|      0|                    }
  460|      0|                }
  461|      0|            }
  462|      0|        }
  463|      0|        else{
  464|       |            /* wait the condition ptfbuf->nfrm_in == 0 for apply new frame_length */
  465|      0|            hLdacBT->stat_alter_op = LDACBT_ALTER_OP__STANDBY;
  ------------------
  |  |   62|      0|#define LDACBT_ALTER_OP__STANDBY 2
  ------------------
  466|      0|        }
  467|       |
  468|      0|    }
  469|     22|    else if( hLdacBT->tgt_frmlen != hLdacBT->frmlen ){
  ------------------
  |  Branch (469:14): [True: 0, False: 22]
  ------------------
  470|      0|        if( ptfbuf->nfrm_in == 0 ){
  ------------------
  |  Branch (470:13): [True: 0, False: 0]
  ------------------
  471|      0|            ldacBT_update_frmlen( hLdacBT, hLdacBT->tgt_frmlen );
  472|      0|            hLdacBT->stat_alter_op = LDACBT_ALTER_OP__NON;
  ------------------
  |  |   60|      0|#define LDACBT_ALTER_OP__NON 0
  ------------------
  473|      0|        }else{
  474|      0|            if( hLdacBT->tgt_nfrm_in_pkt == hLdacBT->tx.nfrm_in_pkt ){
  ------------------
  |  Branch (474:17): [True: 0, False: 0]
  ------------------
  475|      0|                ldacBT_update_frmlen( hLdacBT, hLdacBT->tgt_frmlen );
  476|      0|                hLdacBT->stat_alter_op = LDACBT_ALTER_OP__NON;
  ------------------
  |  |   60|      0|#define LDACBT_ALTER_OP__NON 0
  ------------------
  477|      0|            }else{
  478|      0|                if( hLdacBT->tgt_nfrm_in_pkt > hLdacBT->tx.nfrm_in_pkt ){
  ------------------
  |  Branch (478:21): [True: 0, False: 0]
  ------------------
  479|       |                    /* for better connectivity, apply ASAP */
  480|      0|                    if( !hLdacBT->stat_alter_op ){
  ------------------
  |  Branch (480:25): [True: 0, False: 0]
  ------------------
  481|      0|                        nFrmToPkt = hLdacBT->tgt_nfrm_in_pkt - ptfbuf->nfrm_in;
  482|      0|                        if( nFrmToPkt > 0 ){
  ------------------
  |  Branch (482:29): [True: 0, False: 0]
  ------------------
  483|      0|                            frmlen_adj = (hLdacBT->tx.tx_size - ptfbuf->used) / nFrmToPkt;
  484|      0|                            if( frmlen_adj > hLdacBT->tgt_frmlen ) {
  ------------------
  |  Branch (484:33): [True: 0, False: 0]
  ------------------
  485|      0|                                frmlen_adj = hLdacBT->tgt_frmlen;
  486|      0|                            }
  487|      0|                            if( ldacBT_update_frmlen( hLdacBT, frmlen_adj ) == LDACBT_S_OK ){
  ------------------
  |  |   67|      0|#define LDACBT_S_OK (0)
  ------------------
  |  Branch (487:33): [True: 0, False: 0]
  ------------------
  488|      0|                                hLdacBT->stat_alter_op = LDACBT_ALTER_OP__ACTIVE;
  ------------------
  |  |   61|      0|#define LDACBT_ALTER_OP__ACTIVE 1
  ------------------
  489|      0|                            }
  490|      0|                            if( !hLdacBT->stat_alter_op ){
  ------------------
  |  Branch (490:33): [True: 0, False: 0]
  ------------------
  491|       |                                /* flash streams */
  492|      0|                                hLdacBT->stat_alter_op = LDACBT_ALTER_OP__FLASH;
  ------------------
  |  |   63|      0|#define LDACBT_ALTER_OP__FLASH 9
  ------------------
  493|      0|                            }
  494|      0|                        }
  495|      0|                    }
  496|      0|                }else{
  497|       |                    /* wait the condition ptfbuf->nfrm_in == 0 for apply new frame_length */
  498|      0|                    hLdacBT->stat_alter_op = LDACBT_ALTER_OP__STANDBY;
  ------------------
  |  |   62|      0|#define LDACBT_ALTER_OP__STANDBY 2
  ------------------
  499|      0|                }
  500|      0|            }
  501|      0|        }
  502|      0|    }
  503|       |
  504|       |    /* check write space for encoded data */
  505|     22|    ldaclib_get_encode_frame_length( hLdacBT->hLDAC, &frmlen );
  506|       |
  507|     22|    if( (( ptfbuf->used + frmlen + LDACBT_FRMHDRBYTES) > hLdacBT->tx.tx_size) ||
  ------------------
  |  |   43|     22|#define LDACBT_FRMHDRBYTES LDAC_FRMHDRBYTES
  |  |  ------------------
  |  |  |  |   29|     22|#define LDAC_FRMHDRBYTES   3
  |  |  ------------------
  ------------------
  |  Branch (507:9): [True: 0, False: 22]
  ------------------
  508|     22|        (hLdacBT->stat_alter_op == LDACBT_ALTER_OP__FLASH) || /* need to flash streams? */
  ------------------
  |  |   63|     22|#define LDACBT_ALTER_OP__FLASH 9
  ------------------
  |  Branch (508:9): [True: 0, False: 22]
  ------------------
  509|     22|        (( ptfbuf->used + frmlen + LDACBT_FRMHDRBYTES) >= LDACBT_ENC_STREAM_BUF_SZ )
  ------------------
  |  |   43|     22|#define LDACBT_FRMHDRBYTES LDAC_FRMHDRBYTES
  |  |  ------------------
  |  |  |  |   29|     22|#define LDAC_FRMHDRBYTES   3
  |  |  ------------------
  ------------------
                      (( ptfbuf->used + frmlen + LDACBT_FRMHDRBYTES) >= LDACBT_ENC_STREAM_BUF_SZ )
  ------------------
  |  |   51|     22|#define LDACBT_ENC_STREAM_BUF_SZ 1024
  ------------------
  |  Branch (509:9): [True: 0, False: 22]
  ------------------
  510|     22|        )
  511|      0|    {
  512|      0|        copy_data_ldac( ptfbuf->buf, p_stream, ptfbuf->used );
  ------------------
  |  |   74|      0|#define copy_data_ldac(p1, p2, n)  memcpy((p2), (p1), (n))
  ------------------
  513|      0|        *stream_sz = ptfbuf->used;
  514|      0|        *frame_num = ptfbuf->nfrm_in;
  515|      0|        clear_data_ldac( ptfbuf->buf, sizeof(char)*LDACBT_ENC_STREAM_BUF_SZ);
  ------------------
  |  |   61|      0|#define clear_data_ldac(p, n)      memset((p), 0, (n))
  ------------------
  516|      0|        ptfbuf->used = 0;
  517|      0|        ptfbuf->nfrm_in = 0;
  518|      0|        if( hLdacBT->stat_alter_op != LDACBT_ALTER_OP__NON ){
  ------------------
  |  |   60|      0|#define LDACBT_ALTER_OP__NON 0
  ------------------
  |  Branch (518:13): [True: 0, False: 0]
  ------------------
  519|       |            /* update frame length */
  520|      0|            ldacBT_update_frmlen( hLdacBT, hLdacBT->tgt_frmlen );
  521|      0|            hLdacBT->stat_alter_op = LDACBT_ALTER_OP__NON;
  ------------------
  |  |   60|      0|#define LDACBT_ALTER_OP__NON 0
  ------------------
  522|      0|        }
  523|      0|    }
  524|     22|    p_ldac_transport_frame = ptfbuf->buf + ptfbuf->used;
  525|       |
  526|       |    /* Encode Frame */
  527|     22|    if( ppcmring->nsmpl > 0 ){
  ------------------
  |  Branch (527:9): [True: 22, False: 0]
  ------------------
  528|     22|        char *p_pcm_ring_r;
  529|     22|        int nsmpl_to_clr;
  530|     22|        nsmpl_to_clr = hLdacBT->frm_samples - ppcmring->nsmpl;
  531|     22|        if( nsmpl_to_clr > 0 ){
  ------------------
  |  Branch (531:13): [True: 0, False: 22]
  ------------------
  532|      0|            int pos, nBytesToZero;
  533|      0|            pos = ppcmring->rp + ppcmring->nsmpl * wl * ch;
  534|      0|            nBytesToZero = nsmpl_to_clr * wl * ch;
  535|      0|            while( nBytesToZero > 0 ){
  ------------------
  |  Branch (535:20): [True: 0, False: 0]
  ------------------
  536|      0|                int clearBytes;
  537|      0|                clearBytes = nBytesToZero;
  538|      0|                if ( pos + clearBytes >= LDACBT_ENC_PCM_BUF_SZ ){
  ------------------
  |  |   47|      0|#define LDACBT_ENC_PCM_BUF_SZ 6144 
  ------------------
  |  Branch (538:22): [True: 0, False: 0]
  ------------------
  539|      0|                    clearBytes = (LDACBT_ENC_PCM_BUF_SZ - pos);
  ------------------
  |  |   47|      0|#define LDACBT_ENC_PCM_BUF_SZ 6144 
  ------------------
  540|      0|                }
  541|      0|                clear_data_ldac( ppcmring->buf + pos, clearBytes);
  ------------------
  |  |   61|      0|#define clear_data_ldac(p, n)      memset((p), 0, (n))
  ------------------
  542|      0|                nBytesToZero -= clearBytes;
  543|      0|                if( (pos += clearBytes) >= LDACBT_ENC_PCM_BUF_SZ ){
  ------------------
  |  |   47|      0|#define LDACBT_ENC_PCM_BUF_SZ 6144 
  ------------------
  |  Branch (543:21): [True: 0, False: 0]
  ------------------
  544|      0|                    pos = 0;
  545|      0|                }
  546|      0|            }
  547|      0|        }
  548|     22|        p_pcm_ring_r = ppcmring->buf + ppcmring->rp;
  549|     22|        ldacBT_prepare_pcm_encode( p_pcm_ring_r, hLdacBT->pp_pcm, hLdacBT->frm_samples, ch, fmt );
  550|     22|        result = ldaclib_encode(hLdacBT->hLDAC, hLdacBT->pp_pcm, (LDAC_SMPL_FMT_T)fmt,
  551|     22|                         p_ldac_transport_frame+LDACBT_FRMHDRBYTES, &frmlen_wrote);
  ------------------
  |  |   43|     22|#define LDACBT_FRMHDRBYTES LDAC_FRMHDRBYTES
  |  |  ------------------
  |  |  |  |   29|     22|#define LDAC_FRMHDRBYTES   3
  |  |  ------------------
  ------------------
  552|     22|        if( !LDAC_FAILED(result) ){
  ------------------
  |  |   42|     22|#define LDAC_FAILED(result)    ((LDAC_RESULT)(result)<0)
  ------------------
  |  Branch (552:13): [True: 22, False: 0]
  ------------------
  553|     22|            ppcmring->rp += hLdacBT->frm_samples * wl * ch;
  554|     22|            ppcmring->nsmpl -= hLdacBT->frm_samples;
  555|     22|            if( ppcmring->rp >= LDACBT_ENC_PCM_BUF_SZ ){ ppcmring->rp = 0; }
  ------------------
  |  |   47|     22|#define LDACBT_ENC_PCM_BUF_SZ 6144 
  ------------------
  |  Branch (555:17): [True: 0, False: 22]
  ------------------
  556|     22|            if( ppcmring->nsmpl < 0 ){ ppcmring->nsmpl = 0; }
  ------------------
  |  Branch (556:17): [True: 0, False: 22]
  ------------------
  557|     22|        }
  558|     22|    }else{
  559|      0|        result = ldaclib_flush_encode(hLdacBT->hLDAC, (LDAC_SMPL_FMT_T)fmt,
  560|      0|                             p_ldac_transport_frame+LDACBT_FRMHDRBYTES, &frmlen_wrote);
  ------------------
  |  |   43|      0|#define LDACBT_FRMHDRBYTES LDAC_FRMHDRBYTES
  |  |  ------------------
  |  |  |  |   29|      0|#define LDAC_FRMHDRBYTES   3
  |  |  ------------------
  ------------------
  561|      0|        hLdacBT->flg_encode_flushed = TRUE;
  ------------------
  |  |   76|      0|#define TRUE   1
  ------------------
  562|      0|    }
  563|       |
  564|     22|    if( LDAC_FAILED(result) ){
  ------------------
  |  |   42|     22|#define LDAC_FAILED(result)    ((LDAC_RESULT)(result)<0)
  |  |  ------------------
  |  |  |  Branch (42:32): [True: 0, False: 22]
  |  |  ------------------
  ------------------
  565|      0|        hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE;
  ------------------
  |  |   81|      0|#define LDACBT_GET_LDACLIB_ERROR_CODE   9999
  ------------------
  566|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  567|      0|    }
  568|     22|    else if( result != LDAC_S_OK ){
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  |  Branch (568:14): [True: 0, False: 22]
  ------------------
  569|      0|        hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE;
  ------------------
  |  |   81|      0|#define LDACBT_GET_LDACLIB_ERROR_CODE   9999
  ------------------
  570|      0|    }
  571|       |
  572|     22|    if( frmlen_wrote > 0 ){
  ------------------
  |  Branch (572:9): [True: 22, False: 0]
  ------------------
  573|     22|        if( hLdacBT->transport == TRUE ){
  ------------------
  |  |   76|     22|#define TRUE   1
  ------------------
  |  Branch (573:13): [True: 22, False: 0]
  ------------------
  574|       |            /* Set Frame Header Data */
  575|     22|            clear_data_ldac( a_frm_header, LDACBT_FRMHDRBYTES+2 );
  ------------------
  |  |   61|     22|#define clear_data_ldac(p, n)      memset((p), 0, (n))
  ------------------
  576|       |            /* Get Frame Header Information */
  577|     22|            result = ldaclib_get_config_info(hLdacBT->hLDAC, &hLdacBT->sfid, &hLdacBT->cci,
  578|     22|                            &frmlen, &frm_status);
  579|     22|            if( LDAC_FAILED(result) ){
  ------------------
  |  |   42|     22|#define LDAC_FAILED(result)    ((LDAC_RESULT)(result)<0)
  |  |  ------------------
  |  |  |  Branch (42:32): [True: 0, False: 22]
  |  |  ------------------
  ------------------
  580|      0|                hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE;
  ------------------
  |  |   81|      0|#define LDACBT_GET_LDACLIB_ERROR_CODE   9999
  ------------------
  581|      0|                return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  582|      0|            }
  583|     22|            else if (result != LDAC_S_OK) {
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  |  Branch (583:22): [True: 0, False: 22]
  ------------------
  584|      0|                hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE;
  ------------------
  |  |   81|      0|#define LDACBT_GET_LDACLIB_ERROR_CODE   9999
  ------------------
  585|      0|            }
  586|       |
  587|       |            /* Set Frame Header */
  588|     22|            result = ldaclib_set_frame_header(hLdacBT->hLDAC, a_frm_header, hLdacBT->sfid,
  589|     22|                            hLdacBT->cci, frmlen, frm_status);
  590|     22|            if( LDAC_FAILED(result) ){
  ------------------
  |  |   42|     22|#define LDAC_FAILED(result)    ((LDAC_RESULT)(result)<0)
  |  |  ------------------
  |  |  |  Branch (42:32): [True: 0, False: 22]
  |  |  ------------------
  ------------------
  591|      0|                hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE;
  ------------------
  |  |   81|      0|#define LDACBT_GET_LDACLIB_ERROR_CODE   9999
  ------------------
  592|      0|                return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  593|      0|            }
  594|     22|            else if (result != LDAC_S_OK) {
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  |  Branch (594:22): [True: 0, False: 22]
  ------------------
  595|      0|                hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE;
  ------------------
  |  |   81|      0|#define LDACBT_GET_LDACLIB_ERROR_CODE   9999
  ------------------
  596|      0|            }
  597|     22|            copy_data_ldac( a_frm_header, p_ldac_transport_frame, LDACBT_FRMHDRBYTES );
  ------------------
  |  |   74|     22|#define copy_data_ldac(p1, p2, n)  memcpy((p2), (p1), (n))
  ------------------
  598|     22|            frmlen_wrote += LDACBT_FRMHDRBYTES;
  ------------------
  |  |   43|     22|#define LDACBT_FRMHDRBYTES LDAC_FRMHDRBYTES
  |  |  ------------------
  |  |  |  |   29|     22|#define LDAC_FRMHDRBYTES   3
  |  |  ------------------
  ------------------
  599|     22|        }
  600|     22|        ptfbuf->used += frmlen_wrote;
  601|     22|        ptfbuf->nfrm_in ++;
  602|     22|    }
  603|       |
  604|       |    /* check for next frame buffer status */
  605|     22|    if( *stream_sz == 0 ){
  ------------------
  |  Branch (605:9): [True: 22, False: 0]
  ------------------
  606|     22|        if( (( ptfbuf->used + frmlen_wrote) > hLdacBT->tx.tx_size) ||
  ------------------
  |  Branch (606:13): [True: 0, False: 22]
  ------------------
  607|     22|            (  ptfbuf->nfrm_in >= LDACBT_NFRM_TX_MAX ) || 
  ------------------
  |  |   45|     22|#define LDACBT_NFRM_TX_MAX 15
  ------------------
  |  Branch (607:13): [True: 0, False: 22]
  ------------------
  608|     22|            (( ptfbuf->used + frmlen_wrote) >= LDACBT_ENC_STREAM_BUF_SZ ) ||
  ------------------
  |  |   51|     22|#define LDACBT_ENC_STREAM_BUF_SZ 1024
  ------------------
  |  Branch (608:13): [True: 0, False: 22]
  ------------------
  609|     22|            ( p_pcm == NULL ) /* flush encode */
  ------------------
  |  Branch (609:13): [True: 0, False: 22]
  ------------------
  610|     22|            )
  611|      0|        {
  612|      0|            copy_data_ldac( ptfbuf->buf, p_stream, ptfbuf->used );
  ------------------
  |  |   74|      0|#define copy_data_ldac(p1, p2, n)  memcpy((p2), (p1), (n))
  ------------------
  613|      0|            *stream_sz = ptfbuf->used;
  614|      0|            *frame_num = ptfbuf->nfrm_in;
  615|      0|            clear_data_ldac( ptfbuf->buf, sizeof(char)*LDACBT_ENC_STREAM_BUF_SZ);
  ------------------
  |  |   61|      0|#define clear_data_ldac(p, n)      memset((p), 0, (n))
  ------------------
  616|      0|            ptfbuf->used = 0;
  617|      0|            ptfbuf->nfrm_in = 0;
  618|      0|            if( hLdacBT->stat_alter_op != LDACBT_ALTER_OP__NON ){
  ------------------
  |  |   60|      0|#define LDACBT_ALTER_OP__NON 0
  ------------------
  |  Branch (618:17): [True: 0, False: 0]
  ------------------
  619|      0|                ldacBT_update_frmlen( hLdacBT, hLdacBT->tgt_frmlen );
  620|      0|                hLdacBT->stat_alter_op = LDACBT_ALTER_OP__NON;
  ------------------
  |  |   60|      0|#define LDACBT_ALTER_OP__NON 0
  ------------------
  621|      0|            }
  622|      0|        }
  623|     22|    }
  624|       |
  625|     22|    return LDACBT_S_OK;
  ------------------
  |  |   67|     22|#define LDACBT_S_OK (0)
  ------------------
  626|     22|}

ldacBT.c:ldacBT_param_clear:
   74|     66|{
   75|     66|    int ich;
   76|     66|    if( hLdacBT == NULL ) { return ; }
  ------------------
  |  Branch (76:9): [True: 0, False: 66]
  ------------------
   77|     66|    hLdacBT->proc_mode = LDACBT_PROCMODE_UNSET;
   78|     66|    hLdacBT->error_code = LDACBT_ERR_NONE;
  ------------------
  |  |  380|     66|#define LDACBT_ERR_NONE                     0
  ------------------
   79|     66|    hLdacBT->error_code_api = LDACBT_ERR_NONE;
  ------------------
  |  |  380|     66|#define LDACBT_ERR_NONE                     0
  ------------------
   80|       |
   81|     66|    hLdacBT->frm_samples = 0;
   82|     66|    hLdacBT->sfid = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
   83|     66|    hLdacBT->pcm.sf = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
   84|     66|    hLdacBT->tx.mtu = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
   85|     66|    hLdacBT->tx.tx_size = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
   86|     66|    hLdacBT->tx.pkt_hdr_sz = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
   87|     66|    hLdacBT->frmlen_tx = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
   88|     66|    hLdacBT->tx.nfrm_in_pkt = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
   89|     66|    hLdacBT->pcm.ch = 0;
   90|     66|    hLdacBT->pcm.fmt = LDACBT_SMPL_FMT_S24;
   91|     66|    hLdacBT->nshift = 0;
   92|     66|    hLdacBT->frmlen = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
   93|     66|    hLdacBT->frm_status = 0;
   94|     66|    hLdacBT->bitrate = 0;
   95|       |    /* for alter frame length */
   96|     66|    hLdacBT->tgt_nfrm_in_pkt = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
   97|     66|    hLdacBT->tgt_frmlen = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
   98|     66|    hLdacBT->tgt_eqmid = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
   99|     66|    hLdacBT->stat_alter_op = LDACBT_ALTER_OP__NON;
  ------------------
  |  |   60|     66|#define LDACBT_ALTER_OP__NON 0
  ------------------
  100|       |
  101|     66|    hLdacBT->cm = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
  102|     66|    hLdacBT->cci = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
  103|     66|    hLdacBT->eqmid = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
  104|     66|    hLdacBT->transport = UNSET;
  ------------------
  |  |   79|     66|#define UNSET -1
  ------------------
  105|       |
  106|     66|    clear_data_ldac( hLdacBT->ldac_trns_frm_buf.buf, sizeof(hLdacBT->ldac_trns_frm_buf.buf));
  ------------------
  |  |   61|     66|#define clear_data_ldac(p, n)      memset((p), 0, (n))
  ------------------
  107|     66|    hLdacBT->ldac_trns_frm_buf.used = 0;
  108|     66|    hLdacBT->ldac_trns_frm_buf.nfrm_in = 0;
  109|       |
  110|     66|    clear_data_ldac( hLdacBT->pcmring.buf, sizeof(hLdacBT->pcmring.buf));
  ------------------
  |  |   61|     66|#define clear_data_ldac(p, n)      memset((p), 0, (n))
  ------------------
  111|     66|    hLdacBT->pcmring.wp = 0;
  112|     66|    hLdacBT->pcmring.rp = 0;
  113|     66|    hLdacBT->pcmring.nsmpl = 0;
  114|       |/* work buffer for I/O */
  115|    198|    for( ich = 0; ich < LDAC_PRCNCH; ich++ ){
  ------------------
  |  |   28|    198|#define LDAC_PRCNCH        2
  ------------------
  |  Branch (115:19): [True: 132, False: 66]
  ------------------
  116|    132|        hLdacBT->ap_pcm[ich] = &hLdacBT->a_pcm[ ich * LDACBT_MAX_LSU * LDACBT_PCM_WLEN_MAX ];
  ------------------
  |  |   94|    132|#define LDACBT_MAX_LSU 512
  ------------------
                      hLdacBT->ap_pcm[ich] = &hLdacBT->a_pcm[ ich * LDACBT_MAX_LSU * LDACBT_PCM_WLEN_MAX ];
  ------------------
  |  |   49|    132|#define LDACBT_PCM_WLEN_MAX 4
  ------------------
  117|    132|    }
  118|     66|    hLdacBT->pp_pcm = hLdacBT->ap_pcm;
  119|     66|    clear_data_ldac( hLdacBT->a_pcm, LDAC_PRCNCH * LDACBT_MAX_LSU * LDACBT_PCM_WLEN_MAX );
  ------------------
  |  |   61|     66|#define clear_data_ldac(p, n)      memset((p), 0, (n))
  ------------------
  120|       |
  121|     66|}
ldacBT.c:ldacBT_assert_mtu:
  190|     22|{
  191|     22|    if( mtu < LDACBT_MTU_REQUIRED ){
  ------------------
  |  |   56|     22|#define LDACBT_MTU_REQUIRED  679
  ------------------
  |  Branch (191:9): [True: 0, False: 22]
  ------------------
  192|      0|        return LDACBT_ERR_ILL_MTU_SIZE;
  ------------------
  |  |  451|      0|#define LDACBT_ERR_ILL_MTU_SIZE             1027
  ------------------
  193|      0|    }
  194|     22|    return LDACBT_ERR_NONE;
  ------------------
  |  |  380|     22|#define LDACBT_ERR_NONE                     0
  ------------------
  195|     22|}
ldacBT.c:ldacBT_assert_eqmid:
  197|     22|{
  198|     22|    if( (eqmid == LDACBT_EQMID_HQ) || (eqmid == LDACBT_EQMID_SQ) || (eqmid == LDACBT_EQMID_MQ)){
  ------------------
  |  Branch (198:9): [True: 0, False: 22]
  |  Branch (198:39): [True: 22, False: 0]
  |  Branch (198:69): [True: 0, False: 0]
  ------------------
  199|     22|        return LDACBT_ERR_NONE;
  ------------------
  |  |  380|     22|#define LDACBT_ERR_NONE                     0
  ------------------
  200|     22|    }
  201|       |
  202|      0|    return LDACBT_ERR_ILL_EQMID;
  ------------------
  |  |  448|      0|#define LDACBT_ERR_ILL_EQMID                1024
  ------------------
  203|     22|}
ldacBT.c:ldacBT_assert_cm:
  143|     22|{
  144|     22|    if( (cm != LDACBT_CHANNEL_MODE_STEREO )
  ------------------
  |  |  535|     22|#define LDACBT_CHANNEL_MODE_STEREO         0x01
  ------------------
  |  Branch (144:9): [True: 22, False: 0]
  ------------------
  145|     22|        && (cm != LDACBT_CHANNEL_MODE_DUAL_CHANNEL )
  ------------------
  |  |  533|     22|#define LDACBT_CHANNEL_MODE_DUAL_CHANNEL   0x02
  ------------------
  |  Branch (145:12): [True: 0, False: 22]
  ------------------
  146|      0|        && (cm != LDACBT_CHANNEL_MODE_MONO )
  ------------------
  |  |  531|      0|#define LDACBT_CHANNEL_MODE_MONO           0x04
  ------------------
  |  Branch (146:12): [True: 0, False: 0]
  ------------------
  147|     22|    ){
  148|      0|        return LDACBT_ERR_ASSERT_CHANNEL_MODE;
  ------------------
  |  |  425|      0|#define LDACBT_ERR_ASSERT_CHANNEL_MODE      539
  ------------------
  149|      0|    }
  150|     22|    return LDACBT_ERR_NONE;
  ------------------
  |  |  380|     22|#define LDACBT_ERR_NONE                     0
  ------------------
  151|     22|}
ldacBT.c:ldacBT_assert_sample_format:
  163|     22|{
  164|     22|#ifndef _32BIT_FIXED_POINT
  165|     22|    if( (fmt != LDACBT_SMPL_FMT_S16)
  ------------------
  |  Branch (165:9): [True: 0, False: 22]
  ------------------
  166|      0|        && (fmt != LDACBT_SMPL_FMT_S24)
  ------------------
  |  Branch (166:12): [True: 0, False: 0]
  ------------------
  167|      0|        && (fmt != LDACBT_SMPL_FMT_S32)
  ------------------
  |  Branch (167:12): [True: 0, False: 0]
  ------------------
  168|      0|        && (fmt != LDACBT_SMPL_FMT_F32)
  ------------------
  |  Branch (168:12): [True: 0, False: 0]
  ------------------
  169|     22|    ){
  170|       |#else /* _32BIT_FIXED_POINT */
  171|       |    if( (fmt != LDACBT_SMPL_FMT_S16)
  172|       |        && (fmt != LDACBT_SMPL_FMT_S24)
  173|       |        && (fmt != LDACBT_SMPL_FMT_S32)
  174|       |    ){
  175|       |#endif /* _32BIT_FIXED_POINT */
  176|      0|        return LDACBT_ERR_ILL_SMPL_FORMAT;
  ------------------
  |  |  413|      0|#define LDACBT_ERR_ILL_SMPL_FORMAT          517
  ------------------
  177|      0|    }
  178|     22|    return LDACBT_ERR_NONE;
  ------------------
  |  |  380|     22|#define LDACBT_ERR_NONE                     0
  ------------------
  179|     22|}
ldacBT.c:ldacBT_assert_pcm_sampling_freq:
  181|     22|{
  182|     22|    if( (sampling_freq != 1*44100) && (sampling_freq != 1*48000)
  ------------------
  |  Branch (182:9): [True: 22, False: 0]
  |  Branch (182:39): [True: 0, False: 22]
  ------------------
  183|      0|        && (sampling_freq != 2*44100) && (sampling_freq != 2*48000)
  ------------------
  |  Branch (183:12): [True: 0, False: 0]
  |  Branch (183:42): [True: 0, False: 0]
  ------------------
  184|     22|    ){
  185|      0|        return LDACBT_ERR_ILL_SAMPLING_FREQ;
  ------------------
  |  |  449|      0|#define LDACBT_ERR_ILL_SAMPLING_FREQ        1025
  ------------------
  186|      0|    }
  187|     22|    return LDACBT_ERR_NONE;
  ------------------
  |  |  380|     22|#define LDACBT_ERR_NONE                     0
  ------------------
  188|     22|}
ldacBT.c:ldacBT_cm_to_cci:
  390|     22|{
  391|     22|    if( cm == LDACBT_CHANNEL_MODE_STEREO ){
  ------------------
  |  |  535|     22|#define LDACBT_CHANNEL_MODE_STEREO         0x01
  ------------------
  |  Branch (391:9): [True: 0, False: 22]
  ------------------
  392|      0|        return LDAC_CCI_STEREO;
  ------------------
  |  |  101|      0|#define LDAC_CCI_STEREO       2 /* STEREO */
  ------------------
  393|      0|    }
  394|     22|    else if( cm == LDACBT_CHANNEL_MODE_DUAL_CHANNEL ){
  ------------------
  |  |  533|     22|#define LDACBT_CHANNEL_MODE_DUAL_CHANNEL   0x02
  ------------------
  |  Branch (394:14): [True: 22, False: 0]
  ------------------
  395|     22|        return LDAC_CCI_DUAL_CHANNEL;
  ------------------
  |  |  100|     22|#define LDAC_CCI_DUAL_CHANNEL 1 /* DUAL CHANNEL */
  ------------------
  396|     22|    }
  397|      0|    else/* if( cm == LDACBT_CHANNEL_MODE_MONO )*/{
  398|      0|        return LDAC_CCI_MONO;
  ------------------
  |  |   99|      0|#define LDAC_CCI_MONO         0 /* MONO */
  ------------------
  399|      0|    }
  400|     22|}
ldacBT.c:ldacBT_get_config:
  486|     22|{
  487|     22|    int i, tbl_size, ldac_mode_id;
  488|     22|    P_LDACBT_EQMID_PROPERTY pEqmIdProp;
  489|     22|    P_LDACBT_CONFIG pCfg;
  490|       |
  491|     22|    if( (pEqmIdProp = ldacBT_get_eqmid_conv_tbl( ldac_bt_mode )) == NULL ){
  ------------------
  |  Branch (491:9): [True: 0, False: 22]
  ------------------
  492|      0|        return NULL;
  493|      0|    }
  494|       |
  495|     22|    if( pkt_type == _2_DH5 ){ ldac_mode_id = pEqmIdProp->id_for_2DH5;}
  ------------------
  |  Branch (495:9): [True: 22, False: 0]
  ------------------
  496|      0|    else{
  497|      0|        return NULL;
  498|      0|    }
  499|       |
  500|     22|    pCfg = (P_LDACBT_CONFIG)tbl_ldacbt_config;
  501|     22|    tbl_size = (int)(sizeof(tbl_ldacbt_config)/sizeof(tbl_ldacbt_config[0]));
  502|     44|    for( i = 0; i < tbl_size; ++i, ++pCfg ){
  ------------------
  |  Branch (502:17): [True: 44, False: 0]
  ------------------
  503|     44|        if( ldac_mode_id == pCfg->id ){
  ------------------
  |  Branch (503:13): [True: 22, False: 22]
  ------------------
  504|     22|            return pCfg;
  505|     22|        }
  506|     44|    }
  507|      0|    return NULL; /* not found */
  508|     22|}
ldacBT.c:ldacBT_get_eqmid_conv_tbl:
  435|     22|{
  436|     22|    int i, tbl_size;
  437|     22|    P_LDACBT_EQMID_PROPERTY pEqmIdProp;
  438|       |
  439|     22|    pEqmIdProp = (P_LDACBT_EQMID_PROPERTY)tbl_ldacbt_eqmid_property;
  440|     22|    tbl_size = (int)(sizeof(tbl_ldacbt_eqmid_property)/sizeof(tbl_ldacbt_eqmid_property[0]));
  441|       |    /* Search current eqmid */
  442|     44|    for( i = 0; i < tbl_size; ++i, ++pEqmIdProp ){
  ------------------
  |  Branch (442:17): [True: 44, False: 0]
  ------------------
  443|     44|        if( pEqmIdProp->eqmid == eqmid ){
  ------------------
  |  Branch (443:13): [True: 22, False: 22]
  ------------------
  444|     22|            return pEqmIdProp;
  445|     22|        }
  446|     44|    }
  447|      0|    return NULL;
  448|     22|}
ldacBT.c:ldacBT_frmlen_to_bitrate:
  421|     22|{
  422|     22|    int bitrate;
  423|     22|    if( (frmlen == UNSET) || (flgFrmHdr == UNSET) || (sf == UNSET) || (frame_samples == UNSET) ){
  ------------------
  |  |   79|     22|#define UNSET -1
  ------------------
                  if( (frmlen == UNSET) || (flgFrmHdr == UNSET) || (sf == UNSET) || (frame_samples == UNSET) ){
  ------------------
  |  |   79|     22|#define UNSET -1
  ------------------
                  if( (frmlen == UNSET) || (flgFrmHdr == UNSET) || (sf == UNSET) || (frame_samples == UNSET) ){
  ------------------
  |  |   79|     22|#define UNSET -1
  ------------------
                  if( (frmlen == UNSET) || (flgFrmHdr == UNSET) || (sf == UNSET) || (frame_samples == UNSET) ){
  ------------------
  |  |   79|     22|#define UNSET -1
  ------------------
  |  Branch (423:9): [True: 0, False: 22]
  |  Branch (423:30): [True: 0, False: 22]
  |  Branch (423:54): [True: 0, False: 22]
  |  Branch (423:71): [True: 0, False: 22]
  ------------------
  424|      0|        return LDACBT_E_FAIL;
  ------------------
  |  |   70|      0|#define LDACBT_E_FAIL (-1)
  ------------------
  425|      0|    }
  426|     22|    if( flgFrmHdr ){
  ------------------
  |  Branch (426:9): [True: 22, False: 0]
  ------------------
  427|     22|        frmlen += LDACBT_FRMHDRBYTES;
  ------------------
  |  |   43|     22|#define LDACBT_FRMHDRBYTES LDAC_FRMHDRBYTES
  |  |  ------------------
  |  |  |  |   29|     22|#define LDAC_FRMHDRBYTES   3
  |  |  ------------------
  ------------------
  428|     22|    }
  429|     22|    bitrate  = frmlen * sf / frame_samples / (1000 / 8);
  430|     22|    return bitrate;
  431|     22|}
ldacBT.c:ldacBT_prepare_pcm_encode:
  222|     22|{
  223|     22|    int i;
  224|     22|    if( nch == 2 ){
  ------------------
  |  Branch (224:9): [True: 22, False: 0]
  ------------------
  225|     22|        if( fmt == LDACBT_SMPL_FMT_S16 ){
  ------------------
  |  Branch (225:13): [True: 22, False: 0]
  ------------------
  226|     22|            short *p_pcm_16 = (short *)pbuff;
  227|     22|            short *p_lch_16 = (short *)ap_pcm[0];
  228|     22|            short *p_rch_16 = (short *)ap_pcm[1];
  229|  2.83k|            for (i = 0; i < nsmpl; i++) {
  ------------------
  |  Branch (229:25): [True: 2.81k, False: 22]
  ------------------
  230|  2.81k|                *p_lch_16++ = p_pcm_16[0];
  231|  2.81k|                *p_rch_16++ = p_pcm_16[1];
  232|  2.81k|                p_pcm_16+=2;
  233|  2.81k|            }
  234|     22|        }
  235|      0|        else if( fmt == LDACBT_SMPL_FMT_S24 ){
  ------------------
  |  Branch (235:18): [True: 0, False: 0]
  ------------------
  236|      0|            char *p_pcm_8 = (char *)pbuff;
  237|      0|            char *p_lch_8 = (char *)ap_pcm[0];
  238|      0|            char *p_rch_8 = (char *)ap_pcm[1];
  239|      0|#if __BYTE_ORDER == __LITTLE_ENDIAN
  240|      0|            for (i = 0; i < nsmpl; i++) {
  ------------------
  |  Branch (240:25): [True: 0, False: 0]
  ------------------
  241|      0|                *p_lch_8++ = p_pcm_8[0];
  242|      0|                *p_lch_8++ = p_pcm_8[1];
  243|      0|                *p_lch_8++ = p_pcm_8[2];
  244|      0|                p_pcm_8+=3;
  245|      0|                *p_rch_8++ = p_pcm_8[0];
  246|      0|                *p_rch_8++ = p_pcm_8[1];
  247|      0|                *p_rch_8++ = p_pcm_8[2];
  248|      0|                p_pcm_8+=3;
  249|      0|            }
  250|       |#else   /* __BYTE_ORDER */
  251|       |#error unsupported byte order
  252|       |#endif  /* #if __BYTE_ORDER == __LITTLE_ENDIAN */
  253|      0|        }
  254|      0|        else if ( fmt == LDACBT_SMPL_FMT_S32 ){
  ------------------
  |  Branch (254:19): [True: 0, False: 0]
  ------------------
  255|      0|            char *p_pcm_8 = (char *)pbuff;
  256|      0|            char *p_lch_8 = (char *)ap_pcm[0];
  257|      0|            char *p_rch_8 = (char *)ap_pcm[1];
  258|      0|#if __BYTE_ORDER == __LITTLE_ENDIAN
  259|      0|            for (i = 0; i < nsmpl; i++) {
  ------------------
  |  Branch (259:25): [True: 0, False: 0]
  ------------------
  260|      0|                *p_lch_8++ = p_pcm_8[0]; *p_lch_8++ = p_pcm_8[1]; *p_lch_8++ = p_pcm_8[2]; *p_lch_8++ = p_pcm_8[3];
  261|      0|                p_pcm_8+=4;
  262|      0|                *p_rch_8++ = p_pcm_8[0]; *p_rch_8++ = p_pcm_8[1]; *p_rch_8++ = p_pcm_8[2]; *p_rch_8++ = p_pcm_8[3];
  263|      0|                p_pcm_8+=4;
  264|      0|            }
  265|       |#else   /* __BYTE_ORDER */
  266|       |#error unsupported byte order
  267|       |#endif  /* #if __BYTE_ORDER == __LITTLE_ENDIAN */
  268|      0|        }
  269|      0|        else if ( fmt == LDACBT_SMPL_FMT_F32 ){
  ------------------
  |  Branch (269:19): [True: 0, False: 0]
  ------------------
  270|      0|            float *p_pcm = (float *)pbuff;
  271|      0|            float *p_lch = (float *)ap_pcm[0];
  272|      0|            float *p_rch = (float *)ap_pcm[1];
  273|      0|            for (i = 0; i < nsmpl; i++) {
  ------------------
  |  Branch (273:25): [True: 0, False: 0]
  ------------------
  274|      0|                *p_lch++ = p_pcm[0];
  275|      0|                p_pcm++;
  276|      0|                *p_rch++ = p_pcm[0];
  277|      0|                p_pcm++;
  278|      0|            }
  279|      0|        }
  280|      0|        else{;} /* never be happend */
  281|     22|    }
  282|      0|    else if( nch == 1 ){
  ------------------
  |  Branch (282:14): [True: 0, False: 0]
  ------------------
  283|      0|        switch(fmt){
  284|      0|          case LDACBT_SMPL_FMT_S16:
  ------------------
  |  Branch (284:11): [True: 0, False: 0]
  ------------------
  285|      0|            copy_data_ldac( pbuff, ap_pcm[0], 2*nsmpl );
  ------------------
  |  |   74|      0|#define copy_data_ldac(p1, p2, n)  memcpy((p2), (p1), (n))
  ------------------
  286|      0|            break;
  287|      0|          case LDACBT_SMPL_FMT_S24:
  ------------------
  |  Branch (287:11): [True: 0, False: 0]
  ------------------
  288|      0|            copy_data_ldac( pbuff, ap_pcm[0], 3*nsmpl );
  ------------------
  |  |   74|      0|#define copy_data_ldac(p1, p2, n)  memcpy((p2), (p1), (n))
  ------------------
  289|      0|            break;
  290|      0|          case LDACBT_SMPL_FMT_S32:
  ------------------
  |  Branch (290:11): [True: 0, False: 0]
  ------------------
  291|      0|          case LDACBT_SMPL_FMT_F32:
  ------------------
  |  Branch (291:11): [True: 0, False: 0]
  ------------------
  292|      0|            copy_data_ldac( pbuff, ap_pcm[0], 4*nsmpl );
  ------------------
  |  |   74|      0|#define copy_data_ldac(p1, p2, n)  memcpy((p2), (p1), (n))
  ------------------
  293|      0|            break;
  294|      0|          default:
  ------------------
  |  Branch (294:11): [True: 0, False: 0]
  ------------------
  295|      0|            break;
  296|      0|        }
  297|      0|    }
  298|     22|}

ldaclib_get_sampling_rate_index:
  175|     22|{
  176|     22|    if (smplrate == 44100) {
  ------------------
  |  Branch (176:9): [True: 0, False: 22]
  ------------------
  177|      0|        *p_smplrate_id = LDAC_SMPLRATEID_0;
  ------------------
  |  |   37|      0|#define LDAC_SMPLRATEID_0    0x0
  ------------------
  178|      0|    }
  179|     22|    else if (smplrate == 48000) {
  ------------------
  |  Branch (179:14): [True: 22, False: 0]
  ------------------
  180|     22|        *p_smplrate_id = LDAC_SMPLRATEID_1;
  ------------------
  |  |   38|     22|#define LDAC_SMPLRATEID_1    0x1
  ------------------
  181|     22|    }
  182|      0|    else if (smplrate == 88200) {
  ------------------
  |  Branch (182:14): [True: 0, False: 0]
  ------------------
  183|      0|        *p_smplrate_id = LDAC_SMPLRATEID_2;
  ------------------
  |  |   39|      0|#define LDAC_SMPLRATEID_2    0x2
  ------------------
  184|      0|    }
  185|      0|    else if (smplrate == 96000) {
  ------------------
  |  Branch (185:14): [True: 0, False: 0]
  ------------------
  186|      0|        *p_smplrate_id = LDAC_SMPLRATEID_3;
  ------------------
  |  |   40|      0|#define LDAC_SMPLRATEID_3    0x3
  ------------------
  187|      0|    }
  188|      0|    else {
  189|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  190|      0|    }
  191|       |
  192|     22|    return LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  193|     22|}
ldaclib_get_frame_samples:
  214|     22|{
  215|     22|    if (!ldaclib_assert_sampling_rate_index(smplrate_id)) {
  ------------------
  |  Branch (215:9): [True: 0, False: 22]
  ------------------
  216|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  217|      0|    }
  218|     22|    if (!ldaclib_assert_supported_sampling_rate_index(smplrate_id)) {
  ------------------
  |  Branch (218:9): [True: 0, False: 22]
  ------------------
  219|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  220|      0|    }
  221|       |
  222|     22|    *p_framesmpls = ga_framesmpls_ldac[smplrate_id];
  223|       |
  224|     22|    return LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  225|     22|}
ldaclib_get_nlnn:
  230|     22|{
  231|     22|    if (!ldaclib_assert_sampling_rate_index(smplrate_id)) {
  ------------------
  |  Branch (231:9): [True: 0, False: 22]
  ------------------
  232|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  233|      0|    }
  234|     22|    if (!ldaclib_assert_supported_sampling_rate_index(smplrate_id)) {
  ------------------
  |  Branch (234:9): [True: 0, False: 22]
  ------------------
  235|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  236|      0|    }
  237|       |
  238|     22|    *p_nlnn = ga_ln_framesmpls_ldac[smplrate_id];
  239|       |
  240|     22|    return LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  241|     22|}
ldaclib_get_channel:
  246|     22|{
  247|     22|    if (!ldaclib_assert_channel_config_index(chconfig_id)) {
  ------------------
  |  Branch (247:9): [True: 0, False: 22]
  ------------------
  248|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  249|      0|    }
  250|       |
  251|     22|    *p_ch = ga_ch_ldac[chconfig_id];
  252|       |
  253|     22|    return LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  254|     22|}
ldaclib_get_handle:
  295|     22|{
  296|     22|    HANDLE_LDAC hData;
  297|       |
  298|     22|    hData = (HANDLE_LDAC)malloc(sizeof(HANDLE_LDAC_STRUCT));
  299|     22|    if (hData != (HANDLE_LDAC)NULL) {
  ------------------
  |  Branch (299:9): [True: 22, False: 0]
  ------------------
  300|     22|        clear_data_ldac(hData, sizeof(HANDLE_LDAC_STRUCT));
  ------------------
  |  |   61|     22|#define clear_data_ldac(p, n)      memset((p), 0, (n))
  ------------------
  301|     22|        hData->sfinfo.p_mempos = (char *)NULL;
  302|     22|        hData->error_code = LDAC_ERR_NONE;
  ------------------
  |  |  103|     22|#define LDAC_ERR_NONE                       0
  ------------------
  303|     22|    }
  304|       |
  305|     22|    return hData;
  306|     22|}
ldaclib_free_handle:
  313|     22|{
  314|     22|    if (hData != (HANDLE_LDAC)NULL) {
  ------------------
  |  Branch (314:9): [True: 22, False: 0]
  ------------------
  315|     22|        if (hData->sfinfo.p_mempos != (char *)NULL) {
  ------------------
  |  Branch (315:13): [True: 0, False: 22]
  ------------------
  316|      0|            return LDAC_S_OK;
  ------------------
  |  |   33|      0|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  317|      0|        }
  318|       |
  319|     22|        free(hData);
  320|     22|    }
  321|       |
  322|     22|    return LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  323|     22|}
ldaclib_set_config_info:
  334|     22|{
  335|     22|    CFG *p_cfg = &hData->sfinfo.cfg;
  336|       |
  337|     22|    if (!ldaclib_assert_sampling_rate_index(smplrate_id)) {
  ------------------
  |  Branch (337:9): [True: 0, False: 22]
  ------------------
  338|      0|        hData->error_code = LDAC_ERR_ASSERT_SAMPLING_RATE;
  ------------------
  |  |  138|      0|#define LDAC_ERR_ASSERT_SAMPLING_RATE     530
  ------------------
  339|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  340|      0|    }
  341|       |
  342|     22|    if (!ldaclib_assert_supported_sampling_rate_index(smplrate_id)) {
  ------------------
  |  Branch (342:9): [True: 0, False: 22]
  ------------------
  343|      0|        hData->error_code = LDAC_ERR_ASSERT_SUP_SAMPLING_RATE;
  ------------------
  |  |  139|      0|#define LDAC_ERR_ASSERT_SUP_SAMPLING_RATE 531
  ------------------
  344|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  345|      0|    }
  346|       |
  347|     22|    if (!ldaclib_assert_channel_config_index(chconfig_id)) {
  ------------------
  |  Branch (347:9): [True: 0, False: 22]
  ------------------
  348|      0|        hData->error_code = LDAC_ERR_ASSERT_CHANNEL_CONFIG;
  ------------------
  |  |  141|      0|#define LDAC_ERR_ASSERT_CHANNEL_CONFIG    533
  ------------------
  349|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  350|      0|    }
  351|       |
  352|     22|    if (!ldaclib_assert_frame_length(frame_length)) {
  ------------------
  |  Branch (352:9): [True: 0, False: 22]
  ------------------
  353|      0|        hData->error_code = LDAC_ERR_ASSERT_FRAME_LENGTH;
  ------------------
  |  |  143|      0|#define LDAC_ERR_ASSERT_FRAME_LENGTH      535
  ------------------
  354|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  355|      0|    }
  356|       |
  357|     22|    if (!ldaclib_assert_supported_frame_length(frame_length, chconfig_id)) {
  ------------------
  |  Branch (357:9): [True: 0, False: 22]
  ------------------
  358|      0|        hData->error_code = LDAC_ERR_ASSERT_SUP_FRAME_LENGTH;
  ------------------
  |  |  144|      0|#define LDAC_ERR_ASSERT_SUP_FRAME_LENGTH  536
  ------------------
  359|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  360|      0|    }
  361|       |
  362|     22|    if (!ldaclib_assert_frame_status(frame_status)) {
  ------------------
  |  Branch (362:9): [True: 0, False: 22]
  ------------------
  363|      0|        hData->error_code = LDAC_ERR_ASSERT_FRAME_STATUS;
  ------------------
  |  |  145|      0|#define LDAC_ERR_ASSERT_FRAME_STATUS      537
  ------------------
  364|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  365|      0|    }
  366|       |
  367|     22|    p_cfg->smplrate_id = smplrate_id;
  368|     22|    p_cfg->chconfig_id = chconfig_id;
  369|     22|    p_cfg->frame_length = frame_length;
  370|     22|    p_cfg->frame_status = frame_status;
  371|       |
  372|     22|    ldaclib_get_channel(chconfig_id, &p_cfg->ch);
  373|       |
  374|     22|    return LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  375|     22|}
ldaclib_get_config_info:
  386|     22|{
  387|     22|    CFG *p_cfg = &hData->sfinfo.cfg;
  388|       |
  389|     22|    *p_smplrate_id = p_cfg->smplrate_id;
  390|     22|    *p_chconfig_id = p_cfg->chconfig_id;
  391|     22|    *p_frame_length = p_cfg->frame_length;
  392|     22|    *p_frame_status = p_cfg->frame_status;
  393|       |
  394|     22|    return LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  395|     22|}
ldaclib_set_frame_header:
  408|     22|{
  409|     22|    if (!ldaclib_assert_sampling_rate_index(smplrate_id)) {
  ------------------
  |  Branch (409:9): [True: 0, False: 22]
  ------------------
  410|      0|        hData->error_code = LDAC_ERR_ASSERT_SAMPLING_RATE;
  ------------------
  |  |  138|      0|#define LDAC_ERR_ASSERT_SAMPLING_RATE     530
  ------------------
  411|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  412|      0|    }
  413|       |
  414|     22|    if (!ldaclib_assert_supported_sampling_rate_index(smplrate_id)) {
  ------------------
  |  Branch (414:9): [True: 0, False: 22]
  ------------------
  415|      0|        hData->error_code = LDAC_ERR_ASSERT_SUP_SAMPLING_RATE;
  ------------------
  |  |  139|      0|#define LDAC_ERR_ASSERT_SUP_SAMPLING_RATE 531
  ------------------
  416|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  417|      0|    }
  418|       |
  419|     22|    if (!ldaclib_assert_channel_config_index(chconfig_id)) {
  ------------------
  |  Branch (419:9): [True: 0, False: 22]
  ------------------
  420|      0|        hData->error_code = LDAC_ERR_ASSERT_CHANNEL_CONFIG;
  ------------------
  |  |  141|      0|#define LDAC_ERR_ASSERT_CHANNEL_CONFIG    533
  ------------------
  421|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  422|      0|    }
  423|       |
  424|     22|    if (!ldaclib_assert_frame_length(frame_length)) {
  ------------------
  |  Branch (424:9): [True: 0, False: 22]
  ------------------
  425|      0|        hData->error_code = LDAC_ERR_ASSERT_FRAME_LENGTH;
  ------------------
  |  |  143|      0|#define LDAC_ERR_ASSERT_FRAME_LENGTH      535
  ------------------
  426|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  427|      0|    }
  428|       |
  429|     22|    if (!ldaclib_assert_supported_frame_length(frame_length, chconfig_id)) {
  ------------------
  |  Branch (429:9): [True: 0, False: 22]
  ------------------
  430|      0|        hData->error_code = LDAC_ERR_ASSERT_SUP_FRAME_LENGTH;
  ------------------
  |  |  144|      0|#define LDAC_ERR_ASSERT_SUP_FRAME_LENGTH  536
  ------------------
  431|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  432|      0|    }
  433|       |
  434|     22|    if (!ldaclib_assert_frame_status(frame_status)) {
  ------------------
  |  Branch (434:9): [True: 0, False: 22]
  ------------------
  435|      0|        hData->error_code = LDAC_ERR_ASSERT_FRAME_STATUS;
  ------------------
  |  |  145|      0|#define LDAC_ERR_ASSERT_FRAME_STATUS      537
  ------------------
  436|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  437|      0|    }
  438|       |
  439|     22|    pack_frame_header_ldac(smplrate_id, chconfig_id, frame_length, frame_status,
  440|     22|            (STREAM *)p_stream);
  441|       |
  442|     22|    return LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  443|     22|}
ldaclib_get_encode_setting:
  499|     22|{
  500|     22|    int i, id;
  501|       |
  502|     22|    id = LDAC_ENC_NSETTING-1;
  ------------------
  |  |  453|     22|#define LDAC_ENC_NSETTING 15
  ------------------
  503|    352|    for (i = LDAC_ENC_NSETTING-1; i >= 0; i--) {
  ------------------
  |  |  453|     22|#define LDAC_ENC_NSETTING 15
  ------------------
  |  Branch (503:35): [True: 330, False: 22]
  ------------------
  504|    330|        if (nbytes_ch >= saa_encode_setting_ldac[i][1]) {
  ------------------
  |  Branch (504:13): [True: 264, False: 66]
  ------------------
  505|    264|            id = i;
  506|    264|        }
  507|    330|    }
  508|       |
  509|     22|    *p_nbands = min_ldac(saa_encode_setting_ldac[id][2], ga_max_nbands_ldac[smplrate_id]);
  ------------------
  |  |  275|     22|#define min_ldac(a, b) (((a)<(b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (275:25): [True: 0, False: 22]
  |  |  ------------------
  ------------------
  510|     22|    *p_grad_mode = saa_encode_setting_ldac[id][3];
  511|     22|    *p_grad_qu_l = saa_encode_setting_ldac[id][4];
  512|     22|    *p_grad_qu_h = saa_encode_setting_ldac[id][5];
  513|     22|    *p_grad_os_l = saa_encode_setting_ldac[id][6];
  514|     22|    *p_grad_os_h = saa_encode_setting_ldac[id][7];
  515|     22|    *p_abc_status = saa_encode_setting_ldac[id][8];
  516|       |
  517|     22|    return LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  518|     22|}
ldaclib_get_encode_frame_length:
  552|     22|{
  553|     22|    CFG *p_cfg = &hData->sfinfo.cfg;
  554|       |
  555|     22|    *p_frame_length = p_cfg->frame_length;
  556|       |
  557|     22|    return LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  558|     22|}
ldaclib_set_encode_info:
  572|     22|{
  573|     22|    if ((nbands < LDAC_BAND_OFFSET) ||
  ------------------
  |  |  102|     22|#define LDAC_BAND_OFFSET       2
  ------------------
  |  Branch (573:9): [True: 0, False: 22]
  ------------------
  574|     22|            (ga_max_nbands_ldac[hData->sfinfo.cfg.smplrate_id] < nbands)) {
  ------------------
  |  Branch (574:13): [True: 0, False: 22]
  ------------------
  575|      0|        hData->error_code = LDAC_ERR_ENC_ILL_NBANDS;
  ------------------
  |  |  154|      0|#define LDAC_ERR_ENC_ILL_NBANDS           556
  ------------------
  576|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  577|      0|    }
  578|       |
  579|     22|    if ((grad_mode < LDAC_MODE_0) || (LDAC_MODE_3 < grad_mode)) {
  ------------------
  |  |  150|     22|#define LDAC_MODE_0            0
  ------------------
                  if ((grad_mode < LDAC_MODE_0) || (LDAC_MODE_3 < grad_mode)) {
  ------------------
  |  |  153|     22|#define LDAC_MODE_3            3
  ------------------
  |  Branch (579:9): [True: 0, False: 22]
  |  Branch (579:38): [True: 0, False: 22]
  ------------------
  580|      0|            hData->error_code = LDAC_ERR_ENC_ILL_GRADMODE;
  ------------------
  |  |  149|      0|#define LDAC_ERR_ENC_ILL_GRADMODE         551
  ------------------
  581|      0|            return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  582|      0|    }
  583|       |
  584|     22|    if (grad_mode == LDAC_MODE_0) {
  ------------------
  |  |  150|     22|#define LDAC_MODE_0            0
  ------------------
  |  Branch (584:9): [True: 22, False: 0]
  ------------------
  585|     22|        if ((grad_qu_l < 0) || (LDAC_MAXGRADQU <= grad_qu_l)) {
  ------------------
  |  |   85|     22|#define LDAC_MAXGRADQU        50
  ------------------
  |  Branch (585:13): [True: 0, False: 22]
  |  Branch (585:32): [True: 0, False: 22]
  ------------------
  586|      0|            hData->error_code = LDAC_ERR_ENC_ILL_GRADPAR_A;
  ------------------
  |  |  150|      0|#define LDAC_ERR_ENC_ILL_GRADPAR_A        552
  ------------------
  587|      0|            return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  588|      0|        }
  589|       |
  590|     22|        if ((grad_qu_h < 1) || (LDAC_MAXGRADQU+1 <= grad_qu_h) || (grad_qu_h < grad_qu_l)) {
  ------------------
  |  |   85|     22|#define LDAC_MAXGRADQU        50
  ------------------
  |  Branch (590:13): [True: 0, False: 22]
  |  Branch (590:32): [True: 0, False: 22]
  |  Branch (590:67): [True: 0, False: 22]
  ------------------
  591|      0|            hData->error_code = LDAC_ERR_ENC_ILL_GRADPAR_B;
  ------------------
  |  |  151|      0|#define LDAC_ERR_ENC_ILL_GRADPAR_B        553
  ------------------
  592|      0|            return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  593|      0|        }
  594|       |
  595|     22|        if ((grad_os_h < 0) || (LDAC_NIDSF <= grad_os_h)) {
  ------------------
  |  |  115|     22|#define LDAC_NIDSF            32
  ------------------
  |  Branch (595:13): [True: 0, False: 22]
  |  Branch (595:32): [True: 0, False: 22]
  ------------------
  596|      0|            hData->error_code = LDAC_ERR_ENC_ILL_GRADPAR_C;
  ------------------
  |  |  152|      0|#define LDAC_ERR_ENC_ILL_GRADPAR_C        554
  ------------------
  597|      0|            return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  598|      0|        }
  599|     22|    }
  600|      0|    else {
  601|      0|        if ((grad_qu_l < 0) || (LDAC_DEFGRADQUH < grad_qu_l)) {
  ------------------
  |  |  110|      0|#define LDAC_DEFGRADQUH       26
  ------------------
  |  Branch (601:13): [True: 0, False: 0]
  |  Branch (601:32): [True: 0, False: 0]
  ------------------
  602|      0|            hData->error_code = LDAC_ERR_ENC_ILL_GRADPAR_A;
  ------------------
  |  |  150|      0|#define LDAC_ERR_ENC_ILL_GRADPAR_A        552
  ------------------
  603|      0|            return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  604|      0|        }
  605|      0|    }
  606|       |
  607|     22|    if ((grad_os_l < 0) || (LDAC_NIDSF <= grad_os_l)) {
  ------------------
  |  |  115|     22|#define LDAC_NIDSF            32
  ------------------
  |  Branch (607:9): [True: 0, False: 22]
  |  Branch (607:28): [True: 0, False: 22]
  ------------------
  608|      0|        hData->error_code = LDAC_ERR_ENC_ILL_GRADPAR_D;
  ------------------
  |  |  153|      0|#define LDAC_ERR_ENC_ILL_GRADPAR_D        555
  ------------------
  609|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  610|      0|    }
  611|       |
  612|     22|    hData->nbands = nbands;
  613|     22|    hData->grad_mode = grad_mode;
  614|     22|    hData->grad_qu_l = grad_qu_l;
  615|     22|    hData->grad_os_l = grad_os_l;
  616|     22|    if (grad_mode == LDAC_MODE_0) {
  ------------------
  |  |  150|     22|#define LDAC_MODE_0            0
  ------------------
  |  Branch (616:9): [True: 22, False: 0]
  ------------------
  617|     22|        hData->grad_qu_h = grad_qu_h;
  618|     22|        hData->grad_os_h = grad_os_h;
  619|     22|    }
  620|      0|    else {
  621|      0|        hData->grad_qu_h = LDAC_DEFGRADQUH;
  ------------------
  |  |  110|      0|#define LDAC_DEFGRADQUH       26
  ------------------
  622|      0|        hData->grad_os_h = LDAC_DEFGRADOSH;
  ------------------
  |  |  107|      0|#define LDAC_DEFGRADOSH       31
  ------------------
  623|      0|    }
  624|     22|    hData->abc_status = abc_status;
  625|       |
  626|     22|    return LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  627|     22|}
ldaclib_init_encode:
  634|     22|{
  635|     22|    SFINFO *p_sfinfo = &hData->sfinfo;
  636|     22|    LDAC_RESULT result;
  637|       |
  638|       |
  639|     22|    ldaclib_get_nlnn(p_sfinfo->cfg.smplrate_id, &hData->nlnn);
  640|       |
  641|     22|    set_mdct_table_ldac(hData->nlnn);
  642|       |
  643|     22|    result = init_encode_ldac(p_sfinfo);
  644|     22|    if (result != LDAC_S_OK) {
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  |  Branch (644:9): [True: 0, False: 22]
  ------------------
  645|      0|        hData->error_code = LDAC_ERR_ENC_INIT_ALLOC;
  ------------------
  |  |  148|      0|#define LDAC_ERR_ENC_INIT_ALLOC           550
  ------------------
  646|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  647|      0|    }
  648|       |
  649|     22|    return LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  650|     22|}
ldaclib_free_encode:
  657|     22|{
  658|     22|    if (hData->sfinfo.p_mempos == NULL) {
  ------------------
  |  Branch (658:9): [True: 22, False: 0]
  ------------------
  659|     22|        free_encode_ldac(&hData->sfinfo);
  660|     22|    }
  661|       |
  662|     22|    return LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  663|     22|}
ldaclib_encode:
  674|     22|{
  675|     22|    SFINFO *p_sfinfo = &hData->sfinfo;
  676|     22|    int loc = 0;
  677|     22|    int error_code;
  678|     22|    int frame_length;
  679|       |
  680|       |
  681|     22|    if (!ldaclib_assert_sample_format(sample_format)) {
  ------------------
  |  Branch (681:9): [True: 0, False: 22]
  ------------------
  682|      0|        hData->error_code = LDAC_ERR_ILL_SMPL_FORMAT;
  ------------------
  |  |  136|      0|#define LDAC_ERR_ILL_SMPL_FORMAT          517
  ------------------
  683|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  684|      0|    }
  685|       |
  686|     22|    frame_length = p_sfinfo->cfg.frame_length;
  687|     22|    clear_data_ldac(p_stream, frame_length*sizeof(unsigned char));
  ------------------
  |  |   61|     22|#define clear_data_ldac(p, n)      memset((p), 0, (n))
  ------------------
  688|       |
  689|     22|    set_input_pcm_ldac(p_sfinfo, ap_pcm, sample_format, hData->nlnn);
  690|       |
  691|     22|    proc_mdct_ldac(p_sfinfo, hData->nlnn);
  692|       |
  693|     22|    p_sfinfo->cfg.frame_status = ana_frame_status_ldac(p_sfinfo, hData->nlnn);
  694|       |
  695|     22|    error_code = encode_ldac(p_sfinfo, hData->nbands, hData->grad_mode,
  696|     22|            hData->grad_qu_l, hData->grad_qu_h, hData->grad_os_l, hData->grad_os_h,
  697|     22|            hData->abc_status);
  698|     22|    if (LDAC_ERROR(error_code) && !LDAC_FATAL_ERROR(error_code)) {
  ------------------
  |  |  168|     44|#define LDAC_ERROR(err)       ((LDAC_ERR_NON_FATAL) <= (err) ? 1 : 0)
  |  |  ------------------
  |  |  |  |  106|     22|#define LDAC_ERR_NON_FATAL                  1
  |  |  ------------------
  |  |  |  Branch (168:31): [True: 0, False: 22]
  |  |  |  Branch (168:32): [True: 0, False: 22]
  |  |  ------------------
  ------------------
                  if (LDAC_ERROR(error_code) && !LDAC_FATAL_ERROR(error_code)) {
  ------------------
  |  |  169|      0|#define LDAC_FATAL_ERROR(err) ((LDAC_ERR_FATAL) <= (err) ? 1 : 0)
  |  |  ------------------
  |  |  |  |  116|      0|#define LDAC_ERR_FATAL                    256
  |  |  ------------------
  |  |  |  Branch (169:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (698:35): [True: 0, False: 0]
  ------------------
  699|      0|        int error_code2;
  700|      0|        error_code2 = pack_null_data_frame_ldac(p_sfinfo, (STREAM *)p_stream, &loc, p_nbytes_used);
  701|      0|        if (LDAC_FATAL_ERROR(error_code2)) {
  ------------------
  |  |  169|      0|#define LDAC_FATAL_ERROR(err) ((LDAC_ERR_FATAL) <= (err) ? 1 : 0)
  |  |  ------------------
  |  |  |  |  116|      0|#define LDAC_ERR_FATAL                    256
  |  |  ------------------
  |  |  |  Branch (169:31): [True: 0, False: 0]
  |  |  |  Branch (169:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  702|      0|            clear_data_ldac(p_stream, frame_length*sizeof(unsigned char));
  ------------------
  |  |   61|      0|#define clear_data_ldac(p, n)      memset((p), 0, (n))
  ------------------
  703|      0|            hData->error_code = error_code2;
  704|      0|            return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  705|      0|        }
  706|      0|        hData->error_code = error_code;
  707|      0|        return LDAC_S_FALSE;
  ------------------
  |  |   34|      0|#define LDAC_S_FALSE       ((LDAC_RESULT)0x00000001L)
  ------------------
  708|      0|    }
  709|       |
  710|     22|    error_code = pack_raw_data_frame_ldac(p_sfinfo, (STREAM *)p_stream, &loc, p_nbytes_used);
  711|     22|    if (LDAC_FATAL_ERROR(error_code)) {
  ------------------
  |  |  169|     22|#define LDAC_FATAL_ERROR(err) ((LDAC_ERR_FATAL) <= (err) ? 1 : 0)
  |  |  ------------------
  |  |  |  |  116|     22|#define LDAC_ERR_FATAL                    256
  |  |  ------------------
  |  |  |  Branch (169:31): [True: 0, False: 22]
  |  |  |  Branch (169:32): [True: 0, False: 22]
  |  |  ------------------
  ------------------
  712|      0|        int error_code2;
  713|      0|        loc = 0;
  714|      0|        clear_data_ldac(p_stream, frame_length*sizeof(unsigned char));
  ------------------
  |  |   61|      0|#define clear_data_ldac(p, n)      memset((p), 0, (n))
  ------------------
  715|      0|        error_code2 = pack_null_data_frame_ldac(p_sfinfo, (STREAM *)p_stream, &loc, p_nbytes_used);
  716|      0|        if (LDAC_FATAL_ERROR(error_code2)) {
  ------------------
  |  |  169|      0|#define LDAC_FATAL_ERROR(err) ((LDAC_ERR_FATAL) <= (err) ? 1 : 0)
  |  |  ------------------
  |  |  |  |  116|      0|#define LDAC_ERR_FATAL                    256
  |  |  ------------------
  |  |  |  Branch (169:31): [True: 0, False: 0]
  |  |  |  Branch (169:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  717|      0|            clear_data_ldac(p_stream, frame_length*sizeof(unsigned char));
  ------------------
  |  |   61|      0|#define clear_data_ldac(p, n)      memset((p), 0, (n))
  ------------------
  718|      0|            hData->error_code = error_code2;
  719|      0|            return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  720|      0|        }
  721|      0|        hData->error_code = error_code;
  722|      0|        return LDAC_E_FAIL;
  ------------------
  |  |   38|      0|#define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
  ------------------
  723|      0|    }
  724|       |
  725|     22|    return LDAC_S_OK;
  ------------------
  |  |   33|     22|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  726|     22|}
ldaclib_clear_error_code:
  770|     66|{
  771|     66|    hData->error_code = LDAC_ERR_NONE;
  ------------------
  |  |  103|     66|#define LDAC_ERR_NONE                       0
  ------------------
  772|       |
  773|     66|    return LDAC_S_OK;
  ------------------
  |  |   33|     66|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  774|     66|}
ldaclib_clear_internal_error_code:
  793|     66|{
  794|     66|    hData->sfinfo.error_code = LDAC_ERR_NONE;
  ------------------
  |  |  103|     66|#define LDAC_ERR_NONE                       0
  ------------------
  795|       |
  796|     66|    return LDAC_S_OK;
  ------------------
  |  |   33|     66|#define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
  ------------------
  797|     66|}
ldaclib.c:ldaclib_assert_sampling_rate_index:
   29|     88|{
   30|     88|    if ((LDAC_SMPLRATEID_0 <= smplrate_id) && (smplrate_id < LDAC_NSMPLRATEID)) {
  ------------------
  |  |   37|     88|#define LDAC_SMPLRATEID_0    0x0
  ------------------
                  if ((LDAC_SMPLRATEID_0 <= smplrate_id) && (smplrate_id < LDAC_NSMPLRATEID)) {
  ------------------
  |  |   35|     88|#define LDAC_NSMPLRATEID       6
  ------------------
  |  Branch (30:9): [True: 88, False: 0]
  |  Branch (30:47): [True: 88, False: 0]
  ------------------
   31|     88|        return LDAC_TRUE;
  ------------------
  |  |  146|     88|#define LDAC_TRUE              1
  ------------------
   32|     88|    }
   33|      0|    else {
   34|      0|        return LDAC_FALSE;
  ------------------
  |  |  147|      0|#define LDAC_FALSE             0
  ------------------
   35|      0|    }
   36|     88|}
ldaclib.c:ldaclib_assert_supported_sampling_rate_index:
   40|     88|{
   41|     88|    if ((LDAC_SMPLRATEID_0 <= smplrate_id) && (smplrate_id < LDAC_NSUPSMPLRATEID)) {
  ------------------
  |  |   37|     88|#define LDAC_SMPLRATEID_0    0x0
  ------------------
                  if ((LDAC_SMPLRATEID_0 <= smplrate_id) && (smplrate_id < LDAC_NSUPSMPLRATEID)) {
  ------------------
  |  |   36|     88|#define LDAC_NSUPSMPLRATEID    4
  ------------------
  |  Branch (41:9): [True: 88, False: 0]
  |  Branch (41:47): [True: 88, False: 0]
  ------------------
   42|     88|        return LDAC_TRUE;
  ------------------
  |  |  146|     88|#define LDAC_TRUE              1
  ------------------
   43|     88|    }
   44|      0|    else {
   45|      0|        return LDAC_FALSE;
  ------------------
  |  |  147|      0|#define LDAC_FALSE             0
  ------------------
   46|      0|    }
   47|     88|}
ldaclib.c:ldaclib_assert_channel_config_index:
   51|     66|{
   52|     66|    if ((chconfig_id == LDAC_CHCONFIGID_MN)
  ------------------
  |  |   48|     66|#define LDAC_CHCONFIGID_MN     0
  ------------------
  |  Branch (52:9): [True: 0, False: 66]
  ------------------
   53|     66|            || (chconfig_id == LDAC_CHCONFIGID_DL) || (chconfig_id == LDAC_CHCONFIGID_ST)) {
  ------------------
  |  |   49|     66|#define LDAC_CHCONFIGID_DL     1
  ------------------
                          || (chconfig_id == LDAC_CHCONFIGID_DL) || (chconfig_id == LDAC_CHCONFIGID_ST)) {
  ------------------
  |  |   50|      0|#define LDAC_CHCONFIGID_ST     2
  ------------------
  |  Branch (53:16): [True: 66, False: 0]
  |  Branch (53:55): [True: 0, False: 0]
  ------------------
   54|     66|        return LDAC_TRUE;
  ------------------
  |  |  146|     66|#define LDAC_TRUE              1
  ------------------
   55|     66|    }
   56|      0|    else {
   57|      0|        return LDAC_FALSE;
  ------------------
  |  |  147|      0|#define LDAC_FALSE             0
  ------------------
   58|      0|    }
   59|     66|}
ldaclib.c:ldaclib_assert_frame_length:
   74|     44|{
   75|     44|    if ((0 < frame_length) && (frame_length <= LDAC_MAXNBYTES)) {
  ------------------
  |  |   54|     44|#define LDAC_MAXNBYTES      1024
  ------------------
  |  Branch (75:9): [True: 44, False: 0]
  |  Branch (75:31): [True: 44, False: 0]
  ------------------
   76|     44|        return LDAC_TRUE;
  ------------------
  |  |  146|     44|#define LDAC_TRUE              1
  ------------------
   77|     44|    }
   78|      0|    else {
   79|      0|        return LDAC_FALSE;
  ------------------
  |  |  147|      0|#define LDAC_FALSE             0
  ------------------
   80|      0|    }
   81|     44|}
ldaclib.c:ldaclib_assert_supported_frame_length:
   86|     44|{
   87|     44|    if (chconfig_id == LDAC_CHCONFIGID_MN) {
  ------------------
  |  |   48|     44|#define LDAC_CHCONFIGID_MN     0
  ------------------
  |  Branch (87:9): [True: 0, False: 44]
  ------------------
   88|      0|        if ((LDAC_MINSUPNBYTES/2 <= frame_length) && (frame_length <= LDAC_MAXSUPNBYTES/2)) {
  ------------------
  |  |   56|      0|#define LDAC_MINSUPNBYTES     22
  ------------------
                      if ((LDAC_MINSUPNBYTES/2 <= frame_length) && (frame_length <= LDAC_MAXSUPNBYTES/2)) {
  ------------------
  |  |   55|      0|#define LDAC_MAXSUPNBYTES    512
  ------------------
  |  Branch (88:13): [True: 0, False: 0]
  |  Branch (88:54): [True: 0, False: 0]
  ------------------
   89|      0|            return LDAC_TRUE;
  ------------------
  |  |  146|      0|#define LDAC_TRUE              1
  ------------------
   90|      0|        }
   91|      0|        else {
   92|      0|            return LDAC_FALSE;
  ------------------
  |  |  147|      0|#define LDAC_FALSE             0
  ------------------
   93|      0|        }
   94|      0|    }
   95|     44|    else if ((chconfig_id == LDAC_CHCONFIGID_DL) || (chconfig_id == LDAC_CHCONFIGID_ST)) {
  ------------------
  |  |   49|     44|#define LDAC_CHCONFIGID_DL     1
  ------------------
                  else if ((chconfig_id == LDAC_CHCONFIGID_DL) || (chconfig_id == LDAC_CHCONFIGID_ST)) {
  ------------------
  |  |   50|      0|#define LDAC_CHCONFIGID_ST     2
  ------------------
  |  Branch (95:14): [True: 44, False: 0]
  |  Branch (95:53): [True: 0, False: 0]
  ------------------
   96|     44|        if ((LDAC_MINSUPNBYTES <= frame_length) && (frame_length <= LDAC_MAXSUPNBYTES)) {
  ------------------
  |  |   56|     44|#define LDAC_MINSUPNBYTES     22
  ------------------
                      if ((LDAC_MINSUPNBYTES <= frame_length) && (frame_length <= LDAC_MAXSUPNBYTES)) {
  ------------------
  |  |   55|     44|#define LDAC_MAXSUPNBYTES    512
  ------------------
  |  Branch (96:13): [True: 44, False: 0]
  |  Branch (96:52): [True: 44, False: 0]
  ------------------
   97|     44|            return LDAC_TRUE;
  ------------------
  |  |  146|     44|#define LDAC_TRUE              1
  ------------------
   98|     44|        }
   99|      0|        else {
  100|      0|            return LDAC_FALSE;
  ------------------
  |  |  147|      0|#define LDAC_FALSE             0
  ------------------
  101|      0|        }
  102|     44|    }
  103|      0|    else {
  104|      0|        return LDAC_FALSE;
  ------------------
  |  |  147|      0|#define LDAC_FALSE             0
  ------------------
  105|      0|    }
  106|     44|}
ldaclib.c:ldaclib_assert_frame_status:
  110|     44|{
  111|     44|    if ((LDAC_FRMSTAT_LEV_0 <= frame_status) && (frame_status <= LDAC_FRMSTAT_LEV_3)) {
  ------------------
  |  |   59|     44|#define LDAC_FRMSTAT_LEV_0     0
  ------------------
                  if ((LDAC_FRMSTAT_LEV_0 <= frame_status) && (frame_status <= LDAC_FRMSTAT_LEV_3)) {
  ------------------
  |  |   62|     44|#define LDAC_FRMSTAT_LEV_3     3
  ------------------
  |  Branch (111:9): [True: 44, False: 0]
  |  Branch (111:49): [True: 44, False: 0]
  ------------------
  112|     44|        return LDAC_TRUE;
  ------------------
  |  |  146|     44|#define LDAC_TRUE              1
  ------------------
  113|     44|    }
  114|      0|    else {
  115|      0|        return LDAC_FALSE;
  ------------------
  |  |  147|      0|#define LDAC_FALSE             0
  ------------------
  116|      0|    }
  117|     44|}
ldaclib.c:ldaclib_assert_sample_format:
  132|     22|{
  133|     22|#ifndef _32BIT_FIXED_POINT
  134|     22|    if ((LDAC_SMPL_FMT_S16 <= sample_format) && (sample_format <= LDAC_SMPL_FMT_F32)) {
  ------------------
  |  Branch (134:9): [True: 22, False: 0]
  |  Branch (134:49): [True: 22, False: 0]
  ------------------
  135|       |#else /* _32BIT_FIXED_POINT */
  136|       |    if ((LDAC_SMPL_FMT_S16 <= sample_format) && (sample_format <= LDAC_SMPL_FMT_S32)) {
  137|       |#endif /* _32BIT_FIXED_POINT */
  138|     22|        return LDAC_TRUE;
  ------------------
  |  |  146|     22|#define LDAC_TRUE              1
  ------------------
  139|     22|    }
  140|      0|    else {
  141|      0|        return LDAC_FALSE;
  ------------------
  |  |  147|      0|#define LDAC_FALSE             0
  ------------------
  142|      0|    }
  143|     22|}

ldaclib.c:proc_mdct_ldac:
  103|     22|{
  104|     22|    AC *p_ac;
  105|     22|    int ich;
  106|     22|    int nchs = p_sfinfo->cfg.ch;
  107|       |
  108|     66|    for (ich = 0; ich < nchs; ich++) {
  ------------------
  |  Branch (108:19): [True: 44, False: 22]
  ------------------
  109|     44|        p_ac = p_sfinfo->ap_ac[ich];
  110|     44|        proc_mdct_core_ldac(p_ac->p_acsub->a_time, p_ac->p_acsub->a_spec, nlnn);
  111|     44|    }
  112|       |
  113|     22|    return;
  114|     22|}
ldaclib.c:proc_mdct_core_ldac:
   26|     44|{
   27|     44|    int i, j, k;
   28|     44|    int loop1, loop2;
   29|     44|    int coef, index0, index1, offset;
   30|     44|    int nsmpl = npow2_ldac(nlnn);
  ------------------
  |  |  274|     44|#define npow2_ldac(n)  (1 << (n))
  ------------------
   31|     44|    const int *p_p;
   32|     44|    const SCALAR *p_w, *p_c, *p_s;
   33|     44|    SCALAR a_work[LDAC_MAXLSU];
   34|     44|    SCALAR *p_work = a_work;
   35|     44|    SCALAR a, b, c, d, tmp;
   36|     44|    SCALAR cc, cs;
   37|       |
   38|     44|    i = nlnn - LDAC_1FSLNN;
  ------------------
  |  |   75|     44|#define LDAC_1FSLNN            7
  ------------------
   39|     44|    p_w = gaa_fwin_ldac[i];
   40|     44|    p_c = gaa_wcos_ldac[i];
   41|     44|    p_s = gaa_wsin_ldac[i];
   42|     44|    p_p = gaa_perm_ldac[i];
   43|       |
   44|       |    /* Windowing */
   45|  2.86k|    for (i = 0; i < nsmpl>>1; i++) {
  ------------------
  |  Branch (45:17): [True: 2.81k, False: 44]
  ------------------
   46|  2.81k|        p_work[p_p[i]] = -p_x[3*nsmpl/2-1-i] * p_w[nsmpl/2+i] - p_x[3*nsmpl/2+i] * p_w[nsmpl/2-1-i];
   47|       |
   48|  2.81k|        p_work[p_p[nsmpl/2+i]] = p_x[i] * p_w[i] - p_x[nsmpl-1-i] * p_w[nsmpl-1-i];
   49|  2.81k|    }
   50|       |
   51|       |    /* Butterfly */
   52|     44|    coef = 0;
   53|    308|    for (i = 0; i < nlnn-1; ++i) {
  ------------------
  |  Branch (53:17): [True: 264, False: 44]
  ------------------
   54|    264|        loop1 = 1 << (nlnn-2-i);
   55|    264|        loop2 = 1 << i;
   56|    264|        index0 = 0;
   57|    264|        index1 = 1 << (i+1);
   58|    264|        offset = 1 << (i+2);
   59|       |
   60|  3.03k|        for (k = 0; k < loop2; ++k) {
  ------------------
  |  Branch (60:21): [True: 2.77k, False: 264]
  ------------------
   61|  2.77k|            cc = p_c[coef];
   62|  2.77k|            cs = p_s[coef++];
   63|  11.2k|            for (j = 0; j < loop1; ++j) {
  ------------------
  |  Branch (63:25): [True: 8.44k, False: 2.77k]
  ------------------
   64|  8.44k|                a = p_work[index0+0];
   65|  8.44k|                b = p_work[index0+1];
   66|  8.44k|                c = p_work[index1+0] * cc + p_work[index1+1] * cs;
   67|  8.44k|                d = p_work[index1+0] * cs - p_work[index1+1] * cc;
   68|       |
   69|  8.44k|                p_work[index0+0] = a + c;
   70|  8.44k|                p_work[index0+1] = b + d;
   71|  8.44k|                p_work[index1+0] = a - c;
   72|  8.44k|                p_work[index1+1] = b - d;
   73|  8.44k|                index0 += offset;
   74|  8.44k|                index1 += offset;
   75|  8.44k|            }
   76|  2.77k|            index0 += 2 - nsmpl;
   77|  2.77k|            index1 += 2 - nsmpl;
   78|  2.77k|        }
   79|    264|    }
   80|       |
   81|     44|    tmp = _scalar(1.0) / (SCALAR)(nsmpl>>1);
  ------------------
  |  |   51|     44|#define _scalar(x) x##f
  ------------------
   82|  2.86k|    for (i = 0; i < nsmpl>>1; i++) {
  ------------------
  |  Branch (82:17): [True: 2.81k, False: 44]
  ------------------
   83|  2.81k|        cc = p_c[coef];
   84|  2.81k|        cs = p_s[coef++];
   85|       |
   86|  2.81k|        index0 = i << 1;
   87|  2.81k|        a = p_work[index0] * cc + p_work[index0+1] * cs;
   88|  2.81k|        b = p_work[index0] * cs - p_work[index0+1] * cc;
   89|       |
   90|  2.81k|        p_y[index0] = a * tmp;
   91|  2.81k|        p_y[nsmpl-index0-1] = b * tmp;
   92|  2.81k|    }
   93|       |
   94|     44|    return;
   95|     44|}

ldaclib.c:calloc_ldac:
   41|    110|{
   42|    110|    char *p_tmp;
   43|       |
   44|    110|    if (p_sfinfo->p_mempos != (char *)NULL) {
  ------------------
  |  Branch (44:9): [True: 0, False: 110]
  ------------------
   45|      0|        p_tmp = p_sfinfo->p_mempos;
   46|      0|        p_sfinfo->p_mempos += nmemb * align_ldac(size);
   47|      0|    }
   48|    110|    else {
   49|    110|        p_tmp = calloc(nmemb, size);
   50|    110|    }
   51|       |
   52|    110|    return (void *)p_tmp;
   53|    110|}

ldaclib.c:pack_frame_header_ldac:
   56|     22|{
   57|     22|    int loc = 0;
   58|       |
   59|     22|    pack_store_ldac(LDAC_SYNCWORD, LDAC_SYNCWORDBITS, p_stream, &loc);
  ------------------
  |  |   32|     22|#define LDAC_SYNCWORD       0xAA
  ------------------
                  pack_store_ldac(LDAC_SYNCWORD, LDAC_SYNCWORDBITS, p_stream, &loc);
  ------------------
  |  |   31|     22|#define LDAC_SYNCWORDBITS      8
  ------------------
   60|       |
   61|     22|    pack_store_ldac(smplrate_id, LDAC_SMPLRATEBITS, p_stream, &loc);
  ------------------
  |  |   34|     22|#define LDAC_SMPLRATEBITS      3
  ------------------
   62|       |
   63|     22|    pack_store_ldac(chconfig_id, LDAC_CHCONFIG2BITS, p_stream, &loc);
  ------------------
  |  |   43|     22|#define LDAC_CHCONFIG2BITS     2
  ------------------
   64|       |
   65|     22|    pack_store_ldac(frame_length-1, LDAC_FRAMELEN2BITS, p_stream, &loc);
  ------------------
  |  |   53|     22|#define LDAC_FRAMELEN2BITS     9
  ------------------
   66|       |
   67|     22|    pack_store_ldac(frame_status, LDAC_FRAMESTATBITS, p_stream, &loc);
  ------------------
  |  |   58|     22|#define LDAC_FRAMESTATBITS     2
  ------------------
   68|       |
   69|     22|    return;
   70|     22|}
ldaclib.c:pack_store_ldac:
   27|  6.68k|{
   28|  6.68k|    STREAM *p_bufptr;
   29|  6.68k|    register int bpos;
   30|  6.68k|    register unsigned int tmp;
   31|       |
   32|  6.68k|    p_bufptr = p_block + (*p_loc >> LDAC_LOC_SHIFT);
  ------------------
  |  |  139|  6.68k|#define LDAC_LOC_SHIFT         3
  ------------------
   33|  6.68k|    bpos = *p_loc & LDAC_LOC_MASK;
  ------------------
  |  |  140|  6.68k|#define LDAC_LOC_MASK        0x7
  ------------------
   34|       |
   35|  6.68k|    tmp = (idata << (24-nbits)) & 0xffffff;
   36|  6.68k|    tmp >>= bpos;
   37|  6.68k|    *p_bufptr++ |= (tmp>>16);
   38|  6.68k|    *p_bufptr++ = (tmp>>8) & 0xff;
   39|  6.68k|    *p_bufptr = tmp & 0xff;
   40|       |
   41|  6.68k|    *p_loc += nbits;
   42|       |
   43|  6.68k|    return;
   44|  6.68k|}
ldaclib.c:pack_raw_data_frame_ldac:
  427|     22|{
  428|     22|    CFG *p_cfg = &p_sfinfo->cfg;
  429|     22|    AB *p_ab = p_sfinfo->p_ab;
  430|     22|    int ibk;
  431|     22|    int nbks = gaa_block_setting_ldac[p_cfg->chconfig_id][1];
  432|       |
  433|     66|    for (ibk = 0; ibk < nbks; ibk++) {
  ------------------
  |  Branch (433:19): [True: 44, False: 22]
  ------------------
  434|     44|        if (!pack_audio_block_ldac(p_ab, p_stream, p_loc)) {
  ------------------
  |  Branch (434:13): [True: 0, False: 44]
  ------------------
  435|      0|            return LDAC_ERR_PACK_BLOCK_FAILED;
  ------------------
  |  |  155|      0|#define LDAC_ERR_PACK_BLOCK_FAILED        557
  ------------------
  436|      0|        }
  437|       |
  438|     44|        pack_block_alignment_ldac(p_stream, p_loc);
  ------------------
  |  |   95|     44|#define pack_block_alignment_ldac(p_stream, p_loc) pack_byte_alignment_ldac((p_stream), (p_loc))
  ------------------
  439|       |
  440|     44|        p_ab++;
  441|     44|    }
  442|       |
  443|     22|    pack_frame_alignment_ldac(p_stream, p_loc, p_cfg->frame_length);
  444|       |
  445|     22|    *p_nbytes_used = *p_loc / LDAC_BYTESIZE;
  ------------------
  |  |  141|     22|#define LDAC_BYTESIZE          8
  ------------------
  446|       |
  447|     22|    return LDAC_ERR_NONE;
  ------------------
  |  |  103|     22|#define LDAC_ERR_NONE                       0
  ------------------
  448|     22|}
ldaclib.c:pack_audio_block_ldac:
  367|     44|{
  368|     44|    AC *p_ac;
  369|     44|    int ich;
  370|     44|    int nchs = p_ab->blk_nchs;
  371|     44|    int nbits_band, nbits_grad, a_nbits_scfc[2], a_nbits_spec[2], nbits_used;
  372|     44|    int loc;
  373|       |
  374|    132|    for (ich = 0; ich < 2; ich++) {
  ------------------
  |  Branch (374:19): [True: 88, False: 44]
  ------------------
  375|     88|        a_nbits_scfc[ich] = 0;
  376|     88|        a_nbits_spec[ich] = 0;
  377|     88|    }
  378|       |
  379|     44|    loc = *p_loc;
  380|     44|    pack_band_info_ldac(p_ab, p_stream, p_loc);
  381|     44|    nbits_band = *p_loc - loc;
  382|       |
  383|     44|    loc = *p_loc;
  384|     44|    pack_gradient_ldac(p_ab, p_stream, p_loc);
  385|     44|    nbits_grad = *p_loc - loc;
  386|       |
  387|     44|    nbits_used = nbits_band + nbits_grad;
  388|       |
  389|     88|    for (ich = 0; ich < nchs; ich++) {
  ------------------
  |  Branch (389:19): [True: 44, False: 44]
  ------------------
  390|     44|        p_ac = p_ab->ap_ac[ich];
  391|       |
  392|     44|        loc = *p_loc;
  393|     44|        pack_scale_factor_ldac(p_ac, p_stream, p_loc);
  394|     44|        a_nbits_scfc[ich] = *p_loc - loc;
  395|       |
  396|     44|        loc = *p_loc;
  397|     44|        pack_spectrum_ldac(p_ac, p_stream, p_loc);
  398|     44|        a_nbits_spec[ich] = *p_loc - loc;
  399|       |
  400|     44|        loc = *p_loc;
  401|     44|        pack_residual_ldac(p_ac, p_stream, p_loc);
  402|     44|        a_nbits_spec[ich] += *p_loc - loc;
  403|       |
  404|     44|        nbits_used += a_nbits_scfc[ich] + a_nbits_spec[ich];
  405|     44|    }
  406|       |
  407|     44|    if (nbits_used > p_ab->nbits_used) {
  ------------------
  |  Branch (407:9): [True: 0, False: 44]
  ------------------
  408|      0|        *p_ab->p_error_code = LDAC_ERR_BIT_PACKING;
  ------------------
  |  |  128|      0|#define LDAC_ERR_BIT_PACKING              280
  ------------------
  409|      0|        return LDAC_FALSE;
  ------------------
  |  |  147|      0|#define LDAC_FALSE             0
  ------------------
  410|      0|    }
  411|     44|    else if (nbits_used < p_ab->nbits_used) {
  ------------------
  |  Branch (411:14): [True: 0, False: 44]
  ------------------
  412|      0|        *p_ab->p_error_code = LDAC_ERR_BIT_PACKING;
  ------------------
  |  |  128|      0|#define LDAC_ERR_BIT_PACKING              280
  ------------------
  413|      0|        return LDAC_FALSE;
  ------------------
  |  |  147|      0|#define LDAC_FALSE             0
  ------------------
  414|      0|    }
  415|       |
  416|     44|    return LDAC_TRUE;
  ------------------
  |  |  146|     44|#define LDAC_TRUE              1
  ------------------
  417|     44|}
ldaclib.c:pack_band_info_ldac:
  119|     44|{
  120|     44|    pack_store_ldac(p_ab->nbands-LDAC_BAND_OFFSET, LDAC_NBANDBITS, p_stream, p_loc);
  ------------------
  |  |  102|     44|#define LDAC_BAND_OFFSET       2
  ------------------
                  pack_store_ldac(p_ab->nbands-LDAC_BAND_OFFSET, LDAC_NBANDBITS, p_stream, p_loc);
  ------------------
  |  |  101|     44|#define LDAC_NBANDBITS         4
  ------------------
  121|       |
  122|     44|    pack_store_ldac(LDAC_FALSE, LDAC_FLAGBITS, p_stream, p_loc);
  ------------------
  |  |  147|     44|#define LDAC_FALSE             0
  ------------------
                  pack_store_ldac(LDAC_FALSE, LDAC_FLAGBITS, p_stream, p_loc);
  ------------------
  |  |  145|     44|#define LDAC_FLAGBITS          1
  ------------------
  123|       |
  124|     44|    return;
  125|     44|}
ldaclib.c:pack_gradient_ldac:
  134|     44|{
  135|     44|    pack_store_ldac(p_ab->grad_mode, LDAC_GRADMODEBITS, p_stream, p_loc);
  ------------------
  |  |  104|     44|#define LDAC_GRADMODEBITS      2
  ------------------
  136|       |
  137|     44|    if (p_ab->grad_mode == LDAC_MODE_0) {
  ------------------
  |  |  150|     44|#define LDAC_MODE_0            0
  ------------------
  |  Branch (137:9): [True: 44, False: 0]
  ------------------
  138|     44|        pack_store_ldac(p_ab->grad_qu_l, LDAC_GRADQU0BITS, p_stream, p_loc);
  ------------------
  |  |  108|     44|#define LDAC_GRADQU0BITS       6
  ------------------
  139|       |
  140|     44|        pack_store_ldac(p_ab->grad_qu_h-1, LDAC_GRADQU0BITS, p_stream, p_loc);
  ------------------
  |  |  108|     44|#define LDAC_GRADQU0BITS       6
  ------------------
  141|       |
  142|     44|        pack_store_ldac(p_ab->grad_os_l, LDAC_GRADOSBITS, p_stream, p_loc);
  ------------------
  |  |  105|     44|#define LDAC_GRADOSBITS        5
  ------------------
  143|       |
  144|     44|        pack_store_ldac(p_ab->grad_os_h, LDAC_GRADOSBITS, p_stream, p_loc);
  ------------------
  |  |  105|     44|#define LDAC_GRADOSBITS        5
  ------------------
  145|     44|    }
  146|      0|    else {
  147|      0|        pack_store_ldac(p_ab->grad_qu_l, LDAC_GRADQU1BITS, p_stream, p_loc);
  ------------------
  |  |  109|      0|#define LDAC_GRADQU1BITS       5
  ------------------
  148|       |
  149|      0|        pack_store_ldac(p_ab->grad_os_l, LDAC_GRADOSBITS, p_stream, p_loc);
  ------------------
  |  |  105|      0|#define LDAC_GRADOSBITS        5
  ------------------
  150|      0|    }
  151|       |
  152|     44|    pack_store_ldac(p_ab->nadjqus, LDAC_NADJQUBITS, p_stream, p_loc);
  ------------------
  |  |  111|     44|#define LDAC_NADJQUBITS        5
  ------------------
  153|       |
  154|     44|    return;
  155|     44|}
ldaclib.c:pack_scale_factor_ldac:
  257|     44|{
  258|     44|    int sfc_mode = p_ac->sfc_mode;
  259|       |
  260|     44|    pack_store_ldac(sfc_mode, LDAC_SFCMODEBITS, p_stream, p_loc);
  ------------------
  |  |  116|     44|#define LDAC_SFCMODEBITS       1
  ------------------
  261|       |
  262|     44|    if (p_ac->ich == 0) {
  ------------------
  |  Branch (262:9): [True: 44, False: 0]
  ------------------
  263|     44|        if (sfc_mode == LDAC_MODE_0) {
  ------------------
  |  |  150|     44|#define LDAC_MODE_0            0
  ------------------
  |  Branch (263:13): [True: 44, False: 0]
  ------------------
  264|     44|            pack_scale_factor_0_ldac(p_ac, p_stream, p_loc);
  265|     44|        }
  266|      0|        else {
  267|      0|            pack_scale_factor_1_ldac(p_ac, p_stream, p_loc);
  268|      0|        }
  269|     44|    }
  270|      0|    else {
  271|      0|        if (sfc_mode == LDAC_MODE_0) {
  ------------------
  |  |  150|      0|#define LDAC_MODE_0            0
  ------------------
  |  Branch (271:13): [True: 0, False: 0]
  ------------------
  272|      0|            pack_scale_factor_0_ldac(p_ac, p_stream, p_loc);
  273|      0|        }
  274|      0|        else {
  275|      0|            pack_scale_factor_2_ldac(p_ac, p_stream, p_loc);
  276|      0|        }
  277|      0|    }
  278|       |
  279|     44|    return;
  280|     44|}
ldaclib.c:pack_scale_factor_0_ldac:
  164|     44|{
  165|     44|    HCENC *p_hcsf;
  166|     44|    int iqu;
  167|     44|    int nqus = p_ac->p_ab->nqus;
  168|     44|    int dif, val0, val1;
  169|     44|    const unsigned char *p_tbl;
  170|       |
  171|     44|    pack_store_ldac(p_ac->sfc_bitlen-LDAC_MINSFCBLEN_0, LDAC_SFCBLENBITS, p_stream, p_loc);
  ------------------
  |  |  121|     44|#define LDAC_MINSFCBLEN_0      3
  ------------------
                  pack_store_ldac(p_ac->sfc_bitlen-LDAC_MINSFCBLEN_0, LDAC_SFCBLENBITS, p_stream, p_loc);
  ------------------
  |  |  120|     44|#define LDAC_SFCBLENBITS       2
  ------------------
  172|       |
  173|     44|    pack_store_ldac(p_ac->sfc_offset, LDAC_IDSFBITS, p_stream, p_loc);
  ------------------
  |  |  114|     44|#define LDAC_IDSFBITS          5
  ------------------
  174|       |
  175|     44|    pack_store_ldac(p_ac->sfc_weight, LDAC_SFCWTBLBITS, p_stream, p_loc);
  ------------------
  |  |  118|     44|#define LDAC_SFCWTBLBITS       3
  ------------------
  176|       |
  177|     44|    p_tbl = gaa_sfcwgt_ldac[p_ac->sfc_weight];
  178|     44|    val0 = p_ac->a_idsf[0] + p_tbl[0];
  179|       |
  180|     44|    pack_store_ldac(val0-p_ac->sfc_offset, p_ac->sfc_bitlen, p_stream, p_loc);
  181|       |
  182|     44|    p_hcsf = ga_hcenc_sf0_ldac + (p_ac->sfc_bitlen-LDAC_MINSFCBLEN_0);
  ------------------
  |  |  121|     44|#define LDAC_MINSFCBLEN_0      3
  ------------------
  183|  1.14k|    for (iqu = 1; iqu < nqus; iqu++) {
  ------------------
  |  Branch (183:19): [True: 1.10k, False: 44]
  ------------------
  184|  1.10k|        val1 = p_ac->a_idsf[iqu] + p_tbl[iqu];
  185|  1.10k|        dif = (val1 - val0) & p_hcsf->mask;
  186|  1.10k|        pack_store_ldac(hc_word_ldac(p_hcsf->p_tbl+dif), hc_len_ldac(p_hcsf->p_tbl+dif), p_stream, p_loc);
  ------------------
  |  |  280|  1.10k|#define hc_word_ldac(p) ((p)->word)
  ------------------
                      pack_store_ldac(hc_word_ldac(p_hcsf->p_tbl+dif), hc_len_ldac(p_hcsf->p_tbl+dif), p_stream, p_loc);
  ------------------
  |  |  279|  1.10k|#define hc_len_ldac(p)  ((p)->len)
  ------------------
  187|  1.10k|        val0 = val1;
  188|  1.10k|    }
  189|       |
  190|     44|    return;
  191|     44|}
ldaclib.c:pack_spectrum_ldac:
  289|     44|{
  290|     44|    int iqu, isp, i;
  291|     44|    int lsp, hsp;
  292|     44|    int nqus = p_ac->p_ab->nqus;
  293|     44|    int nsps, idwl1, wl, val;
  294|       |
  295|  1.18k|    for (iqu = 0; iqu < nqus; iqu++) {
  ------------------
  |  Branch (295:19): [True: 1.14k, False: 44]
  ------------------
  296|  1.14k|        lsp = ga_isp_ldac[iqu];
  297|  1.14k|        hsp = ga_isp_ldac[iqu+1];
  298|  1.14k|        nsps = ga_nsps_ldac[iqu];
  299|  1.14k|        idwl1 = p_ac->a_idwl1[iqu];
  300|  1.14k|        wl = ga_wl_ldac[idwl1];
  301|       |
  302|  1.14k|        if (idwl1 == 1) {
  ------------------
  |  Branch (302:13): [True: 66, False: 1.07k]
  ------------------
  303|     66|            isp = lsp;
  304|       |
  305|     66|            if (nsps == 2) {
  ------------------
  |  Branch (305:17): [True: 0, False: 66]
  ------------------
  306|      0|                val  = (p_ac->a_qspec[isp  ]+1) << 2;
  307|      0|                val += (p_ac->a_qspec[isp+1]+1);
  308|      0|                pack_store_ldac(ga_2dimenc_spec_ldac[val], LDAC_2DIMSPECBITS, p_stream, p_loc);
  ------------------
  |  |  132|      0|#define LDAC_2DIMSPECBITS      3
  ------------------
  309|      0|            }
  310|     66|            else {
  311|    330|                for (i = 0; i < nsps>>2; i++, isp+=4) {
  ------------------
  |  Branch (311:29): [True: 264, False: 66]
  ------------------
  312|    264|                    val  = (p_ac->a_qspec[isp  ]+1) << 6;
  313|    264|                    val += (p_ac->a_qspec[isp+1]+1) << 4;
  314|    264|                    val += (p_ac->a_qspec[isp+2]+1) << 2;
  315|    264|                    val += (p_ac->a_qspec[isp+3]+1);
  316|    264|                    pack_store_ldac(ga_4dimenc_spec_ldac[val], LDAC_4DIMSPECBITS, p_stream, p_loc);
  ------------------
  |  |  135|    264|#define LDAC_4DIMSPECBITS      7
  ------------------
  317|    264|                }
  318|     66|            }
  319|     66|        }
  320|  1.07k|        else {
  321|  5.65k|            for (isp = lsp; isp < hsp; isp++) {
  ------------------
  |  Branch (321:29): [True: 4.57k, False: 1.07k]
  ------------------
  322|  4.57k|                pack_store_ldac(p_ac->a_qspec[isp], wl, p_stream, p_loc);
  323|  4.57k|            }
  324|  1.07k|        }
  325|  1.14k|    }
  326|       |
  327|     44|    return;
  328|     44|}
ldaclib.c:pack_residual_ldac:
  337|     44|{
  338|     44|    int iqu, isp;
  339|     44|    int lsp, hsp;
  340|     44|    int nqus = p_ac->p_ab->nqus;
  341|     44|    int idwl2, wl;
  342|       |
  343|  1.18k|    for (iqu = 0; iqu < nqus; iqu++) {
  ------------------
  |  Branch (343:19): [True: 1.14k, False: 44]
  ------------------
  344|  1.14k|        idwl2 = p_ac->a_idwl2[iqu];
  345|       |
  346|  1.14k|        if (idwl2 > 0) {
  ------------------
  |  Branch (346:13): [True: 0, False: 1.14k]
  ------------------
  347|      0|            lsp = ga_isp_ldac[iqu];
  348|      0|            hsp = ga_isp_ldac[iqu+1];
  349|      0|            wl = ga_wl_ldac[idwl2];
  350|       |
  351|      0|            for (isp = lsp; isp < hsp; isp++) {
  ------------------
  |  Branch (351:29): [True: 0, False: 0]
  ------------------
  352|      0|                pack_store_ldac(p_ac->a_rspec[isp], wl, p_stream, p_loc);
  353|      0|            }
  354|      0|        }
  355|  1.14k|    }    
  356|       |
  357|     44|    return;
  358|     44|}
ldaclib.c:pack_byte_alignment_ldac:
  100|     44|{
  101|     44|    int nbits_padding;
  102|       |
  103|     44|    nbits_padding = ((*p_loc + LDAC_BYTESIZE - 1) / LDAC_BYTESIZE) * LDAC_BYTESIZE - *p_loc;
  ------------------
  |  |  141|     44|#define LDAC_BYTESIZE          8
  ------------------
                  nbits_padding = ((*p_loc + LDAC_BYTESIZE - 1) / LDAC_BYTESIZE) * LDAC_BYTESIZE - *p_loc;
  ------------------
  |  |  141|     44|#define LDAC_BYTESIZE          8
  ------------------
                  nbits_padding = ((*p_loc + LDAC_BYTESIZE - 1) / LDAC_BYTESIZE) * LDAC_BYTESIZE - *p_loc;
  ------------------
  |  |  141|     44|#define LDAC_BYTESIZE          8
  ------------------
  104|       |
  105|     44|    if (nbits_padding > 0) {
  ------------------
  |  Branch (105:9): [True: 44, False: 0]
  ------------------
  106|     44|        pack_store_ldac(0, nbits_padding, p_stream, p_loc);
  107|     44|    }
  108|       |
  109|     44|    return;
  110|     44|}
ldaclib.c:pack_frame_alignment_ldac:
   79|     22|{
   80|     22|    int i;
   81|     22|    int nbytes_filled;
   82|       |
   83|     22|    nbytes_filled = nbytes_frame - *p_loc / LDAC_BYTESIZE;
  ------------------
  |  |  141|     22|#define LDAC_BYTESIZE          8
  ------------------
   84|       |
   85|     44|    for (i = 0; i < nbytes_filled; i++) {
  ------------------
  |  Branch (85:17): [True: 22, False: 22]
  ------------------
   86|     22|        pack_store_ldac(LDAC_FILLCODE, LDAC_BYTESIZE, p_stream, p_loc);
  ------------------
  |  |   99|     22|#define LDAC_FILLCODE       0x01
  ------------------
                      pack_store_ldac(LDAC_FILLCODE, LDAC_BYTESIZE, p_stream, p_loc);
  ------------------
  |  |  141|     22|#define LDAC_BYTESIZE          8
  ------------------
   87|     22|    }
   88|       |
   89|     22|    return;
   90|     22|}

ldaclib.c:norm_spectrum_ldac:
   50|     44|{
   51|     44|    int iqu, isp;
   52|     44|    int lsp, hsp;
   53|     44|    int nqus = p_ac->p_ab->nqus;
   54|     44|    int idsf;
   55|     44|    int *p_idsf = p_ac->a_idsf;
   56|     44|    SCALAR maxspec, tmp;
   57|     44|    SCALAR *p_spec = p_ac->p_acsub->a_spec;
   58|       |
   59|  1.18k|    for (iqu = 0; iqu < nqus; iqu++) {
  ------------------
  |  Branch (59:19): [True: 1.14k, False: 44]
  ------------------
   60|  1.14k|        lsp = ga_isp_ldac[iqu];
   61|  1.14k|        hsp = ga_isp_ldac[iqu+1];
   62|       |
   63|  1.14k|        maxspec = fabs(p_spec[lsp]);
   64|  5.63k|        for (isp = lsp+1; isp < hsp; isp++) {
  ------------------
  |  Branch (64:27): [True: 4.48k, False: 1.14k]
  ------------------
   65|  4.48k|            tmp = fabs(p_spec[isp]);
   66|  4.48k|            if (maxspec < tmp) {
  ------------------
  |  Branch (66:17): [True: 1.49k, False: 2.99k]
  ------------------
   67|  1.49k|                maxspec = tmp;
   68|  1.49k|            }
   69|  4.48k|        }
   70|  1.14k|        idsf = get_scale_factor_id_ldac(maxspec);
   71|       |
   72|  1.14k|        if (idsf > 0) {
  ------------------
  |  Branch (72:13): [True: 1.14k, False: 0]
  ------------------
   73|  1.14k|            tmp = ga_isf_ldac[idsf];
   74|  6.77k|            for (isp = lsp; isp < hsp; isp++) {
  ------------------
  |  Branch (74:29): [True: 5.63k, False: 1.14k]
  ------------------
   75|  5.63k|                p_spec[isp] *= tmp;
   76|  5.63k|            }
   77|  1.14k|        }
   78|      0|        else {
   79|      0|            for (isp = lsp; isp < hsp; isp++) {
  ------------------
  |  Branch (79:29): [True: 0, False: 0]
  ------------------
   80|      0|                p_spec[isp] = sa_val_ldac[isp-lsp];
   81|      0|            }
   82|      0|        }
   83|       |
   84|  1.14k|        p_idsf[iqu] = idsf;
   85|  1.14k|    }
   86|       |
   87|     44|    return;
   88|     44|}
ldaclib.c:get_scale_factor_id_ldac:
   24|  1.14k|{
   25|  1.14k|    int id;
   26|  1.14k|    IEEE754_FI fi;
   27|       |
   28|  1.14k|    fi.f = val;
   29|  1.14k|    id = ((fi.i & 0x7fffffff) >> 23) - 111;
   30|       |
   31|  1.14k|    if (id < 0) {
  ------------------
  |  Branch (31:9): [True: 0, False: 1.14k]
  ------------------
   32|      0|        id = 0;
   33|      0|    }
   34|  1.14k|    if (id > LDAC_NIDSF-1) {
  ------------------
  |  |  115|  1.14k|#define LDAC_NIDSF            32
  ------------------
  |  Branch (34:9): [True: 0, False: 1.14k]
  ------------------
   35|      0|        id = LDAC_NIDSF-1;
  ------------------
  |  |  115|      0|#define LDAC_NIDSF            32
  ------------------
   36|      0|    }
   37|       |
   38|  1.14k|    return id;
   39|  1.14k|}
ldaclib.c:quant_spectrum_ldac:
  120|     44|{
  121|     44|    int iqu;
  122|     44|    int nqus = p_ac->p_ab->nqus;
  123|       |
  124|  1.18k|    for (iqu = 0; iqu < nqus; iqu++) {
  ------------------
  |  Branch (124:19): [True: 1.14k, False: 44]
  ------------------
  125|  1.14k|        quant_spectrum_core_ldac(p_ac, iqu);
  126|  1.14k|    }
  127|       |
  128|     44|    return;
  129|     44|}
ldaclib.c:quant_spectrum_core_ldac:
   96|  1.14k|{
   97|  1.14k|    int i;
   98|  1.14k|    int isp = ga_isp_ldac[iqu];
   99|  1.14k|    int nsps = ga_nsps_ldac[iqu];
  100|  1.14k|    int *p_qspec = p_ac->a_qspec+isp;
  101|  1.14k|    SCALAR qf = ga_qf_ldac[p_ac->a_idwl1[iqu]];
  102|  1.14k|    SCALAR *p_nspec = p_ac->p_acsub->a_spec+isp;
  103|       |
  104|  1.14k|    IEEE754_FI fi;
  105|  1.14k|    const float fc = (float)((1 << 23) + (1 << 22));
  106|       |
  107|  6.77k|    for (i = 0; i < nsps; i++) {
  ------------------
  |  Branch (107:17): [True: 5.63k, False: 1.14k]
  ------------------
  108|  5.63k|        fi.f = p_nspec[i] * qf + fc;
  109|  5.63k|        p_qspec[i] = (short)fi.i;
  110|  5.63k|    }
  111|       |
  112|  1.14k|    return;
  113|  1.14k|}
ldaclib.c:quant_residual_ldac:
  166|     44|{
  167|     44|    int iqu;
  168|     44|    int nqus = p_ac->p_ab->nqus;
  169|     44|    int *p_idwl2 = p_ac->a_idwl2;
  170|       |
  171|  1.18k|    for (iqu = 0; iqu < nqus; iqu++) {
  ------------------
  |  Branch (171:19): [True: 1.14k, False: 44]
  ------------------
  172|  1.14k|        if (p_idwl2[iqu] > 0) {
  ------------------
  |  Branch (172:13): [True: 0, False: 1.14k]
  ------------------
  173|      0|            quant_residual_core_ldac(p_ac, iqu);
  174|      0|        }
  175|  1.14k|    }
  176|       |
  177|     44|    return;
  178|     44|}

ldaclib.c:set_input_pcm_ldac:
  115|     22|{
  116|     22|    int ich, isp;
  117|     22|    int nchs = p_sfinfo->cfg.ch;
  118|     22|    int nsmpl = npow2_ldac(nlnn);
  ------------------
  |  |  274|     22|#define npow2_ldac(n)  (1 << (n))
  ------------------
  119|     22|    SCALAR *p_time;
  120|       |
  121|     22|    if (format == LDAC_SMPL_FMT_S16) {
  ------------------
  |  Branch (121:9): [True: 22, False: 0]
  ------------------
  122|     66|        for (ich = 0; ich < nchs; ich++) {
  ------------------
  |  Branch (122:23): [True: 44, False: 22]
  ------------------
  123|     44|            p_time = p_sfinfo->ap_ac[ich]->p_acsub->a_time;
  124|  5.67k|            for (isp = 0; isp < nsmpl; isp++) {
  ------------------
  |  Branch (124:27): [True: 5.63k, False: 44]
  ------------------
  125|  5.63k|                p_time[isp] = p_time[nsmpl+isp];
  126|  5.63k|            }
  127|     44|            byte_data_to_scalar_s16_ldac(pp_pcm[ich], p_time+nsmpl, nsmpl);
  128|     44|        }
  129|     22|    }
  130|      0|    else if (format == LDAC_SMPL_FMT_S24) {
  ------------------
  |  Branch (130:14): [True: 0, False: 0]
  ------------------
  131|      0|        for (ich = 0; ich < nchs; ich++) {
  ------------------
  |  Branch (131:23): [True: 0, False: 0]
  ------------------
  132|      0|            p_time = p_sfinfo->ap_ac[ich]->p_acsub->a_time;
  133|      0|            for (isp = 0; isp < nsmpl; isp++) {
  ------------------
  |  Branch (133:27): [True: 0, False: 0]
  ------------------
  134|      0|                p_time[isp] = p_time[nsmpl+isp];
  135|      0|            }
  136|      0|            byte_data_to_scalar_s24_ldac(pp_pcm[ich], p_time+nsmpl, nsmpl);
  137|      0|        }
  138|      0|    }
  139|      0|    else if (format == LDAC_SMPL_FMT_S32) {
  ------------------
  |  Branch (139:14): [True: 0, False: 0]
  ------------------
  140|      0|        for (ich = 0; ich < nchs; ich++) {
  ------------------
  |  Branch (140:23): [True: 0, False: 0]
  ------------------
  141|      0|            p_time = p_sfinfo->ap_ac[ich]->p_acsub->a_time;
  142|      0|            for (isp = 0; isp < nsmpl; isp++) {
  ------------------
  |  Branch (142:27): [True: 0, False: 0]
  ------------------
  143|      0|                p_time[isp] = p_time[nsmpl+isp];
  144|      0|            }
  145|      0|            byte_data_to_scalar_s32_ldac(pp_pcm[ich], p_time+nsmpl, nsmpl);
  146|      0|        }
  147|      0|    }
  148|      0|    else if (format == LDAC_SMPL_FMT_F32) {
  ------------------
  |  Branch (148:14): [True: 0, False: 0]
  ------------------
  149|      0|        for (ich = 0; ich < nchs; ich++) {
  ------------------
  |  Branch (149:23): [True: 0, False: 0]
  ------------------
  150|      0|            p_time = p_sfinfo->ap_ac[ich]->p_acsub->a_time;
  151|      0|            for (isp = 0; isp < nsmpl; isp++) {
  ------------------
  |  Branch (151:27): [True: 0, False: 0]
  ------------------
  152|      0|                p_time[isp] = p_time[nsmpl+isp];
  153|      0|            }
  154|      0|            byte_data_to_scalar_f32_ldac(pp_pcm[ich], p_time+nsmpl, nsmpl);
  155|      0|        }
  156|      0|    }
  157|       |
  158|     22|    return;
  159|     22|}
ldaclib.c:byte_data_to_scalar_s16_ldac:
   26|     44|{
   27|     44|    int i;
   28|     44|    short *p_s;
   29|       |
   30|     44|    p_s = (short *)p_in;
   31|  5.67k|    for (i = 0; i < nsmpl; i++) {
  ------------------
  |  Branch (31:17): [True: 5.63k, False: 44]
  ------------------
   32|  5.63k|        *p_out++ = (SCALAR)*p_s++;
   33|  5.63k|    }
   34|       |
   35|     44|    return;
   36|     44|}

ldaclib.c:ana_frame_status_ldac:
  127|     22|{
  128|     22|    AC *p_ac;
  129|     22|    int ich;
  130|     22|    int nchs = p_sfinfo->cfg.ch;
  131|     22|    int nsmpl = npow2_ldac(nlnn+1);
  ------------------
  |  |  274|     22|#define npow2_ldac(n)  (1 << (n))
  ------------------
  132|     22|    int cnt, zero_cross;
  133|     22|    int a_status[LDAC_PRCNCH];
  134|     22|    SCALAR low_energy, centroid;
  135|     22|    SCALAR a_psd_spec[LDAC_NSP_PSEUDOANA];
  136|       |
  137|     66|    for (ich = 0; ich < nchs; ich++) {
  ------------------
  |  Branch (137:19): [True: 44, False: 22]
  ------------------
  138|     44|        p_ac = p_sfinfo->ap_ac[ich];
  139|       |
  140|     44|        low_energy = calc_mdct_pseudo_spectrum_ldac(p_ac->p_acsub->a_spec, a_psd_spec, LDAC_NSP_PSEUDOANA);
  ------------------
  |  |   91|     44|#define LDAC_NSP_PSEUDOANA   128
  ------------------
  141|       |
  142|     44|        centroid = calc_spectral_centroid_ldac(a_psd_spec, LDAC_NSP_PSEUDOANA);
  ------------------
  |  |   91|     44|#define LDAC_NSP_PSEUDOANA   128
  ------------------
  143|       |
  144|     44|        zero_cross = calc_zero_cross_number_ldac(p_ac->p_acsub->a_time, nsmpl);
  145|       |
  146|     44|        a_status[ich] = LDAC_FRMSTAT_LEV_0;
  ------------------
  |  |   59|     44|#define LDAC_FRMSTAT_LEV_0     0
  ------------------
  147|     44|        if (low_energy < LDAC_TH_LOWENERGY_L) { 
  ------------------
  |  |   20|     44|#define LDAC_TH_LOWENERGY_L _scalar(225.47)
  |  |  ------------------
  |  |  |  |   51|     44|#define _scalar(x) x##f
  |  |  ------------------
  ------------------
  |  Branch (147:13): [True: 0, False: 44]
  ------------------
  148|      0|            a_status[ich] = LDAC_FRMSTAT_LEV_3;
  ------------------
  |  |   62|      0|#define LDAC_FRMSTAT_LEV_3     3
  ------------------
  149|      0|        }
  150|     44|        else {
  151|     44|            if (low_energy < LDAC_TH_LOWENERGY_M) {
  ------------------
  |  |   21|     44|#define LDAC_TH_LOWENERGY_M _scalar(897.61)
  |  |  ------------------
  |  |  |  |   51|     44|#define _scalar(x) x##f
  |  |  ------------------
  ------------------
  |  Branch (151:17): [True: 0, False: 44]
  ------------------
  152|      0|                a_status[ich] = LDAC_FRMSTAT_LEV_2;
  ------------------
  |  |   61|      0|#define LDAC_FRMSTAT_LEV_2     2
  ------------------
  153|      0|            }
  154|     44|            else if (low_energy < LDAC_TH_LOWENERGY_H) {
  ------------------
  |  |   22|     44|#define LDAC_TH_LOWENERGY_H _scalar(3573.44)
  |  |  ------------------
  |  |  |  |   51|     44|#define _scalar(x) x##f
  |  |  ------------------
  ------------------
  |  Branch (154:22): [True: 0, False: 44]
  ------------------
  155|      0|                a_status[ich] = LDAC_FRMSTAT_LEV_1;
  ------------------
  |  |   60|      0|#define LDAC_FRMSTAT_LEV_1     1
  ------------------
  156|      0|            }
  157|       |
  158|     44|            cnt = p_ac->frmana_cnt;
  159|     44|            if ((centroid > LDAC_TH_CENTROID) && (zero_cross >= LDAC_TH_ZCROSNUM)) {
  ------------------
  |  |   24|     44|#define LDAC_TH_CENTROID    _scalar(45.0)
  |  |  ------------------
  |  |  |  |   51|     44|#define _scalar(x) x##f
  |  |  ------------------
  ------------------
                          if ((centroid > LDAC_TH_CENTROID) && (zero_cross >= LDAC_TH_ZCROSNUM)) {
  ------------------
  |  |   93|     44|#define LDAC_TH_ZCROSNUM      90
  ------------------
  |  Branch (159:17): [True: 44, False: 0]
  |  Branch (159:50): [True: 0, False: 44]
  ------------------
  160|      0|                cnt++;
  161|       |
  162|      0|                if (cnt >= LDAC_MAXCNT_FRMANA) {
  ------------------
  |  |   94|      0|#define LDAC_MAXCNT_FRMANA    10
  ------------------
  |  Branch (162:21): [True: 0, False: 0]
  ------------------
  163|      0|                    cnt = LDAC_MAXCNT_FRMANA;
  ------------------
  |  |   94|      0|#define LDAC_MAXCNT_FRMANA    10
  ------------------
  164|      0|                    a_status[ich] = LDAC_FRMSTAT_LEV_2;
  ------------------
  |  |   61|      0|#define LDAC_FRMSTAT_LEV_2     2
  ------------------
  165|      0|                }
  166|      0|                else if (a_status[ich] <= LDAC_FRMSTAT_LEV_1) {
  ------------------
  |  |   60|      0|#define LDAC_FRMSTAT_LEV_1     1
  ------------------
  |  Branch (166:26): [True: 0, False: 0]
  ------------------
  167|      0|                    a_status[ich]++;
  168|      0|                }
  169|      0|            }
  170|     44|            else {
  171|     44|                cnt = 0;
  172|     44|            }
  173|     44|            p_ac->frmana_cnt = cnt;
  174|     44|        }
  175|     44|    }
  176|       |
  177|     22|    if (nchs == LDAC_CHANNEL_1CH) {
  ------------------
  |  |   46|     22|#define LDAC_CHANNEL_1CH       1
  ------------------
  |  Branch (177:9): [True: 0, False: 22]
  ------------------
  178|      0|        return a_status[0];
  179|      0|    }
  180|     22|    else {
  181|     22|        return min_ldac(a_status[0], a_status[1]);
  ------------------
  |  |  275|     22|#define min_ldac(a, b) (((a)<(b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (275:25): [True: 0, False: 22]
  |  |  ------------------
  ------------------
  182|     22|    }
  183|     22|}
ldaclib.c:calc_mdct_pseudo_spectrum_ldac:
   34|     44|{
   35|     44|    int isp;
   36|     44|    SCALAR low_energy, tmp;
   37|     44|    SCALAR y0, y1, y2;
   38|       |
   39|     44|    {
   40|     44|        y1 = p_spec[0];
   41|     44|        y2 = p_spec[1];
   42|     44|        tmp = y1 * y1 + y2 * y2;
   43|     44|        low_energy = tmp;
   44|     44|        p_psd[0] = sqrt(tmp);
   45|     44|    }
   46|       |
   47|    528|    for (isp = 1; isp < LDAC_NSP_LOWENERGY; isp++) {
  ------------------
  |  |   92|    528|#define LDAC_NSP_LOWENERGY    12
  ------------------
  |  Branch (47:19): [True: 484, False: 44]
  ------------------
   48|    484|        y0 = y1;
   49|    484|        y1 = y2;
   50|    484|        y2 = p_spec[isp+1];
   51|    484|        tmp = y1 * y1 + (y0-y2) * (y0-y2);
   52|    484|        low_energy += tmp;
   53|    484|        p_psd[isp] = sqrt(tmp);
   54|    484|    }
   55|       |
   56|  5.10k|    for (isp = LDAC_NSP_LOWENERGY; isp < n-1; isp++) {
  ------------------
  |  |   92|     44|#define LDAC_NSP_LOWENERGY    12
  ------------------
  |  Branch (56:36): [True: 5.06k, False: 44]
  ------------------
   57|  5.06k|        y0 = y1;
   58|  5.06k|        y1 = y2;
   59|  5.06k|        y2 = p_spec[isp+1];
   60|  5.06k|        tmp = y1 * y1 + (y0-y2) * (y0-y2);
   61|  5.06k|        p_psd[isp] = sqrt(tmp);
   62|  5.06k|    }
   63|       |
   64|     44|    {
   65|     44|        tmp = y1 * y1 + y2 * y2;
   66|     44|        p_psd[n-1] = sqrt(tmp);
   67|     44|    }
   68|       |
   69|     44|    return low_energy;
   70|     44|}
ldaclib.c:calc_spectral_centroid_ldac:
   78|     44|{
   79|     44|    int isp;
   80|     44|    SCALAR centroid;
   81|     44|    SCALAR s1, s2;
   82|       |
   83|     44|    s1 = s2 = _scalar(0.0);
  ------------------
  |  |   51|     44|#define _scalar(x) x##f
  ------------------
   84|  5.67k|    for (isp = 0; isp < nsp; isp++) {
  ------------------
  |  Branch (84:19): [True: 5.63k, False: 44]
  ------------------
   85|  5.63k|        s1 += (SCALAR)isp * *p_spec;
   86|  5.63k|        s2 += *p_spec++;
   87|  5.63k|    }
   88|       |
   89|     44|    if (s2 < LDAC_TH_ZERODIV) {
  ------------------
  |  |   25|     44|#define LDAC_TH_ZERODIV     _scalar(1.0e-6)
  |  |  ------------------
  |  |  |  |   51|     44|#define _scalar(x) x##f
  |  |  ------------------
  ------------------
  |  Branch (89:9): [True: 0, False: 44]
  ------------------
   90|      0|        centroid = _scalar(0.0);
  ------------------
  |  |   51|      0|#define _scalar(x) x##f
  ------------------
   91|      0|    }
   92|     44|    else {
   93|     44|        centroid = s1 / s2;
   94|     44|    }
   95|       |
   96|     44|    return centroid;
   97|     44|}
ldaclib.c:calc_zero_cross_number_ldac:
  105|     44|{
  106|     44|    int i;
  107|     44|    int zero_cross = 0;
  108|     44|    SCALAR prev;
  109|       |
  110|     44|    prev = _scalar(0.0);
  ------------------
  |  |   51|     44|#define _scalar(x) x##f
  ------------------
  111|  11.3k|    for (i = 0; i < n; i++) {
  ------------------
  |  Branch (111:17): [True: 11.2k, False: 44]
  ------------------
  112|  11.2k|        if (prev * *p_time < _scalar(0.0)) {
  ------------------
  |  |   51|  11.2k|#define _scalar(x) x##f
  ------------------
  |  Branch (112:13): [True: 726, False: 10.5k]
  ------------------
  113|    726|            zero_cross++;
  114|    726|        }
  115|  11.2k|        prev = *p_time++;
  116|  11.2k|    }
  117|       |
  118|     44|    return zero_cross;
  119|     44|}

ldaclib.c:get_block_nchs_ldac:
   66|     44|{
   67|     44|    int blk_nchs;
   68|       |
   69|     44|    if (blk_type == LDAC_BLKID_MONO) {
  ------------------
  |  |   97|     44|#define LDAC_BLKID_MONO        0
  ------------------
  |  Branch (69:9): [True: 44, False: 0]
  ------------------
   70|     44|        blk_nchs = 1;
   71|     44|    }
   72|      0|    else if (blk_type == LDAC_BLKID_STEREO) {
  ------------------
  |  |   98|      0|#define LDAC_BLKID_STEREO      1
  ------------------
  |  Branch (72:14): [True: 0, False: 0]
  ------------------
   73|      0|        blk_nchs = 2;
   74|      0|    }
   75|      0|    else {
   76|      0|        blk_nchs = -1;
   77|      0|    }
   78|       |
   79|     44|    return blk_nchs;
   80|     44|}

ldaclib.c:set_mdct_table_ldac:
  412|     22|{
  413|     22|    int index = nlnn - LDAC_1FSLNN;
  ------------------
  |  |   75|     22|#define LDAC_1FSLNN            7
  ------------------
  414|       |
  415|     22|    if (nlnn == LDAC_1FSLNN) {
  ------------------
  |  |   75|     22|#define LDAC_1FSLNN            7
  ------------------
  |  Branch (415:9): [True: 22, False: 0]
  ------------------
  416|     22|        gaa_fwin_ldac[index] = sa_fwin_1fs_ldac;
  417|     22|        gaa_wcos_ldac[index] = sa_wcos_1fs_ldac;
  418|     22|        gaa_wsin_ldac[index] = sa_wsin_1fs_ldac;
  419|     22|        gaa_perm_ldac[index] = sa_perm_1fs_ldac;
  420|     22|    }
  421|      0|    else if (nlnn == LDAC_2FSLNN) {
  ------------------
  |  |   74|      0|#define LDAC_2FSLNN            8
  ------------------
  |  Branch (421:14): [True: 0, False: 0]
  ------------------
  422|      0|        gaa_fwin_ldac[index] = sa_fwin_2fs_ldac;
  423|      0|        gaa_wcos_ldac[index] = sa_wcos_2fs_ldac;
  424|      0|        gaa_wsin_ldac[index] = sa_wsin_2fs_ldac;
  425|      0|        gaa_perm_ldac[index] = sa_perm_2fs_ldac;
  426|      0|    }
  427|       |
  428|     22|    return;
  429|     22|}

LLVMFuzzerTestOneInput:
   13|     22|{
   14|     22|    if (size == 0) {
  ------------------
  |  Branch (14:9): [True: 0, False: 22]
  ------------------
   15|      0|    	return 0;
   16|      0|    }
   17|     22|    HANDLE_LDAC_BT hLdacBt;
   18|     22|    int pcm_used, stream_sz, frame_num;
   19|     22|    unsigned char p_stream[1024];
   20|       |
   21|     22|    hLdacBt = ldacBT_get_handle();
   22|       |
   23|     22|    ldacBT_init_handle_encode(
   24|     22|        hLdacBt,
   25|     22|        679,
   26|     22|        LDACBT_EQMID_SQ,
   27|     22|        LDACBT_CHANNEL_MODE_DUAL_CHANNEL,
  ------------------
  |  |  533|     22|#define LDACBT_CHANNEL_MODE_DUAL_CHANNEL   0x02
  ------------------
   28|     22|        LDACBT_SMPL_FMT_S16,
   29|     22|        48000);
   30|       |
   31|     22|    ldacBT_encode(
   32|     22|        hLdacBt,
   33|     22|        (void *)(&buf + 44),
   34|     22|        &pcm_used,
   35|     22|        p_stream,
   36|     22|        &stream_sz,
   37|     22|        &frame_num);
   38|       |
   39|     22|    ldacBT_get_sampling_freq(hLdacBt);
   40|     22|    ldacBT_get_bitrate(hLdacBt);
   41|     22|    ldacBT_get_version();
   42|       |
   43|     22|    ldacBT_close_handle(hLdacBt);
   44|     22|    ldacBT_free_handle(hLdacBt);
   45|       |
   46|     22|    return 0;
   47|     22|}

