oggpack_writeinit:
   39|  36.3k|void oggpack_writeinit(oggpack_buffer *b){
   40|  36.3k|  memset(b,0,sizeof(*b));
   41|  36.3k|  b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT);
  ------------------
  |  |   21|  36.3k|#define _ogg_malloc  malloc
  ------------------
                b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT);
  ------------------
  |  |   25|  36.3k|#define BUFFER_INCREMENT 256
  ------------------
   42|  36.3k|  if (!b->buffer)
  ------------------
  |  Branch (42:7): [True: 0, False: 36.3k]
  ------------------
   43|      0|    return;
   44|  36.3k|  b->buffer[0]='\0';
   45|  36.3k|  b->storage=BUFFER_INCREMENT;
  ------------------
  |  |   25|  36.3k|#define BUFFER_INCREMENT 256
  ------------------
   46|  36.3k|}
oggpack_write:
   84|  28.0M|void oggpack_write(oggpack_buffer *b,unsigned long value,int bits){
   85|  28.0M|  if(bits<0 || bits>32) goto err;
  ------------------
  |  Branch (85:6): [True: 0, False: 28.0M]
  |  Branch (85:16): [True: 0, False: 28.0M]
  ------------------
   86|  28.0M|  if(b->endbyte>=b->storage-4){
  ------------------
  |  Branch (86:6): [True: 32.9k, False: 27.9M]
  ------------------
   87|  32.9k|    void *ret;
   88|  32.9k|    if(!b->ptr)return;
  ------------------
  |  Branch (88:8): [True: 0, False: 32.9k]
  ------------------
   89|  32.9k|    if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err;
  ------------------
  |  |   25|  32.9k|#define BUFFER_INCREMENT 256
  ------------------
  |  Branch (89:8): [True: 0, False: 32.9k]
  ------------------
   90|  32.9k|    ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT);
  ------------------
  |  |   23|  32.9k|#define _ogg_realloc realloc
  ------------------
                  ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT);
  ------------------
  |  |   25|  32.9k|#define BUFFER_INCREMENT 256
  ------------------
   91|  32.9k|    if(!ret) goto err;
  ------------------
  |  Branch (91:8): [True: 0, False: 32.9k]
  ------------------
   92|  32.9k|    b->buffer=ret;
   93|  32.9k|    b->storage+=BUFFER_INCREMENT;
  ------------------
  |  |   25|  32.9k|#define BUFFER_INCREMENT 256
  ------------------
   94|  32.9k|    b->ptr=b->buffer+b->endbyte;
   95|  32.9k|  }
   96|       |
   97|  28.0M|  value&=mask[bits];
   98|  28.0M|  bits+=b->endbit;
   99|       |
  100|  28.0M|  b->ptr[0]|=value<<b->endbit;
  101|       |
  102|  28.0M|  if(bits>=8){
  ------------------
  |  Branch (102:6): [True: 15.4M, False: 12.5M]
  ------------------
  103|  15.4M|    b->ptr[1]=(unsigned char)(value>>(8-b->endbit));
  104|  15.4M|    if(bits>=16){
  ------------------
  |  Branch (104:8): [True: 823k, False: 14.6M]
  ------------------
  105|   823k|      b->ptr[2]=(unsigned char)(value>>(16-b->endbit));
  106|   823k|      if(bits>=24){
  ------------------
  |  Branch (106:10): [True: 258k, False: 565k]
  ------------------
  107|   258k|        b->ptr[3]=(unsigned char)(value>>(24-b->endbit));
  108|   258k|        if(bits>=32){
  ------------------
  |  Branch (108:12): [True: 75.7k, False: 183k]
  ------------------
  109|  75.7k|          if(b->endbit)
  ------------------
  |  Branch (109:14): [True: 53.1k, False: 22.5k]
  ------------------
  110|  53.1k|            b->ptr[4]=(unsigned char)(value>>(32-b->endbit));
  111|  22.5k|          else
  112|  22.5k|            b->ptr[4]=0;
  113|  75.7k|        }
  114|   258k|      }
  115|   823k|    }
  116|  15.4M|  }
  117|       |
  118|  28.0M|  b->endbyte+=bits/8;
  119|  28.0M|  b->ptr+=bits/8;
  120|  28.0M|  b->endbit=bits&7;
  121|  28.0M|  return;
  122|      0| err:
  123|      0|  oggpack_writeclear(b);
  124|      0|}
oggpack_reset:
  240|   876k|void oggpack_reset(oggpack_buffer *b){
  241|   876k|  if(!b->ptr)return;
  ------------------
  |  Branch (241:6): [True: 0, False: 876k]
  ------------------
  242|   876k|  b->ptr=b->buffer;
  243|   876k|  b->buffer[0]=0;
  244|   876k|  b->endbit=b->endbyte=0;
  245|   876k|}
oggpack_writeclear:
  251|  36.3k|void oggpack_writeclear(oggpack_buffer *b){
  252|  36.3k|  if(b->buffer)_ogg_free(b->buffer);
  ------------------
  |  |   24|  36.3k|#define _ogg_free    free
  ------------------
  |  Branch (252:6): [True: 36.3k, False: 0]
  ------------------
  253|  36.3k|  memset(b,0,sizeof(*b));
  254|  36.3k|}
oggpack_bytes:
  504|   136k|long oggpack_bytes(oggpack_buffer *b){
  505|   136k|  return(b->endbyte+(b->endbit+7)/8);
  506|   136k|}
oggpack_get_buffer:
  520|  58.1k|unsigned char *oggpack_get_buffer(oggpack_buffer *b){
  521|  58.1k|  return(b->buffer);
  522|  58.1k|}

ogg_page_eos:
   45|  3.49k|int ogg_page_eos(const ogg_page *og){
   46|  3.49k|  return((int)(og->header[5]&0x04));
   47|  3.49k|}
ogg_stream_init:
  133|  2.27k|int ogg_stream_init(ogg_stream_state *os,int serialno){
  134|  2.27k|  if(os){
  ------------------
  |  Branch (134:6): [True: 2.27k, False: 0]
  ------------------
  135|  2.27k|    memset(os,0,sizeof(*os));
  136|  2.27k|    os->body_storage=16*1024;
  137|  2.27k|    os->lacing_storage=1024;
  138|       |
  139|  2.27k|    os->body_data=_ogg_malloc(os->body_storage*sizeof(*os->body_data));
  ------------------
  |  |   21|  2.27k|#define _ogg_malloc  malloc
  ------------------
  140|  2.27k|    os->lacing_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->lacing_vals));
  ------------------
  |  |   21|  2.27k|#define _ogg_malloc  malloc
  ------------------
  141|  2.27k|    os->granule_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->granule_vals));
  ------------------
  |  |   21|  2.27k|#define _ogg_malloc  malloc
  ------------------
  142|       |
  143|  2.27k|    if(!os->body_data || !os->lacing_vals || !os->granule_vals){
  ------------------
  |  Branch (143:8): [True: 0, False: 2.27k]
  |  Branch (143:26): [True: 0, False: 2.27k]
  |  Branch (143:46): [True: 0, False: 2.27k]
  ------------------
  144|      0|      ogg_stream_clear(os);
  145|      0|      return -1;
  146|      0|    }
  147|       |
  148|  2.27k|    os->serialno=serialno;
  149|       |
  150|  2.27k|    return(0);
  151|  2.27k|  }
  152|      0|  return(-1);
  153|  2.27k|}
ogg_stream_check:
  156|   190k|int ogg_stream_check(ogg_stream_state *os){
  157|   190k|  if(!os || !os->body_data) return -1;
  ------------------
  |  Branch (157:6): [True: 0, False: 190k]
  |  Branch (157:13): [True: 0, False: 190k]
  ------------------
  158|   190k|  return 0;
  159|   190k|}
ogg_stream_clear:
  162|  2.27k|int ogg_stream_clear(ogg_stream_state *os){
  163|  2.27k|  if(os){
  ------------------
  |  Branch (163:6): [True: 2.27k, False: 0]
  ------------------
  164|  2.27k|    if(os->body_data)_ogg_free(os->body_data);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  |  Branch (164:8): [True: 2.27k, False: 0]
  ------------------
  165|  2.27k|    if(os->lacing_vals)_ogg_free(os->lacing_vals);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  |  Branch (165:8): [True: 2.27k, False: 0]
  ------------------
  166|  2.27k|    if(os->granule_vals)_ogg_free(os->granule_vals);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  |  Branch (166:8): [True: 2.27k, False: 0]
  ------------------
  167|       |
  168|  2.27k|    memset(os,0,sizeof(*os));
  169|  2.27k|  }
  170|  2.27k|  return(0);
  171|  2.27k|}
ogg_page_checksum_set:
  255|  8.03k|void ogg_page_checksum_set(ogg_page *og){
  256|  8.03k|  if(og){
  ------------------
  |  Branch (256:6): [True: 8.03k, False: 0]
  ------------------
  257|  8.03k|    ogg_uint32_t crc_reg=0;
  258|       |
  259|       |    /* safety; needed for API behavior, but not framing code */
  260|  8.03k|    og->header[22]=0;
  261|  8.03k|    og->header[23]=0;
  262|  8.03k|    og->header[24]=0;
  263|  8.03k|    og->header[25]=0;
  264|       |
  265|  8.03k|    crc_reg=_os_update_crc(crc_reg,og->header,og->header_len);
  266|  8.03k|    crc_reg=_os_update_crc(crc_reg,og->body,og->body_len);
  267|       |
  268|  8.03k|    og->header[22]=(unsigned char)(crc_reg&0xff);
  269|  8.03k|    og->header[23]=(unsigned char)((crc_reg>>8)&0xff);
  270|  8.03k|    og->header[24]=(unsigned char)((crc_reg>>16)&0xff);
  271|  8.03k|    og->header[25]=(unsigned char)((crc_reg>>24)&0xff);
  272|  8.03k|  }
  273|  8.03k|}
ogg_stream_iovecin:
  277|  64.9k|                       long e_o_s, ogg_int64_t granulepos){
  278|       |
  279|  64.9k|  long bytes = 0, lacing_vals;
  280|  64.9k|  int i;
  281|       |
  282|  64.9k|  if(ogg_stream_check(os)) return -1;
  ------------------
  |  Branch (282:6): [True: 0, False: 64.9k]
  ------------------
  283|  64.9k|  if(!iov) return 0;
  ------------------
  |  Branch (283:6): [True: 0, False: 64.9k]
  ------------------
  284|       |
  285|   129k|  for (i = 0; i < count; ++i){
  ------------------
  |  Branch (285:15): [True: 64.9k, False: 64.9k]
  ------------------
  286|  64.9k|    if(iov[i].iov_len>LONG_MAX) return -1;
  ------------------
  |  Branch (286:8): [True: 0, False: 64.9k]
  ------------------
  287|  64.9k|    if(bytes>LONG_MAX-(long)iov[i].iov_len) return -1;
  ------------------
  |  Branch (287:8): [True: 0, False: 64.9k]
  ------------------
  288|  64.9k|    bytes += (long)iov[i].iov_len;
  289|  64.9k|  }
  290|  64.9k|  lacing_vals=bytes/255+1;
  291|       |
  292|  64.9k|  if(os->body_returned){
  ------------------
  |  Branch (292:6): [True: 3.41k, False: 61.5k]
  ------------------
  293|       |    /* advance packet data according to the body_returned pointer. We
  294|       |       had to keep it around to return a pointer into the buffer last
  295|       |       call */
  296|       |
  297|  3.41k|    os->body_fill-=os->body_returned;
  298|  3.41k|    if(os->body_fill)
  ------------------
  |  Branch (298:8): [True: 1.10k, False: 2.31k]
  ------------------
  299|  1.10k|      memmove(os->body_data,os->body_data+os->body_returned,
  300|  1.10k|              os->body_fill);
  301|  3.41k|    os->body_returned=0;
  302|  3.41k|  }
  303|       |
  304|       |  /* make sure we have the buffer storage */
  305|  64.9k|  if(_os_body_expand(os,bytes) || _os_lacing_expand(os,lacing_vals))
  ------------------
  |  Branch (305:6): [True: 0, False: 64.9k]
  |  Branch (305:35): [True: 0, False: 64.9k]
  ------------------
  306|      0|    return -1;
  307|       |
  308|       |  /* Copy in the submitted packet.  Yes, the copy is a waste; this is
  309|       |     the liability of overly clean abstraction for the time being.  It
  310|       |     will actually be fairly easy to eliminate the extra copy in the
  311|       |     future */
  312|       |
  313|   129k|  for (i = 0; i < count; ++i) {
  ------------------
  |  Branch (313:15): [True: 64.9k, False: 64.9k]
  ------------------
  314|  64.9k|    memcpy(os->body_data+os->body_fill, iov[i].iov_base, iov[i].iov_len);
  315|  64.9k|    os->body_fill += (long)iov[i].iov_len;
  316|  64.9k|  }
  317|       |
  318|       |  /* Store lacing vals for this packet */
  319|   113k|  for(i=0;i<lacing_vals-1;i++){
  ------------------
  |  Branch (319:11): [True: 48.9k, False: 64.9k]
  ------------------
  320|  48.9k|    os->lacing_vals[os->lacing_fill+i]=255;
  321|  48.9k|    os->granule_vals[os->lacing_fill+i]=os->granulepos;
  322|  48.9k|  }
  323|  64.9k|  os->lacing_vals[os->lacing_fill+i]=bytes%255;
  324|  64.9k|  os->granulepos=os->granule_vals[os->lacing_fill+i]=granulepos;
  325|       |
  326|       |  /* flag the first segment as the beginning of the packet */
  327|  64.9k|  os->lacing_vals[os->lacing_fill]|= 0x100;
  328|       |
  329|  64.9k|  os->lacing_fill+=lacing_vals;
  330|       |
  331|       |  /* for the sake of completeness */
  332|  64.9k|  os->packetno++;
  333|       |
  334|  64.9k|  if(e_o_s)os->e_o_s=1;
  ------------------
  |  Branch (334:6): [True: 2.27k, False: 62.6k]
  ------------------
  335|       |
  336|  64.9k|  return(0);
  337|  64.9k|}
ogg_stream_packetin:
  339|  64.9k|int ogg_stream_packetin(ogg_stream_state *os,ogg_packet *op){
  340|  64.9k|  ogg_iovec_t iov;
  341|  64.9k|  iov.iov_base = op->packet;
  342|  64.9k|  iov.iov_len = op->bytes;
  343|  64.9k|  return ogg_stream_iovecin(os, &iov, 1, op->e_o_s, op->granulepos);
  344|  64.9k|}
ogg_stream_flush:
  495|  6.81k|int ogg_stream_flush(ogg_stream_state *os,ogg_page *og){
  496|  6.81k|  return ogg_stream_flush_i(os,og,1,4096);
  497|  6.81k|}
ogg_stream_pageout:
  511|  59.3k|int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og){
  512|  59.3k|  int force=0;
  513|  59.3k|  if(ogg_stream_check(os)) return 0;
  ------------------
  |  Branch (513:6): [True: 0, False: 59.3k]
  ------------------
  514|       |
  515|  59.3k|  if((os->e_o_s&&os->lacing_fill) ||          /* 'were done, now flush' case */
  ------------------
  |  Branch (515:7): [True: 2.34k, False: 57.0k]
  |  Branch (515:18): [True: 2.34k, False: 0]
  ------------------
  516|  57.0k|     (os->lacing_fill&&!os->b_o_s))           /* 'initial header page' case */
  ------------------
  |  Branch (516:7): [True: 56.9k, False: 42]
  |  Branch (516:24): [True: 0, False: 56.9k]
  ------------------
  517|  2.34k|    force=1;
  518|       |
  519|  59.3k|  return(ogg_stream_flush_i(os,og,force,4096));
  520|  59.3k|}
framing.c:_os_update_crc:
  237|  16.0k|static ogg_uint32_t _os_update_crc(ogg_uint32_t crc, unsigned char *buffer, int size){
  238|  2.13M|  while (size>=8){
  ------------------
  |  Branch (238:10): [True: 2.11M, False: 16.0k]
  ------------------
  239|  2.11M|    crc^=((ogg_uint32_t)buffer[0]<<24)|((ogg_uint32_t)buffer[1]<<16)|((ogg_uint32_t)buffer[2]<<8)|((ogg_uint32_t)buffer[3]);
  240|       |
  241|  2.11M|    crc=crc_lookup[7][ crc>>24      ]^crc_lookup[6][(crc>>16)&0xFF]^
  242|  2.11M|        crc_lookup[5][(crc>> 8)&0xFF]^crc_lookup[4][ crc     &0xFF]^
  243|  2.11M|        crc_lookup[3][buffer[4]     ]^crc_lookup[2][buffer[5]     ]^
  244|  2.11M|        crc_lookup[1][buffer[6]     ]^crc_lookup[0][buffer[7]     ];
  245|       |
  246|  2.11M|    buffer+=8;
  247|  2.11M|    size-=8;
  248|  2.11M|  }
  249|       |
  250|  82.3k|  while (size--)
  ------------------
  |  Branch (250:10): [True: 66.2k, False: 16.0k]
  ------------------
  251|  66.2k|    crc=(crc<<8)^crc_lookup[0][((crc >> 24)&0xff)^*buffer++];
  252|  16.0k|  return crc;
  253|  16.0k|}
framing.c:_os_body_expand:
  184|  64.9k|static int _os_body_expand(ogg_stream_state *os,long needed){
  185|  64.9k|  if(os->body_storage-needed<=os->body_fill){
  ------------------
  |  Branch (185:6): [True: 56, False: 64.8k]
  ------------------
  186|     56|    long body_storage;
  187|     56|    void *ret;
  188|     56|    if(os->body_storage>LONG_MAX-needed){
  ------------------
  |  Branch (188:8): [True: 0, False: 56]
  ------------------
  189|      0|      ogg_stream_clear(os);
  190|      0|      return -1;
  191|      0|    }
  192|     56|    body_storage=os->body_storage+needed;
  193|     56|    if(body_storage<LONG_MAX-1024)body_storage+=1024;
  ------------------
  |  Branch (193:8): [True: 56, False: 0]
  ------------------
  194|     56|    ret=_ogg_realloc(os->body_data,body_storage*sizeof(*os->body_data));
  ------------------
  |  |   23|     56|#define _ogg_realloc realloc
  ------------------
  195|     56|    if(!ret){
  ------------------
  |  Branch (195:8): [True: 0, False: 56]
  ------------------
  196|      0|      ogg_stream_clear(os);
  197|      0|      return -1;
  198|      0|    }
  199|     56|    os->body_storage=body_storage;
  200|     56|    os->body_data=ret;
  201|     56|  }
  202|  64.9k|  return 0;
  203|  64.9k|}
framing.c:_os_lacing_expand:
  205|  64.9k|static int _os_lacing_expand(ogg_stream_state *os,long needed){
  206|  64.9k|  if(os->lacing_storage-needed<=os->lacing_fill){
  ------------------
  |  Branch (206:6): [True: 0, False: 64.9k]
  ------------------
  207|      0|    long lacing_storage;
  208|      0|    void *ret;
  209|      0|    if(os->lacing_storage>LONG_MAX-needed){
  ------------------
  |  Branch (209:8): [True: 0, False: 0]
  ------------------
  210|      0|      ogg_stream_clear(os);
  211|      0|      return -1;
  212|      0|    }
  213|      0|    lacing_storage=os->lacing_storage+needed;
  214|      0|    if(lacing_storage<LONG_MAX-32)lacing_storage+=32;
  ------------------
  |  Branch (214:8): [True: 0, False: 0]
  ------------------
  215|      0|    ret=_ogg_realloc(os->lacing_vals,lacing_storage*sizeof(*os->lacing_vals));
  ------------------
  |  |   23|      0|#define _ogg_realloc realloc
  ------------------
  216|      0|    if(!ret){
  ------------------
  |  Branch (216:8): [True: 0, False: 0]
  ------------------
  217|      0|      ogg_stream_clear(os);
  218|      0|      return -1;
  219|      0|    }
  220|      0|    os->lacing_vals=ret;
  221|      0|    ret=_ogg_realloc(os->granule_vals,lacing_storage*
  ------------------
  |  |   23|      0|#define _ogg_realloc realloc
  ------------------
  222|      0|                     sizeof(*os->granule_vals));
  223|      0|    if(!ret){
  ------------------
  |  Branch (223:8): [True: 0, False: 0]
  ------------------
  224|      0|      ogg_stream_clear(os);
  225|      0|      return -1;
  226|      0|    }
  227|      0|    os->granule_vals=ret;
  228|      0|    os->lacing_storage=lacing_storage;
  229|      0|  }
  230|  64.9k|  return 0;
  231|  64.9k|}
framing.c:ogg_stream_flush_i:
  349|  66.1k|static int ogg_stream_flush_i(ogg_stream_state *os,ogg_page *og, int force, int nfill){
  350|  66.1k|  int i;
  351|  66.1k|  int vals=0;
  352|  66.1k|  int maxvals;
  353|  66.1k|  int bytes=0;
  354|  66.1k|  long acc=0;
  355|  66.1k|  ogg_int64_t granule_pos=-1;
  356|       |
  357|  66.1k|  if(ogg_stream_check(os)) return(0);
  ------------------
  |  Branch (357:6): [True: 0, False: 66.1k]
  ------------------
  358|  66.1k|  maxvals=(os->lacing_fill>255?255:os->lacing_fill);
  ------------------
  |  Branch (358:12): [True: 0, False: 66.1k]
  ------------------
  359|  66.1k|  if(maxvals==0) return(0);
  ------------------
  |  Branch (359:6): [True: 2.31k, False: 63.8k]
  ------------------
  360|       |
  361|       |  /* construct a page */
  362|       |  /* decide how many segments to include */
  363|       |
  364|       |  /* If this is the initial header case, the first page must only include
  365|       |     the initial header packet */
  366|  63.8k|  if(os->b_o_s==0){  /* 'initial header page' case */
  ------------------
  |  Branch (366:6): [True: 2.27k, False: 61.5k]
  ------------------
  367|  2.27k|    granule_pos=0;
  368|  2.27k|    for(vals=0;vals<maxvals;vals++){
  ------------------
  |  Branch (368:16): [True: 2.27k, False: 0]
  ------------------
  369|  2.27k|      if((os->lacing_vals[vals]&0x0ff)<255){
  ------------------
  |  Branch (369:10): [True: 2.27k, False: 0]
  ------------------
  370|  2.27k|        vals++;
  371|  2.27k|        break;
  372|  2.27k|      }
  373|  2.27k|    }
  374|  61.5k|  }else{
  375|       |
  376|       |    /* The extra packets_done, packet_just_done logic here attempts to do two things:
  377|       |       1) Don't unnecessarily span pages.
  378|       |       2) Unless necessary, don't flush pages if there are less than four packets on
  379|       |          them; this expands page size to reduce unnecessary overhead if incoming packets
  380|       |          are large.
  381|       |       These are not necessary behaviors, just 'always better than naive flushing'
  382|       |       without requiring an application to explicitly request a specific optimized
  383|       |       behavior. We'll want an explicit behavior setup pathway eventually as well. */
  384|       |
  385|  61.5k|    int packets_done=0;
  386|  61.5k|    int packet_just_done=0;
  387|  3.35M|    for(vals=0;vals<maxvals;vals++){
  ------------------
  |  Branch (387:16): [True: 3.29M, False: 60.4k]
  ------------------
  388|  3.29M|      if(acc>nfill && packet_just_done>=4){
  ------------------
  |  Branch (388:10): [True: 12.5k, False: 3.28M]
  |  Branch (388:23): [True: 1.17k, False: 11.3k]
  ------------------
  389|  1.17k|        force=1;
  390|  1.17k|        break;
  391|  1.17k|      }
  392|  3.29M|      acc+=os->lacing_vals[vals]&0x0ff;
  393|  3.29M|      if((os->lacing_vals[vals]&0xff)<255){
  ------------------
  |  Branch (393:10): [True: 3.19M, False: 104k]
  ------------------
  394|  3.19M|        granule_pos=os->granule_vals[vals];
  395|  3.19M|        packet_just_done=++packets_done;
  396|  3.19M|      }else
  397|   104k|        packet_just_done=0;
  398|  3.29M|    }
  399|  61.5k|    if(vals==255)force=1;
  ------------------
  |  Branch (399:8): [True: 46, False: 61.5k]
  ------------------
  400|  61.5k|  }
  401|       |
  402|  63.8k|  if(!force) return(0);
  ------------------
  |  Branch (402:6): [True: 55.8k, False: 8.03k]
  ------------------
  403|       |
  404|       |  /* construct the header in temp storage */
  405|  8.03k|  memcpy(os->header,"OggS",4);
  406|       |
  407|       |  /* stream structure version */
  408|  8.03k|  os->header[4]=0x00;
  409|       |
  410|       |  /* continued packet flag? */
  411|  8.03k|  os->header[5]=0x00;
  412|  8.03k|  if((os->lacing_vals[0]&0x100)==0)os->header[5]|=0x01;
  ------------------
  |  Branch (412:6): [True: 0, False: 8.03k]
  ------------------
  413|       |  /* first page flag? */
  414|  8.03k|  if(os->b_o_s==0)os->header[5]|=0x02;
  ------------------
  |  Branch (414:6): [True: 2.27k, False: 5.76k]
  ------------------
  415|       |  /* last page flag? */
  416|  8.03k|  if(os->e_o_s && os->lacing_fill==vals)os->header[5]|=0x04;
  ------------------
  |  Branch (416:6): [True: 2.34k, False: 5.68k]
  |  Branch (416:19): [True: 2.27k, False: 71]
  ------------------
  417|  8.03k|  os->b_o_s=1;
  418|       |
  419|       |  /* 64 bits of PCM position */
  420|  72.2k|  for(i=6;i<14;i++){
  ------------------
  |  Branch (420:11): [True: 64.2k, False: 8.03k]
  ------------------
  421|  64.2k|    os->header[i]=(unsigned char)(granule_pos&0xff);
  422|  64.2k|    granule_pos>>=8;
  423|  64.2k|  }
  424|       |
  425|       |  /* 32 bits of stream serial number */
  426|  8.03k|  {
  427|  8.03k|    long serialno=os->serialno;
  428|  40.1k|    for(i=14;i<18;i++){
  ------------------
  |  Branch (428:14): [True: 32.1k, False: 8.03k]
  ------------------
  429|  32.1k|      os->header[i]=(unsigned char)(serialno&0xff);
  430|  32.1k|      serialno>>=8;
  431|  32.1k|    }
  432|  8.03k|  }
  433|       |
  434|       |  /* 32 bits of page counter (we have both counter and page header
  435|       |     because this val can roll over) */
  436|  8.03k|  if(os->pageno==-1)os->pageno=0; /* because someone called
  ------------------
  |  Branch (436:6): [True: 0, False: 8.03k]
  ------------------
  437|       |                                     stream_reset; this would be a
  438|       |                                     strange thing to do in an
  439|       |                                     encode stream, but it has
  440|       |                                     plausible uses */
  441|  8.03k|  {
  442|  8.03k|    long pageno=os->pageno++;
  443|  40.1k|    for(i=18;i<22;i++){
  ------------------
  |  Branch (443:14): [True: 32.1k, False: 8.03k]
  ------------------
  444|  32.1k|      os->header[i]=(unsigned char)(pageno&0xff);
  445|  32.1k|      pageno>>=8;
  446|  32.1k|    }
  447|  8.03k|  }
  448|       |
  449|       |  /* zero for computation; filled in later */
  450|  8.03k|  os->header[22]=0;
  451|  8.03k|  os->header[23]=0;
  452|  8.03k|  os->header[24]=0;
  453|  8.03k|  os->header[25]=0;
  454|       |
  455|       |  /* segment table */
  456|  8.03k|  os->header[26]=(unsigned char)(vals&0xff);
  457|   121k|  for(i=0;i<vals;i++)
  ------------------
  |  Branch (457:11): [True: 113k, False: 8.03k]
  ------------------
  458|   113k|    bytes+=os->header[i+27]=(unsigned char)(os->lacing_vals[i]&0xff);
  459|       |
  460|       |  /* set pointers in the ogg_page struct */
  461|  8.03k|  og->header=os->header;
  462|  8.03k|  og->header_len=os->header_fill=vals+27;
  463|  8.03k|  og->body=os->body_data+os->body_returned;
  464|  8.03k|  og->body_len=bytes;
  465|       |
  466|       |  /* advance the lacing data and set the body_returned pointer */
  467|       |
  468|  8.03k|  os->lacing_fill-=vals;
  469|  8.03k|  memmove(os->lacing_vals,os->lacing_vals+vals,os->lacing_fill*sizeof(*os->lacing_vals));
  470|  8.03k|  memmove(os->granule_vals,os->granule_vals+vals,os->lacing_fill*sizeof(*os->granule_vals));
  471|  8.03k|  os->body_returned+=bytes;
  472|       |
  473|       |  /* calculate the checksum */
  474|       |
  475|  8.03k|  ogg_page_checksum_set(og);
  476|       |
  477|       |  /* done */
  478|  8.03k|  return(1);
  479|  63.8k|}

LLVMFuzzerTestOneInput:
    8|  2.27k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
    9|  2.27k|  FuzzedDataProvider fdp(data, size);
   10|       |
   11|       |  // Define encoding parameters
   12|  2.27k|  const int channels = fdp.ConsumeIntegralInRange(1, 8);
   13|  2.27k|  const int sample_rate = fdp.PickValueInArray(sample_rates);
   14|  2.27k|  const float base_quality = fdp.ConsumeFloatingPointInRange(0.0, 1.0);
   15|       |
   16|       |  // Temporarily skip configurations with 6 channels due to a known memory leak.
   17|       |  // https://gitlab.xiph.org/xiph/vorbis/-/issues/2357
   18|  2.27k|  if (channels == 6) {
  ------------------
  |  Branch (18:7): [True: 1, False: 2.27k]
  ------------------
   19|      1|    return 0;
   20|      1|  }
   21|       |
   22|       |  // Declare vorbis/ogg structures
   23|  2.27k|  ogg_stream_state os;
   24|  2.27k|  ogg_page og;
   25|  2.27k|  ogg_packet op;
   26|       |
   27|  2.27k|  vorbis_info vi;
   28|  2.27k|  vorbis_comment vc;
   29|  2.27k|  vorbis_dsp_state vd;
   30|  2.27k|  vorbis_block vb;
   31|       |
   32|       |  // Initialize vorbis/ogg structures
   33|  2.27k|  vorbis_info_init(&vi);
   34|  2.27k|  if (vorbis_encode_init_vbr(&vi, channels, sample_rate, base_quality)) {
  ------------------
  |  Branch (34:7): [True: 0, False: 2.27k]
  ------------------
   35|      0|    return 0;
   36|      0|  }
   37|       |
   38|  2.27k|  vorbis_comment_init(&vc);
   39|  2.27k|  vorbis_comment_add_tag(&vc, "ENCODER", "encode_fuzzer.cc");
   40|       |
   41|  2.27k|  vorbis_analysis_init(&vd, &vi);
   42|  2.27k|  vorbis_block_init(&vd, &vb);
   43|       |
   44|  2.27k|  ogg_stream_init(&os, 12345678);
   45|       |
   46|       |  // Output headers
   47|  2.27k|  {
   48|  2.27k|    ogg_packet header;
   49|  2.27k|    ogg_packet header_comm;
   50|  2.27k|    ogg_packet header_code;
   51|       |
   52|  2.27k|    vorbis_analysis_headerout(&vd, &vc, &header, &header_comm, &header_code);
   53|  2.27k|    ogg_stream_packetin(&os, &header);
   54|  2.27k|    ogg_stream_packetin(&os, &header_comm);
   55|  2.27k|    ogg_stream_packetin(&os, &header_code);
   56|       |
   57|  6.81k|    while (ogg_stream_flush(&os, &og)) {
  ------------------
  |  Branch (57:12): [True: 4.54k, False: 2.27k]
  ------------------
   58|  4.54k|    }
   59|  2.27k|  }
   60|       |
   61|       |  // Do the data encoding
   62|  2.27k|  int eos = 0;
   63|  15.7k|  while (!eos) {
  ------------------
  |  Branch (63:10): [True: 13.5k, False: 2.27k]
  ------------------
   64|  13.5k|    const int chunk = (fdp.remaining_bytes() > buffer_size * channels)
  ------------------
  |  Branch (64:23): [True: 9.45k, False: 4.07k]
  ------------------
   65|  13.5k|                          ? buffer_size * channels
   66|  13.5k|                          : static_cast<int>(fdp.remaining_bytes());
   67|       |
   68|  13.5k|    if (chunk == 0) {
  ------------------
  |  Branch (68:9): [True: 2.26k, False: 11.2k]
  ------------------
   69|  2.26k|      vorbis_analysis_wrote(&vd, 0);
   70|  11.2k|    } else {
   71|  11.2k|      float **buffer = vorbis_analysis_buffer(&vd, buffer_size);
   72|       |
   73|  11.2k|      const int frames = chunk / channels;
   74|  10.1M|      for (int i = 0; i < frames; i++) {
  ------------------
  |  Branch (74:23): [True: 10.1M, False: 11.2k]
  ------------------
   75|  26.9M|        for (int j = 0; j < channels; j++) {
  ------------------
  |  Branch (75:25): [True: 16.8M, False: 10.1M]
  ------------------
   76|  16.8M|          buffer[j][i] = fdp.ConsumeFloatingPointInRange(-1.0, 1.0);
   77|  16.8M|        }
   78|  10.1M|      }
   79|       |
   80|  11.2k|      vorbis_analysis_wrote(&vd, frames);
   81|  11.2k|    }
   82|       |
   83|  71.6k|    while (vorbis_analysis_blockout(&vd, &vb) == 1) {
  ------------------
  |  Branch (83:12): [True: 58.1k, False: 13.5k]
  ------------------
   84|  58.1k|      vorbis_analysis(&vb, NULL);
   85|  58.1k|      vorbis_bitrate_addblock(&vb);
   86|       |
   87|   116k|      while (vorbis_bitrate_flushpacket(&vd, &op)) {
  ------------------
  |  Branch (87:14): [True: 58.1k, False: 58.1k]
  ------------------
   88|  58.1k|        ogg_stream_packetin(&os, &op);
   89|       |
   90|  61.6k|        while (!eos) {
  ------------------
  |  Branch (90:16): [True: 59.3k, False: 2.27k]
  ------------------
   91|  59.3k|          int result = ogg_stream_pageout(&os, &og);
   92|  59.3k|          if (result == 0) {
  ------------------
  |  Branch (92:15): [True: 55.8k, False: 3.49k]
  ------------------
   93|  55.8k|            break;
   94|  55.8k|          }
   95|  3.49k|          if (ogg_page_eos(&og)) {
  ------------------
  |  Branch (95:15): [True: 2.27k, False: 1.22k]
  ------------------
   96|  2.27k|            eos = 1;
   97|  2.27k|          }
   98|  3.49k|        }
   99|  58.1k|      }
  100|  58.1k|    }
  101|  13.5k|  }
  102|       |
  103|       |  // Clean up
  104|  2.27k|  ogg_stream_clear(&os);
  105|  2.27k|  vorbis_block_clear(&vb);
  106|  2.27k|  vorbis_dsp_clear(&vd);
  107|  2.27k|  vorbis_comment_clear(&vc);
  108|  2.27k|  vorbis_info_clear(&vi);
  109|  2.27k|  return 0;
  110|  2.27k|}

vorbis_analysis:
   29|  58.1k|int vorbis_analysis(vorbis_block *vb, ogg_packet *op){
   30|  58.1k|  int ret,i;
   31|  58.1k|  vorbis_block_internal *vbi=vb->internal;
   32|       |
   33|  58.1k|  vb->glue_bits=0;
   34|  58.1k|  vb->time_bits=0;
   35|  58.1k|  vb->floor_bits=0;
   36|  58.1k|  vb->res_bits=0;
   37|       |
   38|       |  /* first things first.  Make sure encode is ready */
   39|   930k|  for(i=0;i<PACKETBLOBS;i++)
  ------------------
  |  |   28|   930k|#define PACKETBLOBS 15
  ------------------
  |  Branch (39:11): [True: 872k, False: 58.1k]
  ------------------
   40|   872k|    oggpack_reset(vbi->packetblob[i]);
   41|       |
   42|       |  /* we only have one mapping type (0), and we let the mapping code
   43|       |     itself figure out what soft mode to use.  This allows easier
   44|       |     bitrate management */
   45|       |
   46|  58.1k|  if((ret=_mapping_P[0]->forward(vb)))
  ------------------
  |  Branch (46:6): [True: 0, False: 58.1k]
  ------------------
   47|      0|    return(ret);
   48|       |
   49|  58.1k|  if(op){
  ------------------
  |  Branch (49:6): [True: 0, False: 58.1k]
  ------------------
   50|      0|    if(vorbis_bitrate_managed(vb))
  ------------------
  |  Branch (50:8): [True: 0, False: 0]
  ------------------
   51|       |      /* The app is using a bitmanaged mode... but not using the
   52|       |         bitrate management interface. */
   53|      0|      return(OV_EINVAL);
  ------------------
  |  |  228|      0|#define OV_EINVAL     -131
  ------------------
   54|       |
   55|      0|    op->packet=oggpack_get_buffer(&vb->opb);
   56|      0|    op->bytes=oggpack_bytes(&vb->opb);
   57|      0|    op->b_o_s=0;
   58|      0|    op->e_o_s=vb->eofflag;
   59|      0|    op->granulepos=vb->granulepos;
   60|      0|    op->packetno=vb->sequence; /* for sake of completeness */
   61|      0|  }
   62|  58.1k|  return(0);
   63|  58.1k|}

vorbis_bitrate_init:
   28|  2.27k|void vorbis_bitrate_init(vorbis_info *vi,bitrate_manager_state *bm){
   29|  2.27k|  codec_setup_info *ci=vi->codec_setup;
   30|  2.27k|  bitrate_manager_info *bi=&ci->bi;
   31|       |
   32|  2.27k|  memset(bm,0,sizeof(*bm));
   33|       |
   34|  2.27k|  if(bi && (bi->reservoir_bits>0)){
  ------------------
  |  Branch (34:6): [True: 2.27k, False: 0]
  |  Branch (34:12): [True: 0, False: 2.27k]
  ------------------
   35|      0|    long ratesamples=vi->rate;
   36|      0|    int  halfsamples=ci->blocksizes[0]>>1;
   37|       |
   38|      0|    bm->short_per_long=ci->blocksizes[1]/ci->blocksizes[0];
   39|      0|    bm->managed=1;
   40|       |
   41|      0|    bm->avg_bitsper= rint(1.*bi->avg_rate*halfsamples/ratesamples);
   42|      0|    bm->min_bitsper= rint(1.*bi->min_rate*halfsamples/ratesamples);
   43|      0|    bm->max_bitsper= rint(1.*bi->max_rate*halfsamples/ratesamples);
   44|       |
   45|      0|    bm->avgfloat=PACKETBLOBS/2;
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
   46|       |
   47|       |    /* not a necessary fix, but one that leads to a more balanced
   48|       |       typical initialization */
   49|      0|    {
   50|      0|      long desired_fill=bi->reservoir_bits*bi->reservoir_bias;
   51|      0|      bm->minmax_reservoir=desired_fill;
   52|      0|      bm->avg_reservoir=desired_fill;
   53|      0|    }
   54|       |
   55|      0|  }
   56|  2.27k|}
vorbis_bitrate_clear:
   58|  2.27k|void vorbis_bitrate_clear(bitrate_manager_state *bm){
   59|  2.27k|  memset(bm,0,sizeof(*bm));
   60|  2.27k|  return;
   61|  2.27k|}
vorbis_bitrate_managed:
   63|   336k|int vorbis_bitrate_managed(vorbis_block *vb){
   64|   336k|  vorbis_dsp_state      *vd=vb->vd;
   65|   336k|  private_state         *b=vd->backend_state;
   66|   336k|  bitrate_manager_state *bm=&b->bms;
   67|       |
   68|   336k|  if(bm && bm->managed)return(1);
  ------------------
  |  Branch (68:6): [True: 336k, False: 0]
  |  Branch (68:12): [True: 0, False: 336k]
  ------------------
   69|   336k|  return(0);
   70|   336k|}
vorbis_bitrate_addblock:
   73|  58.1k|int vorbis_bitrate_addblock(vorbis_block *vb){
   74|  58.1k|  vorbis_block_internal *vbi=vb->internal;
   75|  58.1k|  vorbis_dsp_state      *vd=vb->vd;
   76|  58.1k|  private_state         *b=vd->backend_state;
   77|  58.1k|  bitrate_manager_state *bm=&b->bms;
   78|  58.1k|  vorbis_info           *vi=vd->vi;
   79|  58.1k|  codec_setup_info      *ci=vi->codec_setup;
   80|  58.1k|  bitrate_manager_info  *bi=&ci->bi;
   81|       |
   82|  58.1k|  int  choice=rint(bm->avgfloat);
   83|  58.1k|  long this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
   84|  58.1k|  long min_target_bits=(vb->W?bm->min_bitsper*bm->short_per_long:bm->min_bitsper);
  ------------------
  |  Branch (84:25): [True: 2.63k, False: 55.5k]
  ------------------
   85|  58.1k|  long max_target_bits=(vb->W?bm->max_bitsper*bm->short_per_long:bm->max_bitsper);
  ------------------
  |  Branch (85:25): [True: 2.63k, False: 55.5k]
  ------------------
   86|  58.1k|  int  samples=ci->blocksizes[vb->W]>>1;
   87|  58.1k|  long desired_fill=bi->reservoir_bits*bi->reservoir_bias;
   88|  58.1k|  if(!bm->managed){
  ------------------
  |  Branch (88:6): [True: 58.1k, False: 0]
  ------------------
   89|       |    /* not a bitrate managed stream, but for API simplicity, we'll
   90|       |       buffer the packet to keep the code path clean */
   91|       |
   92|  58.1k|    if(bm->vb)return(-1); /* one has been submitted without
  ------------------
  |  Branch (92:8): [True: 0, False: 58.1k]
  ------------------
   93|       |                             being claimed */
   94|  58.1k|    bm->vb=vb;
   95|  58.1k|    return(0);
   96|  58.1k|  }
   97|       |
   98|      0|  bm->vb=vb;
   99|       |
  100|       |  /* look ahead for avg floater */
  101|      0|  if(bm->avg_bitsper>0){
  ------------------
  |  Branch (101:6): [True: 0, False: 0]
  ------------------
  102|      0|    double slew=0.;
  103|      0|    long avg_target_bits=(vb->W?bm->avg_bitsper*bm->short_per_long:bm->avg_bitsper);
  ------------------
  |  Branch (103:27): [True: 0, False: 0]
  ------------------
  104|      0|    double slewlimit= 15./bi->slew_damp;
  105|       |
  106|       |    /* choosing a new floater:
  107|       |       if we're over target, we slew down
  108|       |       if we're under target, we slew up
  109|       |
  110|       |       choose slew as follows: look through packetblobs of this frame
  111|       |       and set slew as the first in the appropriate direction that
  112|       |       gives us the slew we want.  This may mean no slew if delta is
  113|       |       already favorable.
  114|       |
  115|       |       Then limit slew to slew max */
  116|       |
  117|      0|    if(bm->avg_reservoir+(this_bits-avg_target_bits)>desired_fill){
  ------------------
  |  Branch (117:8): [True: 0, False: 0]
  ------------------
  118|      0|      while(choice>0 && this_bits>avg_target_bits &&
  ------------------
  |  Branch (118:13): [True: 0, False: 0]
  |  Branch (118:25): [True: 0, False: 0]
  ------------------
  119|      0|            bm->avg_reservoir+(this_bits-avg_target_bits)>desired_fill){
  ------------------
  |  Branch (119:13): [True: 0, False: 0]
  ------------------
  120|      0|        choice--;
  121|      0|        this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
  122|      0|      }
  123|      0|    }else if(bm->avg_reservoir+(this_bits-avg_target_bits)<desired_fill){
  ------------------
  |  Branch (123:14): [True: 0, False: 0]
  ------------------
  124|      0|      while(choice+1<PACKETBLOBS && this_bits<avg_target_bits &&
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  |  Branch (124:13): [True: 0, False: 0]
  |  Branch (124:37): [True: 0, False: 0]
  ------------------
  125|      0|            bm->avg_reservoir+(this_bits-avg_target_bits)<desired_fill){
  ------------------
  |  Branch (125:13): [True: 0, False: 0]
  ------------------
  126|      0|        choice++;
  127|      0|        this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
  128|      0|      }
  129|      0|    }
  130|       |
  131|      0|    slew=rint(choice-bm->avgfloat)/samples*vi->rate;
  132|      0|    if(slew<-slewlimit)slew=-slewlimit;
  ------------------
  |  Branch (132:8): [True: 0, False: 0]
  ------------------
  133|      0|    if(slew>slewlimit)slew=slewlimit;
  ------------------
  |  Branch (133:8): [True: 0, False: 0]
  ------------------
  134|      0|    choice=rint(bm->avgfloat+= slew/vi->rate*samples);
  135|      0|    this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
  136|      0|  }
  137|       |
  138|       |
  139|       |
  140|       |  /* enforce min(if used) on the current floater (if used) */
  141|      0|  if(bm->min_bitsper>0){
  ------------------
  |  Branch (141:6): [True: 0, False: 0]
  ------------------
  142|       |    /* do we need to force the bitrate up? */
  143|      0|    if(this_bits<min_target_bits){
  ------------------
  |  Branch (143:8): [True: 0, False: 0]
  ------------------
  144|      0|      while(bm->minmax_reservoir-(min_target_bits-this_bits)<0){
  ------------------
  |  Branch (144:13): [True: 0, False: 0]
  ------------------
  145|      0|        choice++;
  146|      0|        if(choice>=PACKETBLOBS)break;
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  |  Branch (146:12): [True: 0, False: 0]
  ------------------
  147|      0|        this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
  148|      0|      }
  149|      0|    }
  150|      0|  }
  151|       |
  152|       |  /* enforce max (if used) on the current floater (if used) */
  153|      0|  if(bm->max_bitsper>0){
  ------------------
  |  Branch (153:6): [True: 0, False: 0]
  ------------------
  154|       |    /* do we need to force the bitrate down? */
  155|      0|    if(this_bits>max_target_bits){
  ------------------
  |  Branch (155:8): [True: 0, False: 0]
  ------------------
  156|      0|      while(bm->minmax_reservoir+(this_bits-max_target_bits)>bi->reservoir_bits){
  ------------------
  |  Branch (156:13): [True: 0, False: 0]
  ------------------
  157|      0|        choice--;
  158|      0|        if(choice<0)break;
  ------------------
  |  Branch (158:12): [True: 0, False: 0]
  ------------------
  159|      0|        this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
  160|      0|      }
  161|      0|    }
  162|      0|  }
  163|       |
  164|       |  /* Choice of packetblobs now made based on floater, and min/max
  165|       |     requirements. Now boundary check extreme choices */
  166|       |
  167|      0|  if(choice<0){
  ------------------
  |  Branch (167:6): [True: 0, False: 0]
  ------------------
  168|       |    /* choosing a smaller packetblob is insufficient to trim bitrate.
  169|       |       frame will need to be truncated */
  170|      0|    long maxsize=(max_target_bits+(bi->reservoir_bits-bm->minmax_reservoir))/8;
  171|      0|    bm->choice=choice=0;
  172|       |
  173|      0|    if(oggpack_bytes(vbi->packetblob[choice])>maxsize){
  ------------------
  |  Branch (173:8): [True: 0, False: 0]
  ------------------
  174|       |
  175|      0|      oggpack_writetrunc(vbi->packetblob[choice],maxsize*8);
  176|      0|      this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
  177|      0|    }
  178|      0|  }else{
  179|      0|    long minsize=(min_target_bits-bm->minmax_reservoir+7)/8;
  180|      0|    if(choice>=PACKETBLOBS)
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  |  Branch (180:8): [True: 0, False: 0]
  ------------------
  181|      0|      choice=PACKETBLOBS-1;
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  182|       |
  183|      0|    bm->choice=choice;
  184|       |
  185|       |    /* prop up bitrate according to demand. pad this frame out with zeroes */
  186|      0|    minsize-=oggpack_bytes(vbi->packetblob[choice]);
  187|      0|    while(minsize-->0)oggpack_write(vbi->packetblob[choice],0,8);
  ------------------
  |  Branch (187:11): [True: 0, False: 0]
  ------------------
  188|      0|    this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
  189|       |
  190|      0|  }
  191|       |
  192|       |  /* now we have the final packet and the final packet size.  Update statistics */
  193|       |  /* min and max reservoir */
  194|      0|  if(bm->min_bitsper>0 || bm->max_bitsper>0){
  ------------------
  |  Branch (194:6): [True: 0, False: 0]
  |  Branch (194:27): [True: 0, False: 0]
  ------------------
  195|       |
  196|      0|    if(max_target_bits>0 && this_bits>max_target_bits){
  ------------------
  |  Branch (196:8): [True: 0, False: 0]
  |  Branch (196:29): [True: 0, False: 0]
  ------------------
  197|      0|      bm->minmax_reservoir+=(this_bits-max_target_bits);
  198|      0|    }else if(min_target_bits>0 && this_bits<min_target_bits){
  ------------------
  |  Branch (198:14): [True: 0, False: 0]
  |  Branch (198:35): [True: 0, False: 0]
  ------------------
  199|      0|      bm->minmax_reservoir+=(this_bits-min_target_bits);
  200|      0|    }else{
  201|       |      /* inbetween; we want to take reservoir toward but not past desired_fill */
  202|      0|      if(bm->minmax_reservoir>desired_fill){
  ------------------
  |  Branch (202:10): [True: 0, False: 0]
  ------------------
  203|      0|        if(max_target_bits>0){ /* logical bulletproofing against initialization state */
  ------------------
  |  Branch (203:12): [True: 0, False: 0]
  ------------------
  204|      0|          bm->minmax_reservoir+=(this_bits-max_target_bits);
  205|      0|          if(bm->minmax_reservoir<desired_fill)bm->minmax_reservoir=desired_fill;
  ------------------
  |  Branch (205:14): [True: 0, False: 0]
  ------------------
  206|      0|        }else{
  207|      0|          bm->minmax_reservoir=desired_fill;
  208|      0|        }
  209|      0|      }else{
  210|      0|        if(min_target_bits>0){ /* logical bulletproofing against initialization state */
  ------------------
  |  Branch (210:12): [True: 0, False: 0]
  ------------------
  211|      0|          bm->minmax_reservoir+=(this_bits-min_target_bits);
  212|      0|          if(bm->minmax_reservoir>desired_fill)bm->minmax_reservoir=desired_fill;
  ------------------
  |  Branch (212:14): [True: 0, False: 0]
  ------------------
  213|      0|        }else{
  214|      0|          bm->minmax_reservoir=desired_fill;
  215|      0|        }
  216|      0|      }
  217|      0|    }
  218|      0|  }
  219|       |
  220|       |  /* avg reservoir */
  221|      0|  if(bm->avg_bitsper>0){
  ------------------
  |  Branch (221:6): [True: 0, False: 0]
  ------------------
  222|      0|    long avg_target_bits=(vb->W?bm->avg_bitsper*bm->short_per_long:bm->avg_bitsper);
  ------------------
  |  Branch (222:27): [True: 0, False: 0]
  ------------------
  223|      0|    bm->avg_reservoir+=this_bits-avg_target_bits;
  224|      0|  }
  225|       |
  226|      0|  return(0);
  227|  58.1k|}
vorbis_bitrate_flushpacket:
  229|   116k|int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,ogg_packet *op){
  230|   116k|  private_state         *b=vd->backend_state;
  231|   116k|  bitrate_manager_state *bm=&b->bms;
  232|   116k|  vorbis_block          *vb=bm->vb;
  233|   116k|  int                    choice=PACKETBLOBS/2;
  ------------------
  |  |   28|   116k|#define PACKETBLOBS 15
  ------------------
  234|   116k|  if(!vb)return 0;
  ------------------
  |  Branch (234:6): [True: 58.1k, False: 58.1k]
  ------------------
  235|       |
  236|  58.1k|  if(op){
  ------------------
  |  Branch (236:6): [True: 58.1k, False: 0]
  ------------------
  237|  58.1k|    vorbis_block_internal *vbi=vb->internal;
  238|       |
  239|  58.1k|    if(vorbis_bitrate_managed(vb))
  ------------------
  |  Branch (239:8): [True: 0, False: 58.1k]
  ------------------
  240|      0|      choice=bm->choice;
  241|       |
  242|  58.1k|    op->packet=oggpack_get_buffer(vbi->packetblob[choice]);
  243|  58.1k|    op->bytes=oggpack_bytes(vbi->packetblob[choice]);
  244|  58.1k|    op->b_o_s=0;
  245|  58.1k|    op->e_o_s=vb->eofflag;
  246|  58.1k|    op->granulepos=vb->granulepos;
  247|  58.1k|    op->packetno=vb->sequence; /* for sake of completeness */
  248|  58.1k|  }
  249|       |
  250|  58.1k|  bm->vb=0;
  251|  58.1k|  return(1);
  252|   116k|}

vorbis_block_init:
   77|  2.27k|int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){
   78|  2.27k|  int i;
   79|  2.27k|  memset(vb,0,sizeof(*vb));
   80|  2.27k|  vb->vd=v;
   81|  2.27k|  vb->localalloc=0;
   82|  2.27k|  vb->localstore=NULL;
   83|  2.27k|  if(v->analysisp){
  ------------------
  |  Branch (83:6): [True: 2.27k, False: 0]
  ------------------
   84|  2.27k|    vorbis_block_internal *vbi=
   85|  2.27k|      vb->internal=_ogg_calloc(1,sizeof(vorbis_block_internal));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
   86|  2.27k|    vbi->ampmax=-9999;
   87|       |
   88|  36.3k|    for(i=0;i<PACKETBLOBS;i++){
  ------------------
  |  |   28|  36.3k|#define PACKETBLOBS 15
  ------------------
  |  Branch (88:13): [True: 34.0k, False: 2.27k]
  ------------------
   89|  34.0k|      if(i==PACKETBLOBS/2){
  ------------------
  |  |   28|  34.0k|#define PACKETBLOBS 15
  ------------------
  |  Branch (89:10): [True: 2.27k, False: 31.7k]
  ------------------
   90|  2.27k|        vbi->packetblob[i]=&vb->opb;
   91|  31.7k|      }else{
   92|  31.7k|        vbi->packetblob[i]=
   93|  31.7k|          _ogg_calloc(1,sizeof(oggpack_buffer));
  ------------------
  |  |   22|  31.7k|#define _ogg_calloc  calloc
  ------------------
   94|  31.7k|      }
   95|  34.0k|      oggpack_writeinit(vbi->packetblob[i]);
   96|  34.0k|    }
   97|  2.27k|  }
   98|       |
   99|  2.27k|  return(0);
  100|  2.27k|}
_vorbis_block_alloc:
  102|  1.07M|void *_vorbis_block_alloc(vorbis_block *vb,long bytes){
  103|  1.07M|  bytes=(bytes+(WORD_ALIGN-1)) & ~(WORD_ALIGN-1);
  ------------------
  |  |   74|  1.07M|#define WORD_ALIGN 8
  ------------------
                bytes=(bytes+(WORD_ALIGN-1)) & ~(WORD_ALIGN-1);
  ------------------
  |  |   74|  1.07M|#define WORD_ALIGN 8
  ------------------
  104|  1.07M|  if(bytes+vb->localtop>vb->localalloc){
  ------------------
  |  Branch (104:6): [True: 69.4k, False: 1.01M]
  ------------------
  105|       |    /* can't just _ogg_realloc... there are outstanding pointers */
  106|  69.4k|    if(vb->localstore){
  ------------------
  |  Branch (106:8): [True: 67.1k, False: 2.27k]
  ------------------
  107|  67.1k|      struct alloc_chain *link=_ogg_malloc(sizeof(*link));
  ------------------
  |  |   21|  67.1k|#define _ogg_malloc  malloc
  ------------------
  108|  67.1k|      vb->totaluse+=vb->localtop;
  109|  67.1k|      link->next=vb->reap;
  110|  67.1k|      link->ptr=vb->localstore;
  111|  67.1k|      vb->reap=link;
  112|  67.1k|    }
  113|       |    /* highly conservative */
  114|  69.4k|    vb->localalloc=bytes;
  115|  69.4k|    vb->localstore=_ogg_malloc(vb->localalloc);
  ------------------
  |  |   21|  69.4k|#define _ogg_malloc  malloc
  ------------------
  116|  69.4k|    vb->localtop=0;
  117|  69.4k|  }
  118|  1.07M|  {
  119|  1.07M|    void *ret=(void *)(((char *)vb->localstore)+vb->localtop);
  120|  1.07M|    vb->localtop+=bytes;
  121|  1.07M|    return ret;
  122|  1.07M|  }
  123|  1.07M|}
_vorbis_block_ripcord:
  126|  60.4k|void _vorbis_block_ripcord(vorbis_block *vb){
  127|       |  /* reap the chain */
  128|  60.4k|  struct alloc_chain *reap=vb->reap;
  129|   127k|  while(reap){
  ------------------
  |  Branch (129:9): [True: 67.1k, False: 60.4k]
  ------------------
  130|  67.1k|    struct alloc_chain *next=reap->next;
  131|  67.1k|    _ogg_free(reap->ptr);
  ------------------
  |  |   24|  67.1k|#define _ogg_free    free
  ------------------
  132|  67.1k|    memset(reap,0,sizeof(*reap));
  133|  67.1k|    _ogg_free(reap);
  ------------------
  |  |   24|  67.1k|#define _ogg_free    free
  ------------------
  134|  67.1k|    reap=next;
  135|  67.1k|  }
  136|       |  /* consolidate storage */
  137|  60.4k|  if(vb->totaluse){
  ------------------
  |  Branch (137:6): [True: 2.79k, False: 57.6k]
  ------------------
  138|  2.79k|    vb->localstore=_ogg_realloc(vb->localstore,vb->totaluse+vb->localalloc);
  ------------------
  |  |   23|  2.79k|#define _ogg_realloc realloc
  ------------------
  139|  2.79k|    vb->localalloc+=vb->totaluse;
  140|  2.79k|    vb->totaluse=0;
  141|  2.79k|  }
  142|       |
  143|       |  /* pull the ripcord */
  144|  60.4k|  vb->localtop=0;
  145|       |  vb->reap=NULL;
  146|  60.4k|}
vorbis_block_clear:
  148|  2.27k|int vorbis_block_clear(vorbis_block *vb){
  149|  2.27k|  int i;
  150|  2.27k|  vorbis_block_internal *vbi=vb->internal;
  151|       |
  152|  2.27k|  _vorbis_block_ripcord(vb);
  153|  2.27k|  if(vb->localstore)_ogg_free(vb->localstore);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  |  Branch (153:6): [True: 2.27k, False: 0]
  ------------------
  154|       |
  155|  2.27k|  if(vbi){
  ------------------
  |  Branch (155:6): [True: 2.27k, False: 0]
  ------------------
  156|  36.3k|    for(i=0;i<PACKETBLOBS;i++){
  ------------------
  |  |   28|  36.3k|#define PACKETBLOBS 15
  ------------------
  |  Branch (156:13): [True: 34.0k, False: 2.27k]
  ------------------
  157|  34.0k|      oggpack_writeclear(vbi->packetblob[i]);
  158|  34.0k|      if(i!=PACKETBLOBS/2)_ogg_free(vbi->packetblob[i]);
  ------------------
  |  |   28|  34.0k|#define PACKETBLOBS 15
  ------------------
                    if(i!=PACKETBLOBS/2)_ogg_free(vbi->packetblob[i]);
  ------------------
  |  |   24|  31.7k|#define _ogg_free    free
  ------------------
  |  Branch (158:10): [True: 31.7k, False: 2.27k]
  ------------------
  159|  34.0k|    }
  160|  2.27k|    _ogg_free(vbi);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  161|  2.27k|  }
  162|  2.27k|  memset(vb,0,sizeof(*vb));
  163|  2.27k|  return(0);
  164|  2.27k|}
vorbis_analysis_init:
  295|  2.27k|int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi){
  296|  2.27k|  private_state *b=NULL;
  297|       |
  298|  2.27k|  if(_vds_shared_init(v,vi,1))return 1;
  ------------------
  |  Branch (298:6): [True: 0, False: 2.27k]
  ------------------
  299|  2.27k|  b=v->backend_state;
  300|  2.27k|  b->psy_g_look=_vp_global_look(vi);
  301|       |
  302|       |  /* Initialize the envelope state storage */
  303|  2.27k|  b->ve=_ogg_calloc(1,sizeof(*b->ve));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
  304|  2.27k|  _ve_envelope_init(b->ve,vi);
  305|       |
  306|  2.27k|  vorbis_bitrate_init(vi,&b->bms);
  307|       |
  308|       |  /* compressed audio packets start after the headers
  309|       |     with sequence number 3 */
  310|  2.27k|  v->sequence=3;
  311|       |
  312|  2.27k|  return(0);
  313|  2.27k|}
vorbis_dsp_clear:
  315|  2.27k|void vorbis_dsp_clear(vorbis_dsp_state *v){
  316|  2.27k|  int i;
  317|  2.27k|  if(v){
  ------------------
  |  Branch (317:6): [True: 2.27k, False: 0]
  ------------------
  318|  2.27k|    vorbis_info *vi=v->vi;
  319|  2.27k|    codec_setup_info *ci=(vi?vi->codec_setup:NULL);
  ------------------
  |  Branch (319:27): [True: 2.27k, False: 0]
  ------------------
  320|  2.27k|    private_state *b=v->backend_state;
  321|       |
  322|  2.27k|    if(b){
  ------------------
  |  Branch (322:8): [True: 2.27k, False: 0]
  ------------------
  323|       |
  324|  2.27k|      if(b->ve){
  ------------------
  |  Branch (324:10): [True: 2.27k, False: 0]
  ------------------
  325|  2.27k|        _ve_envelope_clear(b->ve);
  326|  2.27k|        _ogg_free(b->ve);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  327|  2.27k|      }
  328|       |
  329|  2.27k|      if(b->transform[0]){
  ------------------
  |  Branch (329:10): [True: 2.27k, False: 0]
  ------------------
  330|  2.27k|        mdct_clear(b->transform[0][0]);
  331|  2.27k|        _ogg_free(b->transform[0][0]);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  332|  2.27k|        _ogg_free(b->transform[0]);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  333|  2.27k|      }
  334|  2.27k|      if(b->transform[1]){
  ------------------
  |  Branch (334:10): [True: 2.27k, False: 0]
  ------------------
  335|  2.27k|        mdct_clear(b->transform[1][0]);
  336|  2.27k|        _ogg_free(b->transform[1][0]);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  337|  2.27k|        _ogg_free(b->transform[1]);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  338|  2.27k|      }
  339|       |
  340|  2.27k|      if(b->flr){
  ------------------
  |  Branch (340:10): [True: 2.27k, False: 0]
  ------------------
  341|  2.27k|        if(ci)
  ------------------
  |  Branch (341:12): [True: 2.27k, False: 0]
  ------------------
  342|  6.53k|          for(i=0;i<ci->floors;i++)
  ------------------
  |  Branch (342:19): [True: 4.26k, False: 2.27k]
  ------------------
  343|  4.26k|            _floor_P[ci->floor_type[i]]->
  344|  4.26k|              free_look(b->flr[i]);
  345|  2.27k|        _ogg_free(b->flr);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  346|  2.27k|      }
  347|  2.27k|      if(b->residue){
  ------------------
  |  Branch (347:10): [True: 2.27k, False: 0]
  ------------------
  348|  2.27k|        if(ci)
  ------------------
  |  Branch (348:12): [True: 2.27k, False: 0]
  ------------------
  349|  6.41k|          for(i=0;i<ci->residues;i++)
  ------------------
  |  Branch (349:19): [True: 4.14k, False: 2.27k]
  ------------------
  350|  4.14k|            _residue_P[ci->residue_type[i]]->
  351|  4.14k|              free_look(b->residue[i]);
  352|  2.27k|        _ogg_free(b->residue);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  353|  2.27k|      }
  354|  2.27k|      if(b->psy){
  ------------------
  |  Branch (354:10): [True: 2.27k, False: 0]
  ------------------
  355|  2.27k|        if(ci)
  ------------------
  |  Branch (355:12): [True: 2.27k, False: 0]
  ------------------
  356|  10.5k|          for(i=0;i<ci->psys;i++)
  ------------------
  |  Branch (356:19): [True: 8.29k, False: 2.27k]
  ------------------
  357|  8.29k|            _vp_psy_clear(b->psy+i);
  358|  2.27k|        _ogg_free(b->psy);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  359|  2.27k|      }
  360|       |
  361|  2.27k|      if(b->psy_g_look)_vp_global_free(b->psy_g_look);
  ------------------
  |  Branch (361:10): [True: 2.27k, False: 0]
  ------------------
  362|  2.27k|      vorbis_bitrate_clear(&b->bms);
  363|       |
  364|  2.27k|      drft_clear(&b->fft_look[0]);
  365|  2.27k|      drft_clear(&b->fft_look[1]);
  366|       |
  367|  2.27k|    }
  368|       |
  369|  2.27k|    if(v->pcm){
  ------------------
  |  Branch (369:8): [True: 2.27k, False: 0]
  ------------------
  370|  2.27k|      if(vi)
  ------------------
  |  Branch (370:10): [True: 2.27k, False: 0]
  ------------------
  371|  9.17k|        for(i=0;i<vi->channels;i++)
  ------------------
  |  Branch (371:17): [True: 6.90k, False: 2.27k]
  ------------------
  372|  6.90k|          if(v->pcm[i])_ogg_free(v->pcm[i]);
  ------------------
  |  |   24|  6.90k|#define _ogg_free    free
  ------------------
  |  Branch (372:14): [True: 6.90k, False: 0]
  ------------------
  373|  2.27k|      _ogg_free(v->pcm);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  374|  2.27k|      if(v->pcmret)_ogg_free(v->pcmret);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  |  Branch (374:10): [True: 2.27k, False: 0]
  ------------------
  375|  2.27k|    }
  376|       |
  377|  2.27k|    if(b){
  ------------------
  |  Branch (377:8): [True: 2.27k, False: 0]
  ------------------
  378|       |      /* free header, header1, header2 */
  379|  2.27k|      if(b->header)_ogg_free(b->header);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (379:10): [True: 0, False: 2.27k]
  ------------------
  380|  2.27k|      if(b->header1)_ogg_free(b->header1);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (380:10): [True: 0, False: 2.27k]
  ------------------
  381|  2.27k|      if(b->header2)_ogg_free(b->header2);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (381:10): [True: 0, False: 2.27k]
  ------------------
  382|  2.27k|      _ogg_free(b);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  383|  2.27k|    }
  384|       |
  385|  2.27k|    memset(v,0,sizeof(*v));
  386|  2.27k|  }
  387|  2.27k|}
vorbis_analysis_buffer:
  389|  13.5k|float **vorbis_analysis_buffer(vorbis_dsp_state *v, int vals){
  390|  13.5k|  int i;
  391|  13.5k|  vorbis_info *vi=v->vi;
  392|  13.5k|  private_state *b=v->backend_state;
  393|       |
  394|       |  /* free header, header1, header2 */
  395|  13.5k|  if(b->header) {
  ------------------
  |  Branch (395:6): [True: 2.27k, False: 11.2k]
  ------------------
  396|  2.27k|    _ogg_free(b->header);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  397|  2.27k|    b->header=NULL;
  398|  2.27k|  }
  399|  13.5k|  if(b->header1) {
  ------------------
  |  Branch (399:6): [True: 2.27k, False: 11.2k]
  ------------------
  400|  2.27k|    _ogg_free(b->header1);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  401|  2.27k|    b->header1=NULL;
  402|  2.27k|  }
  403|  13.5k|  if(b->header2) {
  ------------------
  |  Branch (403:6): [True: 2.27k, False: 11.2k]
  ------------------
  404|  2.27k|    _ogg_free(b->header2);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  405|  2.27k|    b->header2=NULL;
  406|  2.27k|  }
  407|       |
  408|       |  /* Do we have enough storage space for the requested buffer? If not,
  409|       |     expand the PCM (and envelope) storage */
  410|       |
  411|  13.5k|  if(v->pcm_current+vals>=v->pcm_storage){
  ------------------
  |  Branch (411:6): [True: 5.23k, False: 8.30k]
  ------------------
  412|  5.23k|    v->pcm_storage=v->pcm_current+vals*2;
  413|       |
  414|  21.0k|    for(i=0;i<vi->channels;i++){
  ------------------
  |  Branch (414:13): [True: 15.8k, False: 5.23k]
  ------------------
  415|  15.8k|      v->pcm[i]=_ogg_realloc(v->pcm[i],v->pcm_storage*sizeof(*v->pcm[i]));
  ------------------
  |  |   23|  15.8k|#define _ogg_realloc realloc
  ------------------
  416|  15.8k|    }
  417|  5.23k|  }
  418|       |
  419|  40.8k|  for(i=0;i<vi->channels;i++)
  ------------------
  |  Branch (419:11): [True: 27.3k, False: 13.5k]
  ------------------
  420|  27.3k|    v->pcmret[i]=v->pcm[i]+v->pcm_current;
  421|       |
  422|  13.5k|  return(v->pcmret);
  423|  13.5k|}
vorbis_analysis_wrote:
  469|  13.5k|int vorbis_analysis_wrote(vorbis_dsp_state *v, int vals){
  470|  13.5k|  vorbis_info *vi=v->vi;
  471|  13.5k|  codec_setup_info *ci=vi->codec_setup;
  472|       |
  473|  13.5k|  if(vals<=0){
  ------------------
  |  Branch (473:6): [True: 2.27k, False: 11.2k]
  ------------------
  474|  2.27k|    int order=32;
  475|  2.27k|    int i;
  476|  2.27k|    float *lpc=alloca(order*sizeof(*lpc));
  477|       |
  478|       |    /* if it wasn't done earlier (very short sample) */
  479|  2.27k|    if(!v->preextrapolate)
  ------------------
  |  Branch (479:8): [True: 1.68k, False: 585]
  ------------------
  480|  1.68k|      _preextrapolate_helper(v);
  481|       |
  482|       |    /* We're encoding the end of the stream.  Just make sure we have
  483|       |       [at least] a few full blocks of zeroes at the end. */
  484|       |    /* actually, we don't want zeroes; that could drop a large
  485|       |       amplitude off a cliff, creating spread spectrum noise that will
  486|       |       suck to encode.  Extrapolate for the sake of cleanliness. */
  487|       |
  488|  2.27k|    vorbis_analysis_buffer(v,ci->blocksizes[1]*3);
  489|  2.27k|    v->eofflag=v->pcm_current;
  490|  2.27k|    v->pcm_current+=ci->blocksizes[1]*3;
  491|       |
  492|  9.17k|    for(i=0;i<vi->channels;i++){
  ------------------
  |  Branch (492:13): [True: 6.90k, False: 2.27k]
  ------------------
  493|  6.90k|      if(v->eofflag>order*2){
  ------------------
  |  Branch (493:10): [True: 6.90k, False: 0]
  ------------------
  494|       |        /* extrapolate with LPC to fill in */
  495|  6.90k|        long n;
  496|       |
  497|       |        /* make a predictor filter */
  498|  6.90k|        n=v->eofflag;
  499|  6.90k|        if(n>ci->blocksizes[1])n=ci->blocksizes[1];
  ------------------
  |  Branch (499:12): [True: 1.15k, False: 5.75k]
  ------------------
  500|  6.90k|        vorbis_lpc_from_data(v->pcm[i]+v->eofflag-n,lpc,n,order);
  501|       |
  502|       |        /* run the predictor filter */
  503|  6.90k|        vorbis_lpc_predict(lpc,v->pcm[i]+v->eofflag-order,order,
  504|  6.90k|                           v->pcm[i]+v->eofflag,v->pcm_current-v->eofflag);
  505|  6.90k|      }else{
  506|       |        /* not enough data to extrapolate (unlikely to happen due to
  507|       |           guarding the overlap, but bulletproof in case that
  508|       |           assumtion goes away). zeroes will do. */
  509|      0|        memset(v->pcm[i]+v->eofflag,0,
  510|      0|               (v->pcm_current-v->eofflag)*sizeof(*v->pcm[i]));
  511|       |
  512|      0|      }
  513|  6.90k|    }
  514|  11.2k|  }else{
  515|       |
  516|  11.2k|    if(v->pcm_current+vals>v->pcm_storage)
  ------------------
  |  Branch (516:8): [True: 0, False: 11.2k]
  ------------------
  517|      0|      return(OV_EINVAL);
  ------------------
  |  |  228|      0|#define OV_EINVAL     -131
  ------------------
  518|       |
  519|  11.2k|    v->pcm_current+=vals;
  520|       |
  521|       |    /* we may want to reverse extrapolate the beginning of a stream
  522|       |       too... in case we're beginning on a cliff! */
  523|       |    /* clumsy, but simple.  It only runs once, so simple is good. */
  524|  11.2k|    if(!v->preextrapolate && v->pcm_current-v->centerW>ci->blocksizes[1])
  ------------------
  |  Branch (524:8): [True: 3.15k, False: 8.10k]
  |  Branch (524:30): [True: 585, False: 2.56k]
  ------------------
  525|    585|      _preextrapolate_helper(v);
  526|       |
  527|  11.2k|  }
  528|  13.5k|  return(0);
  529|  13.5k|}
vorbis_analysis_blockout:
  533|  71.6k|int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){
  534|  71.6k|  int i;
  535|  71.6k|  vorbis_info *vi=v->vi;
  536|  71.6k|  codec_setup_info *ci=vi->codec_setup;
  537|  71.6k|  private_state *b=v->backend_state;
  538|  71.6k|  vorbis_look_psy_global *g=b->psy_g_look;
  539|  71.6k|  long beginW=v->centerW-ci->blocksizes[v->W]/2,centerNext;
  540|  71.6k|  vorbis_block_internal *vbi=(vorbis_block_internal *)vb->internal;
  541|       |
  542|       |  /* check to see if we're started... */
  543|  71.6k|  if(!v->preextrapolate)return(0);
  ------------------
  |  Branch (543:6): [True: 2.56k, False: 69.0k]
  ------------------
  544|       |
  545|       |  /* check to see if we're done... */
  546|  69.0k|  if(v->eofflag==-1)return(0);
  ------------------
  |  Branch (546:6): [True: 2.27k, False: 66.8k]
  ------------------
  547|       |
  548|       |  /* By our invariant, we have lW, W and centerW set.  Search for
  549|       |     the next boundary so we can determine nW (the next window size)
  550|       |     which lets us compute the shape of the current block's window */
  551|       |
  552|       |  /* we do an envelope search even on a single blocksize; we may still
  553|       |     be throwing more bits at impulses, and envelope search handles
  554|       |     marking impulses too. */
  555|  66.8k|  {
  556|  66.8k|    long bp=_ve_envelope_search(v);
  557|  66.8k|    if(bp==-1){
  ------------------
  |  Branch (557:8): [True: 8.51k, False: 58.3k]
  ------------------
  558|       |
  559|  8.51k|      if(v->eofflag==0)return(0); /* not enough data currently to search for a
  ------------------
  |  Branch (559:10): [True: 8.51k, False: 0]
  ------------------
  560|       |                                     full long block */
  561|      0|      v->nW=0;
  562|  58.3k|    }else{
  563|       |
  564|  58.3k|      if(ci->blocksizes[0]==ci->blocksizes[1])
  ------------------
  |  Branch (564:10): [True: 12.4k, False: 45.8k]
  ------------------
  565|  12.4k|        v->nW=0;
  566|  45.8k|      else
  567|  45.8k|        v->nW=bp;
  568|  58.3k|    }
  569|  66.8k|  }
  570|       |
  571|  58.3k|  centerNext=v->centerW+ci->blocksizes[v->W]/4+ci->blocksizes[v->nW]/4;
  572|       |
  573|  58.3k|  {
  574|       |    /* center of next block + next block maximum right side. */
  575|       |
  576|  58.3k|    long blockbound=centerNext+ci->blocksizes[v->nW]/2;
  577|  58.3k|    if(v->pcm_current<blockbound)return(0); /* not enough data yet;
  ------------------
  |  Branch (577:8): [True: 180, False: 58.1k]
  ------------------
  578|       |                                               although this check is
  579|       |                                               less strict that the
  580|       |                                               _ve_envelope_search,
  581|       |                                               the search is not run
  582|       |                                               if we only use one
  583|       |                                               block size */
  584|       |
  585|       |
  586|  58.3k|  }
  587|       |
  588|       |  /* fill in the block.  Note that for a short window, lW and nW are *short*
  589|       |     regardless of actual settings in the stream */
  590|       |
  591|  58.1k|  _vorbis_block_ripcord(vb);
  592|  58.1k|  vb->lW=v->lW;
  593|  58.1k|  vb->W=v->W;
  594|  58.1k|  vb->nW=v->nW;
  595|       |
  596|  58.1k|  if(v->W){
  ------------------
  |  Branch (596:6): [True: 2.63k, False: 55.5k]
  ------------------
  597|  2.63k|    if(!v->lW || !v->nW){
  ------------------
  |  Branch (597:8): [True: 1.06k, False: 1.56k]
  |  Branch (597:18): [True: 259, False: 1.30k]
  ------------------
  598|  1.32k|      vbi->blocktype=BLOCKTYPE_TRANSITION;
  ------------------
  |  |   25|  1.32k|#define BLOCKTYPE_TRANSITION 0
  ------------------
  599|       |      /*fprintf(stderr,"-");*/
  600|  1.32k|    }else{
  601|  1.30k|      vbi->blocktype=BLOCKTYPE_LONG;
  ------------------
  |  |   26|  1.30k|#define BLOCKTYPE_LONG       1
  ------------------
  602|       |      /*fprintf(stderr,"_");*/
  603|  1.30k|    }
  604|  55.5k|  }else{
  605|  55.5k|    if(_ve_envelope_mark(v)){
  ------------------
  |  Branch (605:8): [True: 36.5k, False: 18.9k]
  ------------------
  606|  36.5k|      vbi->blocktype=BLOCKTYPE_IMPULSE;
  ------------------
  |  |   23|  36.5k|#define BLOCKTYPE_IMPULSE    0
  ------------------
  607|       |      /*fprintf(stderr,"|");*/
  608|       |
  609|  36.5k|    }else{
  610|  18.9k|      vbi->blocktype=BLOCKTYPE_PADDING;
  ------------------
  |  |   24|  18.9k|#define BLOCKTYPE_PADDING    1
  ------------------
  611|       |      /*fprintf(stderr,".");*/
  612|       |
  613|  18.9k|    }
  614|  55.5k|  }
  615|       |
  616|  58.1k|  vb->vd=v;
  617|  58.1k|  vb->sequence=v->sequence++;
  618|  58.1k|  vb->granulepos=v->granulepos;
  619|  58.1k|  vb->pcmend=ci->blocksizes[v->W];
  620|       |
  621|       |  /* copy the vectors; this uses the local storage in vb */
  622|       |
  623|       |  /* this tracks 'strongest peak' for later psychoacoustics */
  624|       |  /* moved to the global psy state; clean this mess up */
  625|  58.1k|  if(vbi->ampmax>g->ampmax)g->ampmax=vbi->ampmax;
  ------------------
  |  Branch (625:6): [True: 28.5k, False: 29.5k]
  ------------------
  626|  58.1k|  g->ampmax=_vp_ampmax_decay(g->ampmax,v);
  627|  58.1k|  vbi->ampmax=g->ampmax;
  628|       |
  629|  58.1k|  vb->pcm=_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels);
  630|  58.1k|  vbi->pcmdelay=_vorbis_block_alloc(vb,sizeof(*vbi->pcmdelay)*vi->channels);
  631|   161k|  for(i=0;i<vi->channels;i++){
  ------------------
  |  Branch (631:11): [True: 103k, False: 58.1k]
  ------------------
  632|   103k|    vbi->pcmdelay[i]=
  633|   103k|      _vorbis_block_alloc(vb,(vb->pcmend+beginW)*sizeof(*vbi->pcmdelay[i]));
  634|   103k|    memcpy(vbi->pcmdelay[i],v->pcm[i],(vb->pcmend+beginW)*sizeof(*vbi->pcmdelay[i]));
  635|   103k|    vb->pcm[i]=vbi->pcmdelay[i]+beginW;
  636|       |
  637|       |    /* before we added the delay
  638|       |       vb->pcm[i]=_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
  639|       |       memcpy(vb->pcm[i],v->pcm[i]+beginW,ci->blocksizes[v->W]*sizeof(*vb->pcm[i]));
  640|       |    */
  641|       |
  642|   103k|  }
  643|       |
  644|       |  /* handle eof detection: eof==0 means that we've not yet received EOF
  645|       |                           eof>0  marks the last 'real' sample in pcm[]
  646|       |                           eof<0  'no more to do'; doesn't get here */
  647|       |
  648|  58.1k|  if(v->eofflag){
  ------------------
  |  Branch (648:6): [True: 9.18k, False: 48.9k]
  ------------------
  649|  9.18k|    if(v->centerW>=v->eofflag){
  ------------------
  |  Branch (649:8): [True: 2.27k, False: 6.91k]
  ------------------
  650|  2.27k|      v->eofflag=-1;
  651|  2.27k|      vb->eofflag=1;
  652|  2.27k|      return(1);
  653|  2.27k|    }
  654|  9.18k|  }
  655|       |
  656|       |  /* advance storage vectors and clean up */
  657|  55.8k|  {
  658|  55.8k|    int new_centerNext=ci->blocksizes[1]/2;
  659|  55.8k|    int movementW=centerNext-new_centerNext;
  660|       |
  661|  55.8k|    if(movementW>0){
  ------------------
  |  Branch (661:8): [True: 55.8k, False: 0]
  ------------------
  662|       |
  663|  55.8k|      _ve_envelope_shift(b->ve,movementW);
  664|  55.8k|      v->pcm_current-=movementW;
  665|       |
  666|   152k|      for(i=0;i<vi->channels;i++)
  ------------------
  |  Branch (666:15): [True: 96.6k, False: 55.8k]
  ------------------
  667|  96.6k|        memmove(v->pcm[i],v->pcm[i]+movementW,
  668|  96.6k|                v->pcm_current*sizeof(*v->pcm[i]));
  669|       |
  670|       |
  671|  55.8k|      v->lW=v->W;
  672|  55.8k|      v->W=v->nW;
  673|  55.8k|      v->centerW=new_centerNext;
  674|       |
  675|  55.8k|      if(v->eofflag){
  ------------------
  |  Branch (675:10): [True: 6.91k, False: 48.9k]
  ------------------
  676|  6.91k|        v->eofflag-=movementW;
  677|  6.91k|        if(v->eofflag<=0)v->eofflag=-1;
  ------------------
  |  Branch (677:12): [True: 0, False: 6.91k]
  ------------------
  678|       |        /* do not add padding to end of stream! */
  679|  6.91k|        if(v->centerW>=v->eofflag){
  ------------------
  |  Branch (679:12): [True: 2.16k, False: 4.74k]
  ------------------
  680|  2.16k|          v->granulepos+=movementW-(v->centerW-v->eofflag);
  681|  4.74k|        }else{
  682|  4.74k|          v->granulepos+=movementW;
  683|  4.74k|        }
  684|  48.9k|      }else{
  685|  48.9k|        v->granulepos+=movementW;
  686|  48.9k|      }
  687|  55.8k|    }
  688|  55.8k|  }
  689|       |
  690|       |  /* done */
  691|  55.8k|  return(1);
  692|  58.1k|}
block.c:_vds_shared_init:
  170|  2.27k|static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){
  171|  2.27k|  int i;
  172|  2.27k|  codec_setup_info *ci=vi->codec_setup;
  173|  2.27k|  private_state *b=NULL;
  174|  2.27k|  int hs;
  175|       |
  176|  2.27k|  if(ci==NULL||
  ------------------
  |  Branch (176:6): [True: 0, False: 2.27k]
  ------------------
  177|  2.27k|     ci->modes<=0||
  ------------------
  |  Branch (177:6): [True: 0, False: 2.27k]
  ------------------
  178|  2.27k|     ci->blocksizes[0]<64||
  ------------------
  |  Branch (178:6): [True: 0, False: 2.27k]
  ------------------
  179|  2.27k|     ci->blocksizes[1]<ci->blocksizes[0]){
  ------------------
  |  Branch (179:6): [True: 0, False: 2.27k]
  ------------------
  180|      0|    return 1;
  181|      0|  }
  182|  2.27k|  hs=ci->halfrate_flag;
  183|       |
  184|  2.27k|  memset(v,0,sizeof(*v));
  185|  2.27k|  b=v->backend_state=_ogg_calloc(1,sizeof(*b));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
  186|       |
  187|  2.27k|  v->vi=vi;
  188|  2.27k|  b->modebits=ov_ilog(ci->modes-1);
  189|       |
  190|  2.27k|  b->transform[0]=_ogg_calloc(VI_TRANSFORMB,sizeof(*b->transform[0]));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
                b->transform[0]=_ogg_calloc(VI_TRANSFORMB,sizeof(*b->transform[0]));
  ------------------
  |  |   20|  2.27k|#define VI_TRANSFORMB 1
  ------------------
  191|  2.27k|  b->transform[1]=_ogg_calloc(VI_TRANSFORMB,sizeof(*b->transform[1]));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
                b->transform[1]=_ogg_calloc(VI_TRANSFORMB,sizeof(*b->transform[1]));
  ------------------
  |  |   20|  2.27k|#define VI_TRANSFORMB 1
  ------------------
  192|       |
  193|       |  /* MDCT is tranform 0 */
  194|       |
  195|  2.27k|  b->transform[0][0]=_ogg_calloc(1,sizeof(mdct_lookup));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
  196|  2.27k|  b->transform[1][0]=_ogg_calloc(1,sizeof(mdct_lookup));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
  197|  2.27k|  mdct_init(b->transform[0][0],ci->blocksizes[0]>>hs);
  198|  2.27k|  mdct_init(b->transform[1][0],ci->blocksizes[1]>>hs);
  199|       |
  200|       |  /* Vorbis I uses only window type 0 */
  201|       |  /* note that the correct computation below is technically:
  202|       |       b->window[0]=ov_ilog(ci->blocksizes[0]-1)-6;
  203|       |       b->window[1]=ov_ilog(ci->blocksizes[1]-1)-6;
  204|       |    but since blocksizes are always powers of two,
  205|       |    the below is equivalent.
  206|       |   */
  207|  2.27k|  b->window[0]=ov_ilog(ci->blocksizes[0])-7;
  208|  2.27k|  b->window[1]=ov_ilog(ci->blocksizes[1])-7;
  209|       |
  210|  2.27k|  if(encp){ /* encode/decode differ here */
  ------------------
  |  Branch (210:6): [True: 2.27k, False: 0]
  ------------------
  211|       |
  212|       |    /* analysis always needs an fft */
  213|  2.27k|    drft_init(&b->fft_look[0],ci->blocksizes[0]);
  214|  2.27k|    drft_init(&b->fft_look[1],ci->blocksizes[1]);
  215|       |
  216|       |    /* finish the codebooks */
  217|  2.27k|    if(!ci->fullbooks){
  ------------------
  |  Branch (217:8): [True: 2.27k, False: 0]
  ------------------
  218|  2.27k|      ci->fullbooks=_ogg_calloc(ci->books,sizeof(*ci->fullbooks));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
  219|  83.8k|      for(i=0;i<ci->books;i++)
  ------------------
  |  Branch (219:15): [True: 81.5k, False: 2.27k]
  ------------------
  220|  81.5k|        vorbis_book_init_encode(ci->fullbooks+i,ci->book_param[i]);
  221|  2.27k|    }
  222|       |
  223|  2.27k|    b->psy=_ogg_calloc(ci->psys,sizeof(*b->psy));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
  224|  10.5k|    for(i=0;i<ci->psys;i++){
  ------------------
  |  Branch (224:13): [True: 8.29k, False: 2.27k]
  ------------------
  225|  8.29k|      _vp_psy_init(b->psy+i,
  226|  8.29k|                   ci->psy_param[i],
  227|  8.29k|                   &ci->psy_g_param,
  228|  8.29k|                   ci->blocksizes[ci->psy_param[i]->blockflag]/2,
  229|  8.29k|                   vi->rate);
  230|  8.29k|    }
  231|       |
  232|  2.27k|    v->analysisp=1;
  233|  2.27k|  }else{
  234|       |    /* finish the codebooks */
  235|      0|    if(!ci->fullbooks){
  ------------------
  |  Branch (235:8): [True: 0, False: 0]
  ------------------
  236|      0|      ci->fullbooks=_ogg_calloc(ci->books,sizeof(*ci->fullbooks));
  ------------------
  |  |   22|      0|#define _ogg_calloc  calloc
  ------------------
  237|      0|      for(i=0;i<ci->books;i++){
  ------------------
  |  Branch (237:15): [True: 0, False: 0]
  ------------------
  238|      0|        if(ci->book_param[i]==NULL)
  ------------------
  |  Branch (238:12): [True: 0, False: 0]
  ------------------
  239|      0|          goto abort_books;
  240|      0|        if(vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]))
  ------------------
  |  Branch (240:12): [True: 0, False: 0]
  ------------------
  241|      0|          goto abort_books;
  242|       |        /* decode codebooks are now standalone after init */
  243|      0|        vorbis_staticbook_destroy(ci->book_param[i]);
  244|      0|        ci->book_param[i]=NULL;
  245|      0|      }
  246|      0|    }
  247|      0|  }
  248|       |
  249|       |  /* initialize the storage vectors. blocksize[1] is small for encode,
  250|       |     but the correct size for decode */
  251|  2.27k|  v->pcm_storage=ci->blocksizes[1];
  252|  2.27k|  v->pcm=_ogg_malloc(vi->channels*sizeof(*v->pcm));
  ------------------
  |  |   21|  2.27k|#define _ogg_malloc  malloc
  ------------------
  253|  2.27k|  v->pcmret=_ogg_malloc(vi->channels*sizeof(*v->pcmret));
  ------------------
  |  |   21|  2.27k|#define _ogg_malloc  malloc
  ------------------
  254|  2.27k|  {
  255|  2.27k|    int i;
  256|  9.17k|    for(i=0;i<vi->channels;i++)
  ------------------
  |  Branch (256:13): [True: 6.90k, False: 2.27k]
  ------------------
  257|  6.90k|      v->pcm[i]=_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i]));
  ------------------
  |  |   22|  6.90k|#define _ogg_calloc  calloc
  ------------------
  258|  2.27k|  }
  259|       |
  260|       |  /* all 1 (large block) or 0 (small block) */
  261|       |  /* explicitly set for the sake of clarity */
  262|  2.27k|  v->lW=0; /* previous window size */
  263|  2.27k|  v->W=0;  /* current window size */
  264|       |
  265|       |  /* all vector indexes */
  266|  2.27k|  v->centerW=ci->blocksizes[1]/2;
  267|       |
  268|  2.27k|  v->pcm_current=v->centerW;
  269|       |
  270|       |  /* initialize all the backend lookups */
  271|  2.27k|  b->flr=_ogg_calloc(ci->floors,sizeof(*b->flr));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
  272|  2.27k|  b->residue=_ogg_calloc(ci->residues,sizeof(*b->residue));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
  273|       |
  274|  6.53k|  for(i=0;i<ci->floors;i++)
  ------------------
  |  Branch (274:11): [True: 4.26k, False: 2.27k]
  ------------------
  275|  4.26k|    b->flr[i]=_floor_P[ci->floor_type[i]]->
  276|  4.26k|      look(v,ci->floor_param[i]);
  277|       |
  278|  6.41k|  for(i=0;i<ci->residues;i++)
  ------------------
  |  Branch (278:11): [True: 4.14k, False: 2.27k]
  ------------------
  279|  4.14k|    b->residue[i]=_residue_P[ci->residue_type[i]]->
  280|  4.14k|      look(v,ci->residue_param[i]);
  281|       |
  282|  2.27k|  return 0;
  283|      0| abort_books:
  284|      0|  for(i=0;i<ci->books;i++){
  ------------------
  |  Branch (284:11): [True: 0, False: 0]
  ------------------
  285|      0|    if(ci->book_param[i]!=NULL){
  ------------------
  |  Branch (285:8): [True: 0, False: 0]
  ------------------
  286|      0|      vorbis_staticbook_destroy(ci->book_param[i]);
  287|       |      ci->book_param[i]=NULL;
  288|      0|    }
  289|      0|  }
  290|      0|  vorbis_dsp_clear(v);
  291|      0|  return -1;
  292|  2.27k|}
block.c:_preextrapolate_helper:
  425|  2.27k|static void _preextrapolate_helper(vorbis_dsp_state *v){
  426|  2.27k|  int i;
  427|  2.27k|  int order=16;
  428|  2.27k|  float *lpc=alloca(order*sizeof(*lpc));
  429|  2.27k|  float *work=alloca(v->pcm_current*sizeof(*work));
  430|  2.27k|  long j;
  431|  2.27k|  v->preextrapolate=1;
  432|       |
  433|  2.27k|  if(v->pcm_current-v->centerW>order*2){ /* safety */
  ------------------
  |  Branch (433:6): [True: 1.39k, False: 878]
  ------------------
  434|  5.57k|    for(i=0;i<v->vi->channels;i++){
  ------------------
  |  Branch (434:13): [True: 4.17k, False: 1.39k]
  ------------------
  435|       |      /* need to run the extrapolation in reverse! */
  436|  9.65M|      for(j=0;j<v->pcm_current;j++)
  ------------------
  |  Branch (436:15): [True: 9.65M, False: 4.17k]
  ------------------
  437|  9.65M|        work[j]=v->pcm[i][v->pcm_current-j-1];
  438|       |
  439|       |      /* prime as above */
  440|  4.17k|      vorbis_lpc_from_data(work,lpc,v->pcm_current-v->centerW,order);
  441|       |
  442|       |#if 0
  443|       |      if(v->vi->channels==2){
  444|       |        if(i==0)
  445|       |          _analysis_output("predataL",0,work,v->pcm_current-v->centerW,0,0,0);
  446|       |        else
  447|       |          _analysis_output("predataR",0,work,v->pcm_current-v->centerW,0,0,0);
  448|       |      }else{
  449|       |        _analysis_output("predata",0,work,v->pcm_current-v->centerW,0,0,0);
  450|       |      }
  451|       |#endif
  452|       |
  453|       |      /* run the predictor filter */
  454|  4.17k|      vorbis_lpc_predict(lpc,work+v->pcm_current-v->centerW-order,
  455|  4.17k|                         order,
  456|  4.17k|                         work+v->pcm_current-v->centerW,
  457|  4.17k|                         v->centerW);
  458|       |
  459|  9.65M|      for(j=0;j<v->pcm_current;j++)
  ------------------
  |  Branch (459:15): [True: 9.65M, False: 4.17k]
  ------------------
  460|  9.65M|        v->pcm[i][v->pcm_current-j-1]=work[j];
  461|       |
  462|  4.17k|    }
  463|  1.39k|  }
  464|  2.27k|}

vorbis_staticbook_pack:
   29|  81.5k|int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
   30|  81.5k|  long i,j;
   31|  81.5k|  int ordered=0;
   32|       |
   33|       |  /* first the basic parameters */
   34|  81.5k|  oggpack_write(opb,0x564342,24);
   35|  81.5k|  oggpack_write(opb,c->dim,16);
   36|  81.5k|  oggpack_write(opb,c->entries,24);
   37|       |
   38|       |  /* pack the codewords.  There are two packings; length ordered and
   39|       |     length random.  Decide between the two now. */
   40|       |
   41|   407k|  for(i=1;i<c->entries;i++)
  ------------------
  |  Branch (41:11): [True: 406k, False: 933]
  ------------------
   42|   406k|    if(c->lengthlist[i-1]==0 || c->lengthlist[i]<c->lengthlist[i-1])break;
  ------------------
  |  Branch (42:8): [True: 27.8k, False: 378k]
  |  Branch (42:33): [True: 52.8k, False: 326k]
  ------------------
   43|  81.5k|  if(i==c->entries)ordered=1;
  ------------------
  |  Branch (43:6): [True: 933, False: 80.6k]
  ------------------
   44|       |
   45|  81.5k|  if(ordered){
  ------------------
  |  Branch (45:6): [True: 933, False: 80.6k]
  ------------------
   46|       |    /* length ordered.  We only need to say how many codewords of
   47|       |       each length.  The actual codewords are generated
   48|       |       deterministically */
   49|       |
   50|    933|    long count=0;
   51|    933|    oggpack_write(opb,1,1);  /* ordered */
   52|    933|    oggpack_write(opb,c->lengthlist[0]-1,5); /* 1 to 32 */
   53|       |
   54|  20.2k|    for(i=1;i<c->entries;i++){
  ------------------
  |  Branch (54:13): [True: 19.3k, False: 933]
  ------------------
   55|  19.3k|      char this=c->lengthlist[i];
   56|  19.3k|      char last=c->lengthlist[i-1];
   57|  19.3k|      if(this>last){
  ------------------
  |  Branch (57:10): [True: 1.49k, False: 17.8k]
  ------------------
   58|  3.47k|        for(j=last;j<this;j++){
  ------------------
  |  Branch (58:20): [True: 1.98k, False: 1.49k]
  ------------------
   59|  1.98k|          oggpack_write(opb,i-count,ov_ilog(c->entries-count));
   60|  1.98k|          count=i;
   61|  1.98k|        }
   62|  1.49k|      }
   63|  19.3k|    }
   64|    933|    oggpack_write(opb,i-count,ov_ilog(c->entries-count));
   65|       |
   66|  80.6k|  }else{
   67|       |    /* length random.  Again, we don't code the codeword itself, just
   68|       |       the length.  This time, though, we have to encode each length */
   69|  80.6k|    oggpack_write(opb,0,1);   /* unordered */
   70|       |
   71|       |    /* algortihmic mapping has use for 'unused entries', which we tag
   72|       |       here.  The algorithmic mapping happens as usual, but the unused
   73|       |       entry has no codeword. */
   74|  7.16M|    for(i=0;i<c->entries;i++)
  ------------------
  |  Branch (74:13): [True: 7.12M, False: 47.7k]
  ------------------
   75|  7.12M|      if(c->lengthlist[i]==0)break;
  ------------------
  |  Branch (75:10): [True: 32.9k, False: 7.08M]
  ------------------
   76|       |
   77|  80.6k|    if(i==c->entries){
  ------------------
  |  Branch (77:8): [True: 47.7k, False: 32.9k]
  ------------------
   78|  47.7k|      oggpack_write(opb,0,1); /* no unused entries */
   79|  6.37M|      for(i=0;i<c->entries;i++)
  ------------------
  |  Branch (79:15): [True: 6.32M, False: 47.7k]
  ------------------
   80|  6.32M|        oggpack_write(opb,c->lengthlist[i]-1,5);
   81|  47.7k|    }else{
   82|  32.9k|      oggpack_write(opb,1,1); /* we have unused entries; thus we tag */
   83|  5.59M|      for(i=0;i<c->entries;i++){
  ------------------
  |  Branch (83:15): [True: 5.56M, False: 32.9k]
  ------------------
   84|  5.56M|        if(c->lengthlist[i]==0){
  ------------------
  |  Branch (84:12): [True: 2.85M, False: 2.70M]
  ------------------
   85|  2.85M|          oggpack_write(opb,0,1);
   86|  2.85M|        }else{
   87|  2.70M|          oggpack_write(opb,1,1);
   88|  2.70M|          oggpack_write(opb,c->lengthlist[i]-1,5);
   89|  2.70M|        }
   90|  5.56M|      }
   91|  32.9k|    }
   92|  80.6k|  }
   93|       |
   94|       |  /* is the entry number the desired return value, or do we have a
   95|       |     mapping? If we have a mapping, what type? */
   96|  81.5k|  oggpack_write(opb,c->maptype,4);
   97|  81.5k|  switch(c->maptype){
   98|  52.7k|  case 0:
  ------------------
  |  Branch (98:3): [True: 52.7k, False: 28.8k]
  ------------------
   99|       |    /* no mapping */
  100|  52.7k|    break;
  101|  28.8k|  case 1:case 2:
  ------------------
  |  Branch (101:3): [True: 28.8k, False: 52.7k]
  |  Branch (101:10): [True: 0, False: 81.5k]
  ------------------
  102|       |    /* implicitly populated value mapping */
  103|       |    /* explicitly populated value mapping */
  104|       |
  105|  28.8k|    if(!c->quantlist){
  ------------------
  |  Branch (105:8): [True: 0, False: 28.8k]
  ------------------
  106|       |      /* no quantlist?  error */
  107|      0|      return(-1);
  108|      0|    }
  109|       |
  110|       |    /* values that define the dequantization */
  111|  28.8k|    oggpack_write(opb,c->q_min,32);
  112|  28.8k|    oggpack_write(opb,c->q_delta,32);
  113|  28.8k|    oggpack_write(opb,c->q_quant-1,4);
  114|  28.8k|    oggpack_write(opb,c->q_sequencep,1);
  115|       |
  116|  28.8k|    {
  117|  28.8k|      int quantvals;
  118|  28.8k|      switch(c->maptype){
  119|  28.8k|      case 1:
  ------------------
  |  Branch (119:7): [True: 28.8k, False: 0]
  ------------------
  120|       |        /* a single column of (c->entries/c->dim) quantized values for
  121|       |           building a full value list algorithmically (square lattice) */
  122|  28.8k|        quantvals=_book_maptype1_quantvals(c);
  123|  28.8k|        break;
  124|      0|      case 2:
  ------------------
  |  Branch (124:7): [True: 0, False: 28.8k]
  ------------------
  125|       |        /* every value (c->entries*c->dim total) specified explicitly */
  126|      0|        quantvals=c->entries*c->dim;
  127|      0|        break;
  128|      0|      default: /* NOT_REACHABLE */
  ------------------
  |  Branch (128:7): [True: 0, False: 28.8k]
  ------------------
  129|      0|        quantvals=-1;
  130|  28.8k|      }
  131|       |
  132|       |      /* quantized values */
  133|   340k|      for(i=0;i<quantvals;i++)
  ------------------
  |  Branch (133:15): [True: 311k, False: 28.8k]
  ------------------
  134|   311k|        oggpack_write(opb,labs(c->quantlist[i]),c->q_quant);
  135|       |
  136|  28.8k|    }
  137|      0|    break;
  138|      0|  default:
  ------------------
  |  Branch (138:3): [True: 0, False: 81.5k]
  ------------------
  139|       |    /* error case; we don't have any other map types now */
  140|      0|    return(-1);
  141|  81.5k|  }
  142|       |
  143|  81.5k|  return(0);
  144|  81.5k|}
vorbis_book_encode:
  273|  11.4M|int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b){
  274|  11.4M|  if(a<0 || a>=book->c->entries)return(0);
  ------------------
  |  Branch (274:6): [True: 0, False: 11.4M]
  |  Branch (274:13): [True: 0, False: 11.4M]
  ------------------
  275|  11.4M|  oggpack_write(b,book->codelist[a],book->c->lengthlist[a]);
  276|  11.4M|  return(book->c->lengthlist[a]);
  277|  11.4M|}

_ve_envelope_init:
   31|  2.27k|void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi){
   32|  2.27k|  codec_setup_info *ci=vi->codec_setup;
   33|  2.27k|  vorbis_info_psy_global *gi=&ci->psy_g_param;
   34|  2.27k|  int ch=vi->channels;
   35|  2.27k|  int i,j;
   36|  2.27k|  int n=e->winlength=128;
   37|  2.27k|  e->searchstep=64; /* not random */
   38|       |
   39|  2.27k|  e->minenergy=gi->preecho_minenergy;
   40|  2.27k|  e->ch=ch;
   41|  2.27k|  e->storage=128;
   42|  2.27k|  e->cursor=ci->blocksizes[1]/2;
   43|  2.27k|  e->mdct_win=_ogg_calloc(n,sizeof(*e->mdct_win));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
   44|  2.27k|  mdct_init(&e->mdct,n);
   45|       |
   46|   292k|  for(i=0;i<n;i++){
  ------------------
  |  Branch (46:11): [True: 290k, False: 2.27k]
  ------------------
   47|   290k|    e->mdct_win[i]=sin(i/(n-1.)*M_PI);
   48|   290k|    e->mdct_win[i]*=e->mdct_win[i];
   49|   290k|  }
   50|       |
   51|       |  /* magic follows */
   52|  2.27k|  e->band[0].begin=2;  e->band[0].end=4;
   53|  2.27k|  e->band[1].begin=4;  e->band[1].end=5;
   54|  2.27k|  e->band[2].begin=6;  e->band[2].end=6;
   55|  2.27k|  e->band[3].begin=9;  e->band[3].end=8;
   56|  2.27k|  e->band[4].begin=13;  e->band[4].end=8;
   57|  2.27k|  e->band[5].begin=17;  e->band[5].end=8;
   58|  2.27k|  e->band[6].begin=22;  e->band[6].end=8;
   59|       |
   60|  18.1k|  for(j=0;j<VE_BANDS;j++){
  ------------------
  |  |   27|  18.1k|#define VE_BANDS  7
  ------------------
  |  Branch (60:11): [True: 15.8k, False: 2.27k]
  ------------------
   61|  15.8k|    n=e->band[j].end;
   62|  15.8k|    e->band[j].window=_ogg_malloc(n*sizeof(*e->band[0].window));
  ------------------
  |  |   21|  15.8k|#define _ogg_malloc  malloc
  ------------------
   63|   122k|    for(i=0;i<n;i++){
  ------------------
  |  Branch (63:13): [True: 106k, False: 15.8k]
  ------------------
   64|   106k|      e->band[j].window[i]=sin((i+.5)/n*M_PI);
   65|   106k|      e->band[j].total+=e->band[j].window[i];
   66|   106k|    }
   67|  15.8k|    e->band[j].total=1./e->band[j].total;
   68|  15.8k|  }
   69|       |
   70|  2.27k|  e->filter=_ogg_calloc(VE_BANDS*ch,sizeof(*e->filter));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
                e->filter=_ogg_calloc(VE_BANDS*ch,sizeof(*e->filter));
  ------------------
  |  |   27|  2.27k|#define VE_BANDS  7
  ------------------
   71|  2.27k|  e->mark=_ogg_calloc(e->storage,sizeof(*e->mark));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
   72|       |
   73|  2.27k|}
_ve_envelope_clear:
   75|  2.27k|void _ve_envelope_clear(envelope_lookup *e){
   76|  2.27k|  int i;
   77|  2.27k|  mdct_clear(&e->mdct);
   78|  18.1k|  for(i=0;i<VE_BANDS;i++)
  ------------------
  |  |   27|  18.1k|#define VE_BANDS  7
  ------------------
  |  Branch (78:11): [True: 15.8k, False: 2.27k]
  ------------------
   79|  15.8k|    _ogg_free(e->band[i].window);
  ------------------
  |  |   24|  15.8k|#define _ogg_free    free
  ------------------
   80|  2.27k|  _ogg_free(e->mdct_win);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
   81|  2.27k|  _ogg_free(e->filter);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
   82|  2.27k|  _ogg_free(e->mark);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
   83|  2.27k|  memset(e,0,sizeof(*e));
   84|  2.27k|}
_ve_envelope_search:
  215|  66.8k|long _ve_envelope_search(vorbis_dsp_state *v){
  216|  66.8k|  vorbis_info *vi=v->vi;
  217|  66.8k|  codec_setup_info *ci=vi->codec_setup;
  218|  66.8k|  vorbis_info_psy_global *gi=&ci->psy_g_param;
  219|  66.8k|  envelope_lookup *ve=((private_state *)(v->backend_state))->ve;
  220|  66.8k|  long i,j;
  221|       |
  222|  66.8k|  int first=ve->current/ve->searchstep;
  223|  66.8k|  int last=v->pcm_current/ve->searchstep-VE_WIN;
  ------------------
  |  |   23|  66.8k|#define VE_WIN    4
  ------------------
  224|  66.8k|  if(first<0)first=0;
  ------------------
  |  Branch (224:6): [True: 0, False: 66.8k]
  ------------------
  225|       |
  226|       |  /* make sure we have enough storage to match the PCM */
  227|  66.8k|  if(last+VE_WIN+VE_POST>ve->storage){
  ------------------
  |  |   23|  66.8k|#define VE_WIN    4
  ------------------
                if(last+VE_WIN+VE_POST>ve->storage){
  ------------------
  |  |   24|  66.8k|#define VE_POST   2
  ------------------
  |  Branch (227:6): [True: 280, False: 66.5k]
  ------------------
  228|    280|    ve->storage=last+VE_WIN+VE_POST; /* be sure */
  ------------------
  |  |   23|    280|#define VE_WIN    4
  ------------------
                  ve->storage=last+VE_WIN+VE_POST; /* be sure */
  ------------------
  |  |   24|    280|#define VE_POST   2
  ------------------
  229|    280|    ve->mark=_ogg_realloc(ve->mark,ve->storage*sizeof(*ve->mark));
  ------------------
  |  |   23|    280|#define _ogg_realloc realloc
  ------------------
  230|    280|  }
  231|       |
  232|   424k|  for(j=first;j<last;j++){
  ------------------
  |  Branch (232:15): [True: 358k, False: 66.8k]
  ------------------
  233|   358k|    int ret=0;
  234|       |
  235|   358k|    ve->stretch++;
  236|   358k|    if(ve->stretch>VE_MAXSTRETCH*2)
  ------------------
  |  |   31|   358k|#define VE_MAXSTRETCH 12  /* one-third full block */
  ------------------
  |  Branch (236:8): [True: 177k, False: 180k]
  ------------------
  237|   177k|      ve->stretch=VE_MAXSTRETCH*2;
  ------------------
  |  |   31|   177k|#define VE_MAXSTRETCH 12  /* one-third full block */
  ------------------
  238|       |
  239|  1.25M|    for(i=0;i<ve->ch;i++){
  ------------------
  |  Branch (239:13): [True: 896k, False: 358k]
  ------------------
  240|   896k|      float *pcm=v->pcm[i]+ve->searchstep*(j);
  241|   896k|      ret|=_ve_amp(ve,gi,pcm,ve->band,ve->filter+i*VE_BANDS);
  ------------------
  |  |   27|   896k|#define VE_BANDS  7
  ------------------
  242|   896k|    }
  243|       |
  244|   358k|    ve->mark[j+VE_POST]=0;
  ------------------
  |  |   24|   358k|#define VE_POST   2
  ------------------
  245|   358k|    if(ret&1){
  ------------------
  |  Branch (245:8): [True: 32.7k, False: 325k]
  ------------------
  246|  32.7k|      ve->mark[j]=1;
  247|  32.7k|      ve->mark[j+1]=1;
  248|  32.7k|    }
  249|       |
  250|   358k|    if(ret&2){
  ------------------
  |  Branch (250:8): [True: 23.1k, False: 335k]
  ------------------
  251|  23.1k|      ve->mark[j]=1;
  252|  23.1k|      if(j>0)ve->mark[j-1]=1;
  ------------------
  |  Branch (252:10): [True: 20.8k, False: 2.27k]
  ------------------
  253|  23.1k|    }
  254|       |
  255|   358k|    if(ret&4)ve->stretch=-1;
  ------------------
  |  Branch (255:8): [True: 32.7k, False: 325k]
  ------------------
  256|   358k|  }
  257|       |
  258|  66.8k|  ve->current=last*ve->searchstep;
  259|       |
  260|  66.8k|  {
  261|  66.8k|    long centerW=v->centerW;
  262|  66.8k|    long testW=
  263|  66.8k|      centerW+
  264|  66.8k|      ci->blocksizes[v->W]/4+
  265|  66.8k|      ci->blocksizes[1]/2+
  266|  66.8k|      ci->blocksizes[0]/4;
  267|       |
  268|  66.8k|    j=ve->cursor;
  269|       |
  270|   285k|    while(j<ve->current-(ve->searchstep)){/* account for postecho
  ------------------
  |  Branch (270:11): [True: 276k, False: 8.51k]
  ------------------
  271|       |                                             working back one window */
  272|   276k|      if(j>=testW)return(1);
  ------------------
  |  Branch (272:10): [True: 14.0k, False: 262k]
  ------------------
  273|       |
  274|   262k|      ve->cursor=j;
  275|       |
  276|   262k|      if(ve->mark[j/ve->searchstep]){
  ------------------
  |  Branch (276:10): [True: 102k, False: 160k]
  ------------------
  277|   102k|        if(j>centerW){
  ------------------
  |  Branch (277:12): [True: 44.2k, False: 58.2k]
  ------------------
  278|       |
  279|       |#if 0
  280|       |          if(j>ve->curmark){
  281|       |            float *marker=alloca(v->pcm_current*sizeof(*marker));
  282|       |            int l,m;
  283|       |            memset(marker,0,sizeof(*marker)*v->pcm_current);
  284|       |            fprintf(stderr,"mark! seq=%d, cursor:%fs time:%fs\n",
  285|       |                    seq,
  286|       |                    (totalshift+ve->cursor)/44100.,
  287|       |                    (totalshift+j)/44100.);
  288|       |            _analysis_output_always("pcmL",seq,v->pcm[0],v->pcm_current,0,0,totalshift);
  289|       |            _analysis_output_always("pcmR",seq,v->pcm[1],v->pcm_current,0,0,totalshift);
  290|       |
  291|       |            _analysis_output_always("markL",seq,v->pcm[0],j,0,0,totalshift);
  292|       |            _analysis_output_always("markR",seq,v->pcm[1],j,0,0,totalshift);
  293|       |
  294|       |            for(m=0;m<VE_BANDS;m++){
  295|       |              char buf[80];
  296|       |              sprintf(buf,"delL%d",m);
  297|       |              for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m].markers[l]*.1;
  298|       |              _analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift);
  299|       |            }
  300|       |
  301|       |            for(m=0;m<VE_BANDS;m++){
  302|       |              char buf[80];
  303|       |              sprintf(buf,"delR%d",m);
  304|       |              for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m+VE_BANDS].markers[l]*.1;
  305|       |              _analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift);
  306|       |            }
  307|       |
  308|       |            for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->mark[l]*.4;
  309|       |            _analysis_output_always("mark",seq,marker,v->pcm_current,0,0,totalshift);
  310|       |
  311|       |
  312|       |            seq++;
  313|       |
  314|       |          }
  315|       |#endif
  316|       |
  317|  44.2k|          ve->curmark=j;
  318|  44.2k|          if(j>=testW)return(1);
  ------------------
  |  Branch (318:14): [True: 0, False: 44.2k]
  ------------------
  319|  44.2k|          return(0);
  320|  44.2k|        }
  321|   102k|      }
  322|   218k|      j+=ve->searchstep;
  323|   218k|    }
  324|  66.8k|  }
  325|       |
  326|  8.51k|  return(-1);
  327|  66.8k|}
_ve_envelope_mark:
  329|  55.5k|int _ve_envelope_mark(vorbis_dsp_state *v){
  330|  55.5k|  envelope_lookup *ve=((private_state *)(v->backend_state))->ve;
  331|  55.5k|  vorbis_info *vi=v->vi;
  332|  55.5k|  codec_setup_info *ci=vi->codec_setup;
  333|  55.5k|  long centerW=v->centerW;
  334|  55.5k|  long beginW=centerW-ci->blocksizes[v->W]/4;
  335|  55.5k|  long endW=centerW+ci->blocksizes[v->W]/4;
  336|  55.5k|  if(v->W){
  ------------------
  |  Branch (336:6): [True: 0, False: 55.5k]
  ------------------
  337|      0|    beginW-=ci->blocksizes[v->lW]/4;
  338|      0|    endW+=ci->blocksizes[v->nW]/4;
  339|  55.5k|  }else{
  340|  55.5k|    beginW-=ci->blocksizes[0]/4;
  341|  55.5k|    endW+=ci->blocksizes[0]/4;
  342|  55.5k|  }
  343|       |
  344|  55.5k|  if(ve->curmark>=beginW && ve->curmark<endW)return(1);
  ------------------
  |  Branch (344:6): [True: 46.1k, False: 9.40k]
  |  Branch (344:29): [True: 28.7k, False: 17.3k]
  ------------------
  345|  26.7k|  {
  346|  26.7k|    long first=beginW/ve->searchstep;
  347|  26.7k|    long last=endW/ve->searchstep;
  348|  26.7k|    long i;
  349|   141k|    for(i=first;i<last;i++)
  ------------------
  |  Branch (349:17): [True: 122k, False: 18.9k]
  ------------------
  350|   122k|      if(ve->mark[i])return(1);
  ------------------
  |  Branch (350:10): [True: 7.75k, False: 114k]
  ------------------
  351|  26.7k|  }
  352|  18.9k|  return(0);
  353|  26.7k|}
_ve_envelope_shift:
  355|  55.8k|void _ve_envelope_shift(envelope_lookup *e,long shift){
  356|  55.8k|  int smallsize=e->current/e->searchstep+VE_POST; /* adjust for placing marks
  ------------------
  |  |   24|  55.8k|#define VE_POST   2
  ------------------
  357|       |                                                     ahead of ve->current */
  358|  55.8k|  int smallshift=shift/e->searchstep;
  359|       |
  360|  55.8k|  memmove(e->mark,e->mark+smallshift,(smallsize-smallshift)*sizeof(*e->mark));
  361|       |
  362|       |#if 0
  363|       |  for(i=0;i<VE_BANDS*e->ch;i++)
  364|       |    memmove(e->filter[i].markers,
  365|       |            e->filter[i].markers+smallshift,
  366|       |            (1024-smallshift)*sizeof(*(*e->filter).markers));
  367|       |  totalshift+=shift;
  368|       |#endif
  369|       |
  370|  55.8k|  e->current-=shift;
  371|  55.8k|  if(e->curmark>=0)
  ------------------
  |  Branch (371:6): [True: 45.3k, False: 10.5k]
  ------------------
  372|  45.3k|    e->curmark-=shift;
  373|  55.8k|  e->cursor-=shift;
  374|  55.8k|}
envelope.c:_ve_amp:
   93|   896k|                   envelope_filter_state *filters){
   94|   896k|  long n=ve->winlength;
   95|   896k|  int ret=0;
   96|   896k|  long i,j;
   97|   896k|  float decay;
   98|       |
   99|       |  /* we want to have a 'minimum bar' for energy, else we're just
  100|       |     basing blocks on quantization noise that outweighs the signal
  101|       |     itself (for low power signals) */
  102|       |
  103|   896k|  float minV=ve->minenergy;
  104|   896k|  float *vec=alloca(n*sizeof(*vec));
  105|       |
  106|       |  /* stretch is used to gradually lengthen the number of windows
  107|       |     considered prevoius-to-potential-trigger */
  108|   896k|  int stretch=max(VE_MINSTRETCH,ve->stretch/2);
  ------------------
  |  |   78|   896k|#  define max(x,y)  ((x)<(y)?(y):(x))
  |  |  ------------------
  |  |  |  Branch (78:22): [True: 691k, False: 205k]
  |  |  ------------------
  ------------------
  109|   896k|  float penalty=gi->stretch_penalty-(ve->stretch/2-VE_MINSTRETCH);
  ------------------
  |  |   30|   896k|#define VE_MINSTRETCH 2   /* a bit less than short block */
  ------------------
  110|   896k|  if(penalty<0.f)penalty=0.f;
  ------------------
  |  Branch (110:6): [True: 670k, False: 226k]
  ------------------
  111|   896k|  if(penalty>gi->stretch_penalty)penalty=gi->stretch_penalty;
  ------------------
  |  Branch (111:6): [True: 163k, False: 732k]
  ------------------
  112|       |
  113|       |  /*_analysis_output_always("lpcm",seq2,data,n,0,0,
  114|       |    totalshift+pos*ve->searchstep);*/
  115|       |
  116|       | /* window and transform */
  117|   115M|  for(i=0;i<n;i++)
  ------------------
  |  Branch (117:11): [True: 114M, False: 896k]
  ------------------
  118|   114M|    vec[i]=data[i]*ve->mdct_win[i];
  119|   896k|  mdct_forward(&ve->mdct,vec,vec);
  120|       |
  121|       |  /*_analysis_output_always("mdct",seq2,vec,n/2,0,1,0); */
  122|       |
  123|       |  /* near-DC spreading function; this has nothing to do with
  124|       |     psychoacoustics, just sidelobe leakage and window size */
  125|   896k|  {
  126|   896k|    float temp=vec[0]*vec[0]+.7*vec[1]*vec[1]+.2*vec[2]*vec[2];
  127|   896k|    int ptr=filters->nearptr;
  128|       |
  129|       |    /* the accumulation is regularly refreshed from scratch to avoid
  130|       |       floating point creep */
  131|   896k|    if(ptr==0){
  ------------------
  |  Branch (131:8): [True: 63.8k, False: 832k]
  ------------------
  132|  63.8k|      decay=filters->nearDC_acc=filters->nearDC_partialacc+temp;
  133|  63.8k|      filters->nearDC_partialacc=temp;
  134|   832k|    }else{
  135|   832k|      decay=filters->nearDC_acc+=temp;
  136|   832k|      filters->nearDC_partialacc+=temp;
  137|   832k|    }
  138|   896k|    filters->nearDC_acc-=filters->nearDC[ptr];
  139|   896k|    filters->nearDC[ptr]=temp;
  140|       |
  141|   896k|    decay*=(1./(VE_NEARDC+1));
  ------------------
  |  |   28|   896k|#define VE_NEARDC 15
  ------------------
  142|   896k|    filters->nearptr++;
  143|   896k|    if(filters->nearptr>=VE_NEARDC)filters->nearptr=0;
  ------------------
  |  |   28|   896k|#define VE_NEARDC 15
  ------------------
  |  Branch (143:8): [True: 57.1k, False: 839k]
  ------------------
  144|   896k|    decay=todB(&decay)*.5-15.f;
  145|   896k|  }
  146|       |
  147|       |  /* perform spreading and limiting, also smooth the spectrum.  yes,
  148|       |     the MDCT results in all real coefficients, but it still *behaves*
  149|       |     like real/imaginary pairs */
  150|  29.5M|  for(i=0;i<n/2;i+=2){
  ------------------
  |  Branch (150:11): [True: 28.6M, False: 896k]
  ------------------
  151|  28.6M|    float val=vec[i]*vec[i]+vec[i+1]*vec[i+1];
  152|  28.6M|    val=todB(&val)*.5f;
  153|  28.6M|    if(val<decay)val=decay;
  ------------------
  |  Branch (153:8): [True: 7.11M, False: 21.5M]
  ------------------
  154|  28.6M|    if(val<minV)val=minV;
  ------------------
  |  Branch (154:8): [True: 22.0M, False: 6.65M]
  ------------------
  155|  28.6M|    vec[i>>1]=val;
  156|  28.6M|    decay-=8.;
  157|  28.6M|  }
  158|       |
  159|       |  /*_analysis_output_always("spread",seq2++,vec,n/4,0,0,0);*/
  160|       |
  161|       |  /* perform preecho/postecho triggering by band */
  162|  7.17M|  for(j=0;j<VE_BANDS;j++){
  ------------------
  |  |   27|  7.17M|#define VE_BANDS  7
  ------------------
  |  Branch (162:11): [True: 6.27M, False: 896k]
  ------------------
  163|  6.27M|    float acc=0.;
  164|  6.27M|    float valmax,valmin;
  165|       |
  166|       |    /* accumulate amplitude */
  167|  48.4M|    for(i=0;i<bands[j].end;i++)
  ------------------
  |  Branch (167:13): [True: 42.1M, False: 6.27M]
  ------------------
  168|  42.1M|      acc+=vec[i+bands[j].begin]*bands[j].window[i];
  169|       |
  170|  6.27M|    acc*=bands[j].total;
  171|       |
  172|       |    /* convert amplitude to delta */
  173|  6.27M|    {
  174|  6.27M|      int p,this=filters[j].ampptr;
  175|  6.27M|      float postmax,postmin,premax=-99999.f,premin=99999.f;
  176|       |
  177|  6.27M|      p=this;
  178|  6.27M|      p--;
  179|  6.27M|      if(p<0)p+=VE_AMP;
  ------------------
  |  |   25|   398k|#define VE_AMP    (VE_PRE+VE_POST-1)
  |  |  ------------------
  |  |  |  |   22|   398k|#define VE_PRE    16
  |  |  ------------------
  |  |               #define VE_AMP    (VE_PRE+VE_POST-1)
  |  |  ------------------
  |  |  |  |   24|   398k|#define VE_POST   2
  |  |  ------------------
  ------------------
  |  Branch (179:10): [True: 398k, False: 5.87M]
  ------------------
  180|  6.27M|      postmax=max(acc,filters[j].ampbuf[p]);
  ------------------
  |  |   78|  6.27M|#  define max(x,y)  ((x)<(y)?(y):(x))
  |  |  ------------------
  |  |  |  Branch (78:22): [True: 901k, False: 5.37M]
  |  |  ------------------
  ------------------
  181|  6.27M|      postmin=min(acc,filters[j].ampbuf[p]);
  ------------------
  |  |   74|  6.27M|#  define min(x,y)  ((x)>(y)?(y):(x))
  |  |  ------------------
  |  |  |  Branch (74:22): [True: 751k, False: 5.52M]
  |  |  ------------------
  ------------------
  182|       |
  183|  58.5M|      for(i=0;i<stretch;i++){
  ------------------
  |  Branch (183:15): [True: 52.2M, False: 6.27M]
  ------------------
  184|  52.2M|        p--;
  185|  52.2M|        if(p<0)p+=VE_AMP;
  ------------------
  |  |   25|  3.01M|#define VE_AMP    (VE_PRE+VE_POST-1)
  |  |  ------------------
  |  |  |  |   22|  3.01M|#define VE_PRE    16
  |  |  ------------------
  |  |               #define VE_AMP    (VE_PRE+VE_POST-1)
  |  |  ------------------
  |  |  |  |   24|  3.01M|#define VE_POST   2
  |  |  ------------------
  ------------------
  |  Branch (185:12): [True: 3.01M, False: 49.2M]
  ------------------
  186|  52.2M|        premax=max(premax,filters[j].ampbuf[p]);
  ------------------
  |  |   78|  52.2M|#  define max(x,y)  ((x)<(y)?(y):(x))
  |  |  ------------------
  |  |  |  Branch (78:22): [True: 9.52M, False: 42.7M]
  |  |  ------------------
  ------------------
  187|  52.2M|        premin=min(premin,filters[j].ampbuf[p]);
  ------------------
  |  |   74|  52.2M|#  define min(x,y)  ((x)>(y)?(y):(x))
  |  |  ------------------
  |  |  |  Branch (74:22): [True: 7.84M, False: 44.4M]
  |  |  ------------------
  ------------------
  188|  52.2M|      }
  189|       |
  190|  6.27M|      valmin=postmin-premin;
  191|  6.27M|      valmax=postmax-premax;
  192|       |
  193|       |      /*filters[j].markers[pos]=valmax;*/
  194|  6.27M|      filters[j].ampbuf[this]=acc;
  195|  6.27M|      filters[j].ampptr++;
  196|  6.27M|      if(filters[j].ampptr>=VE_AMP)filters[j].ampptr=0;
  ------------------
  |  |   25|  6.27M|#define VE_AMP    (VE_PRE+VE_POST-1)
  |  |  ------------------
  |  |  |  |   22|  6.27M|#define VE_PRE    16
  |  |  ------------------
  |  |               #define VE_AMP    (VE_PRE+VE_POST-1)
  |  |  ------------------
  |  |  |  |   24|  6.27M|#define VE_POST   2
  |  |  ------------------
  ------------------
  |  Branch (196:10): [True: 351k, False: 5.92M]
  ------------------
  197|  6.27M|    }
  198|       |
  199|       |    /* look at min/max, decide trigger */
  200|  6.27M|    if(valmax>gi->preecho_thresh[j]+penalty){
  ------------------
  |  Branch (200:8): [True: 282k, False: 5.99M]
  ------------------
  201|   282k|      ret|=1;
  202|   282k|      ret|=4;
  203|   282k|    }
  204|  6.27M|    if(valmin<gi->postecho_thresh[j]-penalty)ret|=2;
  ------------------
  |  Branch (204:8): [True: 229k, False: 6.04M]
  ------------------
  205|  6.27M|  }
  206|       |
  207|   896k|  return(ret);
  208|   896k|}

floor1_fit:
  578|   103k|                          const float *logmask){
  579|   103k|  long i,j;
  580|   103k|  vorbis_info_floor1 *info=look->vi;
  581|   103k|  long n=look->n;
  582|   103k|  long posts=look->posts;
  583|   103k|  long nonzero=0;
  584|   103k|  lsfit_acc fits[VIF_POSIT+1];
  585|   103k|  int fit_valueA[VIF_POSIT+2]; /* index by range list position */
  586|   103k|  int fit_valueB[VIF_POSIT+2]; /* index by range list position */
  587|       |
  588|   103k|  int loneighbor[VIF_POSIT+2]; /* sorted index of range list position (+2) */
  589|   103k|  int hineighbor[VIF_POSIT+2];
  590|   103k|  int *output=NULL;
  591|   103k|  int memo[VIF_POSIT+2];
  592|       |
  593|  1.46M|  for(i=0;i<posts;i++)fit_valueA[i]=-200; /* mark all unused */
  ------------------
  |  Branch (593:11): [True: 1.36M, False: 103k]
  ------------------
  594|  1.46M|  for(i=0;i<posts;i++)fit_valueB[i]=-200; /* mark all unused */
  ------------------
  |  Branch (594:11): [True: 1.36M, False: 103k]
  ------------------
  595|  1.46M|  for(i=0;i<posts;i++)loneighbor[i]=0; /* 0 for the implicit 0 post */
  ------------------
  |  Branch (595:11): [True: 1.36M, False: 103k]
  ------------------
  596|  1.46M|  for(i=0;i<posts;i++)hineighbor[i]=1; /* 1 for the implicit post at n */
  ------------------
  |  Branch (596:11): [True: 1.36M, False: 103k]
  ------------------
  597|  1.46M|  for(i=0;i<posts;i++)memo[i]=-1;      /* no neighbor yet */
  ------------------
  |  Branch (597:11): [True: 1.36M, False: 103k]
  ------------------
  598|       |
  599|       |  /* quantize the relevant floor points and collect them into line fit
  600|       |     structures (one per minimal division) at the same time */
  601|   103k|  if(posts==0){
  ------------------
  |  Branch (601:6): [True: 0, False: 103k]
  ------------------
  602|      0|    nonzero+=accumulate_fit(logmask,logmdct,0,n,fits,n,info);
  603|   103k|  }else{
  604|  1.36M|    for(i=0;i<posts-1;i++)
  ------------------
  |  Branch (604:13): [True: 1.25M, False: 103k]
  ------------------
  605|  1.25M|      nonzero+=accumulate_fit(logmask,logmdct,look->sorted_index[i],
  606|  1.25M|                              look->sorted_index[i+1],fits+i,
  607|  1.25M|                              n,info);
  608|   103k|  }
  609|       |
  610|   103k|  if(nonzero){
  ------------------
  |  Branch (610:6): [True: 100k, False: 3.15k]
  ------------------
  611|       |    /* start by fitting the implicit base case.... */
  612|   100k|    int y0=-200;
  613|   100k|    int y1=-200;
  614|   100k|    fit_line(fits,posts-1,&y0,&y1,info);
  615|       |
  616|   100k|    fit_valueA[0]=y0;
  617|   100k|    fit_valueB[0]=y0;
  618|   100k|    fit_valueB[1]=y1;
  619|   100k|    fit_valueA[1]=y1;
  620|       |
  621|       |    /* Non degenerate case */
  622|       |    /* start progressive splitting.  This is a greedy, non-optimal
  623|       |       algorithm, but simple and close enough to the best
  624|       |       answer. */
  625|  1.21M|    for(i=2;i<posts;i++){
  ------------------
  |  Branch (625:13): [True: 1.11M, False: 100k]
  ------------------
  626|  1.11M|      int sortpos=look->reverse_index[i];
  627|  1.11M|      int ln=loneighbor[sortpos];
  628|  1.11M|      int hn=hineighbor[sortpos];
  629|       |
  630|       |      /* eliminate repeat searches of a particular range with a memo */
  631|  1.11M|      if(memo[ln]!=hn){
  ------------------
  |  Branch (631:10): [True: 864k, False: 249k]
  ------------------
  632|       |        /* haven't performed this error search yet */
  633|   864k|        int lsortpos=look->reverse_index[ln];
  634|   864k|        int hsortpos=look->reverse_index[hn];
  635|   864k|        memo[ln]=hn;
  636|       |
  637|   864k|        {
  638|       |          /* A note: we want to bound/minimize *local*, not global, error */
  639|   864k|          int lx=info->postlist[ln];
  640|   864k|          int hx=info->postlist[hn];
  641|   864k|          int ly=post_Y(fit_valueA,fit_valueB,ln);
  642|   864k|          int hy=post_Y(fit_valueA,fit_valueB,hn);
  643|       |
  644|   864k|          if(ly==-1 || hy==-1){
  ------------------
  |  Branch (644:14): [True: 0, False: 864k]
  |  Branch (644:24): [True: 0, False: 864k]
  ------------------
  645|      0|            exit(1);
  646|      0|          }
  647|       |
  648|   864k|          if(inspect_error(lx,hx,ly,hy,logmask,logmdct,info)){
  ------------------
  |  Branch (648:14): [True: 554k, False: 310k]
  ------------------
  649|       |            /* outside error bounds/begin search area.  Split it. */
  650|   554k|            int ly0=-200;
  651|   554k|            int ly1=-200;
  652|   554k|            int hy0=-200;
  653|   554k|            int hy1=-200;
  654|   554k|            int ret0=fit_line(fits+lsortpos,sortpos-lsortpos,&ly0,&ly1,info);
  655|   554k|            int ret1=fit_line(fits+sortpos,hsortpos-sortpos,&hy0,&hy1,info);
  656|       |
  657|   554k|            if(ret0){
  ------------------
  |  Branch (657:16): [True: 3.49k, False: 551k]
  ------------------
  658|  3.49k|              ly0=ly;
  659|  3.49k|              ly1=hy0;
  660|  3.49k|            }
  661|   554k|            if(ret1){
  ------------------
  |  Branch (661:16): [True: 977, False: 553k]
  ------------------
  662|    977|              hy0=ly1;
  663|    977|              hy1=hy;
  664|    977|            }
  665|       |
  666|   554k|            if(ret0 && ret1){
  ------------------
  |  Branch (666:16): [True: 3.49k, False: 551k]
  |  Branch (666:24): [True: 483, False: 3.01k]
  ------------------
  667|    483|              fit_valueA[i]=-200;
  668|    483|              fit_valueB[i]=-200;
  669|   554k|            }else{
  670|       |              /* store new edge values */
  671|   554k|              fit_valueB[ln]=ly0;
  672|   554k|              if(ln==0)fit_valueA[ln]=ly0;
  ------------------
  |  Branch (672:18): [True: 191k, False: 363k]
  ------------------
  673|   554k|              fit_valueA[i]=ly1;
  674|   554k|              fit_valueB[i]=hy0;
  675|   554k|              fit_valueA[hn]=hy1;
  676|   554k|              if(hn==1)fit_valueB[hn]=hy1;
  ------------------
  |  Branch (676:18): [True: 224k, False: 330k]
  ------------------
  677|       |
  678|   554k|              if(ly1>=0 || hy0>=0){
  ------------------
  |  Branch (678:18): [True: 554k, False: 0]
  |  Branch (678:28): [True: 0, False: 0]
  ------------------
  679|       |                /* store new neighbor values */
  680|  2.05M|                for(j=sortpos-1;j>=0;j--)
  ------------------
  |  Branch (680:33): [True: 1.86M, False: 191k]
  ------------------
  681|  1.86M|                  if(hineighbor[j]==hn)
  ------------------
  |  Branch (681:22): [True: 1.50M, False: 363k]
  ------------------
  682|  1.50M|                    hineighbor[j]=i;
  683|   363k|                  else
  684|   363k|                    break;
  685|  2.44M|                for(j=sortpos+1;j<posts;j++)
  ------------------
  |  Branch (685:33): [True: 2.21M, False: 224k]
  ------------------
  686|  2.21M|                  if(loneighbor[j]==ln)
  ------------------
  |  Branch (686:22): [True: 1.88M, False: 330k]
  ------------------
  687|  1.88M|                    loneighbor[j]=i;
  688|   330k|                  else
  689|   330k|                    break;
  690|   554k|              }
  691|   554k|            }
  692|   554k|          }else{
  693|   310k|            fit_valueA[i]=-200;
  694|   310k|            fit_valueB[i]=-200;
  695|   310k|          }
  696|   864k|        }
  697|   864k|      }
  698|  1.11M|    }
  699|       |
  700|   100k|    output=_vorbis_block_alloc(vb,sizeof(*output)*posts);
  701|       |
  702|   100k|    output[0]=post_Y(fit_valueA,fit_valueB,0);
  703|   100k|    output[1]=post_Y(fit_valueA,fit_valueB,1);
  704|       |
  705|       |    /* fill in posts marked as not using a fit; we will zero
  706|       |       back out to 'unused' when encoding them so long as curve
  707|       |       interpolation doesn't force them into use */
  708|  1.21M|    for(i=2;i<posts;i++){
  ------------------
  |  Branch (708:13): [True: 1.11M, False: 100k]
  ------------------
  709|  1.11M|      int ln=look->loneighbor[i-2];
  710|  1.11M|      int hn=look->hineighbor[i-2];
  711|  1.11M|      int x0=info->postlist[ln];
  712|  1.11M|      int x1=info->postlist[hn];
  713|  1.11M|      int y0=output[ln];
  714|  1.11M|      int y1=output[hn];
  715|       |
  716|  1.11M|      int predicted=render_point(x0,x1,y0,y1,info->postlist[i]);
  717|  1.11M|      int vx=post_Y(fit_valueA,fit_valueB,i);
  718|       |
  719|  1.11M|      if(vx>=0 && predicted!=vx){
  ------------------
  |  Branch (719:10): [True: 554k, False: 559k]
  |  Branch (719:19): [True: 550k, False: 3.58k]
  ------------------
  720|   550k|        output[i]=vx;
  721|   563k|      }else{
  722|   563k|        output[i]= predicted|0x8000;
  723|   563k|      }
  724|  1.11M|    }
  725|   100k|  }
  726|       |
  727|   103k|  return(output);
  728|       |
  729|   103k|}
floor1_encode:
  755|   103k|                  int *post,int *ilogmask){
  756|       |
  757|   103k|  long i,j;
  758|   103k|  vorbis_info_floor1 *info=look->vi;
  759|   103k|  long posts=look->posts;
  760|   103k|  codec_setup_info *ci=vb->vd->vi->codec_setup;
  761|   103k|  int out[VIF_POSIT+2];
  762|   103k|  static_codebook **sbooks=ci->book_param;
  763|   103k|  codebook *books=ci->fullbooks;
  764|       |
  765|       |  /* quantize values to multiplier spec */
  766|   103k|  if(post){
  ------------------
  |  Branch (766:6): [True: 100k, False: 3.15k]
  ------------------
  767|  1.41M|    for(i=0;i<posts;i++){
  ------------------
  |  Branch (767:13): [True: 1.31M, False: 100k]
  ------------------
  768|  1.31M|      int val=post[i]&0x7fff;
  769|  1.31M|      switch(info->mult){
  ------------------
  |  Branch (769:14): [True: 1.31M, False: 0]
  ------------------
  770|      0|      case 1: /* 1024 -> 256 */
  ------------------
  |  Branch (770:7): [True: 0, False: 1.31M]
  ------------------
  771|      0|        val>>=2;
  772|      0|        break;
  773|   979k|      case 2: /* 1024 -> 128 */
  ------------------
  |  Branch (773:7): [True: 979k, False: 336k]
  ------------------
  774|   979k|        val>>=3;
  775|   979k|        break;
  776|      0|      case 3: /* 1024 -> 86 */
  ------------------
  |  Branch (776:7): [True: 0, False: 1.31M]
  ------------------
  777|      0|        val/=12;
  778|      0|        break;
  779|   336k|      case 4: /* 1024 -> 64 */
  ------------------
  |  Branch (779:7): [True: 336k, False: 979k]
  ------------------
  780|   336k|        val>>=4;
  781|   336k|        break;
  782|  1.31M|      }
  783|  1.31M|      post[i]=val | (post[i]&0x8000);
  784|  1.31M|    }
  785|       |
  786|   100k|    out[0]=post[0];
  787|   100k|    out[1]=post[1];
  788|       |
  789|       |    /* find prediction values for each post and subtract them */
  790|  1.21M|    for(i=2;i<posts;i++){
  ------------------
  |  Branch (790:13): [True: 1.11M, False: 100k]
  ------------------
  791|  1.11M|      int ln=look->loneighbor[i-2];
  792|  1.11M|      int hn=look->hineighbor[i-2];
  793|  1.11M|      int x0=info->postlist[ln];
  794|  1.11M|      int x1=info->postlist[hn];
  795|  1.11M|      int y0=post[ln];
  796|  1.11M|      int y1=post[hn];
  797|       |
  798|  1.11M|      int predicted=render_point(x0,x1,y0,y1,info->postlist[i]);
  799|       |
  800|  1.11M|      if((post[i]&0x8000) || (predicted==post[i])){
  ------------------
  |  Branch (800:10): [True: 563k, False: 550k]
  |  Branch (800:30): [True: 25.6k, False: 525k]
  ------------------
  801|   589k|        post[i]=predicted|0x8000; /* in case there was roundoff jitter
  802|       |                                     in interpolation */
  803|   589k|        out[i]=0;
  804|   589k|      }else{
  805|   525k|        int headroom=(look->quant_q-predicted<predicted?
  ------------------
  |  Branch (805:23): [True: 401k, False: 123k]
  ------------------
  806|   401k|                      look->quant_q-predicted:predicted);
  807|       |
  808|   525k|        int val=post[i]-predicted;
  809|       |
  810|       |        /* at this point the 'deviation' value is in the range +/- max
  811|       |           range, but the real, unique range can always be mapped to
  812|       |           only [0-maxrange).  So we want to wrap the deviation into
  813|       |           this limited range, but do it in the way that least screws
  814|       |           an essentially gaussian probability distribution. */
  815|       |
  816|   525k|        if(val<0)
  ------------------
  |  Branch (816:12): [True: 362k, False: 162k]
  ------------------
  817|   362k|          if(val<-headroom)
  ------------------
  |  Branch (817:14): [True: 19.1k, False: 343k]
  ------------------
  818|  19.1k|            val=headroom-val-1;
  819|   343k|          else
  820|   343k|            val=-1-(val*2);
  821|   162k|        else
  822|   162k|          if(val>=headroom)
  ------------------
  |  Branch (822:14): [True: 1.04k, False: 161k]
  ------------------
  823|  1.04k|            val= val+headroom;
  824|   161k|          else
  825|   161k|            val<<=1;
  826|       |
  827|   525k|        out[i]=val;
  828|   525k|        post[ln]&=0x7fff;
  829|   525k|        post[hn]&=0x7fff;
  830|   525k|      }
  831|  1.11M|    }
  832|       |
  833|       |    /* we have everything we need. pack it out */
  834|       |    /* mark nontrivial floor */
  835|   100k|    oggpack_write(opb,1,1);
  836|       |
  837|       |    /* beginning/end post */
  838|   100k|    look->frames++;
  839|   100k|    look->postbits+=ov_ilog(look->quant_q-1)*2;
  840|   100k|    oggpack_write(opb,out[0],ov_ilog(look->quant_q-1));
  841|   100k|    oggpack_write(opb,out[1],ov_ilog(look->quant_q-1));
  842|       |
  843|       |
  844|       |    /* partition by partition */
  845|   466k|    for(i=0,j=2;i<info->partitions;i++){
  ------------------
  |  Branch (845:17): [True: 366k, False: 100k]
  ------------------
  846|   366k|      int class=info->partitionclass[i];
  847|   366k|      int cdim=info->class_dim[class];
  848|   366k|      int csubbits=info->class_subs[class];
  849|   366k|      int csub=1<<csubbits;
  850|   366k|      int bookas[8]={0,0,0,0,0,0,0,0};
  851|   366k|      int cval=0;
  852|   366k|      int cshift=0;
  853|   366k|      int k,l;
  854|       |
  855|       |      /* generate the partition's first stage cascade value */
  856|   366k|      if(csubbits){
  ------------------
  |  Branch (856:10): [True: 316k, False: 50.0k]
  ------------------
  857|   316k|        int maxval[8]={0,0,0,0,0,0,0,0}; /* gcc's static analysis
  858|       |                                            issues a warning without
  859|       |                                            initialization */
  860|  1.37M|        for(k=0;k<csub;k++){
  ------------------
  |  Branch (860:17): [True: 1.06M, False: 316k]
  ------------------
  861|  1.06M|          int booknum=info->class_subbook[class][k];
  862|  1.06M|          if(booknum<0){
  ------------------
  |  Branch (862:14): [True: 174k, False: 885k]
  ------------------
  863|   174k|            maxval[k]=1;
  864|   885k|          }else{
  865|   885k|            maxval[k]=sbooks[info->class_subbook[class][k]]->entries;
  866|   885k|          }
  867|  1.06M|        }
  868|  1.32M|        for(k=0;k<cdim;k++){
  ------------------
  |  Branch (868:17): [True: 1.01M, False: 316k]
  ------------------
  869|  1.40M|          for(l=0;l<csub;l++){
  ------------------
  |  Branch (869:19): [True: 1.40M, False: 0]
  ------------------
  870|  1.40M|            int val=out[j+k];
  871|  1.40M|            if(val<maxval[l]){
  ------------------
  |  Branch (871:16): [True: 1.01M, False: 396k]
  ------------------
  872|  1.01M|              bookas[k]=l;
  873|  1.01M|              break;
  874|  1.01M|            }
  875|  1.40M|          }
  876|  1.01M|          cval|= bookas[k]<<cshift;
  877|  1.01M|          cshift+=csubbits;
  878|  1.01M|        }
  879|       |        /* write it */
  880|   316k|        look->phrasebits+=
  881|   316k|          vorbis_book_encode(books+info->class_book[class],cval,opb);
  882|       |
  883|       |#ifdef TRAIN_FLOOR1
  884|       |        {
  885|       |          FILE *of;
  886|       |          char buffer[80];
  887|       |          sprintf(buffer,"line_%dx%ld_class%d.vqd",
  888|       |                  vb->pcmend/2,posts-2,class);
  889|       |          of=fopen(buffer,"a");
  890|       |          fprintf(of,"%d\n",cval);
  891|       |          fclose(of);
  892|       |        }
  893|       |#endif
  894|   316k|      }
  895|       |
  896|       |      /* write post values */
  897|  1.48M|      for(k=0;k<cdim;k++){
  ------------------
  |  Branch (897:15): [True: 1.11M, False: 366k]
  ------------------
  898|  1.11M|        int book=info->class_subbook[class][bookas[k]];
  899|  1.11M|        if(book>=0){
  ------------------
  |  Branch (899:12): [True: 703k, False: 410k]
  ------------------
  900|       |          /* hack to allow training with 'bad' books */
  901|   703k|          if(out[j+k]<(books+book)->entries)
  ------------------
  |  Branch (901:14): [True: 703k, False: 0]
  ------------------
  902|   703k|            look->postbits+=vorbis_book_encode(books+book,
  903|   703k|                                               out[j+k],opb);
  904|       |          /*else
  905|       |            fprintf(stderr,"+!");*/
  906|       |
  907|       |#ifdef TRAIN_FLOOR1
  908|       |          {
  909|       |            FILE *of;
  910|       |            char buffer[80];
  911|       |            sprintf(buffer,"line_%dx%ld_%dsub%d.vqd",
  912|       |                    vb->pcmend/2,posts-2,class,bookas[k]);
  913|       |            of=fopen(buffer,"a");
  914|       |            fprintf(of,"%d\n",out[j+k]);
  915|       |            fclose(of);
  916|       |          }
  917|       |#endif
  918|   703k|        }
  919|  1.11M|      }
  920|   366k|      j+=cdim;
  921|   366k|    }
  922|       |
  923|   100k|    {
  924|       |      /* generate quantized floor equivalent to what we'd unpack in decode */
  925|       |      /* render the lines */
  926|   100k|      int hx=0;
  927|   100k|      int lx=0;
  928|   100k|      int ly=post[0]*info->mult;
  929|   100k|      int n=ci->blocksizes[vb->W]/2;
  930|       |
  931|  1.31M|      for(j=1;j<look->posts;j++){
  ------------------
  |  Branch (931:15): [True: 1.21M, False: 100k]
  ------------------
  932|  1.21M|        int current=look->forward_index[j];
  933|  1.21M|        int hy=post[current]&0x7fff;
  934|  1.21M|        if(hy==post[current]){
  ------------------
  |  Branch (934:12): [True: 642k, False: 572k]
  ------------------
  935|       |
  936|   642k|          hy*=info->mult;
  937|   642k|          hx=info->postlist[current];
  938|       |
  939|   642k|          render_line0(n,lx,hx,ly,hy,ilogmask);
  940|       |
  941|   642k|          lx=hx;
  942|   642k|          ly=hy;
  943|   642k|        }
  944|  1.21M|      }
  945|   100k|      for(j=hx;j<vb->pcmend/2;j++)ilogmask[j]=ly; /* be certain */
  ------------------
  |  Branch (945:16): [True: 0, False: 100k]
  ------------------
  946|   100k|      return(1);
  947|   100k|    }
  948|   100k|  }else{
  949|  3.15k|    oggpack_write(opb,0,1);
  950|  3.15k|    memset(ilogmask,0,vb->pcmend/2*sizeof(*ilogmask));
  951|  3.15k|    return(0);
  952|  3.15k|  }
  953|   103k|}
floor1.c:accumulate_fit:
  408|  1.25M|                          int n,vorbis_info_floor1 *info){
  409|  1.25M|  long i;
  410|       |
  411|  1.25M|  int xa=0,ya=0,x2a=0,y2a=0,xya=0,na=0, xb=0,yb=0,x2b=0,y2b=0,xyb=0,nb=0;
  412|       |
  413|  1.25M|  memset(a,0,sizeof(*a));
  414|  1.25M|  a->x0=x0;
  415|  1.25M|  a->x1=x1;
  416|  1.25M|  if(x1>=n)x1=n-1;
  ------------------
  |  Branch (416:6): [True: 103k, False: 1.15M]
  ------------------
  417|       |
  418|  22.5M|  for(i=x0;i<=x1;i++){
  ------------------
  |  Branch (418:12): [True: 21.2M, False: 1.25M]
  ------------------
  419|  21.2M|    int quantized=vorbis_dBquant(flr+i);
  420|  21.2M|    if(quantized){
  ------------------
  |  Branch (420:8): [True: 21.1M, False: 178k]
  ------------------
  421|  21.1M|      if(mdct[i]+info->twofitatten>=flr[i]){
  ------------------
  |  Branch (421:10): [True: 13.6M, False: 7.43M]
  ------------------
  422|  13.6M|        xa  += i;
  423|  13.6M|        ya  += quantized;
  424|  13.6M|        x2a += i*i;
  425|  13.6M|        y2a += quantized*quantized;
  426|  13.6M|        xya += i*quantized;
  427|  13.6M|        na++;
  428|  13.6M|      }else{
  429|  7.43M|        xb  += i;
  430|  7.43M|        yb  += quantized;
  431|  7.43M|        x2b += i*i;
  432|  7.43M|        y2b += quantized*quantized;
  433|  7.43M|        xyb += i*quantized;
  434|  7.43M|        nb++;
  435|  7.43M|      }
  436|  21.1M|    }
  437|  21.2M|  }
  438|       |
  439|  1.25M|  a->xa=xa;
  440|  1.25M|  a->ya=ya;
  441|  1.25M|  a->x2a=x2a;
  442|  1.25M|  a->y2a=y2a;
  443|  1.25M|  a->xya=xya;
  444|  1.25M|  a->an=na;
  445|       |
  446|  1.25M|  a->xb=xb;
  447|  1.25M|  a->yb=yb;
  448|  1.25M|  a->x2b=x2b;
  449|  1.25M|  a->y2b=y2b;
  450|  1.25M|  a->xyb=xyb;
  451|  1.25M|  a->bn=nb;
  452|       |
  453|  1.25M|  return(na);
  454|  1.25M|}
floor1.c:vorbis_dBquant:
  273|  41.6M|static int vorbis_dBquant(const float *x){
  274|  41.6M|  int i= *x*7.3142857f+1023.5f;
  275|  41.6M|  if(i>1023)return(1023);
  ------------------
  |  Branch (275:6): [True: 740, False: 41.6M]
  ------------------
  276|  41.6M|  if(i<0)return(0);
  ------------------
  |  Branch (276:6): [True: 442k, False: 41.1M]
  ------------------
  277|  41.1M|  return i;
  278|  41.6M|}
floor1.c:fit_line:
  457|  1.21M|                    vorbis_info_floor1 *info){
  458|  1.21M|  double xb=0,yb=0,x2b=0,y2b=0,xyb=0,bn=0;
  459|  1.21M|  int i;
  460|  1.21M|  int x0=a[0].x0;
  461|  1.21M|  int x1=a[fits-1].x1;
  462|       |
  463|  5.81M|  for(i=0;i<fits;i++){
  ------------------
  |  Branch (463:11): [True: 4.60M, False: 1.21M]
  ------------------
  464|  4.60M|    double weight = (a[i].bn+a[i].an)*info->twofitweight/(a[i].an+1)+1.;
  465|       |
  466|  4.60M|    xb+=a[i].xb + a[i].xa * weight;
  467|  4.60M|    yb+=a[i].yb + a[i].ya * weight;
  468|  4.60M|    x2b+=a[i].x2b + a[i].x2a * weight;
  469|  4.60M|    y2b+=a[i].y2b + a[i].y2a * weight;
  470|  4.60M|    xyb+=a[i].xyb + a[i].xya * weight;
  471|  4.60M|    bn+=a[i].bn + a[i].an * weight;
  472|  4.60M|  }
  473|       |
  474|  1.21M|  if(*y0>=0){
  ------------------
  |  Branch (474:6): [True: 0, False: 1.21M]
  ------------------
  475|      0|    xb+=   x0;
  476|      0|    yb+=  *y0;
  477|      0|    x2b+=  x0 *  x0;
  478|      0|    y2b+= *y0 * *y0;
  479|      0|    xyb+= *y0 *  x0;
  480|      0|    bn++;
  481|      0|  }
  482|       |
  483|  1.21M|  if(*y1>=0){
  ------------------
  |  Branch (483:6): [True: 0, False: 1.21M]
  ------------------
  484|      0|    xb+=   x1;
  485|      0|    yb+=  *y1;
  486|      0|    x2b+=  x1 *  x1;
  487|      0|    y2b+= *y1 * *y1;
  488|      0|    xyb+= *y1 *  x1;
  489|      0|    bn++;
  490|      0|  }
  491|       |
  492|  1.21M|  {
  493|  1.21M|    double denom=(bn*x2b-xb*xb);
  494|       |
  495|  1.21M|    if(denom>0.){
  ------------------
  |  Branch (495:8): [True: 1.20M, False: 4.47k]
  ------------------
  496|  1.20M|      double a=(yb*x2b-xyb*xb)/denom;
  497|  1.20M|      double b=(bn*xyb-xb*yb)/denom;
  498|  1.20M|      *y0=rint(a+b*x0);
  499|  1.20M|      *y1=rint(a+b*x1);
  500|       |
  501|       |      /* limit to our range! */
  502|  1.20M|      if(*y0>1023)*y0=1023;
  ------------------
  |  Branch (502:10): [True: 215, False: 1.20M]
  ------------------
  503|  1.20M|      if(*y1>1023)*y1=1023;
  ------------------
  |  Branch (503:10): [True: 10.9k, False: 1.19M]
  ------------------
  504|  1.20M|      if(*y0<0)*y0=0;
  ------------------
  |  Branch (504:10): [True: 4.90k, False: 1.20M]
  ------------------
  505|  1.20M|      if(*y1<0)*y1=0;
  ------------------
  |  Branch (505:10): [True: 2.44k, False: 1.20M]
  ------------------
  506|       |
  507|  1.20M|      return 0;
  508|  1.20M|    }else{
  509|  4.47k|      *y0=0;
  510|  4.47k|      *y1=0;
  511|  4.47k|      return 1;
  512|  4.47k|    }
  513|  1.21M|  }
  514|  1.21M|}
floor1.c:post_Y:
  567|  3.04M|static int post_Y(int *A,int *B,int pos){
  568|  3.04M|  if(A[pos]<0)
  ------------------
  |  Branch (568:6): [True: 559k, False: 2.48M]
  ------------------
  569|   559k|    return B[pos];
  570|  2.48M|  if(B[pos]<0)
  ------------------
  |  Branch (570:6): [True: 0, False: 2.48M]
  ------------------
  571|      0|    return A[pos];
  572|       |
  573|  2.48M|  return (A[pos]+B[pos])>>1;
  574|  2.48M|}
floor1.c:inspect_error:
  518|   864k|                         vorbis_info_floor1 *info){
  519|   864k|  int dy=y1-y0;
  520|   864k|  int adx=x1-x0;
  521|   864k|  int ady=abs(dy);
  522|   864k|  int base=dy/adx;
  523|   864k|  int sy=(dy<0?base-1:base+1);
  ------------------
  |  Branch (523:11): [True: 407k, False: 457k]
  ------------------
  524|   864k|  int x=x0;
  525|   864k|  int y=y0;
  526|   864k|  int err=0;
  527|   864k|  int val=vorbis_dBquant(mask+x);
  528|   864k|  int mse=0;
  529|   864k|  int n=0;
  530|       |
  531|   864k|  ady-=abs(base*adx);
  532|       |
  533|   864k|  mse=(y-val);
  534|   864k|  mse*=mse;
  535|   864k|  n++;
  536|   864k|  if(mdct[x]+info->twofitatten>=mask[x]){
  ------------------
  |  Branch (536:6): [True: 810k, False: 54.1k]
  ------------------
  537|   810k|    if(y+info->maxover<val)return(1);
  ------------------
  |  Branch (537:8): [True: 115k, False: 695k]
  ------------------
  538|   695k|    if(y-info->maxunder>val)return(1);
  ------------------
  |  Branch (538:8): [True: 48.3k, False: 647k]
  ------------------
  539|   695k|  }
  540|       |
  541|  19.8M|  while(++x<x1){
  ------------------
  |  Branch (541:9): [True: 19.4M, False: 345k]
  ------------------
  542|  19.4M|    err=err+ady;
  543|  19.4M|    if(err>=adx){
  ------------------
  |  Branch (543:8): [True: 5.78M, False: 13.6M]
  ------------------
  544|  5.78M|      err-=adx;
  545|  5.78M|      y+=sy;
  546|  13.6M|    }else{
  547|  13.6M|      y+=base;
  548|  13.6M|    }
  549|       |
  550|  19.4M|    val=vorbis_dBquant(mask+x);
  551|  19.4M|    mse+=((y-val)*(y-val));
  552|  19.4M|    n++;
  553|  19.4M|    if(mdct[x]+info->twofitatten>=mask[x]){
  ------------------
  |  Branch (553:8): [True: 13.0M, False: 6.37M]
  ------------------
  554|  13.0M|      if(val){
  ------------------
  |  Branch (554:10): [True: 12.8M, False: 234k]
  ------------------
  555|  12.8M|        if(y+info->maxover<val)return(1);
  ------------------
  |  Branch (555:12): [True: 43.3k, False: 12.8M]
  ------------------
  556|  12.8M|        if(y-info->maxunder>val)return(1);
  ------------------
  |  Branch (556:12): [True: 311k, False: 12.5M]
  ------------------
  557|  12.8M|      }
  558|  13.0M|    }
  559|  19.4M|  }
  560|       |
  561|   345k|  if(info->maxover*info->maxover/n>info->maxerr)return(0);
  ------------------
  |  Branch (561:6): [True: 122k, False: 223k]
  ------------------
  562|   223k|  if(info->maxunder*info->maxunder/n>info->maxerr)return(0);
  ------------------
  |  Branch (562:6): [True: 0, False: 223k]
  ------------------
  563|   223k|  if(mse/n>info->maxerr)return(1);
  ------------------
  |  Branch (563:6): [True: 35.9k, False: 187k]
  ------------------
  564|   187k|  return(0);
  565|   223k|}
floor1.c:render_point:
  257|  2.22M|static int render_point(int x0,int x1,int y0,int y1,int x){
  258|  2.22M|  y0&=0x7fff; /* mask off flag */
  259|  2.22M|  y1&=0x7fff;
  260|       |
  261|  2.22M|  {
  262|  2.22M|    int dy=y1-y0;
  263|  2.22M|    int adx=x1-x0;
  264|  2.22M|    int ady=abs(dy);
  265|  2.22M|    int err=ady*(x-x0);
  266|       |
  267|  2.22M|    int off=err/adx;
  268|  2.22M|    if(dy<0)return(y0-off);
  ------------------
  |  Branch (268:8): [True: 1.04M, False: 1.18M]
  ------------------
  269|  1.18M|    return(y0+off);
  270|  2.22M|  }
  271|  2.22M|}
floor1.c:render_line0:
  376|   642k|static void render_line0(int n, int x0,int x1,int y0,int y1,int *d){
  377|   642k|  int dy=y1-y0;
  378|   642k|  int adx=x1-x0;
  379|   642k|  int ady=abs(dy);
  380|   642k|  int base=dy/adx;
  381|   642k|  int sy=(dy<0?base-1:base+1);
  ------------------
  |  Branch (381:11): [True: 332k, False: 309k]
  ------------------
  382|   642k|  int x=x0;
  383|   642k|  int y=y0;
  384|   642k|  int err=0;
  385|       |
  386|   642k|  ady-=abs(base*adx);
  387|       |
  388|   642k|  if(n>x1)n=x1;
  ------------------
  |  Branch (388:6): [True: 541k, False: 100k]
  ------------------
  389|       |
  390|   642k|  if(x<n)
  ------------------
  |  Branch (390:6): [True: 642k, False: 0]
  ------------------
  391|   642k|    d[x]=y;
  392|       |
  393|  19.2M|  while(++x<n){
  ------------------
  |  Branch (393:9): [True: 18.6M, False: 642k]
  ------------------
  394|  18.6M|    err=err+ady;
  395|  18.6M|    if(err>=adx){
  ------------------
  |  Branch (395:8): [True: 3.15M, False: 15.4M]
  ------------------
  396|  3.15M|      err-=adx;
  397|  3.15M|      y+=sy;
  398|  15.4M|    }else{
  399|  15.4M|      y+=base;
  400|  15.4M|    }
  401|  18.6M|    d[x]=y;
  402|  18.6M|  }
  403|   642k|}
floor1.c:floor1_pack:
   74|  4.26k|static void floor1_pack (vorbis_info_floor *i,oggpack_buffer *opb){
   75|  4.26k|  vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
   76|  4.26k|  int j,k;
   77|  4.26k|  int count=0;
   78|  4.26k|  int rangebits;
   79|  4.26k|  int maxposit=info->postlist[1];
   80|  4.26k|  int maxclass=-1;
   81|       |
   82|       |  /* save out partitions */
   83|  4.26k|  oggpack_write(opb,info->partitions,5); /* only 0 to 31 legal */
   84|  27.1k|  for(j=0;j<info->partitions;j++){
  ------------------
  |  Branch (84:11): [True: 22.9k, False: 4.26k]
  ------------------
   85|  22.9k|    oggpack_write(opb,info->partitionclass[j],4); /* only 0 to 15 legal */
   86|  22.9k|    if(maxclass<info->partitionclass[j])maxclass=info->partitionclass[j];
  ------------------
  |  Branch (86:8): [True: 15.3k, False: 7.51k]
  ------------------
   87|  22.9k|  }
   88|       |
   89|       |  /* save out partition classes */
   90|  19.6k|  for(j=0;j<maxclass+1;j++){
  ------------------
  |  Branch (90:11): [True: 15.3k, False: 4.26k]
  ------------------
   91|  15.3k|    oggpack_write(opb,info->class_dim[j]-1,3); /* 1 to 8 */
   92|  15.3k|    oggpack_write(opb,info->class_subs[j],2); /* 0 to 3 */
   93|  15.3k|    if(info->class_subs[j])oggpack_write(opb,info->class_book[j],8);
  ------------------
  |  Branch (93:8): [True: 12.3k, False: 3.02k]
  ------------------
   94|  58.6k|    for(k=0;k<(1<<info->class_subs[j]);k++)
  ------------------
  |  Branch (94:13): [True: 43.2k, False: 15.3k]
  ------------------
   95|  43.2k|      oggpack_write(opb,info->class_subbook[j][k]+1,8);
   96|  15.3k|  }
   97|       |
   98|       |  /* save out the post list */
   99|  4.26k|  oggpack_write(opb,info->mult-1,2);     /* only 1,2,3,4 legal now */
  100|       |  /* maxposit cannot legally be less than 1; this is encode-side, we
  101|       |     can assume our setup is OK */
  102|  4.26k|  oggpack_write(opb,ov_ilog(maxposit-1),4);
  103|  4.26k|  rangebits=ov_ilog(maxposit-1);
  104|       |
  105|  27.1k|  for(j=0,k=0;j<info->partitions;j++){
  ------------------
  |  Branch (105:15): [True: 22.9k, False: 4.26k]
  ------------------
  106|  22.9k|    count+=info->class_dim[info->partitionclass[j]];
  107|  96.2k|    for(;k<count;k++)
  ------------------
  |  Branch (107:10): [True: 73.3k, False: 22.9k]
  ------------------
  108|  73.3k|      oggpack_write(opb,info->postlist[k+2],rangebits);
  109|  22.9k|  }
  110|  4.26k|}
floor1.c:icomp:
  112|   262k|static int icomp(const void *a,const void *b){
  113|   262k|  return(**(int **)a-**(int **)b);
  114|   262k|}
floor1.c:floor1_look:
  181|  4.26k|                                      vorbis_info_floor *in){
  182|       |
  183|  4.26k|  int *sortpointer[VIF_POSIT+2];
  184|  4.26k|  vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
  185|  4.26k|  vorbis_look_floor1 *look=_ogg_calloc(1,sizeof(*look));
  ------------------
  |  |   22|  4.26k|#define _ogg_calloc  calloc
  ------------------
  186|  4.26k|  int i,j,n=0;
  187|       |
  188|  4.26k|  (void)vd;
  189|       |
  190|  4.26k|  look->vi=info;
  191|  4.26k|  look->n=info->postlist[1];
  192|       |
  193|       |  /* we drop each position value in-between already decoded values,
  194|       |     and use linear interpolation to predict each new value past the
  195|       |     edges.  The positions are read in the order of the position
  196|       |     list... we precompute the bounding positions in the lookup.  Of
  197|       |     course, the neighbors can change (if a position is declined), but
  198|       |     this is an initial mapping */
  199|       |
  200|  27.1k|  for(i=0;i<info->partitions;i++)n+=info->class_dim[info->partitionclass[i]];
  ------------------
  |  Branch (200:11): [True: 22.9k, False: 4.26k]
  ------------------
  201|  4.26k|  n+=2;
  202|  4.26k|  look->posts=n;
  203|       |
  204|       |  /* also store a sorted position index */
  205|  86.1k|  for(i=0;i<n;i++)sortpointer[i]=info->postlist+i;
  ------------------
  |  Branch (205:11): [True: 81.8k, False: 4.26k]
  ------------------
  206|  4.26k|  qsort(sortpointer,n,sizeof(*sortpointer),icomp);
  207|       |
  208|       |  /* points from sort order back to range number */
  209|  86.1k|  for(i=0;i<n;i++)look->forward_index[i]=sortpointer[i]-info->postlist;
  ------------------
  |  Branch (209:11): [True: 81.8k, False: 4.26k]
  ------------------
  210|       |  /* points from range order to sorted position */
  211|  86.1k|  for(i=0;i<n;i++)look->reverse_index[look->forward_index[i]]=i;
  ------------------
  |  Branch (211:11): [True: 81.8k, False: 4.26k]
  ------------------
  212|       |  /* we actually need the post values too */
  213|  86.1k|  for(i=0;i<n;i++)look->sorted_index[i]=info->postlist[look->forward_index[i]];
  ------------------
  |  Branch (213:11): [True: 81.8k, False: 4.26k]
  ------------------
  214|       |
  215|       |  /* quantize values to multiplier spec */
  216|  4.26k|  switch(info->mult){
  ------------------
  |  Branch (216:10): [True: 4.26k, False: 0]
  ------------------
  217|      0|  case 1: /* 1024 -> 256 */
  ------------------
  |  Branch (217:3): [True: 0, False: 4.26k]
  ------------------
  218|      0|    look->quant_q=256;
  219|      0|    break;
  220|  3.02k|  case 2: /* 1024 -> 128 */
  ------------------
  |  Branch (220:3): [True: 3.02k, False: 1.23k]
  ------------------
  221|  3.02k|    look->quant_q=128;
  222|  3.02k|    break;
  223|      0|  case 3: /* 1024 -> 86 */
  ------------------
  |  Branch (223:3): [True: 0, False: 4.26k]
  ------------------
  224|      0|    look->quant_q=86;
  225|      0|    break;
  226|  1.23k|  case 4: /* 1024 -> 64 */
  ------------------
  |  Branch (226:3): [True: 1.23k, False: 3.02k]
  ------------------
  227|  1.23k|    look->quant_q=64;
  228|  1.23k|    break;
  229|  4.26k|  }
  230|       |
  231|       |  /* discover our neighbors for decode where we don't use fit flags
  232|       |     (that would push the neighbors outward) */
  233|  77.6k|  for(i=0;i<n-2;i++){
  ------------------
  |  Branch (233:11): [True: 73.3k, False: 4.26k]
  ------------------
  234|  73.3k|    int lo=0;
  235|  73.3k|    int hi=1;
  236|  73.3k|    int lx=0;
  237|  73.3k|    int hx=look->n;
  238|  73.3k|    int currentx=info->postlist[i+2];
  239|   985k|    for(j=0;j<i+2;j++){
  ------------------
  |  Branch (239:13): [True: 912k, False: 73.3k]
  ------------------
  240|   912k|      int x=info->postlist[j];
  241|   912k|      if(x>lx && x<currentx){
  ------------------
  |  Branch (241:10): [True: 436k, False: 475k]
  |  Branch (241:18): [True: 108k, False: 328k]
  ------------------
  242|   108k|        lo=j;
  243|   108k|        lx=x;
  244|   108k|      }
  245|   912k|      if(x<hx && x>currentx){
  ------------------
  |  Branch (245:10): [True: 678k, False: 234k]
  |  Branch (245:18): [True: 94.6k, False: 583k]
  ------------------
  246|  94.6k|        hi=j;
  247|  94.6k|        hx=x;
  248|  94.6k|      }
  249|   912k|    }
  250|  73.3k|    look->loneighbor[i]=lo;
  251|  73.3k|    look->hineighbor[i]=hi;
  252|  73.3k|  }
  253|       |
  254|  4.26k|  return(look);
  255|  4.26k|}
floor1.c:floor1_free_info:
   53|  4.26k|static void floor1_free_info(vorbis_info_floor *i){
   54|  4.26k|  vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
   55|  4.26k|  if(info){
  ------------------
  |  Branch (55:6): [True: 4.26k, False: 0]
  ------------------
   56|  4.26k|    memset(info,0,sizeof(*info));
   57|  4.26k|    _ogg_free(info);
  ------------------
  |  |   24|  4.26k|#define _ogg_free    free
  ------------------
   58|  4.26k|  }
   59|  4.26k|}
floor1.c:floor1_free_look:
   61|  4.26k|static void floor1_free_look(vorbis_look_floor *i){
   62|  4.26k|  vorbis_look_floor1 *look=(vorbis_look_floor1 *)i;
   63|  4.26k|  if(look){
  ------------------
  |  Branch (63:6): [True: 4.26k, False: 0]
  ------------------
   64|       |    /*fprintf(stderr,"floor 1 bit usage %f:%f (%f total)\n",
   65|       |            (float)look->phrasebits/look->frames,
   66|       |            (float)look->postbits/look->frames,
   67|       |            (float)(look->postbits+look->phrasebits)/look->frames);*/
   68|       |
   69|  4.26k|    memset(look,0,sizeof(*look));
   70|  4.26k|    _ogg_free(look);
  ------------------
  |  |   24|  4.26k|#define _ogg_free    free
  ------------------
   71|  4.26k|  }
   72|  4.26k|}

vorbis_comment_init:
   53|  2.27k|void vorbis_comment_init(vorbis_comment *vc){
   54|  2.27k|  memset(vc,0,sizeof(*vc));
   55|  2.27k|}
vorbis_comment_add:
   57|  2.27k|void vorbis_comment_add(vorbis_comment *vc,const char *comment){
   58|  2.27k|  vc->user_comments=_ogg_realloc(vc->user_comments,
  ------------------
  |  |   23|  2.27k|#define _ogg_realloc realloc
  ------------------
   59|  2.27k|                            (vc->comments+2)*sizeof(*vc->user_comments));
   60|  2.27k|  vc->comment_lengths=_ogg_realloc(vc->comment_lengths,
  ------------------
  |  |   23|  2.27k|#define _ogg_realloc realloc
  ------------------
   61|  2.27k|                                  (vc->comments+2)*sizeof(*vc->comment_lengths));
   62|  2.27k|  vc->comment_lengths[vc->comments]=strlen(comment);
   63|  2.27k|  vc->user_comments[vc->comments]=_ogg_malloc(vc->comment_lengths[vc->comments]+1);
  ------------------
  |  |   21|  2.27k|#define _ogg_malloc  malloc
  ------------------
   64|  2.27k|  strcpy(vc->user_comments[vc->comments], comment);
   65|  2.27k|  vc->comments++;
   66|       |  vc->user_comments[vc->comments]=NULL;
   67|  2.27k|}
vorbis_comment_add_tag:
   69|  2.27k|void vorbis_comment_add_tag(vorbis_comment *vc, const char *tag, const char *contents){
   70|       |  /* Length for key and value +2 for = and \0 */
   71|  2.27k|  char *comment=_ogg_malloc(strlen(tag)+strlen(contents)+2);
  ------------------
  |  |   21|  2.27k|#define _ogg_malloc  malloc
  ------------------
   72|  2.27k|  strcpy(comment, tag);
   73|  2.27k|  strcat(comment, "=");
   74|  2.27k|  strcat(comment, contents);
   75|  2.27k|  vorbis_comment_add(vc, comment);
   76|  2.27k|  _ogg_free(comment);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
   77|  2.27k|}
vorbis_comment_clear:
  131|  2.27k|void vorbis_comment_clear(vorbis_comment *vc){
  132|  2.27k|  if(vc){
  ------------------
  |  Branch (132:6): [True: 2.27k, False: 0]
  ------------------
  133|  2.27k|    long i;
  134|  2.27k|    if(vc->user_comments){
  ------------------
  |  Branch (134:8): [True: 2.27k, False: 0]
  ------------------
  135|  4.54k|      for(i=0;i<vc->comments;i++)
  ------------------
  |  Branch (135:15): [True: 2.27k, False: 2.27k]
  ------------------
  136|  2.27k|        if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  |  Branch (136:12): [True: 2.27k, False: 0]
  ------------------
  137|  2.27k|      _ogg_free(vc->user_comments);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  138|  2.27k|    }
  139|  2.27k|    if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  |  Branch (139:8): [True: 2.27k, False: 0]
  ------------------
  140|  2.27k|    if(vc->vendor)_ogg_free(vc->vendor);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (140:8): [True: 0, False: 2.27k]
  ------------------
  141|  2.27k|    memset(vc,0,sizeof(*vc));
  142|  2.27k|  }
  143|  2.27k|}
vorbis_info_init:
  153|  2.27k|void vorbis_info_init(vorbis_info *vi){
  154|  2.27k|  memset(vi,0,sizeof(*vi));
  155|  2.27k|  vi->codec_setup=_ogg_calloc(1,sizeof(codec_setup_info));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
  156|  2.27k|}
vorbis_info_clear:
  158|  2.27k|void vorbis_info_clear(vorbis_info *vi){
  159|  2.27k|  codec_setup_info     *ci=vi->codec_setup;
  160|  2.27k|  int i;
  161|       |
  162|  2.27k|  if(ci){
  ------------------
  |  Branch (162:6): [True: 2.27k, False: 0]
  ------------------
  163|       |
  164|  6.41k|    for(i=0;i<ci->modes;i++)
  ------------------
  |  Branch (164:13): [True: 4.14k, False: 2.27k]
  ------------------
  165|  4.14k|      if(ci->mode_param[i])_ogg_free(ci->mode_param[i]);
  ------------------
  |  |   24|  4.14k|#define _ogg_free    free
  ------------------
  |  Branch (165:10): [True: 4.14k, False: 0]
  ------------------
  166|       |
  167|  6.41k|    for(i=0;i<ci->maps;i++) /* unpack does the range checking */
  ------------------
  |  Branch (167:13): [True: 4.14k, False: 2.27k]
  ------------------
  168|  4.14k|      if(ci->map_param[i]) /* this may be cleaning up an aborted
  ------------------
  |  Branch (168:10): [True: 4.14k, False: 0]
  ------------------
  169|       |                              unpack, in which case the below type
  170|       |                              cannot be trusted */
  171|  4.14k|        _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
  172|       |
  173|  6.53k|    for(i=0;i<ci->floors;i++) /* unpack does the range checking */
  ------------------
  |  Branch (173:13): [True: 4.26k, False: 2.27k]
  ------------------
  174|  4.26k|      if(ci->floor_param[i]) /* this may be cleaning up an aborted
  ------------------
  |  Branch (174:10): [True: 4.26k, False: 0]
  ------------------
  175|       |                                unpack, in which case the below type
  176|       |                                cannot be trusted */
  177|  4.26k|        _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
  178|       |
  179|  6.41k|    for(i=0;i<ci->residues;i++) /* unpack does the range checking */
  ------------------
  |  Branch (179:13): [True: 4.14k, False: 2.27k]
  ------------------
  180|  4.14k|      if(ci->residue_param[i]) /* this may be cleaning up an aborted
  ------------------
  |  Branch (180:10): [True: 4.14k, False: 0]
  ------------------
  181|       |                                  unpack, in which case the below type
  182|       |                                  cannot be trusted */
  183|  4.14k|        _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
  184|       |
  185|  83.8k|    for(i=0;i<ci->books;i++){
  ------------------
  |  Branch (185:13): [True: 81.5k, False: 2.27k]
  ------------------
  186|  81.5k|      if(ci->book_param[i]){
  ------------------
  |  Branch (186:10): [True: 81.5k, False: 0]
  ------------------
  187|       |        /* knows if the book was not alloced */
  188|  81.5k|        vorbis_staticbook_destroy(ci->book_param[i]);
  189|  81.5k|      }
  190|  81.5k|      if(ci->fullbooks)
  ------------------
  |  Branch (190:10): [True: 81.5k, False: 0]
  ------------------
  191|  81.5k|        vorbis_book_clear(ci->fullbooks+i);
  192|  81.5k|    }
  193|  2.27k|    if(ci->fullbooks)
  ------------------
  |  Branch (193:8): [True: 2.27k, False: 0]
  ------------------
  194|  2.27k|        _ogg_free(ci->fullbooks);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  195|       |
  196|  10.5k|    for(i=0;i<ci->psys;i++)
  ------------------
  |  Branch (196:13): [True: 8.29k, False: 2.27k]
  ------------------
  197|  8.29k|      _vi_psy_free(ci->psy_param[i]);
  198|       |
  199|  2.27k|    _ogg_free(ci);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
  200|  2.27k|  }
  201|       |
  202|  2.27k|  memset(vi,0,sizeof(*vi));
  203|  2.27k|}
vorbis_analysis_headerout:
  593|  2.27k|                              ogg_packet *op_code){
  594|  2.27k|  int ret=OV_EIMPL;
  ------------------
  |  |  227|  2.27k|#define OV_EIMPL      -130
  ------------------
  595|  2.27k|  vorbis_info *vi=v->vi;
  596|  2.27k|  oggpack_buffer opb;
  597|  2.27k|  private_state *b=v->backend_state;
  598|       |
  599|  2.27k|  if(!b||vi->channels<=0||vi->channels>256){
  ------------------
  |  Branch (599:6): [True: 0, False: 2.27k]
  |  Branch (599:10): [True: 0, False: 2.27k]
  |  Branch (599:27): [True: 0, False: 2.27k]
  ------------------
  600|      0|    b = NULL;
  601|      0|    ret=OV_EFAULT;
  ------------------
  |  |  226|      0|#define OV_EFAULT     -129
  ------------------
  602|      0|    goto err_out;
  603|      0|  }
  604|       |
  605|       |  /* first header packet **********************************************/
  606|       |
  607|  2.27k|  oggpack_writeinit(&opb);
  608|  2.27k|  if(_vorbis_pack_info(&opb,vi))goto err_out;
  ------------------
  |  Branch (608:6): [True: 0, False: 2.27k]
  ------------------
  609|       |
  610|       |  /* build the packet */
  611|  2.27k|  if(b->header)_ogg_free(b->header);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (611:6): [True: 0, False: 2.27k]
  ------------------
  612|  2.27k|  b->header=_ogg_malloc(oggpack_bytes(&opb));
  ------------------
  |  |   21|  2.27k|#define _ogg_malloc  malloc
  ------------------
  613|  2.27k|  memcpy(b->header,opb.buffer,oggpack_bytes(&opb));
  614|  2.27k|  op->packet=b->header;
  615|  2.27k|  op->bytes=oggpack_bytes(&opb);
  616|  2.27k|  op->b_o_s=1;
  617|  2.27k|  op->e_o_s=0;
  618|  2.27k|  op->granulepos=0;
  619|  2.27k|  op->packetno=0;
  620|       |
  621|       |  /* second header packet (comments) **********************************/
  622|       |
  623|  2.27k|  oggpack_reset(&opb);
  624|  2.27k|  if(_vorbis_pack_comment(&opb,vc))goto err_out;
  ------------------
  |  Branch (624:6): [True: 0, False: 2.27k]
  ------------------
  625|       |
  626|  2.27k|  if(b->header1)_ogg_free(b->header1);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (626:6): [True: 0, False: 2.27k]
  ------------------
  627|  2.27k|  b->header1=_ogg_malloc(oggpack_bytes(&opb));
  ------------------
  |  |   21|  2.27k|#define _ogg_malloc  malloc
  ------------------
  628|  2.27k|  memcpy(b->header1,opb.buffer,oggpack_bytes(&opb));
  629|  2.27k|  op_comm->packet=b->header1;
  630|  2.27k|  op_comm->bytes=oggpack_bytes(&opb);
  631|  2.27k|  op_comm->b_o_s=0;
  632|  2.27k|  op_comm->e_o_s=0;
  633|  2.27k|  op_comm->granulepos=0;
  634|  2.27k|  op_comm->packetno=1;
  635|       |
  636|       |  /* third header packet (modes/codebooks) ****************************/
  637|       |
  638|  2.27k|  oggpack_reset(&opb);
  639|  2.27k|  if(_vorbis_pack_books(&opb,vi))goto err_out;
  ------------------
  |  Branch (639:6): [True: 0, False: 2.27k]
  ------------------
  640|       |
  641|  2.27k|  if(b->header2)_ogg_free(b->header2);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (641:6): [True: 0, False: 2.27k]
  ------------------
  642|  2.27k|  b->header2=_ogg_malloc(oggpack_bytes(&opb));
  ------------------
  |  |   21|  2.27k|#define _ogg_malloc  malloc
  ------------------
  643|  2.27k|  memcpy(b->header2,opb.buffer,oggpack_bytes(&opb));
  644|  2.27k|  op_code->packet=b->header2;
  645|  2.27k|  op_code->bytes=oggpack_bytes(&opb);
  646|  2.27k|  op_code->b_o_s=0;
  647|  2.27k|  op_code->e_o_s=0;
  648|  2.27k|  op_code->granulepos=0;
  649|  2.27k|  op_code->packetno=2;
  650|       |
  651|  2.27k|  oggpack_writeclear(&opb);
  652|  2.27k|  return(0);
  653|      0| err_out:
  654|      0|  memset(op,0,sizeof(*op));
  655|      0|  memset(op_comm,0,sizeof(*op_comm));
  656|      0|  memset(op_code,0,sizeof(*op_code));
  657|       |
  658|      0|  if(b){
  ------------------
  |  Branch (658:6): [True: 0, False: 0]
  ------------------
  659|      0|    if(vi->channels>0)oggpack_writeclear(&opb);
  ------------------
  |  Branch (659:8): [True: 0, False: 0]
  ------------------
  660|      0|    if(b->header)_ogg_free(b->header);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (660:8): [True: 0, False: 0]
  ------------------
  661|      0|    if(b->header1)_ogg_free(b->header1);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (661:8): [True: 0, False: 0]
  ------------------
  662|      0|    if(b->header2)_ogg_free(b->header2);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (662:8): [True: 0, False: 0]
  ------------------
  663|      0|    b->header=NULL;
  664|      0|    b->header1=NULL;
  665|       |    b->header2=NULL;
  666|      0|  }
  667|      0|  return(ret);
  668|  2.27k|}
info.c:_vorbis_pack_comment:
  479|  2.27k|static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
  480|  2.27k|  int bytes = strlen(ENCODE_VENDOR_STRING);
  ------------------
  |  |   33|  2.27k|#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20200704 (Reducing Environment)"
  ------------------
  481|       |
  482|       |  /* preamble */
  483|  2.27k|  oggpack_write(opb,0x03,8);
  484|  2.27k|  _v_writestring(opb,"vorbis", 6);
  485|       |
  486|       |  /* vendor */
  487|  2.27k|  oggpack_write(opb,bytes,32);
  488|  2.27k|  _v_writestring(opb,ENCODE_VENDOR_STRING, bytes);
  ------------------
  |  |   33|  2.27k|#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20200704 (Reducing Environment)"
  ------------------
  489|       |
  490|       |  /* comments */
  491|       |
  492|  2.27k|  oggpack_write(opb,vc->comments,32);
  493|  2.27k|  if(vc->comments){
  ------------------
  |  Branch (493:6): [True: 2.27k, False: 0]
  ------------------
  494|  2.27k|    int i;
  495|  4.54k|    for(i=0;i<vc->comments;i++){
  ------------------
  |  Branch (495:13): [True: 2.27k, False: 2.27k]
  ------------------
  496|  2.27k|      if(vc->user_comments[i]){
  ------------------
  |  Branch (496:10): [True: 2.27k, False: 0]
  ------------------
  497|  2.27k|        oggpack_write(opb,vc->comment_lengths[i],32);
  498|  2.27k|        _v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]);
  499|  2.27k|      }else{
  500|      0|        oggpack_write(opb,0,32);
  501|      0|      }
  502|  2.27k|    }
  503|  2.27k|  }
  504|  2.27k|  oggpack_write(opb,1,1);
  505|       |
  506|  2.27k|  return(0);
  507|  2.27k|}
info.c:_v_writestring:
   36|  11.3k|static void _v_writestring(oggpack_buffer *o,const char *s, int bytes){
   37|       |
   38|   224k|  while(bytes--){
  ------------------
  |  Branch (38:9): [True: 213k, False: 11.3k]
  ------------------
   39|   213k|    oggpack_write(o,*s++,8);
   40|   213k|  }
   41|  11.3k|}
info.c:_vorbis_pack_info:
  451|  2.27k|static int _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi){
  452|  2.27k|  codec_setup_info     *ci=vi->codec_setup;
  453|  2.27k|  if(!ci||
  ------------------
  |  Branch (453:6): [True: 0, False: 2.27k]
  ------------------
  454|  2.27k|     ci->blocksizes[0]<64||
  ------------------
  |  Branch (454:6): [True: 0, False: 2.27k]
  ------------------
  455|  2.27k|     ci->blocksizes[1]<ci->blocksizes[0]){
  ------------------
  |  Branch (455:6): [True: 0, False: 2.27k]
  ------------------
  456|      0|    return(OV_EFAULT);
  ------------------
  |  |  226|      0|#define OV_EFAULT     -129
  ------------------
  457|      0|  }
  458|       |
  459|       |  /* preamble */
  460|  2.27k|  oggpack_write(opb,0x01,8);
  461|  2.27k|  _v_writestring(opb,"vorbis", 6);
  462|       |
  463|       |  /* basic information about the stream */
  464|  2.27k|  oggpack_write(opb,0x00,32);
  465|  2.27k|  oggpack_write(opb,vi->channels,8);
  466|  2.27k|  oggpack_write(opb,vi->rate,32);
  467|       |
  468|  2.27k|  oggpack_write(opb,vi->bitrate_upper,32);
  469|  2.27k|  oggpack_write(opb,vi->bitrate_nominal,32);
  470|  2.27k|  oggpack_write(opb,vi->bitrate_lower,32);
  471|       |
  472|  2.27k|  oggpack_write(opb,ov_ilog(ci->blocksizes[0]-1),4);
  473|  2.27k|  oggpack_write(opb,ov_ilog(ci->blocksizes[1]-1),4);
  474|  2.27k|  oggpack_write(opb,1,1);
  475|       |
  476|  2.27k|  return(0);
  477|  2.27k|}
info.c:_vorbis_pack_books:
  509|  2.27k|static int _vorbis_pack_books(oggpack_buffer *opb,vorbis_info *vi){
  510|  2.27k|  codec_setup_info     *ci=vi->codec_setup;
  511|  2.27k|  int i;
  512|  2.27k|  if(!ci)return(OV_EFAULT);
  ------------------
  |  |  226|      0|#define OV_EFAULT     -129
  ------------------
  |  Branch (512:6): [True: 0, False: 2.27k]
  ------------------
  513|       |
  514|  2.27k|  oggpack_write(opb,0x05,8);
  515|  2.27k|  _v_writestring(opb,"vorbis", 6);
  516|       |
  517|       |  /* books */
  518|  2.27k|  oggpack_write(opb,ci->books-1,8);
  519|  83.8k|  for(i=0;i<ci->books;i++)
  ------------------
  |  Branch (519:11): [True: 81.5k, False: 2.27k]
  ------------------
  520|  81.5k|    if(vorbis_staticbook_pack(ci->book_param[i],opb))goto err_out;
  ------------------
  |  Branch (520:8): [True: 0, False: 81.5k]
  ------------------
  521|       |
  522|       |  /* times; hook placeholders */
  523|  2.27k|  oggpack_write(opb,0,6);
  524|  2.27k|  oggpack_write(opb,0,16);
  525|       |
  526|       |  /* floors */
  527|  2.27k|  oggpack_write(opb,ci->floors-1,6);
  528|  6.53k|  for(i=0;i<ci->floors;i++){
  ------------------
  |  Branch (528:11): [True: 4.26k, False: 2.27k]
  ------------------
  529|  4.26k|    oggpack_write(opb,ci->floor_type[i],16);
  530|  4.26k|    if(_floor_P[ci->floor_type[i]]->pack)
  ------------------
  |  Branch (530:8): [True: 4.26k, False: 0]
  ------------------
  531|  4.26k|      _floor_P[ci->floor_type[i]]->pack(ci->floor_param[i],opb);
  532|      0|    else
  533|      0|      goto err_out;
  534|  4.26k|  }
  535|       |
  536|       |  /* residues */
  537|  2.27k|  oggpack_write(opb,ci->residues-1,6);
  538|  6.41k|  for(i=0;i<ci->residues;i++){
  ------------------
  |  Branch (538:11): [True: 4.14k, False: 2.27k]
  ------------------
  539|  4.14k|    oggpack_write(opb,ci->residue_type[i],16);
  540|  4.14k|    _residue_P[ci->residue_type[i]]->pack(ci->residue_param[i],opb);
  541|  4.14k|  }
  542|       |
  543|       |  /* maps */
  544|  2.27k|  oggpack_write(opb,ci->maps-1,6);
  545|  6.41k|  for(i=0;i<ci->maps;i++){
  ------------------
  |  Branch (545:11): [True: 4.14k, False: 2.27k]
  ------------------
  546|  4.14k|    oggpack_write(opb,ci->map_type[i],16);
  547|  4.14k|    _mapping_P[ci->map_type[i]]->pack(vi,ci->map_param[i],opb);
  548|  4.14k|  }
  549|       |
  550|       |  /* modes */
  551|  2.27k|  oggpack_write(opb,ci->modes-1,6);
  552|  6.41k|  for(i=0;i<ci->modes;i++){
  ------------------
  |  Branch (552:11): [True: 4.14k, False: 2.27k]
  ------------------
  553|  4.14k|    oggpack_write(opb,ci->mode_param[i]->blockflag,1);
  554|  4.14k|    oggpack_write(opb,ci->mode_param[i]->windowtype,16);
  555|  4.14k|    oggpack_write(opb,ci->mode_param[i]->transformtype,16);
  556|  4.14k|    oggpack_write(opb,ci->mode_param[i]->mapping,8);
  557|  4.14k|  }
  558|  2.27k|  oggpack_write(opb,1,1);
  559|       |
  560|  2.27k|  return(0);
  561|      0|err_out:
  562|      0|  return(-1);
  563|  2.27k|}

vorbis_lpc_from_data:
   60|  11.0k|float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
   61|  11.0k|  double *aut=alloca(sizeof(*aut)*(m+1));
   62|  11.0k|  double *lpc=alloca(sizeof(*lpc)*(m));
   63|  11.0k|  double error;
   64|  11.0k|  double epsilon;
   65|  11.0k|  int i,j;
   66|       |
   67|       |  /* autocorrelation, p+1 lag coefficients */
   68|  11.0k|  j=m+1;
   69|   310k|  while(j--){
  ------------------
  |  Branch (69:9): [True: 298k, False: 11.0k]
  ------------------
   70|   298k|    double d=0; /* double needed for accumulator depth */
   71|   371M|    for(i=j;i<n;i++)d+=(double)data[i]*data[i-j];
  ------------------
  |  Branch (71:13): [True: 371M, False: 298k]
  ------------------
   72|   298k|    aut[j]=d;
   73|   298k|  }
   74|       |
   75|       |  /* Generate lpc coefficients from autocorr values */
   76|       |
   77|       |  /* set our noise floor to about -100dB */
   78|  11.0k|  error=aut[0] * (1. + 1e-10);
   79|  11.0k|  epsilon=1e-9*aut[0]+1e-10;
   80|       |
   81|   284k|  for(i=0;i<m;i++){
  ------------------
  |  Branch (81:11): [True: 274k, False: 10.5k]
  ------------------
   82|   274k|    double r= -aut[i+1];
   83|       |
   84|   274k|    if(error<epsilon){
  ------------------
  |  Branch (84:8): [True: 490, False: 273k]
  ------------------
   85|    490|      memset(lpc+i,0,(m-i)*sizeof(*lpc));
   86|    490|      goto done;
   87|    490|    }
   88|       |
   89|       |    /* Sum up this iteration's reflection coefficient; note that in
   90|       |       Vorbis we don't save it.  If anyone wants to recycle this code
   91|       |       and needs reflection coefficients, save the results of 'r' from
   92|       |       each iteration. */
   93|       |
   94|  3.99M|    for(j=0;j<i;j++)r-=lpc[j]*aut[i-j];
  ------------------
  |  Branch (94:13): [True: 3.71M, False: 273k]
  ------------------
   95|   273k|    r/=error;
   96|       |
   97|       |    /* Update LPC coefficients and total error */
   98|       |
   99|   273k|    lpc[i]=r;
  100|  2.06M|    for(j=0;j<i/2;j++){
  ------------------
  |  Branch (100:13): [True: 1.79M, False: 273k]
  ------------------
  101|  1.79M|      double tmp=lpc[j];
  102|       |
  103|  1.79M|      lpc[j]+=r*lpc[i-1-j];
  104|  1.79M|      lpc[i-1-j]+=r*tmp;
  105|  1.79M|    }
  106|   273k|    if(i&1)lpc[j]+=lpc[j]*r;
  ------------------
  |  Branch (106:8): [True: 136k, False: 136k]
  ------------------
  107|       |
  108|   273k|    error*=1.-r*r;
  109|       |
  110|   273k|  }
  111|       |
  112|  11.0k| done:
  113|       |
  114|       |  /* slightly damp the filter */
  115|  11.0k|  {
  116|  11.0k|    double g = .99;
  117|  11.0k|    double damp = g;
  118|   298k|    for(j=0;j<m;j++){
  ------------------
  |  Branch (118:13): [True: 287k, False: 11.0k]
  ------------------
  119|   287k|      lpc[j]*=damp;
  120|   287k|      damp*=g;
  121|   287k|    }
  122|  11.0k|  }
  123|       |
  124|   298k|  for(j=0;j<m;j++)lpci[j]=(float)lpc[j];
  ------------------
  |  Branch (124:11): [True: 287k, False: 11.0k]
  ------------------
  125|       |
  126|       |  /* we need the error value to know how big an impulse to hit the
  127|       |     filter with later */
  128|       |
  129|  11.0k|  return error;
  130|  11.0k|}
vorbis_lpc_predict:
  133|  11.0k|                     float *data,long n){
  134|       |
  135|       |  /* in: coeff[0...m-1] LPC coefficients
  136|       |         prime[0...m-1] initial values (allocated size of n+m-1)
  137|       |    out: data[0...n-1] data samples */
  138|       |
  139|  11.0k|  long i,j,o,p;
  140|  11.0k|  float y;
  141|  11.0k|  float *work=alloca(sizeof(*work)*(m+n));
  142|       |
  143|  11.0k|  if(!prime)
  ------------------
  |  Branch (143:6): [True: 0, False: 11.0k]
  ------------------
  144|      0|    for(i=0;i<m;i++)
  ------------------
  |  Branch (144:13): [True: 0, False: 0]
  ------------------
  145|      0|      work[i]=0.f;
  146|  11.0k|  else
  147|   298k|    for(i=0;i<m;i++)
  ------------------
  |  Branch (147:13): [True: 287k, False: 11.0k]
  ------------------
  148|   287k|      work[i]=prime[i];
  149|       |
  150|  40.1M|  for(i=0;i<n;i++){
  ------------------
  |  Branch (150:11): [True: 40.1M, False: 11.0k]
  ------------------
  151|  40.1M|    y=0;
  152|  40.1M|    o=i;
  153|  40.1M|    p=m;
  154|  1.26G|    for(j=0;j<m;j++)
  ------------------
  |  Branch (154:13): [True: 1.22G, False: 40.1M]
  ------------------
  155|  1.22G|      y-=work[o++]*coeff[--p];
  156|       |
  157|  40.1M|    data[i]=work[o]=y;
  158|  40.1M|  }
  159|  11.0k|}

mapping0.c:mapping0_pack:
   48|  4.14k|                          oggpack_buffer *opb){
   49|  4.14k|  int i;
   50|  4.14k|  vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)vm;
   51|       |
   52|       |  /* another 'we meant to do it this way' hack...  up to beta 4, we
   53|       |     packed 4 binary zeros here to signify one submapping in use.  We
   54|       |     now redefine that to mean four bitflags that indicate use of
   55|       |     deeper features; bit0:submappings, bit1:coupling,
   56|       |     bit2,3:reserved. This is backward compatable with all actual uses
   57|       |     of the beta code. */
   58|       |
   59|  4.14k|  if(info->submaps>1){
  ------------------
  |  Branch (59:6): [True: 0, False: 4.14k]
  ------------------
   60|      0|    oggpack_write(opb,1,1);
   61|      0|    oggpack_write(opb,info->submaps-1,4);
   62|      0|  }else
   63|  4.14k|    oggpack_write(opb,0,1);
   64|       |
   65|  4.14k|  if(info->coupling_steps>0){
  ------------------
  |  Branch (65:6): [True: 906, False: 3.24k]
  ------------------
   66|    906|    oggpack_write(opb,1,1);
   67|    906|    oggpack_write(opb,info->coupling_steps-1,8);
   68|       |
   69|  1.81k|    for(i=0;i<info->coupling_steps;i++){
  ------------------
  |  Branch (69:13): [True: 906, False: 906]
  ------------------
   70|    906|      oggpack_write(opb,info->coupling_mag[i],ov_ilog(vi->channels-1));
   71|    906|      oggpack_write(opb,info->coupling_ang[i],ov_ilog(vi->channels-1));
   72|    906|    }
   73|    906|  }else
   74|  3.24k|    oggpack_write(opb,0,1);
   75|       |
   76|  4.14k|  oggpack_write(opb,0,2); /* 2,3:reserved */
   77|       |
   78|       |  /* we don't write the channel submappings if we only have one... */
   79|  4.14k|  if(info->submaps>1){
  ------------------
  |  Branch (79:6): [True: 0, False: 4.14k]
  ------------------
   80|      0|    for(i=0;i<vi->channels;i++)
  ------------------
  |  Branch (80:13): [True: 0, False: 0]
  ------------------
   81|      0|      oggpack_write(opb,info->chmuxlist[i],4);
   82|      0|  }
   83|  8.29k|  for(i=0;i<info->submaps;i++){
  ------------------
  |  Branch (83:11): [True: 4.14k, False: 4.14k]
  ------------------
   84|  4.14k|    oggpack_write(opb,0,8); /* time submap unused */
   85|  4.14k|    oggpack_write(opb,info->floorsubmap[i],8);
   86|  4.14k|    oggpack_write(opb,info->residuesubmap[i],8);
   87|  4.14k|  }
   88|  4.14k|}
mapping0.c:mapping0_free_info:
   39|  4.14k|static void mapping0_free_info(vorbis_info_mapping *i){
   40|  4.14k|  vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)i;
   41|  4.14k|  if(info){
  ------------------
  |  Branch (41:6): [True: 4.14k, False: 0]
  ------------------
   42|  4.14k|    memset(info,0,sizeof(*info));
   43|  4.14k|    _ogg_free(info);
  ------------------
  |  |   24|  4.14k|#define _ogg_free    free
  ------------------
   44|  4.14k|  }
   45|  4.14k|}
mapping0.c:mapping0_forward:
  230|  58.1k|static int mapping0_forward(vorbis_block *vb){
  231|  58.1k|  vorbis_dsp_state      *vd=vb->vd;
  232|  58.1k|  vorbis_info           *vi=vd->vi;
  233|  58.1k|  codec_setup_info      *ci=vi->codec_setup;
  234|  58.1k|  private_state         *b=vb->vd->backend_state;
  235|  58.1k|  vorbis_block_internal *vbi=(vorbis_block_internal *)vb->internal;
  236|  58.1k|  int                    n=vb->pcmend;
  237|  58.1k|  int i,j,k;
  238|       |
  239|  58.1k|  int    *nonzero    = alloca(sizeof(*nonzero)*vi->channels);
  240|  58.1k|  float  **gmdct     = _vorbis_block_alloc(vb,vi->channels*sizeof(*gmdct));
  241|  58.1k|  int    **iwork      = _vorbis_block_alloc(vb,vi->channels*sizeof(*iwork));
  242|  58.1k|  int ***floor_posts = _vorbis_block_alloc(vb,vi->channels*sizeof(*floor_posts));
  243|       |
  244|  58.1k|  float global_ampmax=vbi->ampmax;
  245|  58.1k|  float *local_ampmax=alloca(sizeof(*local_ampmax)*vi->channels);
  246|  58.1k|  int blocktype=vbi->blocktype;
  247|       |
  248|  58.1k|  int modenumber=vb->W;
  249|  58.1k|  vorbis_info_mapping0 *info=ci->map_param[modenumber];
  250|  58.1k|  vorbis_look_psy *psy_look=b->psy+blocktype+(vb->W?2:0);
  ------------------
  |  Branch (250:47): [True: 2.63k, False: 55.5k]
  ------------------
  251|       |
  252|  58.1k|  vb->mode=modenumber;
  253|       |
  254|   161k|  for(i=0;i<vi->channels;i++){
  ------------------
  |  Branch (254:11): [True: 103k, False: 58.1k]
  ------------------
  255|   103k|    float scale=4.f/n;
  256|   103k|    float scale_dB;
  257|       |
  258|   103k|    float *pcm     =vb->pcm[i];
  259|   103k|    float *logfft  =pcm;
  260|       |
  261|   103k|    iwork[i]=_vorbis_block_alloc(vb,n/2*sizeof(**iwork));
  262|   103k|    gmdct[i]=_vorbis_block_alloc(vb,n/2*sizeof(**gmdct));
  263|       |
  264|   103k|    scale_dB=todB(&scale) + .345; /* + .345 is a hack; the original
  265|       |                                     todB estimation used on IEEE 754
  266|       |                                     compliant machines had a bug that
  267|       |                                     returned dB values about a third
  268|       |                                     of a decibel too high.  The bug
  269|       |                                     was harmless because tunings
  270|       |                                     implicitly took that into
  271|       |                                     account.  However, fixing the bug
  272|       |                                     in the estimator requires
  273|       |                                     changing all the tunings as well.
  274|       |                                     For now, it's easier to sync
  275|       |                                     things back up here, and
  276|       |                                     recalibrate the tunings in the
  277|       |                                     next major model upgrade. */
  278|       |
  279|       |#if 0
  280|       |    if(vi->channels==2){
  281|       |      if(i==0)
  282|       |        _analysis_output("pcmL",seq,pcm,n,0,0,total-n/2);
  283|       |      else
  284|       |        _analysis_output("pcmR",seq,pcm,n,0,0,total-n/2);
  285|       |    }else{
  286|       |      _analysis_output("pcm",seq,pcm,n,0,0,total-n/2);
  287|       |    }
  288|       |#endif
  289|       |
  290|       |    /* window the PCM data */
  291|   103k|    _vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW);
  292|       |
  293|       |#if 0
  294|       |    if(vi->channels==2){
  295|       |      if(i==0)
  296|       |        _analysis_output("windowedL",seq,pcm,n,0,0,total-n/2);
  297|       |      else
  298|       |        _analysis_output("windowedR",seq,pcm,n,0,0,total-n/2);
  299|       |    }else{
  300|       |      _analysis_output("windowed",seq,pcm,n,0,0,total-n/2);
  301|       |    }
  302|       |#endif
  303|       |
  304|       |    /* transform the PCM data */
  305|       |    /* only MDCT right now.... */
  306|   103k|    mdct_forward(b->transform[vb->W][0],pcm,gmdct[i]);
  307|       |
  308|       |    /* FFT yields more accurate tonal estimation (not phase sensitive) */
  309|   103k|    drft_forward(&b->fft_look[vb->W],pcm);
  310|   103k|    logfft[0]=scale_dB+todB(pcm)  + .345; /* + .345 is a hack; the
  311|       |                                     original todB estimation used on
  312|       |                                     IEEE 754 compliant machines had a
  313|       |                                     bug that returned dB values about
  314|       |                                     a third of a decibel too high.
  315|       |                                     The bug was harmless because
  316|       |                                     tunings implicitly took that into
  317|       |                                     account.  However, fixing the bug
  318|       |                                     in the estimator requires
  319|       |                                     changing all the tunings as well.
  320|       |                                     For now, it's easier to sync
  321|       |                                     things back up here, and
  322|       |                                     recalibrate the tunings in the
  323|       |                                     next major model upgrade. */
  324|   103k|    local_ampmax[i]=logfft[0];
  325|  20.1M|    for(j=1;j<n-1;j+=2){
  ------------------
  |  Branch (325:13): [True: 20.0M, False: 103k]
  ------------------
  326|  20.0M|      float temp=pcm[j]*pcm[j]+pcm[j+1]*pcm[j+1];
  327|  20.0M|      temp=logfft[(j+1)>>1]=scale_dB+.5f*todB(&temp)  + .345; /* +
  328|       |                                     .345 is a hack; the original todB
  329|       |                                     estimation used on IEEE 754
  330|       |                                     compliant machines had a bug that
  331|       |                                     returned dB values about a third
  332|       |                                     of a decibel too high.  The bug
  333|       |                                     was harmless because tunings
  334|       |                                     implicitly took that into
  335|       |                                     account.  However, fixing the bug
  336|       |                                     in the estimator requires
  337|       |                                     changing all the tunings as well.
  338|       |                                     For now, it's easier to sync
  339|       |                                     things back up here, and
  340|       |                                     recalibrate the tunings in the
  341|       |                                     next major model upgrade. */
  342|  20.0M|      if(temp>local_ampmax[i])local_ampmax[i]=temp;
  ------------------
  |  Branch (342:10): [True: 96.4k, False: 19.9M]
  ------------------
  343|  20.0M|    }
  344|       |
  345|   103k|    if(local_ampmax[i]>0.f)local_ampmax[i]=0.f;
  ------------------
  |  Branch (345:8): [True: 38.2k, False: 65.3k]
  ------------------
  346|   103k|    if(local_ampmax[i]>global_ampmax)global_ampmax=local_ampmax[i];
  ------------------
  |  Branch (346:8): [True: 30.6k, False: 72.9k]
  ------------------
  347|       |
  348|       |#if 0
  349|       |    if(vi->channels==2){
  350|       |      if(i==0){
  351|       |        _analysis_output("fftL",seq,logfft,n/2,1,0,0);
  352|       |      }else{
  353|       |        _analysis_output("fftR",seq,logfft,n/2,1,0,0);
  354|       |      }
  355|       |    }else{
  356|       |      _analysis_output("fft",seq,logfft,n/2,1,0,0);
  357|       |    }
  358|       |#endif
  359|       |
  360|   103k|  }
  361|       |
  362|  58.1k|  {
  363|  58.1k|    float   *noise        = _vorbis_block_alloc(vb,n/2*sizeof(*noise));
  364|  58.1k|    float   *tone         = _vorbis_block_alloc(vb,n/2*sizeof(*tone));
  365|       |
  366|   161k|    for(i=0;i<vi->channels;i++){
  ------------------
  |  Branch (366:13): [True: 103k, False: 58.1k]
  ------------------
  367|       |      /* the encoder setup assumes that all the modes used by any
  368|       |         specific bitrate tweaking use the same floor */
  369|       |
  370|   103k|      int submap=info->chmuxlist[i];
  371|       |
  372|       |      /* the following makes things clearer to *me* anyway */
  373|   103k|      float *mdct    =gmdct[i];
  374|   103k|      float *logfft  =vb->pcm[i];
  375|       |
  376|   103k|      float *logmdct =logfft+n/2;
  377|   103k|      float *logmask =logfft;
  378|       |
  379|   103k|      vb->mode=modenumber;
  380|       |
  381|   103k|      floor_posts[i]=_vorbis_block_alloc(vb,PACKETBLOBS*sizeof(**floor_posts));
  ------------------
  |  |   28|   103k|#define PACKETBLOBS 15
  ------------------
  382|   103k|      memset(floor_posts[i],0,sizeof(**floor_posts)*PACKETBLOBS);
  ------------------
  |  |   28|   103k|#define PACKETBLOBS 15
  ------------------
  383|       |
  384|  20.2M|      for(j=0;j<n/2;j++)
  ------------------
  |  Branch (384:15): [True: 20.1M, False: 103k]
  ------------------
  385|  20.1M|        logmdct[j]=todB(mdct+j)  + .345; /* + .345 is a hack; the original
  386|       |                                     todB estimation used on IEEE 754
  387|       |                                     compliant machines had a bug that
  388|       |                                     returned dB values about a third
  389|       |                                     of a decibel too high.  The bug
  390|       |                                     was harmless because tunings
  391|       |                                     implicitly took that into
  392|       |                                     account.  However, fixing the bug
  393|       |                                     in the estimator requires
  394|       |                                     changing all the tunings as well.
  395|       |                                     For now, it's easier to sync
  396|       |                                     things back up here, and
  397|       |                                     recalibrate the tunings in the
  398|       |                                     next major model upgrade. */
  399|       |
  400|       |#if 0
  401|       |      if(vi->channels==2){
  402|       |        if(i==0)
  403|       |          _analysis_output("mdctL",seq,logmdct,n/2,1,0,0);
  404|       |        else
  405|       |          _analysis_output("mdctR",seq,logmdct,n/2,1,0,0);
  406|       |      }else{
  407|       |        _analysis_output("mdct",seq,logmdct,n/2,1,0,0);
  408|       |      }
  409|       |#endif
  410|       |
  411|       |      /* first step; noise masking.  Not only does 'noise masking'
  412|       |         give us curves from which we can decide how much resolution
  413|       |         to give noise parts of the spectrum, it also implicitly hands
  414|       |         us a tonality estimate (the larger the value in the
  415|       |         'noise_depth' vector, the more tonal that area is) */
  416|       |
  417|   103k|      _vp_noisemask(psy_look,
  418|   103k|                    logmdct,
  419|   103k|                    noise); /* noise does not have by-frequency offset
  420|       |                               bias applied yet */
  421|       |#if 0
  422|       |      if(vi->channels==2){
  423|       |        if(i==0)
  424|       |          _analysis_output("noiseL",seq,noise,n/2,1,0,0);
  425|       |        else
  426|       |          _analysis_output("noiseR",seq,noise,n/2,1,0,0);
  427|       |      }else{
  428|       |        _analysis_output("noise",seq,noise,n/2,1,0,0);
  429|       |      }
  430|       |#endif
  431|       |
  432|       |      /* second step: 'all the other crap'; all the stuff that isn't
  433|       |         computed/fit for bitrate management goes in the second psy
  434|       |         vector.  This includes tone masking, peak limiting and ATH */
  435|       |
  436|   103k|      _vp_tonemask(psy_look,
  437|   103k|                   logfft,
  438|   103k|                   tone,
  439|   103k|                   global_ampmax,
  440|   103k|                   local_ampmax[i]);
  441|       |
  442|       |#if 0
  443|       |      if(vi->channels==2){
  444|       |        if(i==0)
  445|       |          _analysis_output("toneL",seq,tone,n/2,1,0,0);
  446|       |        else
  447|       |          _analysis_output("toneR",seq,tone,n/2,1,0,0);
  448|       |      }else{
  449|       |        _analysis_output("tone",seq,tone,n/2,1,0,0);
  450|       |      }
  451|       |#endif
  452|       |
  453|       |      /* third step; we offset the noise vectors, overlay tone
  454|       |         masking.  We then do a floor1-specific line fit.  If we're
  455|       |         performing bitrate management, the line fit is performed
  456|       |         multiple times for up/down tweakage on demand. */
  457|       |
  458|       |#if 0
  459|       |      {
  460|       |      float aotuv[psy_look->n];
  461|       |#endif
  462|       |
  463|   103k|        _vp_offset_and_mix(psy_look,
  464|   103k|                           noise,
  465|   103k|                           tone,
  466|   103k|                           1,
  467|   103k|                           logmask,
  468|   103k|                           mdct,
  469|   103k|                           logmdct);
  470|       |
  471|       |#if 0
  472|       |        if(vi->channels==2){
  473|       |          if(i==0)
  474|       |            _analysis_output("aotuvM1_L",seq,aotuv,psy_look->n,1,1,0);
  475|       |          else
  476|       |            _analysis_output("aotuvM1_R",seq,aotuv,psy_look->n,1,1,0);
  477|       |        }else{
  478|       |          _analysis_output("aotuvM1",seq,aotuv,psy_look->n,1,1,0);
  479|       |        }
  480|       |      }
  481|       |#endif
  482|       |
  483|       |
  484|       |#if 0
  485|       |      if(vi->channels==2){
  486|       |        if(i==0)
  487|       |          _analysis_output("mask1L",seq,logmask,n/2,1,0,0);
  488|       |        else
  489|       |          _analysis_output("mask1R",seq,logmask,n/2,1,0,0);
  490|       |      }else{
  491|       |        _analysis_output("mask1",seq,logmask,n/2,1,0,0);
  492|       |      }
  493|       |#endif
  494|       |
  495|       |      /* this algorithm is hardwired to floor 1 for now; abort out if
  496|       |         we're *not* floor1.  This won't happen unless someone has
  497|       |         broken the encode setup lib.  Guard it anyway. */
  498|   103k|      if(ci->floor_type[info->floorsubmap[submap]]!=1)return(-1);
  ------------------
  |  Branch (498:10): [True: 0, False: 103k]
  ------------------
  499|       |
  500|   103k|      floor_posts[i][PACKETBLOBS/2]=
  ------------------
  |  |   28|   103k|#define PACKETBLOBS 15
  ------------------
  501|   103k|        floor1_fit(vb,b->flr[info->floorsubmap[submap]],
  502|   103k|                   logmdct,
  503|   103k|                   logmask);
  504|       |
  505|       |      /* are we managing bitrate?  If so, perform two more fits for
  506|       |         later rate tweaking (fits represent hi/lo) */
  507|   103k|      if(vorbis_bitrate_managed(vb) && floor_posts[i][PACKETBLOBS/2]){
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  |  Branch (507:10): [True: 0, False: 103k]
  |  Branch (507:40): [True: 0, False: 0]
  ------------------
  508|       |        /* higher rate by way of lower noise curve */
  509|       |
  510|      0|        _vp_offset_and_mix(psy_look,
  511|      0|                           noise,
  512|      0|                           tone,
  513|      0|                           2,
  514|      0|                           logmask,
  515|      0|                           mdct,
  516|      0|                           logmdct);
  517|       |
  518|       |#if 0
  519|       |        if(vi->channels==2){
  520|       |          if(i==0)
  521|       |            _analysis_output("mask2L",seq,logmask,n/2,1,0,0);
  522|       |          else
  523|       |            _analysis_output("mask2R",seq,logmask,n/2,1,0,0);
  524|       |        }else{
  525|       |          _analysis_output("mask2",seq,logmask,n/2,1,0,0);
  526|       |        }
  527|       |#endif
  528|       |
  529|      0|        floor_posts[i][PACKETBLOBS-1]=
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  530|      0|          floor1_fit(vb,b->flr[info->floorsubmap[submap]],
  531|      0|                     logmdct,
  532|      0|                     logmask);
  533|       |
  534|       |        /* lower rate by way of higher noise curve */
  535|      0|        _vp_offset_and_mix(psy_look,
  536|      0|                           noise,
  537|      0|                           tone,
  538|      0|                           0,
  539|      0|                           logmask,
  540|      0|                           mdct,
  541|      0|                           logmdct);
  542|       |
  543|       |#if 0
  544|       |        if(vi->channels==2){
  545|       |          if(i==0)
  546|       |            _analysis_output("mask0L",seq,logmask,n/2,1,0,0);
  547|       |          else
  548|       |            _analysis_output("mask0R",seq,logmask,n/2,1,0,0);
  549|       |        }else{
  550|       |          _analysis_output("mask0",seq,logmask,n/2,1,0,0);
  551|       |        }
  552|       |#endif
  553|       |
  554|      0|        floor_posts[i][0]=
  555|      0|          floor1_fit(vb,b->flr[info->floorsubmap[submap]],
  556|      0|                     logmdct,
  557|      0|                     logmask);
  558|       |
  559|       |        /* we also interpolate a range of intermediate curves for
  560|       |           intermediate rates */
  561|      0|        for(k=1;k<PACKETBLOBS/2;k++)
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  |  Branch (561:17): [True: 0, False: 0]
  ------------------
  562|      0|          floor_posts[i][k]=
  563|      0|            floor1_interpolate_fit(vb,b->flr[info->floorsubmap[submap]],
  564|      0|                                   floor_posts[i][0],
  565|      0|                                   floor_posts[i][PACKETBLOBS/2],
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  566|      0|                                   k*65536/(PACKETBLOBS/2));
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  567|      0|        for(k=PACKETBLOBS/2+1;k<PACKETBLOBS-1;k++)
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
                      for(k=PACKETBLOBS/2+1;k<PACKETBLOBS-1;k++)
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  |  Branch (567:31): [True: 0, False: 0]
  ------------------
  568|      0|          floor_posts[i][k]=
  569|      0|            floor1_interpolate_fit(vb,b->flr[info->floorsubmap[submap]],
  570|      0|                                   floor_posts[i][PACKETBLOBS/2],
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  571|      0|                                   floor_posts[i][PACKETBLOBS-1],
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  572|      0|                                   (k-PACKETBLOBS/2)*65536/(PACKETBLOBS/2));
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
                                                 (k-PACKETBLOBS/2)*65536/(PACKETBLOBS/2));
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  573|      0|      }
  574|   103k|    }
  575|  58.1k|  }
  576|  58.1k|  vbi->ampmax=global_ampmax;
  577|       |
  578|       |  /*
  579|       |    the next phases are performed once for vbr-only and PACKETBLOB
  580|       |    times for bitrate managed modes.
  581|       |
  582|       |    1) encode actual mode being used
  583|       |    2) encode the floor for each channel, compute coded mask curve/res
  584|       |    3) normalize and couple.
  585|       |    4) encode residue
  586|       |    5) save packet bytes to the packetblob vector
  587|       |
  588|       |  */
  589|       |
  590|       |  /* iterate over the many masking curve fits we've created */
  591|       |
  592|  58.1k|  {
  593|  58.1k|    int **couple_bundle=alloca(sizeof(*couple_bundle)*vi->channels);
  594|  58.1k|    int *zerobundle=alloca(sizeof(*zerobundle)*vi->channels);
  595|       |
  596|  58.1k|    for(k=(vorbis_bitrate_managed(vb)?0:PACKETBLOBS/2);
  ------------------
  |  |   28|  58.1k|#define PACKETBLOBS 15
  ------------------
  |  Branch (596:12): [True: 0, False: 58.1k]
  ------------------
  597|   116k|        k<=(vorbis_bitrate_managed(vb)?PACKETBLOBS-1:PACKETBLOBS/2);
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
                      k<=(vorbis_bitrate_managed(vb)?PACKETBLOBS-1:PACKETBLOBS/2);
  ------------------
  |  |   28|   116k|#define PACKETBLOBS 15
  ------------------
  |  Branch (597:9): [True: 58.1k, False: 58.1k]
  |  Branch (597:13): [True: 0, False: 116k]
  ------------------
  598|  58.1k|        k++){
  599|  58.1k|      oggpack_buffer *opb=vbi->packetblob[k];
  600|       |
  601|       |      /* start out our new packet blob with packet type and mode */
  602|       |      /* Encode the packet type */
  603|  58.1k|      oggpack_write(opb,0,1);
  604|       |      /* Encode the modenumber */
  605|       |      /* Encode frame mode, pre,post windowsize, then dispatch */
  606|  58.1k|      oggpack_write(opb,modenumber,b->modebits);
  607|  58.1k|      if(vb->W){
  ------------------
  |  Branch (607:10): [True: 2.63k, False: 55.5k]
  ------------------
  608|  2.63k|        oggpack_write(opb,vb->lW,1);
  609|  2.63k|        oggpack_write(opb,vb->nW,1);
  610|  2.63k|      }
  611|       |
  612|       |      /* encode floor, compute masking curve, sep out residue */
  613|   161k|      for(i=0;i<vi->channels;i++){
  ------------------
  |  Branch (613:15): [True: 103k, False: 58.1k]
  ------------------
  614|   103k|        int submap=info->chmuxlist[i];
  615|   103k|        int *ilogmask=iwork[i];
  616|       |
  617|   103k|        nonzero[i]=floor1_encode(opb,vb,b->flr[info->floorsubmap[submap]],
  618|   103k|                                 floor_posts[i][k],
  619|   103k|                                 ilogmask);
  620|       |#if 0
  621|       |        {
  622|       |          char buf[80];
  623|       |          sprintf(buf,"maskI%c%d",i?'R':'L',k);
  624|       |          float work[n/2];
  625|       |          for(j=0;j<n/2;j++)
  626|       |            work[j]=FLOOR1_fromdB_LOOKUP[iwork[i][j]];
  627|       |          _analysis_output(buf,seq,work,n/2,1,1,0);
  628|       |        }
  629|       |#endif
  630|   103k|      }
  631|       |
  632|       |      /* our iteration is now based on masking curve, not prequant and
  633|       |         coupling.  Only one prequant/coupling step */
  634|       |
  635|       |      /* quantize/couple */
  636|       |      /* incomplete implementation that assumes the tree is all depth
  637|       |         one, or no tree at all */
  638|  58.1k|      _vp_couple_quantize_normalize(k,
  639|  58.1k|                                    &ci->psy_g_param,
  640|  58.1k|                                    psy_look,
  641|  58.1k|                                    info,
  642|  58.1k|                                    gmdct,
  643|  58.1k|                                    iwork,
  644|  58.1k|                                    nonzero,
  645|  58.1k|                                    ci->psy_g_param.sliding_lowpass[vb->W][k],
  646|  58.1k|                                    vi->channels);
  647|       |
  648|       |#if 0
  649|       |      for(i=0;i<vi->channels;i++){
  650|       |        char buf[80];
  651|       |        sprintf(buf,"res%c%d",i?'R':'L',k);
  652|       |        float work[n/2];
  653|       |        for(j=0;j<n/2;j++)
  654|       |          work[j]=iwork[i][j];
  655|       |        _analysis_output(buf,seq,work,n/2,1,0,0);
  656|       |      }
  657|       |#endif
  658|       |
  659|       |      /* classify and encode by submap */
  660|   116k|      for(i=0;i<info->submaps;i++){
  ------------------
  |  Branch (660:15): [True: 58.1k, False: 58.1k]
  ------------------
  661|  58.1k|        int ch_in_bundle=0;
  662|  58.1k|        long **classifications;
  663|  58.1k|        int resnum=info->residuesubmap[i];
  664|       |
  665|   161k|        for(j=0;j<vi->channels;j++){
  ------------------
  |  Branch (665:17): [True: 103k, False: 58.1k]
  ------------------
  666|   103k|          if(info->chmuxlist[j]==i){
  ------------------
  |  Branch (666:14): [True: 103k, False: 0]
  ------------------
  667|   103k|            zerobundle[ch_in_bundle]=0;
  668|   103k|            if(nonzero[j])zerobundle[ch_in_bundle]=1;
  ------------------
  |  Branch (668:16): [True: 100k, False: 3.05k]
  ------------------
  669|   103k|            couple_bundle[ch_in_bundle++]=iwork[j];
  670|   103k|          }
  671|   103k|        }
  672|       |
  673|  58.1k|        classifications=_residue_P[ci->residue_type[resnum]]->
  674|  58.1k|          class(vb,b->residue[resnum],couple_bundle,zerobundle,ch_in_bundle);
  675|       |
  676|  58.1k|        ch_in_bundle=0;
  677|   161k|        for(j=0;j<vi->channels;j++)
  ------------------
  |  Branch (677:17): [True: 103k, False: 58.1k]
  ------------------
  678|   103k|          if(info->chmuxlist[j]==i)
  ------------------
  |  Branch (678:14): [True: 103k, False: 0]
  ------------------
  679|   103k|            couple_bundle[ch_in_bundle++]=iwork[j];
  680|       |
  681|  58.1k|        _residue_P[ci->residue_type[resnum]]->
  682|  58.1k|          forward(opb,vb,b->residue[resnum],
  683|  58.1k|                  couple_bundle,zerobundle,ch_in_bundle,classifications,i);
  684|  58.1k|      }
  685|       |
  686|       |      /* ok, done encoding.  Next protopacket. */
  687|  58.1k|    }
  688|       |
  689|  58.1k|  }
  690|       |
  691|       |#if 0
  692|       |  seq++;
  693|       |  total+=ci->blocksizes[vb->W]/4+ci->blocksizes[vb->nW]/4;
  694|       |#endif
  695|  58.1k|  return(0);
  696|  58.1k|}

mdct_init:
   51|  6.81k|void mdct_init(mdct_lookup *lookup,int n){
   52|  6.81k|  int   *bitrev=_ogg_malloc(sizeof(*bitrev)*(n/4));
  ------------------
  |  |   21|  6.81k|#define _ogg_malloc  malloc
  ------------------
   53|  6.81k|  DATA_TYPE *T=_ogg_malloc(sizeof(*T)*(n+n/4));
  ------------------
  |  |   42|  6.81k|#define DATA_TYPE float
  ------------------
                DATA_TYPE *T=_ogg_malloc(sizeof(*T)*(n+n/4));
  ------------------
  |  |   21|  6.81k|#define _ogg_malloc  malloc
  ------------------
   54|       |
   55|  6.81k|  int i;
   56|  6.81k|  int n2=n>>1;
   57|  6.81k|  int log2n=lookup->log2n=rint(log((float)n)/log(2.f));
   58|  6.81k|  lookup->n=n;
   59|  6.81k|  lookup->trig=T;
   60|  6.81k|  lookup->bitrev=bitrev;
   61|       |
   62|       |/* trig lookups... */
   63|       |
   64|  1.23M|  for(i=0;i<n/4;i++){
  ------------------
  |  Branch (64:11): [True: 1.23M, False: 6.81k]
  ------------------
   65|  1.23M|    T[i*2]=FLOAT_CONV(cos((M_PI/n)*(4*i)));
  ------------------
  |  |   48|  1.23M|#define FLOAT_CONV(x) (x)
  ------------------
   66|  1.23M|    T[i*2+1]=FLOAT_CONV(-sin((M_PI/n)*(4*i)));
  ------------------
  |  |   48|  1.23M|#define FLOAT_CONV(x) (x)
  ------------------
   67|  1.23M|    T[n2+i*2]=FLOAT_CONV(cos((M_PI/(2*n))*(2*i+1)));
  ------------------
  |  |   48|  1.23M|#define FLOAT_CONV(x) (x)
  ------------------
   68|  1.23M|    T[n2+i*2+1]=FLOAT_CONV(sin((M_PI/(2*n))*(2*i+1)));
  ------------------
  |  |   48|  1.23M|#define FLOAT_CONV(x) (x)
  ------------------
   69|  1.23M|  }
   70|   622k|  for(i=0;i<n/8;i++){
  ------------------
  |  Branch (70:11): [True: 615k, False: 6.81k]
  ------------------
   71|   615k|    T[n+i*2]=FLOAT_CONV(cos((M_PI/n)*(4*i+2))*.5);
  ------------------
  |  |   48|   615k|#define FLOAT_CONV(x) (x)
  ------------------
   72|   615k|    T[n+i*2+1]=FLOAT_CONV(-sin((M_PI/n)*(4*i+2))*.5);
  ------------------
  |  |   48|   615k|#define FLOAT_CONV(x) (x)
  ------------------
   73|   615k|  }
   74|       |
   75|       |  /* bitreverse lookup... */
   76|       |
   77|  6.81k|  {
   78|  6.81k|    int mask=(1<<(log2n-1))-1,i,j;
   79|  6.81k|    int msb=1<<(log2n-2);
   80|   622k|    for(i=0;i<n/8;i++){
  ------------------
  |  Branch (80:13): [True: 615k, False: 6.81k]
  ------------------
   81|   615k|      int acc=0;
   82|  6.30M|      for(j=0;msb>>j;j++)
  ------------------
  |  Branch (82:15): [True: 5.68M, False: 615k]
  ------------------
   83|  5.68M|        if((msb>>j)&i)acc|=1<<j;
  ------------------
  |  Branch (83:12): [True: 2.22M, False: 3.46M]
  ------------------
   84|   615k|      bitrev[i*2]=((~acc)&mask)-1;
   85|   615k|      bitrev[i*2+1]=acc;
   86|       |
   87|   615k|    }
   88|  6.81k|  }
   89|  6.81k|  lookup->scale=FLOAT_CONV(4.f/n);
  ------------------
  |  |   48|  6.81k|#define FLOAT_CONV(x) (x)
  ------------------
   90|  6.81k|}
mdct_clear:
  338|  6.81k|void mdct_clear(mdct_lookup *l){
  339|  6.81k|  if(l){
  ------------------
  |  Branch (339:6): [True: 6.81k, False: 0]
  ------------------
  340|  6.81k|    if(l->trig)_ogg_free(l->trig);
  ------------------
  |  |   24|  6.81k|#define _ogg_free    free
  ------------------
  |  Branch (340:8): [True: 6.81k, False: 0]
  ------------------
  341|  6.81k|    if(l->bitrev)_ogg_free(l->bitrev);
  ------------------
  |  |   24|  6.81k|#define _ogg_free    free
  ------------------
  |  Branch (341:8): [True: 6.81k, False: 0]
  ------------------
  342|  6.81k|    memset(l,0,sizeof(*l));
  343|  6.81k|  }
  344|  6.81k|}
mdct_forward:
  492|   999k|void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out){
  493|   999k|  int n=init->n;
  494|   999k|  int n2=n>>1;
  495|   999k|  int n4=n>>2;
  496|   999k|  int n8=n>>3;
  497|   999k|  DATA_TYPE *w=alloca(n*sizeof(*w)); /* forward needs working space */
  ------------------
  |  |   42|   999k|#define DATA_TYPE float
  ------------------
  498|   999k|  DATA_TYPE *w2=w+n2;
  ------------------
  |  |   42|   999k|#define DATA_TYPE float
  ------------------
  499|       |
  500|       |  /* rotate */
  501|       |
  502|       |  /* window + rotate + step 1 */
  503|       |
  504|   999k|  REG_TYPE r0;
  ------------------
  |  |   43|   999k|#define REG_TYPE  float
  ------------------
  505|   999k|  REG_TYPE r1;
  ------------------
  |  |   43|   999k|#define REG_TYPE  float
  ------------------
  506|   999k|  DATA_TYPE *x0=in+n2+n4;
  ------------------
  |  |   42|   999k|#define DATA_TYPE float
  ------------------
  507|   999k|  DATA_TYPE *x1=x0+1;
  ------------------
  |  |   42|   999k|#define DATA_TYPE float
  ------------------
  508|   999k|  DATA_TYPE *T=init->trig+n2;
  ------------------
  |  |   42|   999k|#define DATA_TYPE float
  ------------------
  509|       |
  510|   999k|  int i=0;
  511|       |
  512|  10.6M|  for(i=0;i<n8;i+=2){
  ------------------
  |  Branch (512:11): [True: 9.68M, False: 999k]
  ------------------
  513|  9.68M|    x0 -=4;
  514|  9.68M|    T-=2;
  515|  9.68M|    r0= x0[2] + x1[0];
  516|  9.68M|    r1= x0[0] + x1[2];
  517|  9.68M|    w2[i]=   MULT_NORM(r1*T[1] + r0*T[0]);
  ------------------
  |  |   49|  9.68M|#define MULT_NORM(x) (x)
  ------------------
  518|  9.68M|    w2[i+1]= MULT_NORM(r1*T[0] - r0*T[1]);
  ------------------
  |  |   49|  9.68M|#define MULT_NORM(x) (x)
  ------------------
  519|  9.68M|    x1 +=4;
  520|  9.68M|  }
  521|       |
  522|   999k|  x1=in+1;
  523|       |
  524|  20.3M|  for(;i<n2-n8;i+=2){
  ------------------
  |  Branch (524:8): [True: 19.3M, False: 999k]
  ------------------
  525|  19.3M|    T-=2;
  526|  19.3M|    x0 -=4;
  527|  19.3M|    r0= x0[2] - x1[0];
  528|  19.3M|    r1= x0[0] - x1[2];
  529|  19.3M|    w2[i]=   MULT_NORM(r1*T[1] + r0*T[0]);
  ------------------
  |  |   49|  19.3M|#define MULT_NORM(x) (x)
  ------------------
  530|  19.3M|    w2[i+1]= MULT_NORM(r1*T[0] - r0*T[1]);
  ------------------
  |  |   49|  19.3M|#define MULT_NORM(x) (x)
  ------------------
  531|  19.3M|    x1 +=4;
  532|  19.3M|  }
  533|       |
  534|   999k|  x0=in+n;
  535|       |
  536|  10.6M|  for(;i<n2;i+=2){
  ------------------
  |  Branch (536:8): [True: 9.68M, False: 999k]
  ------------------
  537|  9.68M|    T-=2;
  538|  9.68M|    x0 -=4;
  539|  9.68M|    r0= -x0[2] - x1[0];
  540|  9.68M|    r1= -x0[0] - x1[2];
  541|  9.68M|    w2[i]=   MULT_NORM(r1*T[1] + r0*T[0]);
  ------------------
  |  |   49|  9.68M|#define MULT_NORM(x) (x)
  ------------------
  542|  9.68M|    w2[i+1]= MULT_NORM(r1*T[0] - r0*T[1]);
  ------------------
  |  |   49|  9.68M|#define MULT_NORM(x) (x)
  ------------------
  543|  9.68M|    x1 +=4;
  544|  9.68M|  }
  545|       |
  546|       |
  547|   999k|  mdct_butterflies(init,w+n2,n2);
  548|   999k|  mdct_bitreverse(init,w);
  549|       |
  550|       |  /* roatate + window */
  551|       |
  552|   999k|  T=init->trig+n2;
  553|   999k|  x0=out+n2;
  554|       |
  555|  39.7M|  for(i=0;i<n4;i++){
  ------------------
  |  Branch (555:11): [True: 38.7M, False: 999k]
  ------------------
  556|  38.7M|    x0--;
  557|  38.7M|    out[i] =MULT_NORM((w[0]*T[0]+w[1]*T[1])*init->scale);
  ------------------
  |  |   49|  38.7M|#define MULT_NORM(x) (x)
  ------------------
  558|  38.7M|    x0[0]  =MULT_NORM((w[0]*T[1]-w[1]*T[0])*init->scale);
  ------------------
  |  |   49|  38.7M|#define MULT_NORM(x) (x)
  ------------------
  559|  38.7M|    w+=2;
  560|  38.7M|    T+=2;
  561|  38.7M|  }
  562|   999k|}
mdct.c:mdct_butterflies:
  318|   999k|                             int points){
  319|       |
  320|   999k|  DATA_TYPE *T=init->trig;
  ------------------
  |  |   42|   999k|#define DATA_TYPE float
  ------------------
  321|   999k|  int stages=init->log2n-5;
  322|   999k|  int i,j;
  323|       |
  324|   999k|  if(--stages>0){
  ------------------
  |  Branch (324:6): [True: 999k, False: 0]
  ------------------
  325|   999k|    mdct_butterfly_first(T,x,points);
  326|   999k|  }
  327|       |
  328|  1.13M|  for(i=1;--stages>0;i++){
  ------------------
  |  Branch (328:11): [True: 138k, False: 999k]
  ------------------
  329|   560k|    for(j=0;j<(1<<i);j++)
  ------------------
  |  Branch (329:13): [True: 421k, False: 138k]
  ------------------
  330|   421k|      mdct_butterfly_generic(T,x+(points>>i)*j,points>>i,4<<i);
  331|   138k|  }
  332|       |
  333|  3.42M|  for(j=0;j<points;j+=32)
  ------------------
  |  Branch (333:11): [True: 2.42M, False: 999k]
  ------------------
  334|  2.42M|    mdct_butterfly_32(x+j);
  335|       |
  336|   999k|}
mdct.c:mdct_butterfly_first:
  218|   999k|                                        int points){
  219|       |
  220|   999k|  DATA_TYPE *x1        = x          + points      - 8;
  ------------------
  |  |   42|   999k|#define DATA_TYPE float
  ------------------
  221|   999k|  DATA_TYPE *x2        = x          + (points>>1) - 8;
  ------------------
  |  |   42|   999k|#define DATA_TYPE float
  ------------------
  222|   999k|  REG_TYPE   r0;
  ------------------
  |  |   43|   999k|#define REG_TYPE  float
  ------------------
  223|   999k|  REG_TYPE   r1;
  ------------------
  |  |   43|   999k|#define REG_TYPE  float
  ------------------
  224|       |
  225|  4.84M|  do{
  226|       |
  227|  4.84M|               r0      = x1[6]      -  x2[6];
  228|  4.84M|               r1      = x1[7]      -  x2[7];
  229|  4.84M|               x1[6]  += x2[6];
  230|  4.84M|               x1[7]  += x2[7];
  231|  4.84M|               x2[6]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
  ------------------
  |  |   49|  4.84M|#define MULT_NORM(x) (x)
  ------------------
  232|  4.84M|               x2[7]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
  ------------------
  |  |   49|  4.84M|#define MULT_NORM(x) (x)
  ------------------
  233|       |
  234|  4.84M|               r0      = x1[4]      -  x2[4];
  235|  4.84M|               r1      = x1[5]      -  x2[5];
  236|  4.84M|               x1[4]  += x2[4];
  237|  4.84M|               x1[5]  += x2[5];
  238|  4.84M|               x2[4]   = MULT_NORM(r1 * T[5]  +  r0 * T[4]);
  ------------------
  |  |   49|  4.84M|#define MULT_NORM(x) (x)
  ------------------
  239|  4.84M|               x2[5]   = MULT_NORM(r1 * T[4]  -  r0 * T[5]);
  ------------------
  |  |   49|  4.84M|#define MULT_NORM(x) (x)
  ------------------
  240|       |
  241|  4.84M|               r0      = x1[2]      -  x2[2];
  242|  4.84M|               r1      = x1[3]      -  x2[3];
  243|  4.84M|               x1[2]  += x2[2];
  244|  4.84M|               x1[3]  += x2[3];
  245|  4.84M|               x2[2]   = MULT_NORM(r1 * T[9]  +  r0 * T[8]);
  ------------------
  |  |   49|  4.84M|#define MULT_NORM(x) (x)
  ------------------
  246|  4.84M|               x2[3]   = MULT_NORM(r1 * T[8]  -  r0 * T[9]);
  ------------------
  |  |   49|  4.84M|#define MULT_NORM(x) (x)
  ------------------
  247|       |
  248|  4.84M|               r0      = x1[0]      -  x2[0];
  249|  4.84M|               r1      = x1[1]      -  x2[1];
  250|  4.84M|               x1[0]  += x2[0];
  251|  4.84M|               x1[1]  += x2[1];
  252|  4.84M|               x2[0]   = MULT_NORM(r1 * T[13] +  r0 * T[12]);
  ------------------
  |  |   49|  4.84M|#define MULT_NORM(x) (x)
  ------------------
  253|  4.84M|               x2[1]   = MULT_NORM(r1 * T[12] -  r0 * T[13]);
  ------------------
  |  |   49|  4.84M|#define MULT_NORM(x) (x)
  ------------------
  254|       |
  255|  4.84M|    x1-=8;
  256|  4.84M|    x2-=8;
  257|  4.84M|    T+=16;
  258|       |
  259|  4.84M|  }while(x2>=x);
  ------------------
  |  Branch (259:10): [True: 3.84M, False: 999k]
  ------------------
  260|   999k|}
mdct.c:mdct_butterfly_generic:
  266|   421k|                                          int trigint){
  267|       |
  268|   421k|  DATA_TYPE *x1        = x          + points      - 8;
  ------------------
  |  |   42|   421k|#define DATA_TYPE float
  ------------------
  269|   421k|  DATA_TYPE *x2        = x          + (points>>1) - 8;
  ------------------
  |  |   42|   421k|#define DATA_TYPE float
  ------------------
  270|   421k|  REG_TYPE   r0;
  ------------------
  |  |   43|   421k|#define REG_TYPE  float
  ------------------
  271|   421k|  REG_TYPE   r1;
  ------------------
  |  |   43|   421k|#define REG_TYPE  float
  ------------------
  272|       |
  273|  2.48M|  do{
  274|       |
  275|  2.48M|               r0      = x1[6]      -  x2[6];
  276|  2.48M|               r1      = x1[7]      -  x2[7];
  277|  2.48M|               x1[6]  += x2[6];
  278|  2.48M|               x1[7]  += x2[7];
  279|  2.48M|               x2[6]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
  ------------------
  |  |   49|  2.48M|#define MULT_NORM(x) (x)
  ------------------
  280|  2.48M|               x2[7]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
  ------------------
  |  |   49|  2.48M|#define MULT_NORM(x) (x)
  ------------------
  281|       |
  282|  2.48M|               T+=trigint;
  283|       |
  284|  2.48M|               r0      = x1[4]      -  x2[4];
  285|  2.48M|               r1      = x1[5]      -  x2[5];
  286|  2.48M|               x1[4]  += x2[4];
  287|  2.48M|               x1[5]  += x2[5];
  288|  2.48M|               x2[4]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
  ------------------
  |  |   49|  2.48M|#define MULT_NORM(x) (x)
  ------------------
  289|  2.48M|               x2[5]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
  ------------------
  |  |   49|  2.48M|#define MULT_NORM(x) (x)
  ------------------
  290|       |
  291|  2.48M|               T+=trigint;
  292|       |
  293|  2.48M|               r0      = x1[2]      -  x2[2];
  294|  2.48M|               r1      = x1[3]      -  x2[3];
  295|  2.48M|               x1[2]  += x2[2];
  296|  2.48M|               x1[3]  += x2[3];
  297|  2.48M|               x2[2]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
  ------------------
  |  |   49|  2.48M|#define MULT_NORM(x) (x)
  ------------------
  298|  2.48M|               x2[3]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
  ------------------
  |  |   49|  2.48M|#define MULT_NORM(x) (x)
  ------------------
  299|       |
  300|  2.48M|               T+=trigint;
  301|       |
  302|  2.48M|               r0      = x1[0]      -  x2[0];
  303|  2.48M|               r1      = x1[1]      -  x2[1];
  304|  2.48M|               x1[0]  += x2[0];
  305|  2.48M|               x1[1]  += x2[1];
  306|  2.48M|               x2[0]   = MULT_NORM(r1 * T[1]  +  r0 * T[0]);
  ------------------
  |  |   49|  2.48M|#define MULT_NORM(x) (x)
  ------------------
  307|  2.48M|               x2[1]   = MULT_NORM(r1 * T[0]  -  r0 * T[1]);
  ------------------
  |  |   49|  2.48M|#define MULT_NORM(x) (x)
  ------------------
  308|       |
  309|  2.48M|               T+=trigint;
  310|  2.48M|    x1-=8;
  311|  2.48M|    x2-=8;
  312|       |
  313|  2.48M|  }while(x2>=x);
  ------------------
  |  Branch (313:10): [True: 2.05M, False: 421k]
  ------------------
  314|   421k|}
mdct.c:mdct_butterfly_32:
  152|  2.42M|STIN void mdct_butterfly_32(DATA_TYPE *x){
  153|  2.42M|  REG_TYPE r0     = x[30] - x[14];
  ------------------
  |  |   43|  2.42M|#define REG_TYPE  float
  ------------------
  154|  2.42M|  REG_TYPE r1     = x[31] - x[15];
  ------------------
  |  |   43|  2.42M|#define REG_TYPE  float
  ------------------
  155|       |
  156|  2.42M|           x[30] +=         x[14];
  157|  2.42M|           x[31] +=         x[15];
  158|  2.42M|           x[14]  =         r0;
  159|  2.42M|           x[15]  =         r1;
  160|       |
  161|  2.42M|           r0     = x[28] - x[12];
  162|  2.42M|           r1     = x[29] - x[13];
  163|  2.42M|           x[28] +=         x[12];
  164|  2.42M|           x[29] +=         x[13];
  165|  2.42M|           x[12]  = MULT_NORM( r0 * cPI1_8  -  r1 * cPI3_8 );
  ------------------
  |  |   49|  2.42M|#define MULT_NORM(x) (x)
  ------------------
  166|  2.42M|           x[13]  = MULT_NORM( r0 * cPI3_8  +  r1 * cPI1_8 );
  ------------------
  |  |   49|  2.42M|#define MULT_NORM(x) (x)
  ------------------
  167|       |
  168|  2.42M|           r0     = x[26] - x[10];
  169|  2.42M|           r1     = x[27] - x[11];
  170|  2.42M|           x[26] +=         x[10];
  171|  2.42M|           x[27] +=         x[11];
  172|  2.42M|           x[10]  = MULT_NORM(( r0  - r1 ) * cPI2_8);
  ------------------
  |  |   49|  2.42M|#define MULT_NORM(x) (x)
  ------------------
  173|  2.42M|           x[11]  = MULT_NORM(( r0  + r1 ) * cPI2_8);
  ------------------
  |  |   49|  2.42M|#define MULT_NORM(x) (x)
  ------------------
  174|       |
  175|  2.42M|           r0     = x[24] - x[8];
  176|  2.42M|           r1     = x[25] - x[9];
  177|  2.42M|           x[24] += x[8];
  178|  2.42M|           x[25] += x[9];
  179|  2.42M|           x[8]   = MULT_NORM( r0 * cPI3_8  -  r1 * cPI1_8 );
  ------------------
  |  |   49|  2.42M|#define MULT_NORM(x) (x)
  ------------------
  180|  2.42M|           x[9]   = MULT_NORM( r1 * cPI3_8  +  r0 * cPI1_8 );
  ------------------
  |  |   49|  2.42M|#define MULT_NORM(x) (x)
  ------------------
  181|       |
  182|  2.42M|           r0     = x[22] - x[6];
  183|  2.42M|           r1     = x[7]  - x[23];
  184|  2.42M|           x[22] += x[6];
  185|  2.42M|           x[23] += x[7];
  186|  2.42M|           x[6]   = r1;
  187|  2.42M|           x[7]   = r0;
  188|       |
  189|  2.42M|           r0     = x[4]  - x[20];
  190|  2.42M|           r1     = x[5]  - x[21];
  191|  2.42M|           x[20] += x[4];
  192|  2.42M|           x[21] += x[5];
  193|  2.42M|           x[4]   = MULT_NORM( r1 * cPI1_8  +  r0 * cPI3_8 );
  ------------------
  |  |   49|  2.42M|#define MULT_NORM(x) (x)
  ------------------
  194|  2.42M|           x[5]   = MULT_NORM( r1 * cPI3_8  -  r0 * cPI1_8 );
  ------------------
  |  |   49|  2.42M|#define MULT_NORM(x) (x)
  ------------------
  195|       |
  196|  2.42M|           r0     = x[2]  - x[18];
  197|  2.42M|           r1     = x[3]  - x[19];
  198|  2.42M|           x[18] += x[2];
  199|  2.42M|           x[19] += x[3];
  200|  2.42M|           x[2]   = MULT_NORM(( r1  + r0 ) * cPI2_8);
  ------------------
  |  |   49|  2.42M|#define MULT_NORM(x) (x)
  ------------------
  201|  2.42M|           x[3]   = MULT_NORM(( r1  - r0 ) * cPI2_8);
  ------------------
  |  |   49|  2.42M|#define MULT_NORM(x) (x)
  ------------------
  202|       |
  203|  2.42M|           r0     = x[0]  - x[16];
  204|  2.42M|           r1     = x[1]  - x[17];
  205|  2.42M|           x[16] += x[0];
  206|  2.42M|           x[17] += x[1];
  207|  2.42M|           x[0]   = MULT_NORM( r1 * cPI3_8  +  r0 * cPI1_8 );
  ------------------
  |  |   49|  2.42M|#define MULT_NORM(x) (x)
  ------------------
  208|  2.42M|           x[1]   = MULT_NORM( r1 * cPI1_8  -  r0 * cPI3_8 );
  ------------------
  |  |   49|  2.42M|#define MULT_NORM(x) (x)
  ------------------
  209|       |
  210|  2.42M|           mdct_butterfly_16(x);
  211|  2.42M|           mdct_butterfly_16(x+16);
  212|       |
  213|  2.42M|}
mdct.c:mdct_butterfly_16:
  117|  4.84M|STIN void mdct_butterfly_16(DATA_TYPE *x){
  118|  4.84M|  REG_TYPE r0     = x[1]  - x[9];
  ------------------
  |  |   43|  4.84M|#define REG_TYPE  float
  ------------------
  119|  4.84M|  REG_TYPE r1     = x[0]  - x[8];
  ------------------
  |  |   43|  4.84M|#define REG_TYPE  float
  ------------------
  120|       |
  121|  4.84M|           x[8]  += x[0];
  122|  4.84M|           x[9]  += x[1];
  123|  4.84M|           x[0]   = MULT_NORM((r0   + r1) * cPI2_8);
  ------------------
  |  |   49|  4.84M|#define MULT_NORM(x) (x)
  ------------------
  124|  4.84M|           x[1]   = MULT_NORM((r0   - r1) * cPI2_8);
  ------------------
  |  |   49|  4.84M|#define MULT_NORM(x) (x)
  ------------------
  125|       |
  126|  4.84M|           r0     = x[3]  - x[11];
  127|  4.84M|           r1     = x[10] - x[2];
  128|  4.84M|           x[10] += x[2];
  129|  4.84M|           x[11] += x[3];
  130|  4.84M|           x[2]   = r0;
  131|  4.84M|           x[3]   = r1;
  132|       |
  133|  4.84M|           r0     = x[12] - x[4];
  134|  4.84M|           r1     = x[13] - x[5];
  135|  4.84M|           x[12] += x[4];
  136|  4.84M|           x[13] += x[5];
  137|  4.84M|           x[4]   = MULT_NORM((r0   - r1) * cPI2_8);
  ------------------
  |  |   49|  4.84M|#define MULT_NORM(x) (x)
  ------------------
  138|  4.84M|           x[5]   = MULT_NORM((r0   + r1) * cPI2_8);
  ------------------
  |  |   49|  4.84M|#define MULT_NORM(x) (x)
  ------------------
  139|       |
  140|  4.84M|           r0     = x[14] - x[6];
  141|  4.84M|           r1     = x[15] - x[7];
  142|  4.84M|           x[14] += x[6];
  143|  4.84M|           x[15] += x[7];
  144|  4.84M|           x[6]  = r0;
  145|  4.84M|           x[7]  = r1;
  146|       |
  147|  4.84M|           mdct_butterfly_8(x);
  148|  4.84M|           mdct_butterfly_8(x+8);
  149|  4.84M|}
mdct.c:mdct_butterfly_8:
   93|  9.68M|STIN void mdct_butterfly_8(DATA_TYPE *x){
   94|  9.68M|  REG_TYPE r0   = x[6] + x[2];
  ------------------
  |  |   43|  9.68M|#define REG_TYPE  float
  ------------------
   95|  9.68M|  REG_TYPE r1   = x[6] - x[2];
  ------------------
  |  |   43|  9.68M|#define REG_TYPE  float
  ------------------
   96|  9.68M|  REG_TYPE r2   = x[4] + x[0];
  ------------------
  |  |   43|  9.68M|#define REG_TYPE  float
  ------------------
   97|  9.68M|  REG_TYPE r3   = x[4] - x[0];
  ------------------
  |  |   43|  9.68M|#define REG_TYPE  float
  ------------------
   98|       |
   99|  9.68M|           x[6] = r0   + r2;
  100|  9.68M|           x[4] = r0   - r2;
  101|       |
  102|  9.68M|           r0   = x[5] - x[1];
  103|  9.68M|           r2   = x[7] - x[3];
  104|  9.68M|           x[0] = r1   + r0;
  105|  9.68M|           x[2] = r1   - r0;
  106|       |
  107|  9.68M|           r0   = x[5] + x[1];
  108|  9.68M|           r1   = x[7] + x[3];
  109|  9.68M|           x[3] = r2   + r3;
  110|  9.68M|           x[1] = r2   - r3;
  111|  9.68M|           x[7] = r1   + r0;
  112|  9.68M|           x[5] = r1   - r0;
  113|       |
  114|  9.68M|}
mdct.c:mdct_bitreverse:
  347|   999k|                            DATA_TYPE *x){
  348|   999k|  int        n       = init->n;
  349|   999k|  int       *bit     = init->bitrev;
  350|   999k|  DATA_TYPE *w0      = x;
  ------------------
  |  |   42|   999k|#define DATA_TYPE float
  ------------------
  351|   999k|  DATA_TYPE *w1      = x = w0+(n>>1);
  ------------------
  |  |   42|   999k|#define DATA_TYPE float
  ------------------
  352|   999k|  DATA_TYPE *T       = init->trig+n;
  ------------------
  |  |   42|   999k|#define DATA_TYPE float
  ------------------
  353|       |
  354|  9.68M|  do{
  355|  9.68M|    DATA_TYPE *x0    = x+bit[0];
  ------------------
  |  |   42|  9.68M|#define DATA_TYPE float
  ------------------
  356|  9.68M|    DATA_TYPE *x1    = x+bit[1];
  ------------------
  |  |   42|  9.68M|#define DATA_TYPE float
  ------------------
  357|       |
  358|  9.68M|    REG_TYPE  r0     = x0[1]  - x1[1];
  ------------------
  |  |   43|  9.68M|#define REG_TYPE  float
  ------------------
  359|  9.68M|    REG_TYPE  r1     = x0[0]  + x1[0];
  ------------------
  |  |   43|  9.68M|#define REG_TYPE  float
  ------------------
  360|  9.68M|    REG_TYPE  r2     = MULT_NORM(r1     * T[0]   + r0 * T[1]);
  ------------------
  |  |   43|  9.68M|#define REG_TYPE  float
  ------------------
                  REG_TYPE  r2     = MULT_NORM(r1     * T[0]   + r0 * T[1]);
  ------------------
  |  |   49|  9.68M|#define MULT_NORM(x) (x)
  ------------------
  361|  9.68M|    REG_TYPE  r3     = MULT_NORM(r1     * T[1]   - r0 * T[0]);
  ------------------
  |  |   43|  9.68M|#define REG_TYPE  float
  ------------------
                  REG_TYPE  r3     = MULT_NORM(r1     * T[1]   - r0 * T[0]);
  ------------------
  |  |   49|  9.68M|#define MULT_NORM(x) (x)
  ------------------
  362|       |
  363|  9.68M|              w1    -= 4;
  364|       |
  365|  9.68M|              r0     = HALVE(x0[1] + x1[1]);
  ------------------
  |  |   50|  9.68M|#define HALVE(x) ((x)*.5f)
  ------------------
  366|  9.68M|              r1     = HALVE(x0[0] - x1[0]);
  ------------------
  |  |   50|  9.68M|#define HALVE(x) ((x)*.5f)
  ------------------
  367|       |
  368|  9.68M|              w0[0]  = r0     + r2;
  369|  9.68M|              w1[2]  = r0     - r2;
  370|  9.68M|              w0[1]  = r1     + r3;
  371|  9.68M|              w1[3]  = r3     - r1;
  372|       |
  373|  9.68M|              x0     = x+bit[2];
  374|  9.68M|              x1     = x+bit[3];
  375|       |
  376|  9.68M|              r0     = x0[1]  - x1[1];
  377|  9.68M|              r1     = x0[0]  + x1[0];
  378|  9.68M|              r2     = MULT_NORM(r1     * T[2]   + r0 * T[3]);
  ------------------
  |  |   49|  9.68M|#define MULT_NORM(x) (x)
  ------------------
  379|  9.68M|              r3     = MULT_NORM(r1     * T[3]   - r0 * T[2]);
  ------------------
  |  |   49|  9.68M|#define MULT_NORM(x) (x)
  ------------------
  380|       |
  381|  9.68M|              r0     = HALVE(x0[1] + x1[1]);
  ------------------
  |  |   50|  9.68M|#define HALVE(x) ((x)*.5f)
  ------------------
  382|  9.68M|              r1     = HALVE(x0[0] - x1[0]);
  ------------------
  |  |   50|  9.68M|#define HALVE(x) ((x)*.5f)
  ------------------
  383|       |
  384|  9.68M|              w0[2]  = r0     + r2;
  385|  9.68M|              w1[0]  = r0     - r2;
  386|  9.68M|              w0[3]  = r1     + r3;
  387|  9.68M|              w1[1]  = r3     - r1;
  388|       |
  389|  9.68M|              T     += 4;
  390|  9.68M|              bit   += 4;
  391|  9.68M|              w0    += 4;
  392|       |
  393|  9.68M|  }while(w0<w1);
  ------------------
  |  Branch (393:10): [True: 8.68M, False: 999k]
  ------------------
  394|   999k|}

_vp_global_look:
   35|  2.27k|vorbis_look_psy_global *_vp_global_look(vorbis_info *vi){
   36|  2.27k|  codec_setup_info *ci=vi->codec_setup;
   37|  2.27k|  vorbis_info_psy_global *gi=&ci->psy_g_param;
   38|  2.27k|  vorbis_look_psy_global *look=_ogg_calloc(1,sizeof(*look));
  ------------------
  |  |   22|  2.27k|#define _ogg_calloc  calloc
  ------------------
   39|       |
   40|  2.27k|  look->channels=vi->channels;
   41|       |
   42|  2.27k|  look->ampmax=-9999.;
   43|  2.27k|  look->gi=gi;
   44|  2.27k|  return(look);
   45|  2.27k|}
_vp_global_free:
   47|  2.27k|void _vp_global_free(vorbis_look_psy_global *look){
   48|  2.27k|  if(look){
  ------------------
  |  Branch (48:6): [True: 2.27k, False: 0]
  ------------------
   49|  2.27k|    memset(look,0,sizeof(*look));
   50|  2.27k|    _ogg_free(look);
  ------------------
  |  |   24|  2.27k|#define _ogg_free    free
  ------------------
   51|  2.27k|  }
   52|  2.27k|}
_vi_psy_free:
   61|  8.29k|void _vi_psy_free(vorbis_info_psy *i){
   62|  8.29k|  if(i){
  ------------------
  |  Branch (62:6): [True: 8.29k, False: 0]
  ------------------
   63|  8.29k|    memset(i,0,sizeof(*i));
   64|  8.29k|    _ogg_free(i);
  ------------------
  |  |   24|  8.29k|#define _ogg_free    free
  ------------------
   65|  8.29k|  }
   66|  8.29k|}
_vp_psy_init:
  267|  8.29k|                  vorbis_info_psy_global *gi,int n,long rate){
  268|  8.29k|  long i,j,lo=-99,hi=1;
  269|  8.29k|  long maxoc;
  270|  8.29k|  memset(p,0,sizeof(*p));
  271|       |
  272|  8.29k|  p->eighth_octave_lines=gi->eighth_octave_lines;
  273|  8.29k|  p->shiftoc=rint(log(gi->eighth_octave_lines*8.f)/log(2.f))-1;
  274|       |
  275|  8.29k|  p->firstoc=toOC(.25f*rate*.5/n)*(1<<(p->shiftoc+1))-gi->eighth_octave_lines;
  ------------------
  |  |   86|  8.29k|#define toOC(n)     (log(n)*1.442695f-5.965784f)
  ------------------
  276|  8.29k|  maxoc=toOC((n+.25f)*rate*.5/n)*(1<<(p->shiftoc+1))+.5f;
  ------------------
  |  |   86|  8.29k|#define toOC(n)     (log(n)*1.442695f-5.965784f)
  ------------------
  277|  8.29k|  p->total_octave_lines=maxoc-p->firstoc+1;
  278|  8.29k|  p->ath=_ogg_malloc(n*sizeof(*p->ath));
  ------------------
  |  |   21|  8.29k|#define _ogg_malloc  malloc
  ------------------
  279|       |
  280|  8.29k|  p->octave=_ogg_malloc(n*sizeof(*p->octave));
  ------------------
  |  |   21|  8.29k|#define _ogg_malloc  malloc
  ------------------
  281|  8.29k|  p->bark=_ogg_malloc(n*sizeof(*p->bark));
  ------------------
  |  |   21|  8.29k|#define _ogg_malloc  malloc
  ------------------
  282|  8.29k|  p->vi=vi;
  283|  8.29k|  p->n=n;
  284|  8.29k|  p->rate=rate;
  285|       |
  286|       |  /* AoTuV HF weighting */
  287|  8.29k|  p->m_val = 1.;
  288|  8.29k|  if(rate < 26000) p->m_val = 0;
  ------------------
  |  Branch (288:6): [True: 1.86k, False: 6.43k]
  ------------------
  289|  6.43k|  else if(rate < 38000) p->m_val = .94;   /* 32kHz */
  ------------------
  |  Branch (289:11): [True: 1.84k, False: 4.59k]
  ------------------
  290|  4.59k|  else if(rate > 46000) p->m_val = 1.275; /* 48kHz */
  ------------------
  |  Branch (290:11): [True: 3.38k, False: 1.20k]
  ------------------
  291|       |
  292|       |  /* set up the lookups for a given blocksize and sample rate */
  293|       |
  294|   730k|  for(i=0,j=0;i<MAX_ATH-1;i++){
  ------------------
  |  |   23|   730k|#define MAX_ATH 88
  ------------------
  |  Branch (294:15): [True: 721k, False: 8.29k]
  ------------------
  295|   721k|    int endpos=rint(fromOC((i+1)*.125-2.)*2*n/rate);
  ------------------
  |  |   87|   721k|#define fromOC(o)   (exp(((o)+5.965784f)*.693147f))
  ------------------
  296|   721k|    float base=ATH[i];
  297|   721k|    if(j<endpos){
  ------------------
  |  Branch (297:8): [True: 447k, False: 274k]
  ------------------
  298|   447k|      float delta=(ATH[i+1]-base)/(endpos-j);
  299|  3.98M|      for(;j<endpos && j<n;j++){
  ------------------
  |  Branch (299:12): [True: 3.58M, False: 396k]
  |  Branch (299:24): [True: 3.53M, False: 50.9k]
  ------------------
  300|  3.53M|        p->ath[j]=base+100.;
  301|  3.53M|        base+=delta;
  302|  3.53M|      }
  303|   447k|    }
  304|   721k|  }
  305|       |
  306|   852k|  for(;j<n;j++){
  ------------------
  |  Branch (306:8): [True: 844k, False: 8.29k]
  ------------------
  307|   844k|    p->ath[j]=p->ath[j-1];
  308|   844k|  }
  309|       |
  310|  4.38M|  for(i=0;i<n;i++){
  ------------------
  |  Branch (310:11): [True: 4.37M, False: 8.29k]
  ------------------
  311|  4.37M|    float bark=toBARK(rate/(2*n)*i);
  ------------------
  |  |   78|  4.37M|#define toBARK(n)   (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))
  ------------------
  312|       |
  313|  9.12M|    for(;lo+vi->noisewindowlomin<i &&
  ------------------
  |  Branch (313:10): [True: 8.24M, False: 874k]
  ------------------
  314|  8.24M|          toBARK(rate/(2*n)*lo)<(bark-vi->noisewindowlo);lo++);
  ------------------
  |  |   78|  8.24M|#define toBARK(n)   (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))
  ------------------
  |  Branch (314:11): [True: 4.74M, False: 3.50M]
  ------------------
  315|       |
  316|  8.75M|    for(;hi<=n && (hi<i+vi->noisewindowhimin ||
  ------------------
  |  Branch (316:10): [True: 8.30M, False: 450k]
  |  Branch (316:20): [True: 787k, False: 7.51M]
  ------------------
  317|  7.51M|          toBARK(rate/(2*n)*hi)<(bark+vi->noisewindowhi));hi++);
  ------------------
  |  |   78|  7.51M|#define toBARK(n)   (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))
  ------------------
  |  Branch (317:11): [True: 3.59M, False: 3.92M]
  ------------------
  318|       |
  319|  4.37M|    p->bark[i]=((lo-1)*(1<<16))+(hi-1);
  320|       |
  321|  4.37M|  }
  322|       |
  323|  4.38M|  for(i=0;i<n;i++)
  ------------------
  |  Branch (323:11): [True: 4.37M, False: 8.29k]
  ------------------
  324|  4.37M|    p->octave[i]=toOC((i+.25f)*.5*rate/n)*(1<<(p->shiftoc+1))+.5f;
  ------------------
  |  |   86|  4.37M|#define toOC(n)     (log(n)*1.442695f-5.965784f)
  ------------------
  325|       |
  326|  8.29k|  p->tonecurves=setup_tone_curves(vi->toneatt,rate*.5/n,n,
  327|  8.29k|                                  vi->tone_centerboost,vi->tone_decay);
  328|       |
  329|       |  /* set up rolling noise median */
  330|  8.29k|  p->noiseoffset=_ogg_malloc(P_NOISECURVES*sizeof(*p->noiseoffset));
  ------------------
  |  |   21|  8.29k|#define _ogg_malloc  malloc
  ------------------
                p->noiseoffset=_ogg_malloc(P_NOISECURVES*sizeof(*p->noiseoffset));
  ------------------
  |  |   32|  8.29k|#define P_NOISECURVES 3
  ------------------
  331|  33.1k|  for(i=0;i<P_NOISECURVES;i++)
  ------------------
  |  |   32|  33.1k|#define P_NOISECURVES 3
  ------------------
  |  Branch (331:11): [True: 24.8k, False: 8.29k]
  ------------------
  332|  24.8k|    p->noiseoffset[i]=_ogg_malloc(n*sizeof(**p->noiseoffset));
  ------------------
  |  |   21|  24.8k|#define _ogg_malloc  malloc
  ------------------
  333|       |
  334|  4.38M|  for(i=0;i<n;i++){
  ------------------
  |  Branch (334:11): [True: 4.37M, False: 8.29k]
  ------------------
  335|  4.37M|    float halfoc=toOC((i+.5)*rate/(2.*n))*2.;
  ------------------
  |  |   86|  4.37M|#define toOC(n)     (log(n)*1.442695f-5.965784f)
  ------------------
  336|  4.37M|    int inthalfoc;
  337|  4.37M|    float del;
  338|       |
  339|  4.37M|    if(halfoc<0)halfoc=0;
  ------------------
  |  Branch (339:8): [True: 13.8k, False: 4.36M]
  ------------------
  340|  4.37M|    if(halfoc>=P_BANDS-1)halfoc=P_BANDS-1;
  ------------------
  |  |   29|  4.37M|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
                  if(halfoc>=P_BANDS-1)halfoc=P_BANDS-1;
  ------------------
  |  |   29|  1.47M|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
  |  Branch (340:8): [True: 1.47M, False: 2.89M]
  ------------------
  341|  4.37M|    inthalfoc=(int)halfoc;
  342|       |    /*If we hit the P_BANDS-1 clamp above, inthalfoc+1 will be out of bounds,
  343|       |       even though it will have an interpolation weight of 0.
  344|       |      Shift the interval so we don't read past the end of the array.*/
  345|  4.37M|    if(inthalfoc>=P_BANDS-2)inthalfoc=P_BANDS-2;
  ------------------
  |  |   29|  4.37M|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
                  if(inthalfoc>=P_BANDS-2)inthalfoc=P_BANDS-2;
  ------------------
  |  |   29|  2.13M|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
  |  Branch (345:8): [True: 2.13M, False: 2.24M]
  ------------------
  346|  4.37M|    del=halfoc-inthalfoc;
  347|       |
  348|  17.5M|    for(j=0;j<P_NOISECURVES;j++)
  ------------------
  |  |   32|  17.5M|#define P_NOISECURVES 3
  ------------------
  |  Branch (348:13): [True: 13.1M, False: 4.37M]
  ------------------
  349|  13.1M|      p->noiseoffset[j][i]=
  350|  13.1M|        p->vi->noiseoff[j][inthalfoc]*(1.-del) +
  351|  13.1M|        p->vi->noiseoff[j][inthalfoc+1]*del;
  352|       |
  353|  4.37M|  }
  354|       |#if 0
  355|       |  {
  356|       |    static int ls=0;
  357|       |    _analysis_output_always("noiseoff0",ls,p->noiseoffset[0],n,1,0,0);
  358|       |    _analysis_output_always("noiseoff1",ls,p->noiseoffset[1],n,1,0,0);
  359|       |    _analysis_output_always("noiseoff2",ls++,p->noiseoffset[2],n,1,0,0);
  360|       |  }
  361|       |#endif
  362|  8.29k|}
_vp_psy_clear:
  364|  8.29k|void _vp_psy_clear(vorbis_look_psy *p){
  365|  8.29k|  int i,j;
  366|  8.29k|  if(p){
  ------------------
  |  Branch (366:6): [True: 8.29k, False: 0]
  ------------------
  367|  8.29k|    if(p->ath)_ogg_free(p->ath);
  ------------------
  |  |   24|  8.29k|#define _ogg_free    free
  ------------------
  |  Branch (367:8): [True: 8.29k, False: 0]
  ------------------
  368|  8.29k|    if(p->octave)_ogg_free(p->octave);
  ------------------
  |  |   24|  8.29k|#define _ogg_free    free
  ------------------
  |  Branch (368:8): [True: 8.29k, False: 0]
  ------------------
  369|  8.29k|    if(p->bark)_ogg_free(p->bark);
  ------------------
  |  |   24|  8.29k|#define _ogg_free    free
  ------------------
  |  Branch (369:8): [True: 8.29k, False: 0]
  ------------------
  370|  8.29k|    if(p->tonecurves){
  ------------------
  |  Branch (370:8): [True: 8.29k, False: 0]
  ------------------
  371|   149k|      for(i=0;i<P_BANDS;i++){
  ------------------
  |  |   29|   149k|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
  |  Branch (371:15): [True: 141k, False: 8.29k]
  ------------------
  372|  1.26M|        for(j=0;j<P_LEVELS;j++){
  ------------------
  |  |   30|  1.26M|#define P_LEVELS 8      /* 30dB to 100dB */
  ------------------
  |  Branch (372:17): [True: 1.12M, False: 141k]
  ------------------
  373|  1.12M|          _ogg_free(p->tonecurves[i][j]);
  ------------------
  |  |   24|  1.12M|#define _ogg_free    free
  ------------------
  374|  1.12M|        }
  375|   141k|        _ogg_free(p->tonecurves[i]);
  ------------------
  |  |   24|   141k|#define _ogg_free    free
  ------------------
  376|   141k|      }
  377|  8.29k|      _ogg_free(p->tonecurves);
  ------------------
  |  |   24|  8.29k|#define _ogg_free    free
  ------------------
  378|  8.29k|    }
  379|  8.29k|    if(p->noiseoffset){
  ------------------
  |  Branch (379:8): [True: 8.29k, False: 0]
  ------------------
  380|  33.1k|      for(i=0;i<P_NOISECURVES;i++){
  ------------------
  |  |   32|  33.1k|#define P_NOISECURVES 3
  ------------------
  |  Branch (380:15): [True: 24.8k, False: 8.29k]
  ------------------
  381|  24.8k|        _ogg_free(p->noiseoffset[i]);
  ------------------
  |  |   24|  24.8k|#define _ogg_free    free
  ------------------
  382|  24.8k|      }
  383|  8.29k|      _ogg_free(p->noiseoffset);
  ------------------
  |  |   24|  8.29k|#define _ogg_free    free
  ------------------
  384|  8.29k|    }
  385|  8.29k|    memset(p,0,sizeof(*p));
  386|  8.29k|  }
  387|  8.29k|}
_vp_noisemask:
  708|   103k|                   float *logmask){
  709|       |
  710|   103k|  int i,n=p->n;
  711|   103k|  float *work=alloca(n*sizeof(*work));
  712|       |
  713|   103k|  bark_noise_hybridmp(n,p->bark,logmdct,logmask,
  714|   103k|                      140.,-1);
  715|       |
  716|  20.2M|  for(i=0;i<n;i++)work[i]=logmdct[i]-logmask[i];
  ------------------
  |  Branch (716:11): [True: 20.1M, False: 103k]
  ------------------
  717|       |
  718|   103k|  bark_noise_hybridmp(n,p->bark,work,logmask,0.,
  719|   103k|                      p->vi->noisewindowfixed);
  720|       |
  721|  20.2M|  for(i=0;i<n;i++)work[i]=logmdct[i]-work[i];
  ------------------
  |  Branch (721:11): [True: 20.1M, False: 103k]
  ------------------
  722|       |
  723|       |#if 0
  724|       |  {
  725|       |    static int seq=0;
  726|       |
  727|       |    float work2[n];
  728|       |    for(i=0;i<n;i++){
  729|       |      work2[i]=logmask[i]+work[i];
  730|       |    }
  731|       |
  732|       |    if(seq&1)
  733|       |      _analysis_output("median2R",seq/2,work,n,1,0,0);
  734|       |    else
  735|       |      _analysis_output("median2L",seq/2,work,n,1,0,0);
  736|       |
  737|       |    if(seq&1)
  738|       |      _analysis_output("envelope2R",seq/2,work2,n,1,0,0);
  739|       |    else
  740|       |      _analysis_output("envelope2L",seq/2,work2,n,1,0,0);
  741|       |    seq++;
  742|       |  }
  743|       |#endif
  744|       |
  745|  20.2M|  for(i=0;i<n;i++){
  ------------------
  |  Branch (745:11): [True: 20.1M, False: 103k]
  ------------------
  746|  20.1M|    int dB=logmask[i]+.5;
  747|  20.1M|    if(dB>=NOISE_COMPAND_LEVELS)dB=NOISE_COMPAND_LEVELS-1;
  ------------------
  |  |   34|  20.1M|#define NOISE_COMPAND_LEVELS 40
  ------------------
                  if(dB>=NOISE_COMPAND_LEVELS)dB=NOISE_COMPAND_LEVELS-1;
  ------------------
  |  |   34|  2.00k|#define NOISE_COMPAND_LEVELS 40
  ------------------
  |  Branch (747:8): [True: 2.00k, False: 20.1M]
  ------------------
  748|  20.1M|    if(dB<0)dB=0;
  ------------------
  |  Branch (748:8): [True: 12.6k, False: 20.1M]
  ------------------
  749|  20.1M|    logmask[i]= work[i]+p->vi->noisecompand[dB];
  750|  20.1M|  }
  751|       |
  752|   103k|}
_vp_tonemask:
  758|   103k|                  float local_specmax){
  759|       |
  760|   103k|  int i,n=p->n;
  761|       |
  762|   103k|  float *seed=alloca(sizeof(*seed)*p->total_octave_lines);
  763|   103k|  float att=local_specmax+p->vi->ath_adjatt;
  764|  62.9M|  for(i=0;i<p->total_octave_lines;i++)seed[i]=NEGINF;
  ------------------
  |  |   31|  62.8M|#define NEGINF -9999.f
  ------------------
  |  Branch (764:11): [True: 62.8M, False: 103k]
  ------------------
  765|       |
  766|       |  /* set the ATH (floating below localmax, not global max by a
  767|       |     specified att) */
  768|   103k|  if(att<p->vi->ath_maxatt)att=p->vi->ath_maxatt;
  ------------------
  |  Branch (768:6): [True: 8.50k, False: 95.1k]
  ------------------
  769|       |
  770|  20.2M|  for(i=0;i<n;i++)
  ------------------
  |  Branch (770:11): [True: 20.1M, False: 103k]
  ------------------
  771|  20.1M|    logmask[i]=p->ath[i]+att;
  772|       |
  773|       |  /* tone masking */
  774|   103k|  seed_loop(p,(const float ***)p->tonecurves,logfft,logmask,seed,global_specmax);
  775|   103k|  max_seeds(p,seed,logmask);
  776|       |
  777|   103k|}
_vp_offset_and_mix:
  785|   103k|                        float *logmdct){
  786|   103k|  int i,n=p->n;
  787|   103k|  float de, coeffi, cx;/* AoTuV */
  788|   103k|  float toneatt=p->vi->tone_masteratt[offset_select];
  789|       |
  790|   103k|  cx = p->m_val;
  791|       |
  792|  20.2M|  for(i=0;i<n;i++){
  ------------------
  |  Branch (792:11): [True: 20.1M, False: 103k]
  ------------------
  793|  20.1M|    float val= noise[i]+p->noiseoffset[offset_select][i];
  794|  20.1M|    if(val>p->vi->noisemaxsupp)val=p->vi->noisemaxsupp;
  ------------------
  |  Branch (794:8): [True: 657k, False: 19.4M]
  ------------------
  795|  20.1M|    logmask[i]=max(val,tone[i]+toneatt);
  ------------------
  |  |   78|  20.1M|#  define max(x,y)  ((x)<(y)?(y):(x))
  |  |  ------------------
  |  |  |  Branch (78:22): [True: 10.5M, False: 9.58M]
  |  |  ------------------
  ------------------
  796|       |
  797|       |
  798|       |    /* AoTuV */
  799|       |    /** @ M1 **
  800|       |        The following codes improve a noise problem.
  801|       |        A fundamental idea uses the value of masking and carries out
  802|       |        the relative compensation of the MDCT.
  803|       |        However, this code is not perfect and all noise problems cannot be solved.
  804|       |        by Aoyumi @ 2004/04/18
  805|       |    */
  806|       |
  807|  20.1M|    if(offset_select == 1) {
  ------------------
  |  Branch (807:8): [True: 20.1M, False: 0]
  ------------------
  808|  20.1M|      coeffi = -17.2;       /* coeffi is a -17.2dB threshold */
  809|  20.1M|      val = val - logmdct[i];  /* val == mdct line value relative to floor in dB */
  810|       |
  811|  20.1M|      if(val > coeffi){
  ------------------
  |  Branch (811:10): [True: 14.9M, False: 5.20M]
  ------------------
  812|       |        /* mdct value is > -17.2 dB below floor */
  813|       |
  814|  14.9M|        de = 1.0-((val-coeffi)*0.005*cx);
  815|       |        /* pro-rated attenuation:
  816|       |           -0.00 dB boost if mdct value is -17.2dB (relative to floor)
  817|       |           -0.77 dB boost if mdct value is 0dB (relative to floor)
  818|       |           -1.64 dB boost if mdct value is +17.2dB (relative to floor)
  819|       |           etc... */
  820|       |
  821|  14.9M|        if(de < 0) de = 0.0001;
  ------------------
  |  Branch (821:12): [True: 257k, False: 14.6M]
  ------------------
  822|  14.9M|      }else
  823|       |        /* mdct value is <= -17.2 dB below floor */
  824|       |
  825|  5.20M|        de = 1.0-((val-coeffi)*0.0003*cx);
  826|       |      /* pro-rated attenuation:
  827|       |         +0.00 dB atten if mdct value is -17.2dB (relative to floor)
  828|       |         +0.45 dB atten if mdct value is -34.4dB (relative to floor)
  829|       |         etc... */
  830|       |
  831|  20.1M|      mdct[i] *= de;
  832|       |
  833|  20.1M|    }
  834|  20.1M|  }
  835|   103k|}
_vp_ampmax_decay:
  837|  58.1k|float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd){
  838|  58.1k|  vorbis_info *vi=vd->vi;
  839|  58.1k|  codec_setup_info *ci=vi->codec_setup;
  840|  58.1k|  vorbis_info_psy_global *gi=&ci->psy_g_param;
  841|       |
  842|  58.1k|  int n=ci->blocksizes[vd->W]/2;
  843|  58.1k|  float secs=(float)n/vi->rate;
  844|       |
  845|  58.1k|  amp+=secs*gi->ampmax_att_per_sec;
  846|  58.1k|  if(amp<-9999)amp=-9999;
  ------------------
  |  Branch (846:6): [True: 2.27k, False: 55.8k]
  ------------------
  847|  58.1k|  return(amp);
  848|  58.1k|}
_vp_couple_quantize_normalize:
 1022|  58.1k|                                   int     ch){
 1023|       |
 1024|  58.1k|  int i;
 1025|  58.1k|  int n = p->n;
 1026|  58.1k|  int partition=(p->vi->normal_p ? p->vi->normal_partition : 16);
  ------------------
  |  Branch (1026:18): [True: 58.1k, False: 0]
  ------------------
 1027|  58.1k|  int limit = g->coupling_pointlimit[p->vi->blockflag][blobno];
 1028|  58.1k|  float prepoint=stereo_threshholds[g->coupling_prepointamp[blobno]];
 1029|  58.1k|  float postpoint=stereo_threshholds[g->coupling_postpointamp[blobno]];
 1030|       |#if 0
 1031|       |  float de=0.1*p->m_val; /* a blend of the AoTuV M2 and M3 code here and below */
 1032|       |#endif
 1033|       |
 1034|       |  /* mdct is our raw mdct output, floor not removed. */
 1035|       |  /* inout passes in the ifloor, passes back quantized result */
 1036|       |
 1037|       |  /* unquantized energy (negative indicates amplitude has negative sign) */
 1038|  58.1k|  float **raw = alloca(ch*sizeof(*raw));
 1039|       |
 1040|       |  /* dual pupose; quantized energy (if flag set), othersize fabs(raw) */
 1041|  58.1k|  float **quant = alloca(ch*sizeof(*quant));
 1042|       |
 1043|       |  /* floor energy */
 1044|  58.1k|  float **floor = alloca(ch*sizeof(*floor));
 1045|       |
 1046|       |  /* flags indicating raw/quantized status of elements in raw vector */
 1047|  58.1k|  int   **flag  = alloca(ch*sizeof(*flag));
 1048|       |
 1049|       |  /* non-zero flag working vector */
 1050|  58.1k|  int    *nz    = alloca(ch*sizeof(*nz));
 1051|       |
 1052|       |  /* energy surplus/defecit tracking */
 1053|  58.1k|  float  *acc   = alloca((ch+vi->coupling_steps)*sizeof(*acc));
 1054|       |
 1055|       |  /* The threshold of a stereo is changed with the size of n */
 1056|  58.1k|  if(n > 1000)
  ------------------
  |  Branch (1056:6): [True: 1.58k, False: 56.5k]
  ------------------
 1057|  1.58k|    postpoint=stereo_threshholds_limited[g->coupling_postpointamp[blobno]];
 1058|       |
 1059|  58.1k|  raw[0]   = alloca(ch*partition*sizeof(**raw));
 1060|  58.1k|  quant[0] = alloca(ch*partition*sizeof(**quant));
 1061|  58.1k|  floor[0] = alloca(ch*partition*sizeof(**floor));
 1062|  58.1k|  flag[0]  = alloca(ch*partition*sizeof(**flag));
 1063|       |
 1064|   103k|  for(i=1;i<ch;i++){
  ------------------
  |  Branch (1064:11): [True: 45.4k, False: 58.1k]
  ------------------
 1065|  45.4k|    raw[i]   = &raw[0][partition*i];
 1066|  45.4k|    quant[i] = &quant[0][partition*i];
 1067|  45.4k|    floor[i] = &floor[0][partition*i];
 1068|  45.4k|    flag[i]  = &flag[0][partition*i];
 1069|  45.4k|  }
 1070|   166k|  for(i=0;i<ch+vi->coupling_steps;i++)
  ------------------
  |  Branch (1070:11): [True: 108k, False: 58.1k]
  ------------------
 1071|   108k|    acc[i]=0.f;
 1072|       |
 1073|  1.30M|  for(i=0;i<n;i+=partition){
  ------------------
  |  Branch (1073:11): [True: 1.24M, False: 58.1k]
  ------------------
 1074|  1.24M|    int k,j,jn = partition > n-i ? n-i : partition;
  ------------------
  |  Branch (1074:18): [True: 0, False: 1.24M]
  ------------------
 1075|  1.24M|    int step,track = 0;
 1076|       |
 1077|  1.24M|    memcpy(nz,nonzero,sizeof(*nz)*ch);
 1078|       |
 1079|       |    /* prefill */
 1080|  1.24M|    memset(flag[0],0,ch*partition*sizeof(**flag));
 1081|  3.36M|    for(k=0;k<ch;k++){
  ------------------
  |  Branch (1081:13): [True: 2.12M, False: 1.24M]
  ------------------
 1082|  2.12M|      int *iout = &iwork[k][i];
 1083|  2.12M|      if(nz[k]){
  ------------------
  |  Branch (1083:10): [True: 2.04M, False: 73.3k]
  ------------------
 1084|       |
 1085|  21.3M|        for(j=0;j<jn;j++)
  ------------------
  |  Branch (1085:17): [True: 19.2M, False: 2.04M]
  ------------------
 1086|  19.2M|          floor[k][j] = FLOOR1_fromdB_LOOKUP[iout[j]];
 1087|       |
 1088|  2.04M|        flag_lossless(limit,prepoint,postpoint,&mdct[k][i],floor[k],flag[k],i,jn);
 1089|       |
 1090|  21.3M|        for(j=0;j<jn;j++){
  ------------------
  |  Branch (1090:17): [True: 19.2M, False: 2.04M]
  ------------------
 1091|  19.2M|          quant[k][j] = raw[k][j] = mdct[k][i+j]*mdct[k][i+j];
 1092|  19.2M|          if(mdct[k][i+j]<0.f) raw[k][j]*=-1.f;
  ------------------
  |  Branch (1092:14): [True: 9.58M, False: 9.68M]
  ------------------
 1093|  19.2M|          floor[k][j]*=floor[k][j];
 1094|  19.2M|        }
 1095|       |
 1096|  2.04M|        acc[track]=noise_normalize(p,limit,raw[k],quant[k],floor[k],NULL,acc[track],i,jn,iout);
 1097|       |
 1098|  2.04M|      }else{
 1099|   924k|        for(j=0;j<jn;j++){
  ------------------
  |  Branch (1099:17): [True: 850k, False: 73.3k]
  ------------------
 1100|   850k|          floor[k][j] = 1e-10f;
 1101|   850k|          raw[k][j] = 0.f;
 1102|   850k|          quant[k][j] = 0.f;
 1103|   850k|          flag[k][j] = 0;
 1104|   850k|          iout[j]=0;
 1105|   850k|        }
 1106|  73.3k|        acc[track]=0.f;
 1107|  73.3k|      }
 1108|  2.12M|      track++;
 1109|  2.12M|    }
 1110|       |
 1111|       |    /* coupling */
 1112|  1.35M|    for(step=0;step<vi->coupling_steps;step++){
  ------------------
  |  Branch (1112:16): [True: 106k, False: 1.24M]
  ------------------
 1113|   106k|      int Mi = vi->coupling_mag[step];
 1114|   106k|      int Ai = vi->coupling_ang[step];
 1115|   106k|      int *iM = &iwork[Mi][i];
 1116|   106k|      int *iA = &iwork[Ai][i];
 1117|   106k|      float *reM = raw[Mi];
 1118|   106k|      float *reA = raw[Ai];
 1119|   106k|      float *qeM = quant[Mi];
 1120|   106k|      float *qeA = quant[Ai];
 1121|   106k|      float *floorM = floor[Mi];
 1122|   106k|      float *floorA = floor[Ai];
 1123|   106k|      int *fM = flag[Mi];
 1124|   106k|      int *fA = flag[Ai];
 1125|       |
 1126|   106k|      if(nz[Mi] || nz[Ai]){
  ------------------
  |  Branch (1126:10): [True: 95.4k, False: 10.8k]
  |  Branch (1126:20): [True: 1.36k, False: 9.50k]
  ------------------
 1127|  96.8k|        nz[Mi] = nz[Ai] = 1;
 1128|       |
 1129|   967k|        for(j=0;j<jn;j++){
  ------------------
  |  Branch (1129:17): [True: 870k, False: 96.8k]
  ------------------
 1130|       |
 1131|   870k|          if(j<sliding_lowpass-i){
  ------------------
  |  Branch (1131:14): [True: 870k, False: 0]
  ------------------
 1132|   870k|            if(fM[j] || fA[j]){
  ------------------
  |  Branch (1132:16): [True: 409k, False: 460k]
  |  Branch (1132:25): [True: 31.4k, False: 429k]
  ------------------
 1133|       |              /* lossless coupling */
 1134|       |
 1135|   440k|              reM[j] = fabs(reM[j])+fabs(reA[j]);
 1136|   440k|              qeM[j] = qeM[j]+qeA[j];
 1137|   440k|              fM[j]=fA[j]=1;
 1138|       |
 1139|       |              /* couple iM/iA */
 1140|   440k|              {
 1141|   440k|                int A = iM[j];
 1142|   440k|                int B = iA[j];
 1143|       |
 1144|   440k|                if(abs(A)>abs(B)){
  ------------------
  |  Branch (1144:20): [True: 151k, False: 289k]
  ------------------
 1145|   151k|                  iA[j]=(A>0?A-B:B-A);
  ------------------
  |  Branch (1145:26): [True: 76.4k, False: 75.3k]
  ------------------
 1146|   289k|                }else{
 1147|   289k|                  iA[j]=(B>0?A-B:B-A);
  ------------------
  |  Branch (1147:26): [True: 126k, False: 162k]
  ------------------
 1148|   289k|                  iM[j]=B;
 1149|   289k|                }
 1150|       |
 1151|       |                /* collapse two equivalent tuples to one */
 1152|   440k|                if(iA[j]>=abs(iM[j])*2){
  ------------------
  |  Branch (1152:20): [True: 37.9k, False: 402k]
  ------------------
 1153|  37.9k|                  iA[j]= -iA[j];
 1154|  37.9k|                  iM[j]= -iM[j];
 1155|  37.9k|                }
 1156|       |
 1157|   440k|              }
 1158|       |
 1159|   440k|            }else{
 1160|       |              /* lossy (point) coupling */
 1161|   429k|              if(j<limit-i){
  ------------------
  |  Branch (1161:18): [True: 99.4k, False: 329k]
  ------------------
 1162|       |                /* dipole */
 1163|  99.4k|                reM[j] += reA[j];
 1164|  99.4k|                qeM[j] = fabs(reM[j]);
 1165|   329k|              }else{
 1166|       |#if 0
 1167|       |                /* AoTuV */
 1168|       |                /** @ M2 **
 1169|       |                    The boost problem by the combination of noise normalization and point stereo is eased.
 1170|       |                    However, this is a temporary patch.
 1171|       |                    by Aoyumi @ 2004/04/18
 1172|       |                */
 1173|       |                float derate = (1.0 - de*((float)(j-limit+i) / (float)(n-limit)));
 1174|       |                /* elliptical */
 1175|       |                if(reM[j]+reA[j]<0){
 1176|       |                  reM[j] = - (qeM[j] = (fabs(reM[j])+fabs(reA[j]))*derate*derate);
 1177|       |                }else{
 1178|       |                  reM[j] =   (qeM[j] = (fabs(reM[j])+fabs(reA[j]))*derate*derate);
 1179|       |                }
 1180|       |#else
 1181|       |                /* elliptical */
 1182|   329k|                if(reM[j]+reA[j]<0){
  ------------------
  |  Branch (1182:20): [True: 164k, False: 165k]
  ------------------
 1183|   164k|                  reM[j] = - (qeM[j] = fabs(reM[j])+fabs(reA[j]));
 1184|   165k|                }else{
 1185|   165k|                  reM[j] =   (qeM[j] = fabs(reM[j])+fabs(reA[j]));
 1186|   165k|                }
 1187|   329k|#endif
 1188|       |
 1189|   329k|              }
 1190|   429k|              reA[j]=qeA[j]=0.f;
 1191|   429k|              fA[j]=1;
 1192|   429k|              iA[j]=0;
 1193|   429k|            }
 1194|   870k|          }
 1195|   870k|          floorM[j]=floorA[j]=floorM[j]+floorA[j];
 1196|   870k|        }
 1197|       |        /* normalize the resulting mag vector */
 1198|  96.8k|        acc[track]=noise_normalize(p,limit,raw[Mi],quant[Mi],floor[Mi],flag[Mi],acc[track],i,jn,iM);
 1199|  96.8k|        track++;
 1200|  96.8k|      }
 1201|   106k|    }
 1202|  1.24M|  }
 1203|       |
 1204|  63.2k|  for(i=0;i<vi->coupling_steps;i++){
  ------------------
  |  Branch (1204:11): [True: 5.06k, False: 58.1k]
  ------------------
 1205|       |    /* make sure coupling a zero and a nonzero channel results in two
 1206|       |       nonzero channels. */
 1207|  5.06k|    if(nonzero[vi->coupling_mag[i]] ||
  ------------------
  |  Branch (1207:8): [True: 4.57k, False: 490]
  ------------------
 1208|  4.65k|       nonzero[vi->coupling_ang[i]]){
  ------------------
  |  Branch (1208:8): [True: 75, False: 415]
  ------------------
 1209|  4.65k|      nonzero[vi->coupling_mag[i]]=1;
 1210|  4.65k|      nonzero[vi->coupling_ang[i]]=1;
 1211|  4.65k|    }
 1212|  5.06k|  }
 1213|  58.1k|}
psy.c:setup_tone_curves:
   86|  8.29k|                                  float center_boost, float center_decay_rate){
   87|  8.29k|  int i,j,k,m;
   88|  8.29k|  float ath[EHMER_MAX];
   89|  8.29k|  float workc[P_BANDS][P_LEVELS][EHMER_MAX];
   90|  8.29k|  float athc[P_LEVELS][EHMER_MAX];
   91|  8.29k|  float *brute_buffer=alloca(n*sizeof(*brute_buffer));
   92|       |
   93|  8.29k|  float ***ret=_ogg_malloc(sizeof(*ret)*P_BANDS);
  ------------------
  |  |   21|  8.29k|#define _ogg_malloc  malloc
  ------------------
                float ***ret=_ogg_malloc(sizeof(*ret)*P_BANDS);
  ------------------
  |  |   29|  8.29k|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
   94|       |
   95|  8.29k|  memset(workc,0,sizeof(workc));
   96|       |
   97|   149k|  for(i=0;i<P_BANDS;i++){
  ------------------
  |  |   29|   149k|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
  |  Branch (97:11): [True: 141k, False: 8.29k]
  ------------------
   98|       |    /* we add back in the ATH to avoid low level curves falling off to
   99|       |       -infinity and unnecessarily cutting off high level curves in the
  100|       |       curve limiting (last step). */
  101|       |
  102|       |    /* A half-band's settings must be valid over the whole band, and
  103|       |       it's better to mask too little than too much */
  104|   141k|    int ath_offset=i*4;
  105|  8.04M|    for(j=0;j<EHMER_MAX;j++){
  ------------------
  |  |   43|  8.04M|#define EHMER_MAX 56
  ------------------
  |  Branch (105:13): [True: 7.89M, False: 141k]
  ------------------
  106|  7.89M|      float min=999.;
  107|  39.4M|      for(k=0;k<4;k++)
  ------------------
  |  Branch (107:15): [True: 31.5M, False: 7.89M]
  ------------------
  108|  31.5M|        if(j+k+ath_offset<MAX_ATH){
  ------------------
  |  |   23|  31.5M|#define MAX_ATH 88
  ------------------
  |  Branch (108:12): [True: 26.3M, False: 5.22M]
  ------------------
  109|  26.3M|          if(min>ATH[j+k+ath_offset])min=ATH[j+k+ath_offset];
  ------------------
  |  Branch (109:14): [True: 17.0M, False: 9.36M]
  ------------------
  110|  26.3M|        }else{
  111|  5.22M|          if(min>ATH[MAX_ATH-1])min=ATH[MAX_ATH-1];
  ------------------
  |  |   23|  5.22M|#define MAX_ATH 88
  ------------------
                        if(min>ATH[MAX_ATH-1])min=ATH[MAX_ATH-1];
  ------------------
  |  |   23|  1.19M|#define MAX_ATH 88
  ------------------
  |  Branch (111:14): [True: 1.19M, False: 4.03M]
  ------------------
  112|  5.22M|        }
  113|  7.89M|      ath[j]=min;
  114|  7.89M|    }
  115|       |
  116|       |    /* copy curves into working space, replicate the 50dB curve to 30
  117|       |       and 40, replicate the 100dB curve to 110 */
  118|   987k|    for(j=0;j<6;j++)
  ------------------
  |  Branch (118:13): [True: 846k, False: 141k]
  ------------------
  119|   846k|      memcpy(workc[i][j+2],tonemasks[i][j],EHMER_MAX*sizeof(*tonemasks[i][j]));
  ------------------
  |  |   43|   846k|#define EHMER_MAX 56
  ------------------
  120|   141k|    memcpy(workc[i][0],tonemasks[i][0],EHMER_MAX*sizeof(*tonemasks[i][0]));
  ------------------
  |  |   43|   141k|#define EHMER_MAX 56
  ------------------
  121|   141k|    memcpy(workc[i][1],tonemasks[i][0],EHMER_MAX*sizeof(*tonemasks[i][0]));
  ------------------
  |  |   43|   141k|#define EHMER_MAX 56
  ------------------
  122|       |
  123|       |    /* apply centered curve boost/decay */
  124|  1.26M|    for(j=0;j<P_LEVELS;j++){
  ------------------
  |  |   30|  1.26M|#define P_LEVELS 8      /* 30dB to 100dB */
  ------------------
  |  Branch (124:13): [True: 1.12M, False: 141k]
  ------------------
  125|  64.3M|      for(k=0;k<EHMER_MAX;k++){
  ------------------
  |  |   43|  64.3M|#define EHMER_MAX 56
  ------------------
  |  Branch (125:15): [True: 63.1M, False: 1.12M]
  ------------------
  126|  63.1M|        float adj=center_boost+abs(EHMER_OFFSET-k)*center_decay_rate;
  ------------------
  |  |   42|  63.1M|#define EHMER_OFFSET 16
  ------------------
  127|  63.1M|        if(adj<0. && center_boost>0)adj=0.;
  ------------------
  |  Branch (127:12): [True: 499k, False: 62.6M]
  |  Branch (127:22): [True: 0, False: 499k]
  ------------------
  128|  63.1M|        if(adj>0. && center_boost<0)adj=0.;
  ------------------
  |  Branch (128:12): [True: 8.82M, False: 54.3M]
  |  Branch (128:22): [True: 8.82M, False: 0]
  ------------------
  129|  63.1M|        workc[i][j][k]+=adj;
  130|  63.1M|      }
  131|  1.12M|    }
  132|       |
  133|       |    /* normalize curves so the driving amplitude is 0dB */
  134|       |    /* make temp curves with the ATH overlayed */
  135|  1.26M|    for(j=0;j<P_LEVELS;j++){
  ------------------
  |  |   30|  1.26M|#define P_LEVELS 8      /* 30dB to 100dB */
  ------------------
  |  Branch (135:13): [True: 1.12M, False: 141k]
  ------------------
  136|  1.12M|      attenuate_curve(workc[i][j],curveatt_dB[i]+100.-(j<2?2:j)*10.-P_LEVEL_0);
  ------------------
  |  |   31|  1.12M|#define P_LEVEL_0 30.    /* 30 dB */
  ------------------
  |  Branch (136:56): [True: 282k, False: 846k]
  ------------------
  137|  1.12M|      memcpy(athc[j],ath,EHMER_MAX*sizeof(**athc));
  ------------------
  |  |   43|  1.12M|#define EHMER_MAX 56
  ------------------
  138|  1.12M|      attenuate_curve(athc[j],+100.-j*10.f-P_LEVEL_0);
  ------------------
  |  |   31|  1.12M|#define P_LEVEL_0 30.    /* 30 dB */
  ------------------
  139|  1.12M|      max_curve(athc[j],workc[i][j]);
  140|  1.12M|    }
  141|       |
  142|       |    /* Now limit the louder curves.
  143|       |
  144|       |       the idea is this: We don't know what the playback attenuation
  145|       |       will be; 0dB SL moves every time the user twiddles the volume
  146|       |       knob. So that means we have to use a single 'most pessimal' curve
  147|       |       for all masking amplitudes, right?  Wrong.  The *loudest* sound
  148|       |       can be in (we assume) a range of ...+100dB] SL.  However, sounds
  149|       |       20dB down will be in a range ...+80], 40dB down is from ...+60],
  150|       |       etc... */
  151|       |
  152|  1.12M|    for(j=1;j<P_LEVELS;j++){
  ------------------
  |  |   30|  1.12M|#define P_LEVELS 8      /* 30dB to 100dB */
  ------------------
  |  Branch (152:13): [True: 987k, False: 141k]
  ------------------
  153|   987k|      min_curve(athc[j],athc[j-1]);
  154|   987k|      min_curve(workc[i][j],athc[j]);
  155|   987k|    }
  156|   141k|  }
  157|       |
  158|   149k|  for(i=0;i<P_BANDS;i++){
  ------------------
  |  |   29|   149k|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
  |  Branch (158:11): [True: 141k, False: 8.29k]
  ------------------
  159|   141k|    int hi_curve,lo_curve,bin;
  160|   141k|    ret[i]=_ogg_malloc(sizeof(**ret)*P_LEVELS);
  ------------------
  |  |   21|   141k|#define _ogg_malloc  malloc
  ------------------
                  ret[i]=_ogg_malloc(sizeof(**ret)*P_LEVELS);
  ------------------
  |  |   30|   141k|#define P_LEVELS 8      /* 30dB to 100dB */
  ------------------
  161|       |
  162|       |    /* low frequency curves are measured with greater resolution than
  163|       |       the MDCT/FFT will actually give us; we want the curve applied
  164|       |       to the tone data to be pessimistic and thus apply the minimum
  165|       |       masking possible for a given bin.  That means that a single bin
  166|       |       could span more than one octave and that the curve will be a
  167|       |       composite of multiple octaves.  It also may mean that a single
  168|       |       bin may span > an eighth of an octave and that the eighth
  169|       |       octave values may also be composited. */
  170|       |
  171|       |    /* which octave curves will we be compositing? */
  172|   141k|    bin=floor(fromOC(i*.5)/binHz);
  ------------------
  |  |   87|   141k|#define fromOC(o)   (exp(((o)+5.965784f)*.693147f))
  ------------------
  173|   141k|    lo_curve=  ceil(toOC(bin*binHz+1)*2);
  ------------------
  |  |   86|   141k|#define toOC(n)     (log(n)*1.442695f-5.965784f)
  ------------------
  174|   141k|    hi_curve=  floor(toOC((bin+1)*binHz)*2);
  ------------------
  |  |   86|   141k|#define toOC(n)     (log(n)*1.442695f-5.965784f)
  ------------------
  175|   141k|    if(lo_curve>i)lo_curve=i;
  ------------------
  |  Branch (175:8): [True: 5.06k, False: 136k]
  ------------------
  176|   141k|    if(lo_curve<0)lo_curve=0;
  ------------------
  |  Branch (176:8): [True: 18.4k, False: 122k]
  ------------------
  177|   141k|    if(hi_curve>=P_BANDS)hi_curve=P_BANDS-1;
  ------------------
  |  |   29|   141k|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
                  if(hi_curve>=P_BANDS)hi_curve=P_BANDS-1;
  ------------------
  |  |   29|      0|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
  |  Branch (177:8): [True: 0, False: 141k]
  ------------------
  178|       |
  179|  1.26M|    for(m=0;m<P_LEVELS;m++){
  ------------------
  |  |   30|  1.26M|#define P_LEVELS 8      /* 30dB to 100dB */
  ------------------
  |  Branch (179:13): [True: 1.12M, False: 141k]
  ------------------
  180|  1.12M|      ret[i][m]=_ogg_malloc(sizeof(***ret)*(EHMER_MAX+2));
  ------------------
  |  |   21|  1.12M|#define _ogg_malloc  malloc
  ------------------
                    ret[i][m]=_ogg_malloc(sizeof(***ret)*(EHMER_MAX+2));
  ------------------
  |  |   43|  1.12M|#define EHMER_MAX 56
  ------------------
  181|       |
  182|   596M|      for(j=0;j<n;j++)brute_buffer[j]=999.;
  ------------------
  |  Branch (182:15): [True: 595M, False: 1.12M]
  ------------------
  183|       |
  184|       |      /* render the curve into bins, then pull values back into curve.
  185|       |         The point is that any inherent subsampling aliasing results in
  186|       |         a safe minimum */
  187|  2.93M|      for(k=lo_curve;k<=hi_curve;k++){
  ------------------
  |  Branch (187:22): [True: 1.80M, False: 1.12M]
  ------------------
  188|  1.80M|        int l=0;
  189|       |
  190|   102M|        for(j=0;j<EHMER_MAX;j++){
  ------------------
  |  |   43|   102M|#define EHMER_MAX 56
  ------------------
  |  Branch (190:17): [True: 101M, False: 1.80M]
  ------------------
  191|   101M|          int lo_bin= fromOC(j*.125+k*.5-2.0625)/binHz;
  ------------------
  |  |   87|   101M|#define fromOC(o)   (exp(((o)+5.965784f)*.693147f))
  ------------------
  192|   101M|          int hi_bin= fromOC(j*.125+k*.5-1.9375)/binHz+1;
  ------------------
  |  |   87|   101M|#define fromOC(o)   (exp(((o)+5.965784f)*.693147f))
  ------------------
  193|       |
  194|   101M|          if(lo_bin<0)lo_bin=0;
  ------------------
  |  Branch (194:14): [True: 0, False: 101M]
  ------------------
  195|   101M|          if(lo_bin>n)lo_bin=n;
  ------------------
  |  Branch (195:14): [True: 11.9M, False: 89.2M]
  ------------------
  196|   101M|          if(lo_bin<l)l=lo_bin;
  ------------------
  |  Branch (196:14): [True: 87.4M, False: 13.7M]
  ------------------
  197|   101M|          if(hi_bin<0)hi_bin=0;
  ------------------
  |  Branch (197:14): [True: 0, False: 101M]
  ------------------
  198|   101M|          if(hi_bin>n)hi_bin=n;
  ------------------
  |  Branch (198:14): [True: 12.5M, False: 88.6M]
  ------------------
  199|       |
  200|   608M|          for(;l<hi_bin && l<n;l++)
  ------------------
  |  Branch (200:16): [True: 506M, False: 101M]
  |  Branch (200:28): [True: 506M, False: 0]
  ------------------
  201|   506M|            if(brute_buffer[l]>workc[k][m][j])
  ------------------
  |  Branch (201:16): [True: 421M, False: 85.3M]
  ------------------
  202|   421M|              brute_buffer[l]=workc[k][m][j];
  203|   101M|        }
  204|       |
  205|   294M|        for(;l<n;l++)
  ------------------
  |  Branch (205:14): [True: 292M, False: 1.80M]
  ------------------
  206|   292M|          if(brute_buffer[l]>workc[k][m][EHMER_MAX-1])
  ------------------
  |  |   43|   292M|#define EHMER_MAX 56
  ------------------
  |  Branch (206:14): [True: 224M, False: 67.7M]
  ------------------
  207|   224M|            brute_buffer[l]=workc[k][m][EHMER_MAX-1];
  ------------------
  |  |   43|   224M|#define EHMER_MAX 56
  ------------------
  208|       |
  209|  1.80M|      }
  210|       |
  211|       |      /* be equally paranoid about being valid up to next half ocatve */
  212|  1.12M|      if(i+1<P_BANDS){
  ------------------
  |  |   29|  1.12M|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
  |  Branch (212:10): [True: 1.06M, False: 66.3k]
  ------------------
  213|  1.06M|        int l=0;
  214|  1.06M|        k=i+1;
  215|  60.5M|        for(j=0;j<EHMER_MAX;j++){
  ------------------
  |  |   43|  60.5M|#define EHMER_MAX 56
  ------------------
  |  Branch (215:17): [True: 59.4M, False: 1.06M]
  ------------------
  216|  59.4M|          int lo_bin= fromOC(j*.125+i*.5-2.0625)/binHz;
  ------------------
  |  |   87|  59.4M|#define fromOC(o)   (exp(((o)+5.965784f)*.693147f))
  ------------------
  217|  59.4M|          int hi_bin= fromOC(j*.125+i*.5-1.9375)/binHz+1;
  ------------------
  |  |   87|  59.4M|#define fromOC(o)   (exp(((o)+5.965784f)*.693147f))
  ------------------
  218|       |
  219|  59.4M|          if(lo_bin<0)lo_bin=0;
  ------------------
  |  Branch (219:14): [True: 0, False: 59.4M]
  ------------------
  220|  59.4M|          if(lo_bin>n)lo_bin=n;
  ------------------
  |  Branch (220:14): [True: 9.67M, False: 49.8M]
  ------------------
  221|  59.4M|          if(lo_bin<l)l=lo_bin;
  ------------------
  |  Branch (221:14): [True: 48.7M, False: 10.7M]
  ------------------
  222|  59.4M|          if(hi_bin<0)hi_bin=0;
  ------------------
  |  Branch (222:14): [True: 0, False: 59.4M]
  ------------------
  223|  59.4M|          if(hi_bin>n)hi_bin=n;
  ------------------
  |  Branch (223:14): [True: 10.2M, False: 49.2M]
  ------------------
  224|       |
  225|   479M|          for(;l<hi_bin && l<n;l++)
  ------------------
  |  Branch (225:16): [True: 420M, False: 59.4M]
  |  Branch (225:28): [True: 420M, False: 0]
  ------------------
  226|   420M|            if(brute_buffer[l]>workc[k][m][j])
  ------------------
  |  Branch (226:16): [True: 70.3M, False: 349M]
  ------------------
  227|  70.3M|              brute_buffer[l]=workc[k][m][j];
  228|  59.4M|        }
  229|       |
  230|   190M|        for(;l<n;l++)
  ------------------
  |  Branch (230:14): [True: 189M, False: 1.06M]
  ------------------
  231|   189M|          if(brute_buffer[l]>workc[k][m][EHMER_MAX-1])
  ------------------
  |  |   43|   189M|#define EHMER_MAX 56
  ------------------
  |  Branch (231:14): [True: 22.7M, False: 166M]
  ------------------
  232|  22.7M|            brute_buffer[l]=workc[k][m][EHMER_MAX-1];
  ------------------
  |  |   43|  22.7M|#define EHMER_MAX 56
  ------------------
  233|       |
  234|  1.06M|      }
  235|       |
  236|       |
  237|  64.3M|      for(j=0;j<EHMER_MAX;j++){
  ------------------
  |  |   43|  64.3M|#define EHMER_MAX 56
  ------------------
  |  Branch (237:15): [True: 63.1M, False: 1.12M]
  ------------------
  238|  63.1M|        int bin=fromOC(j*.125+i*.5-2.)/binHz;
  ------------------
  |  |   87|  63.1M|#define fromOC(o)   (exp(((o)+5.965784f)*.693147f))
  ------------------
  239|  63.1M|        if(bin<0){
  ------------------
  |  Branch (239:12): [True: 0, False: 63.1M]
  ------------------
  240|      0|          ret[i][m][j+2]=-999.;
  241|  63.1M|        }else{
  242|  63.1M|          if(bin>=n){
  ------------------
  |  Branch (242:14): [True: 12.2M, False: 50.9M]
  ------------------
  243|  12.2M|            ret[i][m][j+2]=-999.;
  244|  50.9M|          }else{
  245|  50.9M|            ret[i][m][j+2]=brute_buffer[bin];
  246|  50.9M|          }
  247|  63.1M|        }
  248|  63.1M|      }
  249|       |
  250|       |      /* add fenceposts */
  251|  12.6M|      for(j=0;j<EHMER_OFFSET;j++)
  ------------------
  |  |   42|  12.6M|#define EHMER_OFFSET 16
  ------------------
  |  Branch (251:15): [True: 12.4M, False: 129k]
  ------------------
  252|  12.4M|        if(ret[i][m][j+2]>-200.f)break;
  ------------------
  |  Branch (252:12): [True: 998k, False: 11.4M]
  ------------------
  253|  1.12M|      ret[i][m][0]=j;
  254|       |
  255|  32.1M|      for(j=EHMER_MAX-1;j>EHMER_OFFSET+1;j--)
  ------------------
  |  |   43|  1.12M|#define EHMER_MAX 56
  ------------------
                    for(j=EHMER_MAX-1;j>EHMER_OFFSET+1;j--)
  ------------------
  |  |   42|  32.1M|#define EHMER_OFFSET 16
  ------------------
  |  Branch (255:25): [True: 32.0M, False: 141k]
  ------------------
  256|  32.0M|        if(ret[i][m][j+2]>-200.f)
  ------------------
  |  Branch (256:12): [True: 987k, False: 31.0M]
  ------------------
  257|   987k|          break;
  258|  1.12M|      ret[i][m][1]=j;
  259|       |
  260|  1.12M|    }
  261|   141k|  }
  262|       |
  263|  8.29k|  return(ret);
  264|  8.29k|}
psy.c:attenuate_curve:
   79|  2.25M|static void attenuate_curve(float *c,float att){
   80|  2.25M|  int i;
   81|   128M|  for(i=0;i<EHMER_MAX;i++)
  ------------------
  |  |   43|   128M|#define EHMER_MAX 56
  ------------------
  |  Branch (81:11): [True: 126M, False: 2.25M]
  ------------------
   82|   126M|    c[i]+=att;
   83|  2.25M|}
psy.c:max_curve:
   74|  1.12M|                       float *c2){
   75|  1.12M|  int i;
   76|  64.3M|  for(i=0;i<EHMER_MAX;i++)if(c2[i]>c[i])c[i]=c2[i];
  ------------------
  |  |   43|  64.3M|#define EHMER_MAX 56
  ------------------
  |  Branch (76:11): [True: 63.1M, False: 1.12M]
  |  Branch (76:30): [True: 13.7M, False: 49.4M]
  ------------------
   77|  1.12M|}
psy.c:min_curve:
   69|  1.97M|                       float *c2){
   70|  1.97M|  int i;
   71|   112M|  for(i=0;i<EHMER_MAX;i++)if(c2[i]<c[i])c[i]=c2[i];
  ------------------
  |  |   43|   112M|#define EHMER_MAX 56
  ------------------
  |  Branch (71:11): [True: 110M, False: 1.97M]
  |  Branch (71:30): [True: 12.3M, False: 98.2M]
  ------------------
   72|  1.97M|}
psy.c:bark_noise_hybridmp:
  551|   207k|                                const int fixed){
  552|       |
  553|   207k|  float *N=alloca(n*sizeof(*N));
  554|   207k|  float *X=alloca(n*sizeof(*N));
  555|   207k|  float *XX=alloca(n*sizeof(*N));
  556|   207k|  float *Y=alloca(n*sizeof(*N));
  557|   207k|  float *XY=alloca(n*sizeof(*N));
  558|       |
  559|   207k|  float tN, tX, tXX, tY, tXY;
  560|   207k|  int i;
  561|       |
  562|   207k|  int lo, hi;
  563|   207k|  float R=0.f;
  564|   207k|  float A=0.f;
  565|   207k|  float B=0.f;
  566|   207k|  float D=1.f;
  567|   207k|  float w, x, y;
  568|       |
  569|   207k|  tN = tX = tXX = tY = tXY = 0.f;
  570|       |
  571|   207k|  y = f[0] + offset;
  572|   207k|  if (y < 1.f) y = 1.f;
  ------------------
  |  Branch (572:7): [True: 19.1k, False: 188k]
  ------------------
  573|       |
  574|   207k|  w = y * y * .5;
  575|       |
  576|   207k|  tN += w;
  577|   207k|  tX += w;
  578|   207k|  tY += w * y;
  579|       |
  580|   207k|  N[0] = tN;
  581|   207k|  X[0] = tX;
  582|   207k|  XX[0] = tXX;
  583|   207k|  Y[0] = tY;
  584|   207k|  XY[0] = tXY;
  585|       |
  586|  40.2M|  for (i = 1, x = 1.f; i < n; i++, x += 1.f) {
  ------------------
  |  Branch (586:24): [True: 40.0M, False: 207k]
  ------------------
  587|       |
  588|  40.0M|    y = f[i] + offset;
  589|  40.0M|    if (y < 1.f) y = 1.f;
  ------------------
  |  Branch (589:9): [True: 15.4M, False: 24.6M]
  ------------------
  590|       |
  591|  40.0M|    w = y * y;
  592|       |
  593|  40.0M|    tN += w;
  594|  40.0M|    tX += w * x;
  595|  40.0M|    tXX += w * x * x;
  596|  40.0M|    tY += w * y;
  597|  40.0M|    tXY += w * x * y;
  598|       |
  599|  40.0M|    N[i] = tN;
  600|  40.0M|    X[i] = tX;
  601|  40.0M|    XX[i] = tXX;
  602|  40.0M|    Y[i] = tY;
  603|  40.0M|    XY[i] = tXY;
  604|  40.0M|  }
  605|       |
  606|  1.40M|  for (i = 0, x = 0.f; i < n; i++, x += 1.f) {
  ------------------
  |  Branch (606:24): [True: 1.40M, False: 0]
  ------------------
  607|       |
  608|  1.40M|    lo = b[i] >> 16;
  609|  1.40M|    hi = b[i] & 0xffff;
  610|  1.40M|    if( lo>=0 || -lo>=n ) break;
  ------------------
  |  Branch (610:9): [True: 207k, False: 1.20M]
  |  Branch (610:18): [True: 0, False: 1.20M]
  ------------------
  611|  1.20M|    if( hi>=n ) break;
  ------------------
  |  Branch (611:9): [True: 0, False: 1.20M]
  ------------------
  612|       |
  613|  1.20M|    tN = N[hi] + N[-lo];
  614|  1.20M|    tX = X[hi] - X[-lo];
  615|  1.20M|    tXX = XX[hi] + XX[-lo];
  616|  1.20M|    tY = Y[hi] + Y[-lo];
  617|  1.20M|    tXY = XY[hi] - XY[-lo];
  618|       |
  619|  1.20M|    A = tY * tXX - tX * tXY;
  620|  1.20M|    B = tN * tXY - tX * tY;
  621|  1.20M|    D = tN * tXX - tX * tX;
  622|  1.20M|    R = (A + x * B) / D;
  623|  1.20M|    if (R < 0.f) R = 0.f;
  ------------------
  |  Branch (623:9): [True: 8.14k, False: 1.19M]
  ------------------
  624|       |
  625|  1.20M|    noise[i] = R - offset;
  626|  1.20M|  }
  627|       |
  628|  35.3M|  for ( ; i < n; i++, x += 1.f) {
  ------------------
  |  Branch (628:11): [True: 35.3M, False: 0]
  ------------------
  629|       |
  630|  35.3M|    lo = b[i] >> 16;
  631|  35.3M|    hi = b[i] & 0xffff;
  632|  35.3M|    if( lo<0 || lo>=n ) break;
  ------------------
  |  Branch (632:9): [True: 0, False: 35.3M]
  |  Branch (632:17): [True: 0, False: 35.3M]
  ------------------
  633|  35.3M|    if( hi>=n ) break;
  ------------------
  |  Branch (633:9): [True: 207k, False: 35.1M]
  ------------------
  634|       |
  635|  35.1M|    tN = N[hi] - N[lo];
  636|  35.1M|    tX = X[hi] - X[lo];
  637|  35.1M|    tXX = XX[hi] - XX[lo];
  638|  35.1M|    tY = Y[hi] - Y[lo];
  639|  35.1M|    tXY = XY[hi] - XY[lo];
  640|       |
  641|  35.1M|    A = tY * tXX - tX * tXY;
  642|  35.1M|    B = tN * tXY - tX * tY;
  643|  35.1M|    D = tN * tXX - tX * tX;
  644|  35.1M|    R = (A + x * B) / D;
  645|  35.1M|    if (R < 0.f) R = 0.f;
  ------------------
  |  Branch (645:9): [True: 115k, False: 35.0M]
  ------------------
  646|       |
  647|  35.1M|    noise[i] = R - offset;
  648|  35.1M|  }
  649|       |
  650|  4.13M|  for ( ; i < n; i++, x += 1.f) {
  ------------------
  |  Branch (650:11): [True: 3.93M, False: 207k]
  ------------------
  651|       |
  652|  3.93M|    R = (A + x * B) / D;
  653|  3.93M|    if (R < 0.f) R = 0.f;
  ------------------
  |  Branch (653:9): [True: 7.08k, False: 3.92M]
  ------------------
  654|       |
  655|  3.93M|    noise[i] = R - offset;
  656|  3.93M|  }
  657|       |
  658|   207k|  if (fixed <= 0) return;
  ------------------
  |  Branch (658:7): [True: 123k, False: 83.2k]
  ------------------
  659|       |
  660|   920k|  for (i = 0, x = 0.f; i < n; i++, x += 1.f) {
  ------------------
  |  Branch (660:24): [True: 920k, False: 0]
  ------------------
  661|   920k|    hi = i + fixed / 2;
  662|   920k|    lo = hi - fixed;
  663|   920k|    if ( hi>=n ) break;
  ------------------
  |  Branch (663:10): [True: 0, False: 920k]
  ------------------
  664|   920k|    if ( lo>=0 ) break;
  ------------------
  |  Branch (664:10): [True: 83.2k, False: 837k]
  ------------------
  665|       |
  666|   837k|    tN = N[hi] + N[-lo];
  667|   837k|    tX = X[hi] - X[-lo];
  668|   837k|    tXX = XX[hi] + XX[-lo];
  669|   837k|    tY = Y[hi] + Y[-lo];
  670|   837k|    tXY = XY[hi] - XY[-lo];
  671|       |
  672|       |
  673|   837k|    A = tY * tXX - tX * tXY;
  674|   837k|    B = tN * tXY - tX * tY;
  675|   837k|    D = tN * tXX - tX * tX;
  676|   837k|    R = (A + x * B) / D;
  677|       |
  678|   837k|    if (R - offset < noise[i]) noise[i] = R - offset;
  ------------------
  |  Branch (678:9): [True: 247k, False: 590k]
  ------------------
  679|   837k|  }
  680|  12.8M|  for ( ; i < n; i++, x += 1.f) {
  ------------------
  |  Branch (680:11): [True: 12.8M, False: 0]
  ------------------
  681|       |
  682|  12.8M|    hi = i + fixed / 2;
  683|  12.8M|    lo = hi - fixed;
  684|  12.8M|    if ( hi>=n ) break;
  ------------------
  |  Branch (684:10): [True: 83.2k, False: 12.7M]
  ------------------
  685|  12.7M|    if ( lo<0 ) break;
  ------------------
  |  Branch (685:10): [True: 0, False: 12.7M]
  ------------------
  686|       |
  687|  12.7M|    tN = N[hi] - N[lo];
  688|  12.7M|    tX = X[hi] - X[lo];
  689|  12.7M|    tXX = XX[hi] - XX[lo];
  690|  12.7M|    tY = Y[hi] - Y[lo];
  691|  12.7M|    tXY = XY[hi] - XY[lo];
  692|       |
  693|  12.7M|    A = tY * tXX - tX * tXY;
  694|  12.7M|    B = tN * tXY - tX * tY;
  695|  12.7M|    D = tN * tXX - tX * tX;
  696|  12.7M|    R = (A + x * B) / D;
  697|       |
  698|  12.7M|    if (R - offset < noise[i]) noise[i] = R - offset;
  ------------------
  |  Branch (698:9): [True: 5.47M, False: 7.24M]
  ------------------
  699|  12.7M|  }
  700|   841k|  for ( ; i < n; i++, x += 1.f) {
  ------------------
  |  Branch (700:11): [True: 758k, False: 83.2k]
  ------------------
  701|   758k|    R = (A + x * B) / D;
  702|   758k|    if (R - offset < noise[i]) noise[i] = R - offset;
  ------------------
  |  Branch (702:9): [True: 387k, False: 370k]
  ------------------
  703|   758k|  }
  704|  83.2k|}
psy.c:seed_loop:
  422|   103k|                      float specmax){
  423|   103k|  vorbis_info_psy *vi=p->vi;
  424|   103k|  long n=p->n,i;
  425|   103k|  float dBoffset=vi->max_curve_dB-specmax;
  426|       |
  427|       |  /* prime the working vector with peak values */
  428|       |
  429|  15.0M|  for(i=0;i<n;i++){
  ------------------
  |  Branch (429:11): [True: 14.9M, False: 103k]
  ------------------
  430|  14.9M|    float max=f[i];
  431|  14.9M|    long oc=p->octave[i];
  432|  20.1M|    while(i+1<n && p->octave[i+1]==oc){
  ------------------
  |  Branch (432:11): [True: 20.0M, False: 103k]
  |  Branch (432:20): [True: 5.17M, False: 14.8M]
  ------------------
  433|  5.17M|      i++;
  434|  5.17M|      if(f[i]>max)max=f[i];
  ------------------
  |  Branch (434:10): [True: 1.92M, False: 3.25M]
  ------------------
  435|  5.17M|    }
  436|       |
  437|  14.9M|    if(max+6.f>flr[i]){
  ------------------
  |  Branch (437:8): [True: 9.88M, False: 5.06M]
  ------------------
  438|  9.88M|      oc=oc>>p->shiftoc;
  439|       |
  440|  9.88M|      if(oc>=P_BANDS)oc=P_BANDS-1;
  ------------------
  |  |   29|  9.88M|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
                    if(oc>=P_BANDS)oc=P_BANDS-1;
  ------------------
  |  |   29|   759k|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
  |  Branch (440:10): [True: 759k, False: 9.12M]
  ------------------
  441|  9.88M|      if(oc<0)oc=0;
  ------------------
  |  Branch (441:10): [True: 126k, False: 9.75M]
  ------------------
  442|       |
  443|  9.88M|      seed_curve(seed,
  444|  9.88M|                 curves[oc],
  445|  9.88M|                 max,
  446|  9.88M|                 p->octave[i]-p->firstoc,
  447|  9.88M|                 p->total_octave_lines,
  448|  9.88M|                 p->eighth_octave_lines,
  449|  9.88M|                 dBoffset);
  450|  9.88M|    }
  451|  14.9M|  }
  452|   103k|}
psy.c:seed_curve:
  394|  9.88M|                       int linesper,float dBoffset){
  395|  9.88M|  int i,post1;
  396|  9.88M|  int seedptr;
  397|  9.88M|  const float *posts,*curve;
  398|       |
  399|  9.88M|  int choice=(int)((amp+dBoffset-P_LEVEL_0)*.1f);
  ------------------
  |  |   31|  9.88M|#define P_LEVEL_0 30.    /* 30 dB */
  ------------------
  400|  9.88M|  choice=max(choice,0);
  ------------------
  |  |   78|  9.88M|#  define max(x,y)  ((x)<(y)?(y):(x))
  |  |  ------------------
  |  |  |  Branch (78:22): [True: 853k, False: 9.03M]
  |  |  ------------------
  ------------------
  401|  9.88M|  choice=min(choice,P_LEVELS-1);
  ------------------
  |  |   74|  9.88M|#  define min(x,y)  ((x)>(y)?(y):(x))
  |  |  ------------------
  |  |  |  Branch (74:22): [True: 11.4k, False: 9.87M]
  |  |  ------------------
  ------------------
  402|  9.88M|  posts=curves[choice];
  403|  9.88M|  curve=posts+2;
  404|  9.88M|  post1=(int)posts[1];
  405|  9.88M|  seedptr=oc+(posts[0]-EHMER_OFFSET)*linesper-(linesper>>1);
  ------------------
  |  |   42|  9.88M|#define EHMER_OFFSET 16
  ------------------
  406|       |
  407|   120M|  for(i=posts[0];i<post1;i++){
  ------------------
  |  Branch (407:18): [True: 112M, False: 7.74M]
  ------------------
  408|   112M|    if(seedptr>0){
  ------------------
  |  Branch (408:8): [True: 111M, False: 1.10M]
  ------------------
  409|   111M|      float lin=amp+curve[i];
  410|   111M|      if(seed[seedptr]<lin)seed[seedptr]=lin;
  ------------------
  |  Branch (410:10): [True: 66.5M, False: 45.3M]
  ------------------
  411|   111M|    }
  412|   112M|    seedptr+=linesper;
  413|   112M|    if(seedptr>=n)break;
  ------------------
  |  Branch (413:8): [True: 2.13M, False: 110M]
  ------------------
  414|   112M|  }
  415|  9.88M|}
psy.c:max_seeds:
  514|   103k|                      float *flr){
  515|   103k|  long   n=p->total_octave_lines;
  516|   103k|  int    linesper=p->eighth_octave_lines;
  517|   103k|  long   linpos=0;
  518|   103k|  long   pos;
  519|       |
  520|   103k|  seed_chase(seed,linesper,n); /* for masking */
  521|       |
  522|   103k|  pos=p->octave[0]-p->firstoc-(linesper>>1);
  523|       |
  524|  14.9M|  while(linpos+1<p->n){
  ------------------
  |  Branch (524:9): [True: 14.8M, False: 103k]
  ------------------
  525|  14.8M|    float minV=seed[pos];
  526|  14.8M|    long end=((p->octave[linpos]+p->octave[linpos+1])>>1)-p->firstoc;
  527|  14.8M|    if(minV>p->vi->tone_abs_limit)minV=p->vi->tone_abs_limit;
  ------------------
  |  Branch (527:8): [True: 208k, False: 14.6M]
  ------------------
  528|  77.0M|    while(pos+1<=end){
  ------------------
  |  Branch (528:11): [True: 62.1M, False: 14.8M]
  ------------------
  529|  62.1M|      pos++;
  530|  62.1M|      if((seed[pos]>NEGINF && seed[pos]<minV) || minV==NEGINF)
  ------------------
  |  |   31|   124M|#define NEGINF -9999.f
  ------------------
                    if((seed[pos]>NEGINF && seed[pos]<minV) || minV==NEGINF)
  ------------------
  |  |   31|  59.2M|#define NEGINF -9999.f
  ------------------
  |  Branch (530:11): [True: 50.0M, False: 12.1M]
  |  Branch (530:31): [True: 2.94M, False: 47.0M]
  |  Branch (530:50): [True: 10.1M, False: 49.0M]
  ------------------
  531|  13.0M|        minV=seed[pos];
  532|  62.1M|    }
  533|       |
  534|  14.8M|    end=pos+p->firstoc;
  535|  34.9M|    for(;linpos<p->n && p->octave[linpos]<=end;linpos++)
  ------------------
  |  Branch (535:10): [True: 34.9M, False: 40.3k]
  |  Branch (535:25): [True: 20.0M, False: 14.8M]
  ------------------
  536|  20.0M|      if(flr[linpos]<minV)flr[linpos]=minV;
  ------------------
  |  Branch (536:10): [True: 11.3M, False: 8.69M]
  ------------------
  537|  14.8M|  }
  538|       |
  539|   103k|  {
  540|   103k|    float minV=seed[p->total_octave_lines-1];
  541|   166k|    for(;linpos<p->n;linpos++)
  ------------------
  |  Branch (541:10): [True: 63.2k, False: 103k]
  ------------------
  542|  63.2k|      if(flr[linpos]<minV)flr[linpos]=minV;
  ------------------
  |  Branch (542:10): [True: 18.5k, False: 44.6k]
  ------------------
  543|   103k|  }
  544|       |
  545|   103k|}
psy.c:seed_chase:
  454|   103k|static void seed_chase(float *seeds, int linesper, long n){
  455|   103k|  long  *posstack=alloca(n*sizeof(*posstack));
  456|   103k|  float *ampstack=alloca(n*sizeof(*ampstack));
  457|   103k|  long   stack=0;
  458|   103k|  long   pos=0;
  459|   103k|  long   i;
  460|       |
  461|  62.9M|  for(i=0;i<n;i++){
  ------------------
  |  Branch (461:11): [True: 62.8M, False: 103k]
  ------------------
  462|  62.8M|    if(stack<2){
  ------------------
  |  Branch (462:8): [True: 207k, False: 62.6M]
  ------------------
  463|   207k|      posstack[stack]=i;
  464|   207k|      ampstack[stack++]=seeds[i];
  465|  62.6M|    }else{
  466|   110M|      while(1){
  ------------------
  |  Branch (466:13): [True: 110M, Folded]
  ------------------
  467|   110M|        if(seeds[i]<ampstack[stack-1]){
  ------------------
  |  Branch (467:12): [True: 43.2M, False: 66.8M]
  ------------------
  468|  43.2M|          posstack[stack]=i;
  469|  43.2M|          ampstack[stack++]=seeds[i];
  470|  43.2M|          break;
  471|  66.8M|        }else{
  472|  66.8M|          if(i<posstack[stack-1]+linesper){
  ------------------
  |  Branch (472:14): [True: 66.8M, False: 0]
  ------------------
  473|  66.8M|            if(stack>1 && ampstack[stack-1]<=ampstack[stack-2] &&
  ------------------
  |  Branch (473:16): [True: 66.5M, False: 337k]
  |  Branch (473:27): [True: 64.7M, False: 1.83M]
  ------------------
  474|  64.7M|               i<posstack[stack-2]+linesper){
  ------------------
  |  Branch (474:16): [True: 47.5M, False: 17.2M]
  ------------------
  475|       |              /* we completely overlap, making stack-1 irrelevant.  pop it */
  476|  47.5M|              stack--;
  477|  47.5M|              continue;
  478|  47.5M|            }
  479|  66.8M|          }
  480|  19.3M|          posstack[stack]=i;
  481|  19.3M|          ampstack[stack++]=seeds[i];
  482|  19.3M|          break;
  483|       |
  484|  66.8M|        }
  485|   110M|      }
  486|  62.6M|    }
  487|  62.8M|  }
  488|       |
  489|       |  /* the stack now contains only the positions that are relevant. Scan
  490|       |     'em straight through */
  491|       |
  492|  15.4M|  for(i=0;i<stack;i++){
  ------------------
  |  Branch (492:11): [True: 15.3M, False: 103k]
  ------------------
  493|  15.3M|    long endpos;
  494|  15.3M|    if(i<stack-1 && ampstack[i+1]>ampstack[i]){
  ------------------
  |  Branch (494:8): [True: 15.2M, False: 103k]
  |  Branch (494:21): [True: 6.47M, False: 8.74M]
  ------------------
  495|  6.47M|      endpos=posstack[i+1];
  496|  8.84M|    }else{
  497|  8.84M|      endpos=posstack[i]+linesper+1; /* +1 is important, else bin 0 is
  498|       |                                        discarded in short frames */
  499|  8.84M|    }
  500|  15.3M|    if(endpos>n)endpos=n;
  ------------------
  |  Branch (500:8): [True: 307k, False: 15.0M]
  ------------------
  501|  78.1M|    for(;pos<endpos;pos++)
  ------------------
  |  Branch (501:10): [True: 62.8M, False: 15.3M]
  ------------------
  502|  62.8M|      seeds[pos]=ampstack[i];
  503|  15.3M|  }
  504|       |
  505|       |  /* there.  Linear time.  I now remember this was on a problem set I
  506|       |     had in Grad Skool... I didn't solve it at the time ;-) */
  507|       |
  508|   103k|}
psy.c:flag_lossless:
  925|  2.04M|                         float *floor, int *flag, int i, int jn){
  926|  2.04M|  int j;
  927|  21.3M|  for(j=0;j<jn;j++){
  ------------------
  |  Branch (927:11): [True: 19.2M, False: 2.04M]
  ------------------
  928|  19.2M|    float point = j>=limit-i ? postpoint : prepoint;
  ------------------
  |  Branch (928:19): [True: 16.4M, False: 2.84M]
  ------------------
  929|  19.2M|    float r = fabs(mdct[j])/floor[j];
  930|  19.2M|    if(r<point)
  ------------------
  |  Branch (930:8): [True: 5.96M, False: 13.3M]
  ------------------
  931|  5.96M|      flag[j]=0;
  932|  13.3M|    else
  933|  13.3M|      flag[j]=1;
  934|  19.2M|  }
  935|  2.04M|}
psy.c:noise_normalize:
  941|  2.14M|static float noise_normalize(vorbis_look_psy *p, int limit, float *r, float *q, float *f, int *flags, float acc, int i, int n, int *out){
  942|       |
  943|  2.14M|  vorbis_info_psy *vi=p->vi;
  944|  2.14M|  float **sort = alloca(n*sizeof(*sort));
  945|  2.14M|  int j,count=0;
  946|  2.14M|  int start = (vi->normal_p ? vi->normal_start-i : n);
  ------------------
  |  Branch (946:16): [True: 2.14M, False: 0]
  ------------------
  947|  2.14M|  if(start>n)start=n;
  ------------------
  |  Branch (947:6): [True: 1.21M, False: 933k]
  ------------------
  948|       |
  949|       |  /* force classic behavior where only energy in the current band is considered */
  950|  2.14M|  acc=0.f;
  951|       |
  952|       |  /* still responsible for populating *out where noise norm not in
  953|       |     effect.  There's no need to [re]populate *q in these areas */
  954|  14.4M|  for(j=0;j<start;j++){
  ------------------
  |  Branch (954:11): [True: 12.2M, False: 2.14M]
  ------------------
  955|  12.2M|    if(!flags || !flags[j]){ /* lossless coupling already quantized.
  ------------------
  |  Branch (955:8): [True: 11.7M, False: 569k]
  |  Branch (955:18): [True: 147k, False: 422k]
  ------------------
  956|       |                                Don't touch; requantizing based on
  957|       |                                energy would be incorrect. */
  958|  11.8M|      float ve = q[j]/f[j];
  959|  11.8M|      if(r[j]<0)
  ------------------
  |  Branch (959:10): [True: 5.88M, False: 5.98M]
  ------------------
  960|  5.88M|        out[j] = -rint(sqrt(ve));
  961|  5.98M|      else
  962|  5.98M|        out[j] = rint(sqrt(ve));
  963|  11.8M|    }
  964|  12.2M|  }
  965|       |
  966|       |  /* sort magnitudes for noise norm portion of partition */
  967|  9.99M|  for(;j<n;j++){
  ------------------
  |  Branch (967:8): [True: 7.84M, False: 2.14M]
  ------------------
  968|  7.84M|    if(!flags || !flags[j]){ /* can't noise norm elements that have
  ------------------
  |  Branch (968:8): [True: 7.54M, False: 300k]
  |  Branch (968:18): [True: 282k, False: 18.7k]
  ------------------
  969|       |                                already been loslessly coupled; we can
  970|       |                                only account for their energy error */
  971|  7.82M|      float ve = q[j]/f[j];
  972|       |      /* Despite all the new, more capable coupling code, for now we
  973|       |         implement noise norm as it has been up to this point. Only
  974|       |         consider promotions to unit magnitude from 0.  In addition
  975|       |         the only energy error counted is quantizations to zero. */
  976|       |      /* also-- the original point code only applied noise norm at > pointlimit */
  977|  7.82M|      if(ve<.25f && (!flags || j>=limit-i)){
  ------------------
  |  Branch (977:10): [True: 6.27M, False: 1.55M]
  |  Branch (977:22): [True: 6.06M, False: 207k]
  |  Branch (977:32): [True: 199k, False: 7.78k]
  ------------------
  978|  6.26M|        acc += ve;
  979|  6.26M|        sort[count++]=q+j; /* q is fabs(r) for unflagged element */
  980|  6.26M|      }else{
  981|       |        /* For now: no acc adjustment for nonzero quantization.  populate *out and q as this value is final. */
  982|  1.56M|        if(r[j]<0)
  ------------------
  |  Branch (982:12): [True: 790k, False: 773k]
  ------------------
  983|   790k|          out[j] = -rint(sqrt(ve));
  984|   773k|        else
  985|   773k|          out[j] = rint(sqrt(ve));
  986|  1.56M|        q[j] = out[j]*out[j]*f[j];
  987|  1.56M|      }
  988|  7.82M|    }/* else{
  989|       |        again, no energy adjustment for error in nonzero quant-- for now
  990|       |        }*/
  991|  7.84M|  }
  992|       |
  993|  2.14M|  if(count){
  ------------------
  |  Branch (993:6): [True: 845k, False: 1.30M]
  ------------------
  994|       |    /* noise norm to do */
  995|   845k|    qsort(sort,count,sizeof(*sort),apsort);
  996|  7.11M|    for(j=0;j<count;j++){
  ------------------
  |  Branch (996:13): [True: 6.26M, False: 845k]
  ------------------
  997|  6.26M|      int k=sort[j]-q;
  998|  6.26M|      if(acc>=vi->normal_thresh){
  ------------------
  |  Branch (998:10): [True: 144k, False: 6.12M]
  ------------------
  999|   144k|        out[k]=unitnorm(r[k]);
 1000|   144k|        acc-=1.f;
 1001|   144k|        q[k]=f[k];
 1002|  6.12M|      }else{
 1003|  6.12M|        out[k]=0;
 1004|  6.12M|        q[k]=0.f;
 1005|  6.12M|      }
 1006|  6.26M|    }
 1007|   845k|  }
 1008|       |
 1009|  2.14M|  return acc;
 1010|  2.14M|}
psy.c:apsort:
  918|  12.2M|static int apsort(const void *a, const void *b){
  919|  12.2M|  float f1=**(float**)a;
  920|  12.2M|  float f2=**(float**)b;
  921|  12.2M|  return (f1<f2)-(f1>f2);
  922|  12.2M|}

res0_free_info:
   65|  4.14k|void res0_free_info(vorbis_info_residue *i){
   66|  4.14k|  vorbis_info_residue0 *info=(vorbis_info_residue0 *)i;
   67|  4.14k|  if(info){
  ------------------
  |  Branch (67:6): [True: 4.14k, False: 0]
  ------------------
   68|  4.14k|    memset(info,0,sizeof(*info));
   69|  4.14k|    _ogg_free(info);
  ------------------
  |  |   24|  4.14k|#define _ogg_free    free
  ------------------
   70|  4.14k|  }
   71|  4.14k|}
res0_free_look:
   73|  4.14k|void res0_free_look(vorbis_look_residue *i){
   74|  4.14k|  int j;
   75|  4.14k|  if(i){
  ------------------
  |  Branch (75:6): [True: 4.14k, False: 0]
  ------------------
   76|       |
   77|  4.14k|    vorbis_look_residue0 *look=(vorbis_look_residue0 *)i;
   78|       |
   79|       |#ifdef TRAIN_RES
   80|       |    {
   81|       |      int j,k,l;
   82|       |      for(j=0;j<look->parts;j++){
   83|       |        /*fprintf(stderr,"partition %d: ",j);*/
   84|       |        for(k=0;k<8;k++)
   85|       |          if(look->training_data[k][j]){
   86|       |            char buffer[80];
   87|       |            FILE *of;
   88|       |            codebook *statebook=look->partbooks[j][k];
   89|       |
   90|       |            /* long and short into the same bucket by current convention */
   91|       |            sprintf(buffer,"res_sub%d_part%d_pass%d.vqd",look->submap,j,k);
   92|       |            of=fopen(buffer,"a");
   93|       |
   94|       |            for(l=0;l<statebook->entries;l++)
   95|       |              fprintf(of,"%d:%ld\n",l,look->training_data[k][j][l]);
   96|       |
   97|       |            fclose(of);
   98|       |
   99|       |            /*fprintf(stderr,"%d(%.2f|%.2f) ",k,
  100|       |              look->training_min[k][j],look->training_max[k][j]);*/
  101|       |
  102|       |            _ogg_free(look->training_data[k][j]);
  103|       |            look->training_data[k][j]=NULL;
  104|       |          }
  105|       |        /*fprintf(stderr,"\n");*/
  106|       |      }
  107|       |    }
  108|       |    fprintf(stderr,"min/max residue: %g::%g\n",look->tmin,look->tmax);
  109|       |
  110|       |    /*fprintf(stderr,"residue bit usage %f:%f (%f total)\n",
  111|       |            (float)look->phrasebits/look->frames,
  112|       |            (float)look->postbits/look->frames,
  113|       |            (float)(look->postbits+look->phrasebits)/look->frames);*/
  114|       |#endif
  115|       |
  116|       |
  117|       |    /*vorbis_info_residue0 *info=look->info;
  118|       |
  119|       |    fprintf(stderr,
  120|       |            "%ld frames encoded in %ld phrasebits and %ld residue bits "
  121|       |            "(%g/frame) \n",look->frames,look->phrasebits,
  122|       |            look->resbitsflat,
  123|       |            (look->phrasebits+look->resbitsflat)/(float)look->frames);
  124|       |
  125|       |    for(j=0;j<look->parts;j++){
  126|       |      long acc=0;
  127|       |      fprintf(stderr,"\t[%d] == ",j);
  128|       |      for(k=0;k<look->stages;k++)
  129|       |        if((info->secondstages[j]>>k)&1){
  130|       |          fprintf(stderr,"%ld,",look->resbits[j][k]);
  131|       |          acc+=look->resbits[j][k];
  132|       |        }
  133|       |
  134|       |      fprintf(stderr,":: (%ld vals) %1.2fbits/sample\n",look->resvals[j],
  135|       |              acc?(float)acc/(look->resvals[j]*info->grouping):0);
  136|       |    }
  137|       |    fprintf(stderr,"\n");*/
  138|       |
  139|  42.9k|    for(j=0;j<look->parts;j++)
  ------------------
  |  Branch (139:13): [True: 38.7k, False: 4.14k]
  ------------------
  140|  38.7k|      if(look->partbooks[j])_ogg_free(look->partbooks[j]);
  ------------------
  |  |   24|  34.5k|#define _ogg_free    free
  ------------------
  |  Branch (140:10): [True: 34.5k, False: 4.23k]
  ------------------
  141|  4.14k|    _ogg_free(look->partbooks);
  ------------------
  |  |   24|  4.14k|#define _ogg_free    free
  ------------------
  142|   369k|    for(j=0;j<look->partvals;j++)
  ------------------
  |  Branch (142:13): [True: 365k, False: 4.14k]
  ------------------
  143|   365k|      _ogg_free(look->decodemap[j]);
  ------------------
  |  |   24|   365k|#define _ogg_free    free
  ------------------
  144|  4.14k|    _ogg_free(look->decodemap);
  ------------------
  |  |   24|  4.14k|#define _ogg_free    free
  ------------------
  145|       |
  146|  4.14k|    memset(look,0,sizeof(*look));
  147|  4.14k|    _ogg_free(look);
  ------------------
  |  |   24|  4.14k|#define _ogg_free    free
  ------------------
  148|  4.14k|  }
  149|  4.14k|}
res0_pack:
  161|  4.14k|void res0_pack(vorbis_info_residue *vr,oggpack_buffer *opb){
  162|  4.14k|  vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr;
  163|  4.14k|  int j,acc=0;
  164|  4.14k|  oggpack_write(opb,info->begin,24);
  165|  4.14k|  oggpack_write(opb,info->end,24);
  166|       |
  167|  4.14k|  oggpack_write(opb,info->grouping-1,24);  /* residue vectors to group and
  168|       |                                             code with a partitioned book */
  169|  4.14k|  oggpack_write(opb,info->partitions-1,6); /* possible partition choices */
  170|  4.14k|  oggpack_write(opb,info->groupbook,8);  /* group huffman book */
  171|       |
  172|       |  /* secondstages is a bitmask; as encoding progresses pass by pass, a
  173|       |     bitmask of one indicates this partition class has bits to write
  174|       |     this pass */
  175|  42.9k|  for(j=0;j<info->partitions;j++){
  ------------------
  |  Branch (175:11): [True: 38.7k, False: 4.14k]
  ------------------
  176|  38.7k|    if(ov_ilog(info->secondstages[j])>3){
  ------------------
  |  Branch (176:8): [True: 0, False: 38.7k]
  ------------------
  177|       |      /* yes, this is a minor hack due to not thinking ahead */
  178|      0|      oggpack_write(opb,info->secondstages[j],3);
  179|      0|      oggpack_write(opb,1,1);
  180|      0|      oggpack_write(opb,info->secondstages[j]>>3,5);
  181|      0|    }else
  182|  38.7k|      oggpack_write(opb,info->secondstages[j],4); /* trailing zero */
  183|  38.7k|    acc+=icount(info->secondstages[j]);
  184|  38.7k|  }
  185|  57.0k|  for(j=0;j<acc;j++)
  ------------------
  |  Branch (185:11): [True: 52.8k, False: 4.14k]
  ------------------
  186|  52.8k|    oggpack_write(opb,info->booklist[j],8);
  187|       |
  188|  4.14k|}
res0_look:
  256|  4.14k|                               vorbis_info_residue *vr){
  257|  4.14k|  vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr;
  258|  4.14k|  vorbis_look_residue0 *look=_ogg_calloc(1,sizeof(*look));
  ------------------
  |  |   22|  4.14k|#define _ogg_calloc  calloc
  ------------------
  259|  4.14k|  codec_setup_info     *ci=vd->vi->codec_setup;
  260|       |
  261|  4.14k|  int j,k,acc=0;
  262|  4.14k|  int dim;
  263|  4.14k|  int maxstage=0;
  264|  4.14k|  look->info=info;
  265|       |
  266|  4.14k|  look->parts=info->partitions;
  267|  4.14k|  look->fullbooks=ci->fullbooks;
  268|  4.14k|  look->phrasebook=ci->fullbooks+info->groupbook;
  269|  4.14k|  dim=look->phrasebook->dim;
  270|       |
  271|  4.14k|  look->partbooks=_ogg_calloc(look->parts,sizeof(*look->partbooks));
  ------------------
  |  |   22|  4.14k|#define _ogg_calloc  calloc
  ------------------
  272|       |
  273|  42.9k|  for(j=0;j<look->parts;j++){
  ------------------
  |  Branch (273:11): [True: 38.7k, False: 4.14k]
  ------------------
  274|  38.7k|    int stages=ov_ilog(info->secondstages[j]);
  275|  38.7k|    if(stages){
  ------------------
  |  Branch (275:8): [True: 34.5k, False: 4.23k]
  ------------------
  276|  34.5k|      if(stages>maxstage)maxstage=stages;
  ------------------
  |  Branch (276:10): [True: 4.14k, False: 30.3k]
  ------------------
  277|  34.5k|      look->partbooks[j]=_ogg_calloc(stages,sizeof(*look->partbooks[j]));
  ------------------
  |  |   22|  34.5k|#define _ogg_calloc  calloc
  ------------------
  278|   128k|      for(k=0;k<stages;k++)
  ------------------
  |  Branch (278:15): [True: 93.5k, False: 34.5k]
  ------------------
  279|  93.5k|        if(info->secondstages[j]&(1<<k)){
  ------------------
  |  Branch (279:12): [True: 52.8k, False: 40.6k]
  ------------------
  280|  52.8k|          look->partbooks[j][k]=ci->fullbooks+info->booklist[acc++];
  281|       |#ifdef TRAIN_RES
  282|       |          look->training_data[k][j]=_ogg_calloc(look->partbooks[j][k]->entries,
  283|       |                                           sizeof(***look->training_data));
  284|       |#endif
  285|  52.8k|        }
  286|  34.5k|    }
  287|  38.7k|  }
  288|       |
  289|  4.14k|  look->partvals=1;
  290|  12.4k|  for(j=0;j<dim;j++)
  ------------------
  |  Branch (290:11): [True: 8.29k, False: 4.14k]
  ------------------
  291|  8.29k|      look->partvals*=look->parts;
  292|       |
  293|  4.14k|  look->stages=maxstage;
  294|  4.14k|  look->decodemap=_ogg_malloc(look->partvals*sizeof(*look->decodemap));
  ------------------
  |  |   21|  4.14k|#define _ogg_malloc  malloc
  ------------------
  295|   369k|  for(j=0;j<look->partvals;j++){
  ------------------
  |  Branch (295:11): [True: 365k, False: 4.14k]
  ------------------
  296|   365k|    long val=j;
  297|   365k|    long mult=look->partvals/look->parts;
  298|   365k|    look->decodemap[j]=_ogg_malloc(dim*sizeof(*look->decodemap[j]));
  ------------------
  |  |   21|   365k|#define _ogg_malloc  malloc
  ------------------
  299|  1.09M|    for(k=0;k<dim;k++){
  ------------------
  |  Branch (299:13): [True: 731k, False: 365k]
  ------------------
  300|   731k|      long deco=val/mult;
  301|   731k|      val-=deco*mult;
  302|   731k|      mult/=look->parts;
  303|   731k|      look->decodemap[j][k]=deco;
  304|   731k|    }
  305|   365k|  }
  306|       |#if defined(TRAIN_RES) || defined (TRAIN_RESAUX)
  307|       |  {
  308|       |    static int train_seq=0;
  309|       |    look->train_seq=train_seq++;
  310|       |  }
  311|       |#endif
  312|  4.14k|  return(look);
  313|  4.14k|}
res1_forward:
  716|  53.0k|                 int **in,int *nonzero,int ch, long **partword, int submap){
  717|  53.0k|  int i,used=0;
  718|  53.0k|  (void)vb;
  719|   146k|  for(i=0;i<ch;i++)
  ------------------
  |  Branch (719:11): [True: 93.4k, False: 53.0k]
  ------------------
  720|  93.4k|    if(nonzero[i])
  ------------------
  |  Branch (720:8): [True: 91.2k, False: 2.22k]
  ------------------
  721|  91.2k|      in[used++]=in[i];
  722|       |
  723|  53.0k|  if(used){
  ------------------
  |  Branch (723:6): [True: 52.5k, False: 571]
  ------------------
  724|       |#ifdef TRAIN_RES
  725|       |    return _01forward(opb,vl,in,used,partword,_encodepart,submap);
  726|       |#else
  727|  52.5k|    (void)submap;
  728|  52.5k|    return _01forward(opb,vl,in,used,partword,_encodepart);
  729|  52.5k|#endif
  730|  52.5k|  }else{
  731|    571|    return(0);
  732|    571|  }
  733|  53.0k|}
res1_class:
  736|  53.0k|                  int **in,int *nonzero,int ch){
  737|  53.0k|  int i,used=0;
  738|   146k|  for(i=0;i<ch;i++)
  ------------------
  |  Branch (738:11): [True: 93.4k, False: 53.0k]
  ------------------
  739|  93.4k|    if(nonzero[i])
  ------------------
  |  Branch (739:8): [True: 91.2k, False: 2.22k]
  ------------------
  740|  91.2k|      in[used++]=in[i];
  741|  53.0k|  if(used)
  ------------------
  |  Branch (741:6): [True: 52.5k, False: 571]
  ------------------
  742|  52.5k|    return(_01class(vb,vl,in,used));
  743|    571|  else
  744|    571|    return(0);
  745|  53.0k|}
res2_class:
  760|  5.06k|                  int **in,int *nonzero,int ch){
  761|  5.06k|  int i,used=0;
  762|  15.1k|  for(i=0;i<ch;i++)
  ------------------
  |  Branch (762:11): [True: 10.1k, False: 5.06k]
  ------------------
  763|  10.1k|    if(nonzero[i])used++;
  ------------------
  |  Branch (763:8): [True: 9.30k, False: 830]
  ------------------
  764|  5.06k|  if(used)
  ------------------
  |  Branch (764:6): [True: 4.65k, False: 415]
  ------------------
  765|  4.65k|    return(_2class(vb,vl,in,ch));
  766|    415|  else
  767|    415|    return(0);
  768|  5.06k|}
res2_forward:
  775|  5.06k|                 int **in,int *nonzero,int ch, long **partword,int submap){
  776|  5.06k|  long i,j,k,n=vb->pcmend/2,used=0;
  777|       |
  778|       |  /* don't duplicate the code; use a working vector hack for now and
  779|       |     reshape ourselves into a single channel res1 */
  780|       |  /* ugly; reallocs for each coupling pass :-( */
  781|  5.06k|  int *work=_vorbis_block_alloc(vb,ch*n*sizeof(*work));
  782|  15.1k|  for(i=0;i<ch;i++){
  ------------------
  |  Branch (782:11): [True: 10.1k, False: 5.06k]
  ------------------
  783|  10.1k|    int *pcm=in[i];
  784|  10.1k|    if(nonzero[i])used++;
  ------------------
  |  Branch (784:8): [True: 9.30k, False: 830]
  ------------------
  785|  1.92M|    for(j=0,k=i;j<n;j++,k+=ch)
  ------------------
  |  Branch (785:17): [True: 1.91M, False: 10.1k]
  ------------------
  786|  1.91M|      work[k]=pcm[j];
  787|  10.1k|  }
  788|       |
  789|  5.06k|  if(used){
  ------------------
  |  Branch (789:6): [True: 4.65k, False: 415]
  ------------------
  790|       |#ifdef TRAIN_RES
  791|       |    return _01forward(opb,vl,&work,1,partword,_encodepart,submap);
  792|       |#else
  793|  4.65k|    (void)submap;
  794|  4.65k|    return _01forward(opb,vl,&work,1,partword,_encodepart);
  795|  4.65k|#endif
  796|  4.65k|  }else{
  797|    415|    return(0);
  798|    415|  }
  799|  5.06k|}
res0.c:icount:
  151|  38.7k|static int icount(unsigned int v){
  152|  38.7k|  int ret=0;
  153|   132k|  while(v){
  ------------------
  |  Branch (153:9): [True: 93.5k, False: 38.7k]
  ------------------
  154|  93.5k|    ret+=v&1;
  155|  93.5k|    v>>=1;
  156|  93.5k|  }
  157|  38.7k|  return(ret);
  158|  38.7k|}
res0.c:_01forward:
  540|  57.1k|){
  541|  57.1k|  long i,j,k,s;
  542|  57.1k|  vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
  543|  57.1k|  vorbis_info_residue0 *info=look->info;
  544|       |
  545|       |#ifdef TRAIN_RES
  546|       |  look->submap=submap;
  547|       |#endif
  548|       |
  549|       |  /* move all this setup out later */
  550|  57.1k|  int samples_per_partition=info->grouping;
  551|  57.1k|  int possible_partitions=info->partitions;
  552|  57.1k|  int partitions_per_word=look->phrasebook->dim;
  553|  57.1k|  int n=info->end-info->begin;
  554|       |
  555|  57.1k|  int partvals=n/samples_per_partition;
  556|  57.1k|  long resbits[128];
  557|  57.1k|  long resvals[128];
  558|       |
  559|       |#ifdef TRAIN_RES
  560|       |  for(i=0;i<ch;i++)
  561|       |    for(j=info->begin;j<info->end;j++){
  562|       |      if(in[i][j]>look->tmax)look->tmax=in[i][j];
  563|       |      if(in[i][j]<look->tmin)look->tmin=in[i][j];
  564|       |    }
  565|       |#endif
  566|       |
  567|  57.1k|  memset(resbits,0,sizeof(resbits));
  568|  57.1k|  memset(resvals,0,sizeof(resvals));
  569|       |
  570|       |  /* we code the partition words for each channel, then the residual
  571|       |     words for a partition per channel until we've written all the
  572|       |     residual words for that partition word.  Then write the next
  573|       |     partition channel words... */
  574|       |
  575|   228k|  for(s=0;s<look->stages;s++){
  ------------------
  |  Branch (575:11): [True: 171k, False: 57.1k]
  ------------------
  576|       |
  577|   787k|    for(i=0;i<partvals;){
  ------------------
  |  Branch (577:13): [True: 615k, False: 171k]
  ------------------
  578|       |
  579|       |      /* first we encode a partition codeword for each channel */
  580|   615k|      if(s==0){
  ------------------
  |  Branch (580:10): [True: 205k, False: 410k]
  ------------------
  581|   576k|        for(j=0;j<ch;j++){
  ------------------
  |  Branch (581:17): [True: 371k, False: 205k]
  ------------------
  582|   371k|          long val=partword[j][i];
  583|   742k|          for(k=1;k<partitions_per_word;k++){
  ------------------
  |  Branch (583:19): [True: 371k, False: 371k]
  ------------------
  584|   371k|            val*=possible_partitions;
  585|   371k|            if(i+k<partvals)
  ------------------
  |  Branch (585:16): [True: 358k, False: 13.0k]
  ------------------
  586|   358k|              val+=partword[j][i+k];
  587|   371k|          }
  588|       |
  589|       |          /* training hack */
  590|   371k|          if(val<look->phrasebook->entries)
  ------------------
  |  Branch (590:14): [True: 371k, False: 0]
  ------------------
  591|   371k|            look->phrasebits+=vorbis_book_encode(look->phrasebook,val,opb);
  592|       |#if 0 /*def TRAIN_RES*/
  593|       |          else
  594|       |            fprintf(stderr,"!");
  595|       |#endif
  596|       |
  597|   371k|        }
  598|   205k|      }
  599|       |
  600|       |      /* now we encode interleaved residual values for the partitions */
  601|  1.82M|      for(k=0;k<partitions_per_word && i<partvals;k++,i++){
  ------------------
  |  Branch (601:15): [True: 1.23M, False: 590k]
  |  Branch (601:40): [True: 1.20M, False: 25.2k]
  ------------------
  602|  1.20M|        long offset=i*samples_per_partition+info->begin;
  603|       |
  604|  3.39M|        for(j=0;j<ch;j++){
  ------------------
  |  Branch (604:17): [True: 2.18M, False: 1.20M]
  ------------------
  605|  2.18M|          if(s==0)resvals[partword[j][i]]+=samples_per_partition;
  ------------------
  |  Branch (605:14): [True: 729k, False: 1.45M]
  ------------------
  606|  2.18M|          if(info->secondstages[partword[j][i]]&(1<<s)){
  ------------------
  |  Branch (606:14): [True: 1.07M, False: 1.11M]
  ------------------
  607|  1.07M|            codebook *statebook=look->partbooks[partword[j][i]][s];
  608|  1.07M|            if(statebook){
  ------------------
  |  Branch (608:16): [True: 1.07M, False: 0]
  ------------------
  609|  1.07M|              int ret;
  610|       |#ifdef TRAIN_RES
  611|       |              long *accumulator=NULL;
  612|       |              accumulator=look->training_data[s][partword[j][i]];
  613|       |              {
  614|       |                int l;
  615|       |                int *samples=in[j]+offset;
  616|       |                for(l=0;l<samples_per_partition;l++){
  617|       |                  if(samples[l]<look->training_min[s][partword[j][i]])
  618|       |                    look->training_min[s][partword[j][i]]=samples[l];
  619|       |                  if(samples[l]>look->training_max[s][partword[j][i]])
  620|       |                    look->training_max[s][partword[j][i]]=samples[l];
  621|       |                }
  622|       |              }
  623|       |              ret=encode(opb,in[j]+offset,samples_per_partition,
  624|       |                         statebook,accumulator);
  625|       |#else
  626|  1.07M|              ret=encode(opb,in[j]+offset,samples_per_partition,
  627|  1.07M|                         statebook);
  628|  1.07M|#endif
  629|       |
  630|  1.07M|              look->postbits+=ret;
  631|  1.07M|              resbits[partword[j][i]]+=ret;
  632|  1.07M|            }
  633|  1.07M|          }
  634|  2.18M|        }
  635|  1.20M|      }
  636|   615k|    }
  637|   171k|  }
  638|       |
  639|  57.1k|  return(0);
  640|  57.1k|}
res0.c:_encodepart:
  385|  1.07M|                       codebook *book){
  386|  1.07M|#endif
  387|  1.07M|  int i,bits=0;
  388|  1.07M|  int dim=book->dim;
  389|  1.07M|  int step=n/dim;
  390|       |
  391|  11.1M|  for(i=0;i<step;i++){
  ------------------
  |  Branch (391:11): [True: 10.0M, False: 1.07M]
  ------------------
  392|  10.0M|    int entry=local_book_besterror(book,vec+i*dim);
  393|       |
  394|       |#ifdef TRAIN_RES
  395|       |    if(entry>=0)
  396|       |      acc[entry]++;
  397|       |#endif
  398|       |
  399|  10.0M|    bits+=vorbis_book_encode(book,entry,opb);
  400|       |
  401|  10.0M|  }
  402|       |
  403|  1.07M|  return(bits);
  404|  1.07M|}
res0.c:local_book_besterror:
  316|  10.0M|static int local_book_besterror(codebook *book,int *a){
  317|  10.0M|  int dim=book->dim;
  318|  10.0M|  int i,j,o;
  319|  10.0M|  int minval=book->minval;
  320|  10.0M|  int del=book->delta;
  321|  10.0M|  int qv=book->quantvals;
  322|  10.0M|  int ze=(qv>>1);
  323|  10.0M|  int index=0;
  324|       |  /* assumes integer/centered encoder codebook maptype 1 no more than dim 8 */
  325|  10.0M|  int p[8]={0,0,0,0,0,0,0,0};
  326|       |
  327|  10.0M|  if(del!=1){
  ------------------
  |  Branch (327:6): [True: 4.14M, False: 5.89M]
  ------------------
  328|  13.1M|    for(i=0,o=dim;i<dim;i++){
  ------------------
  |  Branch (328:19): [True: 8.96M, False: 4.14M]
  ------------------
  329|  8.96M|      int v = (a[--o]-minval+(del>>1))/del;
  330|  8.96M|      int m = (v<ze ? ((ze-v)<<1)-1 : ((v-ze)<<1));
  ------------------
  |  Branch (330:16): [True: 2.39M, False: 6.56M]
  ------------------
  331|  8.96M|      index = index*qv+ (m<0?0:(m>=qv?qv-1:m));
  ------------------
  |  Branch (331:26): [True: 0, False: 8.96M]
  |  Branch (331:33): [True: 727, False: 8.96M]
  ------------------
  332|  8.96M|      p[o]=v*del+minval;
  333|  8.96M|    }
  334|  5.89M|  }else{
  335|  18.8M|    for(i=0,o=dim;i<dim;i++){
  ------------------
  |  Branch (335:19): [True: 12.9M, False: 5.89M]
  ------------------
  336|  12.9M|      int v = a[--o]-minval;
  337|  12.9M|      int m = (v<ze ? ((ze-v)<<1)-1 : ((v-ze)<<1));
  ------------------
  |  Branch (337:16): [True: 4.83M, False: 8.15M]
  ------------------
  338|  12.9M|      index = index*qv+ (m<0?0:(m>=qv?qv-1:m));
  ------------------
  |  Branch (338:26): [True: 0, False: 12.9M]
  |  Branch (338:33): [True: 447, False: 12.9M]
  ------------------
  339|  12.9M|      p[o]=v*del+minval;
  340|  12.9M|    }
  341|  5.89M|  }
  342|       |
  343|  10.0M|  if(book->c->lengthlist[index]<=0){
  ------------------
  |  Branch (343:6): [True: 734, False: 10.0M]
  ------------------
  344|    734|    const static_codebook *c=book->c;
  345|    734|    int best=-1;
  346|       |    /* assumes integer/centered encoder codebook maptype 1 no more than dim 8 */
  347|    734|    int e[8]={0,0,0,0,0,0,0,0};
  348|    734|    int maxval = book->minval + book->delta*(book->quantvals-1);
  349|   110k|    for(i=0;i<book->entries;i++){
  ------------------
  |  Branch (349:13): [True: 109k, False: 734]
  ------------------
  350|   109k|      if(c->lengthlist[i]>0){
  ------------------
  |  Branch (350:10): [True: 79.4k, False: 29.9k]
  ------------------
  351|  79.4k|        int this=0;
  352|   317k|        for(j=0;j<dim;j++){
  ------------------
  |  Branch (352:17): [True: 238k, False: 79.4k]
  ------------------
  353|   238k|          int val=(e[j]-a[j]);
  354|   238k|          this+=val*val;
  355|   238k|        }
  356|  79.4k|        if(best==-1 || this<best){
  ------------------
  |  Branch (356:12): [True: 734, False: 78.7k]
  |  Branch (356:24): [True: 3.80k, False: 74.9k]
  ------------------
  357|  4.53k|          memcpy(p,e,sizeof(p));
  358|  4.53k|          best=this;
  359|  4.53k|          index=i;
  360|  4.53k|        }
  361|  79.4k|      }
  362|       |      /* assumes the value patterning created by the tools in vq/ */
  363|   109k|      j=0;
  364|   126k|      while(e[j]>=maxval)
  ------------------
  |  Branch (364:13): [True: 17.3k, False: 109k]
  ------------------
  365|  17.3k|        e[j++]=0;
  366|   109k|      if(e[j]>=0)
  ------------------
  |  Branch (366:10): [True: 55.0k, False: 54.3k]
  ------------------
  367|  55.0k|        e[j]+=book->delta;
  368|   109k|      e[j]= -e[j];
  369|   109k|    }
  370|    734|  }
  371|       |
  372|  10.0M|  if(index>-1){
  ------------------
  |  Branch (372:6): [True: 10.0M, False: 0]
  ------------------
  373|  31.9M|    for(i=0;i<dim;i++)
  ------------------
  |  Branch (373:13): [True: 21.9M, False: 10.0M]
  ------------------
  374|  21.9M|      *a++ -= p[i];
  375|  10.0M|  }
  376|       |
  377|  10.0M|  return(index);
  378|  10.0M|}
res0.c:_01class:
  407|  52.5k|                       int **in,int ch){
  408|  52.5k|  long i,j,k;
  409|  52.5k|  vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
  410|  52.5k|  vorbis_info_residue0 *info=look->info;
  411|       |
  412|       |  /* move all this setup out later */
  413|  52.5k|  int samples_per_partition=info->grouping;
  414|  52.5k|  int possible_partitions=info->partitions;
  415|  52.5k|  int n=info->end-info->begin;
  416|       |
  417|  52.5k|  int partvals=n/samples_per_partition;
  418|  52.5k|  long **partword=_vorbis_block_alloc(vb,ch*sizeof(*partword));
  419|  52.5k|  float scale=100./samples_per_partition;
  420|       |
  421|       |  /* we find the partition type for each partition of each
  422|       |     channel.  We'll go back and do the interleaved encoding in a
  423|       |     bit.  For now, clarity */
  424|       |
  425|   143k|  for(i=0;i<ch;i++){
  ------------------
  |  Branch (425:11): [True: 91.2k, False: 52.5k]
  ------------------
  426|  91.2k|    partword[i]=_vorbis_block_alloc(vb,n/samples_per_partition*sizeof(*partword[i]));
  427|  91.2k|    memset(partword[i],0,n/samples_per_partition*sizeof(*partword[i]));
  428|  91.2k|  }
  429|       |
  430|   386k|  for(i=0;i<partvals;i++){
  ------------------
  |  Branch (430:11): [True: 334k, False: 52.5k]
  ------------------
  431|   334k|    int offset=i*samples_per_partition+info->begin;
  432|   996k|    for(j=0;j<ch;j++){
  ------------------
  |  Branch (432:13): [True: 661k, False: 334k]
  ------------------
  433|   661k|      int max=0;
  434|   661k|      int ent=0;
  435|  15.1M|      for(k=0;k<samples_per_partition;k++){
  ------------------
  |  Branch (435:15): [True: 14.5M, False: 661k]
  ------------------
  436|  14.5M|        if(abs(in[j][offset+k])>max)max=abs(in[j][offset+k]);
  ------------------
  |  Branch (436:12): [True: 1.34M, False: 13.1M]
  ------------------
  437|  14.5M|        ent+=abs(in[j][offset+k]);
  438|  14.5M|      }
  439|   661k|      ent*=scale;
  440|       |
  441|  3.85M|      for(k=0;k<possible_partitions-1;k++)
  ------------------
  |  Branch (441:15): [True: 3.81M, False: 46.5k]
  ------------------
  442|  3.81M|        if(max<=info->classmetric1[k] &&
  ------------------
  |  Branch (442:12): [True: 717k, False: 3.09M]
  ------------------
  443|   717k|           (info->classmetric2[k]<0 || ent<info->classmetric2[k]))
  ------------------
  |  Branch (443:13): [True: 582k, False: 135k]
  |  Branch (443:40): [True: 33.1k, False: 102k]
  ------------------
  444|   615k|          break;
  445|       |
  446|   661k|      partword[j][i]=k;
  447|   661k|    }
  448|   334k|  }
  449|       |
  450|       |#ifdef TRAIN_RESAUX
  451|       |  {
  452|       |    FILE *of;
  453|       |    char buffer[80];
  454|       |
  455|       |    for(i=0;i<ch;i++){
  456|       |      sprintf(buffer,"resaux_%d.vqd",look->train_seq);
  457|       |      of=fopen(buffer,"a");
  458|       |      for(j=0;j<partvals;j++)
  459|       |        fprintf(of,"%ld, ",partword[i][j]);
  460|       |      fprintf(of,"\n");
  461|       |      fclose(of);
  462|       |    }
  463|       |  }
  464|       |#endif
  465|  52.5k|  look->frames++;
  466|       |
  467|  52.5k|  return(partword);
  468|  52.5k|}
res0.c:_2class:
  474|  4.65k|                      int ch){
  475|  4.65k|  long i,j,k,l;
  476|  4.65k|  vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
  477|  4.65k|  vorbis_info_residue0 *info=look->info;
  478|       |
  479|       |  /* move all this setup out later */
  480|  4.65k|  int samples_per_partition=info->grouping;
  481|  4.65k|  int possible_partitions=info->partitions;
  482|  4.65k|  int n=info->end-info->begin;
  483|       |
  484|  4.65k|  int partvals=n/samples_per_partition;
  485|  4.65k|  long **partword=_vorbis_block_alloc(vb,sizeof(*partword));
  486|       |
  487|       |#if defined(TRAIN_RES) || defined (TRAIN_RESAUX)
  488|       |  FILE *of;
  489|       |  char buffer[80];
  490|       |#endif
  491|       |
  492|  4.65k|  partword[0]=_vorbis_block_alloc(vb,partvals*sizeof(*partword[0]));
  493|  4.65k|  memset(partword[0],0,partvals*sizeof(*partword[0]));
  494|       |
  495|  72.4k|  for(i=0,l=info->begin/ch;i<partvals;i++){
  ------------------
  |  Branch (495:28): [True: 67.7k, False: 4.65k]
  ------------------
  496|  67.7k|    int magmax=0;
  497|  67.7k|    int angmax=0;
  498|   801k|    for(j=0;j<samples_per_partition;j+=ch){
  ------------------
  |  Branch (498:13): [True: 734k, False: 67.7k]
  ------------------
  499|   734k|      if(abs(in[0][l])>magmax)magmax=abs(in[0][l]);
  ------------------
  |  Branch (499:10): [True: 114k, False: 619k]
  ------------------
  500|  1.46M|      for(k=1;k<ch;k++)
  ------------------
  |  Branch (500:15): [True: 734k, False: 734k]
  ------------------
  501|   734k|        if(abs(in[k][l])>angmax)angmax=abs(in[k][l]);
  ------------------
  |  Branch (501:12): [True: 91.3k, False: 642k]
  ------------------
  502|   734k|      l++;
  503|   734k|    }
  504|       |
  505|   352k|    for(j=0;j<possible_partitions-1;j++)
  ------------------
  |  Branch (505:13): [True: 349k, False: 3.65k]
  ------------------
  506|   349k|      if(magmax<=info->classmetric1[j] &&
  ------------------
  |  Branch (506:10): [True: 83.2k, False: 266k]
  ------------------
  507|  83.2k|         angmax<=info->classmetric2[j])
  ------------------
  |  Branch (507:10): [True: 64.1k, False: 19.0k]
  ------------------
  508|  64.1k|        break;
  509|       |
  510|  67.7k|    partword[0][i]=j;
  511|       |
  512|  67.7k|  }
  513|       |
  514|       |#ifdef TRAIN_RESAUX
  515|       |  sprintf(buffer,"resaux_%d.vqd",look->train_seq);
  516|       |  of=fopen(buffer,"a");
  517|       |  for(i=0;i<partvals;i++)
  518|       |    fprintf(of,"%ld, ",partword[0][i]);
  519|       |  fprintf(of,"\n");
  520|       |  fclose(of);
  521|       |#endif
  522|       |
  523|  4.65k|  look->frames++;
  524|       |
  525|  4.65k|  return(partword);
  526|  4.65k|}

envelope.c:todB:
   43|  29.5M|static inline float todB(const float *x){
   44|  29.5M|  union {
   45|  29.5M|    ogg_uint32_t i;
   46|  29.5M|    float f;
   47|  29.5M|  } ix;
   48|  29.5M|  ix.f = *x;
   49|  29.5M|  ix.i = ix.i&0x7fffffff;
   50|  29.5M|  return (float)(ix.i * 7.17711438e-7f -764.6161886f);
   51|  29.5M|}
psy.c:unitnorm:
   32|   144k|static inline float unitnorm(float x){
   33|   144k|  union {
   34|   144k|    ogg_uint32_t i;
   35|   144k|    float f;
   36|   144k|  } ix;
   37|   144k|  ix.f = x;
   38|   144k|  ix.i = (ix.i & 0x80000000U) | (0x3f800000U);
   39|   144k|  return ix.f;
   40|   144k|}
mapping0.c:todB:
   43|  40.3M|static inline float todB(const float *x){
   44|  40.3M|  union {
   45|  40.3M|    ogg_uint32_t i;
   46|  40.3M|    float f;
   47|  40.3M|  } ix;
   48|  40.3M|  ix.f = *x;
   49|  40.3M|  ix.i = ix.i&0x7fffffff;
   50|  40.3M|  return (float)(ix.i * 7.17711438e-7f -764.6161886f);
   51|  40.3M|}

ov_ilog:
   30|   403k|int ov_ilog(ogg_uint32_t v){
   31|   403k|  int ret;
   32|  2.73M|  for(ret=0;v;ret++)v>>=1;
  ------------------
  |  Branch (32:13): [True: 2.32M, False: 403k]
  ------------------
   33|   403k|  return ret;
   34|   403k|}
_float32_unpack:
   60|   163k|float _float32_unpack(long val){
   61|   163k|  double mant=val&0x1fffff;
   62|   163k|  int    sign=val&0x80000000;
   63|   163k|  long   exp =(val&0x7fe00000L)>>VQ_FMAN;
  ------------------
  |  |   41|   163k|#define VQ_FMAN 21
  ------------------
   64|   163k|  if(sign)mant= -mant;
  ------------------
  |  Branch (64:6): [True: 28.8k, False: 134k]
  ------------------
   65|   163k|  exp=exp-(VQ_FMAN-1)-VQ_FEXP_BIAS;
  ------------------
  |  |   41|   163k|#define VQ_FMAN 21
  ------------------
                exp=exp-(VQ_FMAN-1)-VQ_FEXP_BIAS;
  ------------------
  |  |   42|   163k|#define VQ_FEXP_BIAS 768 /* bias toward values smaller than 1. */
  ------------------
   66|       |  /* clamp excessive exponent values */
   67|   163k|  if (exp>63){
  ------------------
  |  Branch (67:7): [True: 0, False: 163k]
  ------------------
   68|      0|    exp=63;
   69|      0|  }
   70|   163k|  if (exp<-63){
  ------------------
  |  Branch (70:7): [True: 105k, False: 57.6k]
  ------------------
   71|   105k|    exp=-63;
   72|   105k|  }
   73|   163k|  return(ldexp(mant,exp));
   74|   163k|}
_make_words:
   79|  81.5k|ogg_uint32_t *_make_words(char *l,long n,long sparsecount){
   80|  81.5k|  long i,j,count=0;
   81|  81.5k|  ogg_uint32_t marker[33];
   82|  81.5k|  ogg_uint32_t *r=_ogg_malloc((sparsecount?sparsecount:n)*sizeof(*r));
  ------------------
  |  |   21|  81.5k|#define _ogg_malloc  malloc
  ------------------
  |  Branch (82:32): [True: 0, False: 81.5k]
  ------------------
   83|  81.5k|  memset(marker,0,sizeof(marker));
   84|       |
   85|  11.9M|  for(i=0;i<n;i++){
  ------------------
  |  Branch (85:11): [True: 11.9M, False: 81.5k]
  ------------------
   86|  11.9M|    long length=l[i];
   87|  11.9M|    if(length>0){
  ------------------
  |  Branch (87:8): [True: 9.05M, False: 2.85M]
  ------------------
   88|  9.05M|      ogg_uint32_t entry=marker[length];
   89|       |
   90|       |      /* when we claim a node for an entry, we also claim the nodes
   91|       |         below it (pruning off the imagined tree that may have dangled
   92|       |         from it) as well as blocking the use of any nodes directly
   93|       |         above for leaves */
   94|       |
   95|       |      /* update ourself */
   96|  9.05M|      if(length<32 && (entry>>length)){
  ------------------
  |  Branch (96:10): [True: 9.05M, False: 0]
  |  Branch (96:23): [True: 0, False: 9.05M]
  ------------------
   97|       |        /* error condition; the lengths must specify an overpopulated tree */
   98|      0|        _ogg_free(r);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
   99|      0|        return(NULL);
  100|      0|      }
  101|  9.05M|      r[count++]=entry;
  102|       |
  103|       |      /* Look to see if the next shorter marker points to the node
  104|       |         above. if so, update it and repeat.  */
  105|  9.05M|      {
  106|  18.0M|        for(j=length;j>0;j--){
  ------------------
  |  Branch (106:22): [True: 17.9M, False: 81.5k]
  ------------------
  107|       |
  108|  17.9M|          if(marker[j]&1){
  ------------------
  |  Branch (108:14): [True: 8.97M, False: 8.97M]
  ------------------
  109|       |            /* have to jump branches */
  110|  8.97M|            if(j==1)
  ------------------
  |  Branch (110:16): [True: 81.5k, False: 8.89M]
  ------------------
  111|  81.5k|              marker[1]++;
  112|  8.89M|            else
  113|  8.89M|              marker[j]=marker[j-1]<<1;
  114|  8.97M|            break; /* invariant says next upper marker would already
  115|       |                      have been moved if it was on the same path */
  116|  8.97M|          }
  117|  8.97M|          marker[j]++;
  118|  8.97M|        }
  119|  9.05M|      }
  120|       |
  121|       |      /* prune the tree; the implicit invariant says all the longer
  122|       |         markers were dangling from our just-taken node.  Dangle them
  123|       |         from our *new* node. */
  124|   110M|      for(j=length+1;j<33;j++)
  ------------------
  |  Branch (124:22): [True: 105M, False: 4.70M]
  ------------------
  125|   105M|        if((marker[j]>>1) == entry){
  ------------------
  |  Branch (125:12): [True: 101M, False: 4.34M]
  ------------------
  126|   101M|          entry=marker[j];
  127|   101M|          marker[j]=marker[j-1]<<1;
  128|   101M|        }else
  129|  4.34M|          break;
  130|  9.05M|    }else
  131|  2.85M|      if(sparsecount==0)count++;
  ------------------
  |  Branch (131:10): [True: 2.85M, False: 0]
  ------------------
  132|  11.9M|  }
  133|       |
  134|       |  /* any underpopulated tree must be rejected. */
  135|       |  /* Single-entry codebooks are a retconned extension to the spec.
  136|       |     They have a single codeword '0' of length 1 that results in an
  137|       |     underpopulated tree.  Shield that case from the underformed tree check. */
  138|  81.5k|  if(!(count==1 && marker[2]==2)){
  ------------------
  |  Branch (138:8): [True: 0, False: 81.5k]
  |  Branch (138:20): [True: 0, False: 0]
  ------------------
  139|  2.69M|    for(i=1;i<33;i++)
  ------------------
  |  Branch (139:13): [True: 2.61M, False: 81.5k]
  ------------------
  140|  2.61M|      if(marker[i] & (0xffffffffUL>>(32-i))){
  ------------------
  |  Branch (140:10): [True: 0, False: 2.61M]
  ------------------
  141|      0|        _ogg_free(r);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  142|      0|        return(NULL);
  143|      0|      }
  144|  81.5k|  }
  145|       |
  146|       |  /* bitreverse the words because our bitwise packer/unpacker is LSb
  147|       |     endian */
  148|  11.9M|  for(i=0,count=0;i<n;i++){
  ------------------
  |  Branch (148:19): [True: 11.9M, False: 81.5k]
  ------------------
  149|  11.9M|    ogg_uint32_t temp=0;
  150|   107M|    for(j=0;j<l[i];j++){
  ------------------
  |  Branch (150:13): [True: 95.4M, False: 11.9M]
  ------------------
  151|  95.4M|      temp<<=1;
  152|  95.4M|      temp|=(r[count]>>j)&1;
  153|  95.4M|    }
  154|       |
  155|  11.9M|    if(sparsecount){
  ------------------
  |  Branch (155:8): [True: 0, False: 11.9M]
  ------------------
  156|      0|      if(l[i])
  ------------------
  |  Branch (156:10): [True: 0, False: 0]
  ------------------
  157|      0|        r[count++]=temp;
  158|      0|    }else
  159|  11.9M|      r[count++]=temp;
  160|  11.9M|  }
  161|       |
  162|  81.5k|  return(r);
  163|  81.5k|}
_book_maptype1_quantvals:
  168|   110k|long _book_maptype1_quantvals(const static_codebook *b){
  169|   110k|  long vals;
  170|   110k|  if(b->entries<1){
  ------------------
  |  Branch (170:6): [True: 0, False: 110k]
  ------------------
  171|      0|    return(0);
  172|      0|  }
  173|   110k|  vals=floor(pow((float)b->entries,1.f/b->dim));
  174|       |
  175|       |  /* the above *should* be reliable, but we'll not assume that FP is
  176|       |     ever reliable when bitstream sync is at stake; verify via integer
  177|       |     means that vals really is the greatest value of dim for which
  178|       |     vals^b->bim <= b->entries */
  179|       |  /* treat the above as an initial guess */
  180|   110k|  if(vals<1){
  ------------------
  |  Branch (180:6): [True: 0, False: 110k]
  ------------------
  181|      0|    vals=1;
  182|      0|  }
  183|   110k|  while(1){
  ------------------
  |  Branch (183:9): [True: 110k, Folded]
  ------------------
  184|   110k|    long acc=1;
  185|   110k|    long acc1=1;
  186|   110k|    int i;
  187|   319k|    for(i=0;i<b->dim;i++){
  ------------------
  |  Branch (187:13): [True: 209k, False: 110k]
  ------------------
  188|   209k|      if(b->entries/vals<acc)break;
  ------------------
  |  Branch (188:10): [True: 0, False: 209k]
  ------------------
  189|   209k|      acc*=vals;
  190|   209k|      if(LONG_MAX/(vals+1)<acc1)acc1=LONG_MAX;
  ------------------
  |  Branch (190:10): [True: 0, False: 209k]
  ------------------
  191|   209k|      else acc1*=vals+1;
  192|   209k|    }
  193|   110k|    if(i>=b->dim && acc<=b->entries && acc1>b->entries){
  ------------------
  |  Branch (193:8): [True: 110k, False: 0]
  |  Branch (193:21): [True: 110k, False: 0]
  |  Branch (193:40): [True: 110k, False: 0]
  ------------------
  194|   110k|      return(vals);
  195|   110k|    }else{
  196|      0|      if(i<b->dim || acc>b->entries){
  ------------------
  |  Branch (196:10): [True: 0, False: 0]
  |  Branch (196:22): [True: 0, False: 0]
  ------------------
  197|      0|        vals--;
  198|      0|      }else{
  199|      0|        vals++;
  200|      0|      }
  201|      0|    }
  202|   110k|  }
  203|   110k|}
vorbis_staticbook_destroy:
  275|  81.5k|void vorbis_staticbook_destroy(static_codebook *b){
  276|  81.5k|  if(b->allocedp){
  ------------------
  |  Branch (276:6): [True: 0, False: 81.5k]
  ------------------
  277|      0|    if(b->quantlist)_ogg_free(b->quantlist);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (277:8): [True: 0, False: 0]
  ------------------
  278|      0|    if(b->lengthlist)_ogg_free(b->lengthlist);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (278:8): [True: 0, False: 0]
  ------------------
  279|      0|    memset(b,0,sizeof(*b));
  280|      0|    _ogg_free(b);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  281|      0|  } /* otherwise, it is in static memory */
  282|  81.5k|}
vorbis_book_clear:
  284|  81.5k|void vorbis_book_clear(codebook *b){
  285|       |  /* static book is not cleared; we're likely called on the lookup and
  286|       |     the static codebook belongs to the info struct */
  287|  81.5k|  if(b->valuelist)_ogg_free(b->valuelist);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (287:6): [True: 0, False: 81.5k]
  ------------------
  288|  81.5k|  if(b->codelist)_ogg_free(b->codelist);
  ------------------
  |  |   24|  81.5k|#define _ogg_free    free
  ------------------
  |  Branch (288:6): [True: 81.5k, False: 0]
  ------------------
  289|       |
  290|  81.5k|  if(b->dec_index)_ogg_free(b->dec_index);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (290:6): [True: 0, False: 81.5k]
  ------------------
  291|  81.5k|  if(b->dec_codelengths)_ogg_free(b->dec_codelengths);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (291:6): [True: 0, False: 81.5k]
  ------------------
  292|  81.5k|  if(b->dec_firsttable)_ogg_free(b->dec_firsttable);
  ------------------
  |  |   24|      0|#define _ogg_free    free
  ------------------
  |  Branch (292:6): [True: 0, False: 81.5k]
  ------------------
  293|       |
  294|  81.5k|  memset(b,0,sizeof(*b));
  295|  81.5k|}
vorbis_book_init_encode:
  297|  81.5k|int vorbis_book_init_encode(codebook *c,const static_codebook *s){
  298|       |
  299|  81.5k|  memset(c,0,sizeof(*c));
  300|  81.5k|  c->c=s;
  301|  81.5k|  c->entries=s->entries;
  302|  81.5k|  c->used_entries=s->entries;
  303|  81.5k|  c->dim=s->dim;
  304|  81.5k|  c->codelist=_make_words(s->lengthlist,s->entries,0);
  305|       |  /* c->valuelist=_book_unquantize(s,s->entries,NULL); */
  306|  81.5k|  c->quantvals=_book_maptype1_quantvals(s);
  307|  81.5k|  c->minval=(int)rint(_float32_unpack(s->q_min));
  308|  81.5k|  c->delta=(int)rint(_float32_unpack(s->q_delta));
  309|       |
  310|  81.5k|  return(0);
  311|  81.5k|}

drft_forward:
 1231|   103k|void drft_forward(drft_lookup *l,float *data){
 1232|   103k|  if(l->n==1)return;
  ------------------
  |  Branch (1232:6): [True: 0, False: 103k]
  ------------------
 1233|   103k|  drftf1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache);
 1234|   103k|}
drft_init:
 1241|  4.54k|void drft_init(drft_lookup *l,int n){
 1242|  4.54k|  l->n=n;
 1243|  4.54k|  l->trigcache=_ogg_calloc(3*n,sizeof(*l->trigcache));
  ------------------
  |  |   22|  4.54k|#define _ogg_calloc  calloc
  ------------------
 1244|  4.54k|  l->splitcache=_ogg_calloc(32,sizeof(*l->splitcache));
  ------------------
  |  |   22|  4.54k|#define _ogg_calloc  calloc
  ------------------
 1245|  4.54k|  fdrffti(n, l->trigcache, l->splitcache);
 1246|  4.54k|}
drft_clear:
 1248|  4.54k|void drft_clear(drft_lookup *l){
 1249|  4.54k|  if(l){
  ------------------
  |  Branch (1249:6): [True: 4.54k, False: 0]
  ------------------
 1250|  4.54k|    if(l->trigcache)_ogg_free(l->trigcache);
  ------------------
  |  |   24|  4.54k|#define _ogg_free    free
  ------------------
  |  Branch (1250:8): [True: 4.54k, False: 0]
  ------------------
 1251|  4.54k|    if(l->splitcache)_ogg_free(l->splitcache);
  ------------------
  |  |   24|  4.54k|#define _ogg_free    free
  ------------------
  |  Branch (1251:8): [True: 4.54k, False: 0]
  ------------------
 1252|  4.54k|    memset(l,0,sizeof(*l));
 1253|  4.54k|  }
 1254|  4.54k|}
smallft.c:drftf1:
  572|   103k|static void drftf1(int n,float *c,float *ch,float *wa,int *ifac){
  573|   103k|  int i,k1,l1,l2;
  574|   103k|  int na,kh,nf;
  575|   103k|  int ip,iw,ido,idl1,ix2,ix3;
  576|       |
  577|   103k|  nf=ifac[1];
  578|   103k|  na=1;
  579|   103k|  l2=n;
  580|   103k|  iw=n;
  581|       |
  582|   546k|  for(k1=0;k1<nf;k1++){
  ------------------
  |  Branch (582:12): [True: 442k, False: 103k]
  ------------------
  583|   442k|    kh=nf-k1;
  584|   442k|    ip=ifac[kh+1];
  585|   442k|    l1=l2/ip;
  586|   442k|    ido=n/l2;
  587|   442k|    idl1=ido*l1;
  588|   442k|    iw-=(ip-1)*ido;
  589|   442k|    na=1-na;
  590|       |
  591|   442k|    if(ip!=4)goto L102;
  ------------------
  |  Branch (591:8): [True: 22.0k, False: 420k]
  ------------------
  592|       |
  593|   420k|    ix2=iw+ido;
  594|   420k|    ix3=ix2+ido;
  595|   420k|    if(na!=0)
  ------------------
  |  Branch (595:8): [True: 207k, False: 213k]
  ------------------
  596|   207k|      dradf4(ido,l1,ch,c,wa+iw-1,wa+ix2-1,wa+ix3-1);
  597|   213k|    else
  598|   213k|      dradf4(ido,l1,c,ch,wa+iw-1,wa+ix2-1,wa+ix3-1);
  599|   420k|    goto L110;
  600|       |
  601|  22.0k| L102:
  602|  22.0k|    if(ip!=2)goto L104;
  ------------------
  |  Branch (602:8): [True: 0, False: 22.0k]
  ------------------
  603|  22.0k|    if(na!=0)goto L103;
  ------------------
  |  Branch (603:8): [True: 4.08k, False: 18.0k]
  ------------------
  604|       |
  605|  18.0k|    dradf2(ido,l1,c,ch,wa+iw-1);
  606|  18.0k|    goto L110;
  607|       |
  608|  4.08k|  L103:
  609|  4.08k|    dradf2(ido,l1,ch,c,wa+iw-1);
  610|  4.08k|    goto L110;
  611|       |
  612|      0|  L104:
  613|      0|    if(ido==1)na=1-na;
  ------------------
  |  Branch (613:8): [True: 0, False: 0]
  ------------------
  614|      0|    if(na!=0)goto L109;
  ------------------
  |  Branch (614:8): [True: 0, False: 0]
  ------------------
  615|       |
  616|      0|    dradfg(ido,ip,l1,idl1,c,c,c,ch,ch,wa+iw-1);
  617|      0|    na=1;
  618|      0|    goto L110;
  619|       |
  620|      0|  L109:
  621|      0|    dradfg(ido,ip,l1,idl1,ch,ch,ch,c,c,wa+iw-1);
  622|      0|    na=0;
  623|       |
  624|   442k|  L110:
  625|   442k|    l2=l1;
  626|   442k|  }
  627|       |
  628|   103k|  if(na==1)return;
  ------------------
  |  Branch (628:6): [True: 83.2k, False: 20.3k]
  ------------------
  629|       |
  630|  11.6M|  for(i=0;i<n;i++)c[i]=ch[i];
  ------------------
  |  Branch (630:11): [True: 11.6M, False: 20.3k]
  ------------------
  631|  20.3k|}
smallft.c:dradf4:
  169|   420k|            float *wa2,float *wa3){
  170|   420k|  static const float hsqt2 = .70710678118654752f;
  171|   420k|  int i,k,t0,t1,t2,t3,t4,t5,t6;
  172|   420k|  float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4;
  173|   420k|  t0=l1*ido;
  174|       |
  175|   420k|  t1=t0;
  176|   420k|  t4=t1<<1;
  177|   420k|  t2=t1+(t1<<1);
  178|   420k|  t3=0;
  179|       |
  180|  13.7M|  for(k=0;k<l1;k++){
  ------------------
  |  Branch (180:11): [True: 13.3M, False: 420k]
  ------------------
  181|  13.3M|    tr1=cc[t1]+cc[t2];
  182|  13.3M|    tr2=cc[t3]+cc[t4];
  183|       |
  184|  13.3M|    ch[t5=t3<<2]=tr1+tr2;
  185|  13.3M|    ch[(ido<<2)+t5-1]=tr2-tr1;
  186|  13.3M|    ch[(t5+=(ido<<1))-1]=cc[t3]-cc[t4];
  187|  13.3M|    ch[t5]=cc[t2]-cc[t1];
  188|       |
  189|  13.3M|    t1+=ido;
  190|  13.3M|    t2+=ido;
  191|  13.3M|    t3+=ido;
  192|  13.3M|    t4+=ido;
  193|  13.3M|  }
  194|       |
  195|   420k|  if(ido<2)return;
  ------------------
  |  Branch (195:6): [True: 103k, False: 317k]
  ------------------
  196|   317k|  if(ido==2)goto L105;
  ------------------
  |  Branch (196:6): [True: 0, False: 317k]
  ------------------
  197|       |
  198|       |
  199|   317k|  t1=0;
  200|  3.62M|  for(k=0;k<l1;k++){
  ------------------
  |  Branch (200:11): [True: 3.31M, False: 317k]
  ------------------
  201|  3.31M|    t2=t1;
  202|  3.31M|    t4=t1<<2;
  203|  3.31M|    t5=(t6=ido<<1)+t4;
  204|  16.4M|    for(i=2;i<ido;i+=2){
  ------------------
  |  Branch (204:13): [True: 13.1M, False: 3.31M]
  ------------------
  205|  13.1M|      t3=(t2+=2);
  206|  13.1M|      t4+=2;
  207|  13.1M|      t5-=2;
  208|       |
  209|  13.1M|      t3+=t0;
  210|  13.1M|      cr2=wa1[i-2]*cc[t3-1]+wa1[i-1]*cc[t3];
  211|  13.1M|      ci2=wa1[i-2]*cc[t3]-wa1[i-1]*cc[t3-1];
  212|  13.1M|      t3+=t0;
  213|  13.1M|      cr3=wa2[i-2]*cc[t3-1]+wa2[i-1]*cc[t3];
  214|  13.1M|      ci3=wa2[i-2]*cc[t3]-wa2[i-1]*cc[t3-1];
  215|  13.1M|      t3+=t0;
  216|  13.1M|      cr4=wa3[i-2]*cc[t3-1]+wa3[i-1]*cc[t3];
  217|  13.1M|      ci4=wa3[i-2]*cc[t3]-wa3[i-1]*cc[t3-1];
  218|       |
  219|  13.1M|      tr1=cr2+cr4;
  220|  13.1M|      tr4=cr4-cr2;
  221|  13.1M|      ti1=ci2+ci4;
  222|  13.1M|      ti4=ci2-ci4;
  223|       |
  224|  13.1M|      ti2=cc[t2]+ci3;
  225|  13.1M|      ti3=cc[t2]-ci3;
  226|  13.1M|      tr2=cc[t2-1]+cr3;
  227|  13.1M|      tr3=cc[t2-1]-cr3;
  228|       |
  229|  13.1M|      ch[t4-1]=tr1+tr2;
  230|  13.1M|      ch[t4]=ti1+ti2;
  231|       |
  232|  13.1M|      ch[t5-1]=tr3-ti4;
  233|  13.1M|      ch[t5]=tr4-ti3;
  234|       |
  235|  13.1M|      ch[t4+t6-1]=ti4+tr3;
  236|  13.1M|      ch[t4+t6]=tr4+ti3;
  237|       |
  238|  13.1M|      ch[t5+t6-1]=tr2-tr1;
  239|  13.1M|      ch[t5+t6]=ti1-ti2;
  240|  13.1M|    }
  241|  3.31M|    t1+=ido;
  242|  3.31M|  }
  243|   317k|  if(ido&1)return;
  ------------------
  |  Branch (243:6): [True: 0, False: 317k]
  ------------------
  244|       |
  245|   317k| L105:
  246|       |
  247|   317k|  t2=(t1=t0+ido-1)+(t0<<1);
  248|   317k|  t3=ido<<2;
  249|   317k|  t4=ido;
  250|   317k|  t5=ido<<1;
  251|   317k|  t6=ido;
  252|       |
  253|  3.62M|  for(k=0;k<l1;k++){
  ------------------
  |  Branch (253:11): [True: 3.31M, False: 317k]
  ------------------
  254|  3.31M|    ti1=-hsqt2*(cc[t1]+cc[t2]);
  255|  3.31M|    tr1=hsqt2*(cc[t1]-cc[t2]);
  256|       |
  257|  3.31M|    ch[t4-1]=tr1+cc[t6-1];
  258|  3.31M|    ch[t4+t5-1]=cc[t6-1]-tr1;
  259|       |
  260|  3.31M|    ch[t4]=ti1-cc[t1+t0];
  261|  3.31M|    ch[t4+t5]=ti1+cc[t1+t0];
  262|       |
  263|  3.31M|    t1+=ido;
  264|  3.31M|    t2+=ido;
  265|  3.31M|    t4+=t3;
  266|  3.31M|    t6+=ido;
  267|  3.31M|  }
  268|   317k|}
smallft.c:dradf2:
  113|  22.0k|static void dradf2(int ido,int l1,float *cc,float *ch,float *wa1){
  114|  22.0k|  int i,k;
  115|  22.0k|  float ti2,tr2;
  116|  22.0k|  int t0,t1,t2,t3,t4,t5,t6;
  117|       |
  118|  22.0k|  t1=0;
  119|  22.0k|  t0=(t2=l1*ido);
  120|  22.0k|  t3=ido<<1;
  121|  44.1k|  for(k=0;k<l1;k++){
  ------------------
  |  Branch (121:11): [True: 22.0k, False: 22.0k]
  ------------------
  122|  22.0k|    ch[t1<<1]=cc[t1]+cc[t2];
  123|  22.0k|    ch[(t1<<1)+t3-1]=cc[t1]-cc[t2];
  124|  22.0k|    t1+=ido;
  125|  22.0k|    t2+=ido;
  126|  22.0k|  }
  127|       |
  128|  22.0k|  if(ido<2)return;
  ------------------
  |  Branch (128:6): [True: 0, False: 22.0k]
  ------------------
  129|  22.0k|  if(ido==2)goto L105;
  ------------------
  |  Branch (129:6): [True: 0, False: 22.0k]
  ------------------
  130|       |
  131|  22.0k|  t1=0;
  132|  22.0k|  t2=t0;
  133|  44.1k|  for(k=0;k<l1;k++){
  ------------------
  |  Branch (133:11): [True: 22.0k, False: 22.0k]
  ------------------
  134|  22.0k|    t3=t2;
  135|  22.0k|    t4=(t1<<1)+(ido<<1);
  136|  22.0k|    t5=t1;
  137|  22.0k|    t6=t1+t1;
  138|  4.39M|    for(i=2;i<ido;i+=2){
  ------------------
  |  Branch (138:13): [True: 4.37M, False: 22.0k]
  ------------------
  139|  4.37M|      t3+=2;
  140|  4.37M|      t4-=2;
  141|  4.37M|      t5+=2;
  142|  4.37M|      t6+=2;
  143|  4.37M|      tr2=wa1[i-2]*cc[t3-1]+wa1[i-1]*cc[t3];
  144|  4.37M|      ti2=wa1[i-2]*cc[t3]-wa1[i-1]*cc[t3-1];
  145|  4.37M|      ch[t6]=cc[t5]+ti2;
  146|  4.37M|      ch[t4]=ti2-cc[t5];
  147|  4.37M|      ch[t6-1]=cc[t5-1]+tr2;
  148|  4.37M|      ch[t4-1]=cc[t5-1]-tr2;
  149|  4.37M|    }
  150|  22.0k|    t1+=ido;
  151|  22.0k|    t2+=ido;
  152|  22.0k|  }
  153|       |
  154|  22.0k|  if(ido%2==1)return;
  ------------------
  |  Branch (154:6): [True: 0, False: 22.0k]
  ------------------
  155|       |
  156|  22.0k| L105:
  157|  22.0k|  t3=(t2=(t1=ido)-1);
  158|  22.0k|  t2+=t0;
  159|  44.1k|  for(k=0;k<l1;k++){
  ------------------
  |  Branch (159:11): [True: 22.0k, False: 22.0k]
  ------------------
  160|  22.0k|    ch[t1]=-cc[t2];
  161|  22.0k|    ch[t1-1]=cc[t3];
  162|  22.0k|    t1+=ido<<1;
  163|  22.0k|    t2+=ido;
  164|  22.0k|    t3+=ido;
  165|  22.0k|  }
  166|  22.0k|}
smallft.c:fdrffti:
  107|  4.54k|static void fdrffti(int n, float *wsave, int *ifac){
  108|       |
  109|  4.54k|  if (n == 1) return;
  ------------------
  |  Branch (109:7): [True: 0, False: 4.54k]
  ------------------
  110|  4.54k|  drfti1(n, wsave+n, ifac);
  111|  4.54k|}
smallft.c:drfti1:
   37|  4.54k|static void drfti1(int n, float *wa, int *ifac){
   38|  4.54k|  static const int ntryh[4] = { 4,2,3,5 };
   39|  4.54k|  static const float tpi = 6.28318530717958648f;
   40|  4.54k|  float arg,argh,argld,fi;
   41|  4.54k|  int ntry=0,i,j=-1;
   42|  4.54k|  int k1, l1, l2, ib;
   43|  4.54k|  int ld, ii, ip, is, nq, nr;
   44|  4.54k|  int ido, ipm, nfm1;
   45|  4.54k|  int nl=n;
   46|  4.54k|  int nf=0;
   47|       |
   48|  6.97k| L101:
   49|  6.97k|  j++;
   50|  6.97k|  if (j < 4)
  ------------------
  |  Branch (50:7): [True: 6.97k, False: 0]
  ------------------
   51|  6.97k|    ntry=ntryh[j];
   52|      0|  else
   53|      0|    ntry+=2;
   54|       |
   55|  25.1k| L104:
   56|  25.1k|  nq=nl/ntry;
   57|  25.1k|  nr=nl-ntry*nq;
   58|  25.1k|  if (nr!=0) goto L101;
  ------------------
  |  Branch (58:7): [True: 2.43k, False: 22.7k]
  ------------------
   59|       |
   60|  22.7k|  nf++;
   61|  22.7k|  ifac[nf+1]=ntry;
   62|  22.7k|  nl=nq;
   63|  22.7k|  if(ntry!=2)goto L107;
  ------------------
  |  Branch (63:6): [True: 20.2k, False: 2.43k]
  ------------------
   64|  2.43k|  if(nf==1)goto L107;
  ------------------
  |  Branch (64:6): [True: 0, False: 2.43k]
  ------------------
   65|       |
   66|  13.8k|  for (i=1;i<nf;i++){
  ------------------
  |  Branch (66:12): [True: 11.3k, False: 2.43k]
  ------------------
   67|  11.3k|    ib=nf-i+1;
   68|  11.3k|    ifac[ib+1]=ifac[ib];
   69|  11.3k|  }
   70|  2.43k|  ifac[2] = 2;
   71|       |
   72|  22.7k| L107:
   73|  22.7k|  if(nl!=1)goto L104;
  ------------------
  |  Branch (73:6): [True: 18.1k, False: 4.54k]
  ------------------
   74|  4.54k|  ifac[0]=n;
   75|  4.54k|  ifac[1]=nf;
   76|  4.54k|  argh=tpi/n;
   77|  4.54k|  is=0;
   78|  4.54k|  nfm1=nf-1;
   79|  4.54k|  l1=1;
   80|       |
   81|  4.54k|  if(nfm1==0)return;
  ------------------
  |  Branch (81:6): [True: 0, False: 4.54k]
  ------------------
   82|       |
   83|  22.7k|  for (k1=0;k1<nfm1;k1++){
  ------------------
  |  Branch (83:13): [True: 18.1k, False: 4.54k]
  ------------------
   84|  18.1k|    ip=ifac[k1+2];
   85|  18.1k|    ld=0;
   86|  18.1k|    l2=l1*ip;
   87|  18.1k|    ido=n/l2;
   88|  18.1k|    ipm=ip-1;
   89|       |
   90|  67.7k|    for (j=0;j<ipm;j++){
  ------------------
  |  Branch (90:14): [True: 49.6k, False: 18.1k]
  ------------------
   91|  49.6k|      ld+=l1;
   92|  49.6k|      i=is;
   93|  49.6k|      argld=(float)ld*argh;
   94|  49.6k|      fi=0.f;
   95|  2.30M|      for (ii=2;ii<ido;ii+=2){
  ------------------
  |  Branch (95:17): [True: 2.25M, False: 49.6k]
  ------------------
   96|  2.25M|        fi+=1.f;
   97|  2.25M|        arg=fi*argld;
   98|  2.25M|        wa[i++]=cos(arg);
   99|  2.25M|        wa[i++]=sin(arg);
  100|  2.25M|      }
  101|  49.6k|      is+=ido;
  102|  49.6k|    }
  103|  18.1k|    l1=l2;
  104|  18.1k|  }
  105|  4.54k|}

vorbis_encode_setup_init:
  682|  2.27k|int vorbis_encode_setup_init(vorbis_info *vi){
  683|  2.27k|  int i,i0=0,singleblock=0;
  684|  2.27k|  codec_setup_info *ci=vi->codec_setup;
  685|  2.27k|  ve_setup_data_template *setup=NULL;
  686|  2.27k|  highlevel_encode_setup *hi=&ci->hi;
  687|       |
  688|  2.27k|  if(ci==NULL)return(OV_EINVAL);
  ------------------
  |  |  228|      0|#define OV_EINVAL     -131
  ------------------
  |  Branch (688:6): [True: 0, False: 2.27k]
  ------------------
  689|  2.27k|  if(vi->channels<1||vi->channels>255)return(OV_EINVAL);
  ------------------
  |  |  228|      0|#define OV_EINVAL     -131
  ------------------
  |  Branch (689:6): [True: 0, False: 2.27k]
  |  Branch (689:22): [True: 0, False: 2.27k]
  ------------------
  690|  2.27k|  if(!hi->impulse_block_p)i0=1;
  ------------------
  |  Branch (690:6): [True: 0, False: 2.27k]
  ------------------
  691|       |
  692|       |  /* too low/high an ATH floater is nonsensical, but doesn't break anything */
  693|  2.27k|  if(hi->ath_floating_dB>-80)hi->ath_floating_dB=-80;
  ------------------
  |  Branch (693:6): [True: 0, False: 2.27k]
  ------------------
  694|  2.27k|  if(hi->ath_floating_dB<-200)hi->ath_floating_dB=-200;
  ------------------
  |  Branch (694:6): [True: 0, False: 2.27k]
  ------------------
  695|       |
  696|       |  /* again, bound this to avoid the app shooting itself int he foot
  697|       |     too badly */
  698|  2.27k|  if(hi->amplitude_track_dBpersec>0.)hi->amplitude_track_dBpersec=0.;
  ------------------
  |  Branch (698:6): [True: 0, False: 2.27k]
  ------------------
  699|  2.27k|  if(hi->amplitude_track_dBpersec<-99999.)hi->amplitude_track_dBpersec=-99999.;
  ------------------
  |  Branch (699:6): [True: 0, False: 2.27k]
  ------------------
  700|       |
  701|       |  /* get the appropriate setup template; matches the fetch in previous
  702|       |     stages */
  703|  2.27k|  setup=(ve_setup_data_template *)hi->setup;
  704|  2.27k|  if(setup==NULL)return(OV_EINVAL);
  ------------------
  |  |  228|      0|#define OV_EINVAL     -131
  ------------------
  |  Branch (704:6): [True: 0, False: 2.27k]
  ------------------
  705|       |
  706|  2.27k|  hi->set_in_stone=1;
  707|       |  /* choose block sizes from configured sizes as well as paying
  708|       |     attention to long_block_p and short_block_p.  If the configured
  709|       |     short and long blocks are the same length, we set long_block_p
  710|       |     and unset short_block_p */
  711|  2.27k|  vorbis_encode_blocksize_setup(vi,hi->base_setting,
  712|  2.27k|                                setup->blocksize_short,
  713|  2.27k|                                setup->blocksize_long);
  714|  2.27k|  if(ci->blocksizes[0]==ci->blocksizes[1])singleblock=1;
  ------------------
  |  Branch (714:6): [True: 391, False: 1.87k]
  ------------------
  715|       |
  716|       |  /* floor setup; choose proper floor params.  Allocated on the floor
  717|       |     stack in order; if we alloc only a single long floor, it's 0 */
  718|  6.53k|  for(i=0;i<setup->floor_mappings;i++)
  ------------------
  |  Branch (718:11): [True: 4.26k, False: 2.27k]
  ------------------
  719|  4.26k|    vorbis_encode_floor_setup(vi,hi->base_setting,
  720|  4.26k|                              setup->floor_books,
  721|  4.26k|                              setup->floor_params,
  722|  4.26k|                              setup->floor_mapping_list[i]);
  723|       |
  724|       |  /* setup of [mostly] short block detection and stereo*/
  725|  2.27k|  vorbis_encode_global_psych_setup(vi,hi->trigger_setting,
  726|  2.27k|                                   setup->global_params,
  727|  2.27k|                                   setup->global_mapping);
  728|  2.27k|  vorbis_encode_global_stereo(vi,hi,setup->stereo_modes);
  729|       |
  730|       |  /* basic psych setup and noise normalization */
  731|  2.27k|  vorbis_encode_psyset_setup(vi,hi->base_setting,
  732|  2.27k|                             setup->psy_noise_normal_start[0],
  733|  2.27k|                             setup->psy_noise_normal_partition[0],
  734|  2.27k|                             setup->psy_noise_normal_thresh,
  735|  2.27k|                             0);
  736|  2.27k|  vorbis_encode_psyset_setup(vi,hi->base_setting,
  737|  2.27k|                             setup->psy_noise_normal_start[0],
  738|  2.27k|                             setup->psy_noise_normal_partition[0],
  739|  2.27k|                             setup->psy_noise_normal_thresh,
  740|  2.27k|                             1);
  741|  2.27k|  if(!singleblock){
  ------------------
  |  Branch (741:6): [True: 1.87k, False: 391]
  ------------------
  742|  1.87k|    vorbis_encode_psyset_setup(vi,hi->base_setting,
  743|  1.87k|                               setup->psy_noise_normal_start[1],
  744|  1.87k|                               setup->psy_noise_normal_partition[1],
  745|  1.87k|                                    setup->psy_noise_normal_thresh,
  746|  1.87k|                               2);
  747|  1.87k|    vorbis_encode_psyset_setup(vi,hi->base_setting,
  748|  1.87k|                               setup->psy_noise_normal_start[1],
  749|  1.87k|                               setup->psy_noise_normal_partition[1],
  750|  1.87k|                               setup->psy_noise_normal_thresh,
  751|  1.87k|                               3);
  752|  1.87k|  }
  753|       |
  754|       |  /* tone masking setup */
  755|  2.27k|  vorbis_encode_tonemask_setup(vi,hi->block[i0].tone_mask_setting,0,
  756|  2.27k|                               setup->psy_tone_masteratt,
  757|  2.27k|                               setup->psy_tone_0dB,
  758|  2.27k|                               setup->psy_tone_adj_impulse);
  759|  2.27k|  vorbis_encode_tonemask_setup(vi,hi->block[1].tone_mask_setting,1,
  760|  2.27k|                               setup->psy_tone_masteratt,
  761|  2.27k|                               setup->psy_tone_0dB,
  762|  2.27k|                               setup->psy_tone_adj_other);
  763|  2.27k|  if(!singleblock){
  ------------------
  |  Branch (763:6): [True: 1.87k, False: 391]
  ------------------
  764|  1.87k|    vorbis_encode_tonemask_setup(vi,hi->block[2].tone_mask_setting,2,
  765|  1.87k|                                 setup->psy_tone_masteratt,
  766|  1.87k|                                 setup->psy_tone_0dB,
  767|  1.87k|                                 setup->psy_tone_adj_other);
  768|  1.87k|    vorbis_encode_tonemask_setup(vi,hi->block[3].tone_mask_setting,3,
  769|  1.87k|                                 setup->psy_tone_masteratt,
  770|  1.87k|                                 setup->psy_tone_0dB,
  771|  1.87k|                                 setup->psy_tone_adj_long);
  772|  1.87k|  }
  773|       |
  774|       |  /* noise companding setup */
  775|  2.27k|  vorbis_encode_compand_setup(vi,hi->block[i0].noise_compand_setting,0,
  776|  2.27k|                              setup->psy_noise_compand,
  777|  2.27k|                              setup->psy_noise_compand_short_mapping);
  778|  2.27k|  vorbis_encode_compand_setup(vi,hi->block[1].noise_compand_setting,1,
  779|  2.27k|                              setup->psy_noise_compand,
  780|  2.27k|                              setup->psy_noise_compand_short_mapping);
  781|  2.27k|  if(!singleblock){
  ------------------
  |  Branch (781:6): [True: 1.87k, False: 391]
  ------------------
  782|  1.87k|    vorbis_encode_compand_setup(vi,hi->block[2].noise_compand_setting,2,
  783|  1.87k|                                setup->psy_noise_compand,
  784|  1.87k|                                setup->psy_noise_compand_long_mapping);
  785|  1.87k|    vorbis_encode_compand_setup(vi,hi->block[3].noise_compand_setting,3,
  786|  1.87k|                                setup->psy_noise_compand,
  787|  1.87k|                                setup->psy_noise_compand_long_mapping);
  788|  1.87k|  }
  789|       |
  790|       |  /* peak guarding setup  */
  791|  2.27k|  vorbis_encode_peak_setup(vi,hi->block[i0].tone_peaklimit_setting,0,
  792|  2.27k|                           setup->psy_tone_dBsuppress);
  793|  2.27k|  vorbis_encode_peak_setup(vi,hi->block[1].tone_peaklimit_setting,1,
  794|  2.27k|                           setup->psy_tone_dBsuppress);
  795|  2.27k|  if(!singleblock){
  ------------------
  |  Branch (795:6): [True: 1.87k, False: 391]
  ------------------
  796|  1.87k|    vorbis_encode_peak_setup(vi,hi->block[2].tone_peaklimit_setting,2,
  797|  1.87k|                             setup->psy_tone_dBsuppress);
  798|  1.87k|    vorbis_encode_peak_setup(vi,hi->block[3].tone_peaklimit_setting,3,
  799|  1.87k|                             setup->psy_tone_dBsuppress);
  800|  1.87k|  }
  801|       |
  802|       |  /* noise bias setup */
  803|  2.27k|  vorbis_encode_noisebias_setup(vi,hi->block[i0].noise_bias_setting,0,
  804|  2.27k|                                setup->psy_noise_dBsuppress,
  805|  2.27k|                                setup->psy_noise_bias_impulse,
  806|  2.27k|                                setup->psy_noiseguards,
  807|  2.27k|                                (i0==0?hi->impulse_noisetune:0.));
  ------------------
  |  Branch (807:34): [True: 2.27k, False: 0]
  ------------------
  808|  2.27k|  vorbis_encode_noisebias_setup(vi,hi->block[1].noise_bias_setting,1,
  809|  2.27k|                                setup->psy_noise_dBsuppress,
  810|  2.27k|                                setup->psy_noise_bias_padding,
  811|  2.27k|                                setup->psy_noiseguards,0.);
  812|  2.27k|  if(!singleblock){
  ------------------
  |  Branch (812:6): [True: 1.87k, False: 391]
  ------------------
  813|  1.87k|    vorbis_encode_noisebias_setup(vi,hi->block[2].noise_bias_setting,2,
  814|  1.87k|                                  setup->psy_noise_dBsuppress,
  815|  1.87k|                                  setup->psy_noise_bias_trans,
  816|  1.87k|                                  setup->psy_noiseguards,0.);
  817|  1.87k|    vorbis_encode_noisebias_setup(vi,hi->block[3].noise_bias_setting,3,
  818|  1.87k|                                  setup->psy_noise_dBsuppress,
  819|  1.87k|                                  setup->psy_noise_bias_long,
  820|  1.87k|                                  setup->psy_noiseguards,0.);
  821|  1.87k|  }
  822|       |
  823|  2.27k|  vorbis_encode_ath_setup(vi,0);
  824|  2.27k|  vorbis_encode_ath_setup(vi,1);
  825|  2.27k|  if(!singleblock){
  ------------------
  |  Branch (825:6): [True: 1.87k, False: 391]
  ------------------
  826|  1.87k|    vorbis_encode_ath_setup(vi,2);
  827|  1.87k|    vorbis_encode_ath_setup(vi,3);
  828|  1.87k|  }
  829|       |
  830|  2.27k|  vorbis_encode_map_n_res_setup(vi,hi->base_setting,setup->maps);
  831|       |
  832|       |  /* set bitrate readonlies and management */
  833|  2.27k|  if(hi->bitrate_av>0)
  ------------------
  |  Branch (833:6): [True: 0, False: 2.27k]
  ------------------
  834|      0|    vi->bitrate_nominal=hi->bitrate_av;
  835|  2.27k|  else{
  836|  2.27k|    vi->bitrate_nominal=setting_to_approx_bitrate(vi);
  837|  2.27k|  }
  838|       |
  839|  2.27k|  vi->bitrate_lower=hi->bitrate_min;
  840|  2.27k|  vi->bitrate_upper=hi->bitrate_max;
  841|  2.27k|  if(hi->bitrate_av)
  ------------------
  |  Branch (841:6): [True: 0, False: 2.27k]
  ------------------
  842|      0|    vi->bitrate_window=(double)hi->bitrate_reservoir/hi->bitrate_av;
  843|  2.27k|  else
  844|  2.27k|    vi->bitrate_window=0.;
  845|       |
  846|  2.27k|  if(hi->managed){
  ------------------
  |  Branch (846:6): [True: 0, False: 2.27k]
  ------------------
  847|      0|    ci->bi.avg_rate=hi->bitrate_av;
  848|      0|    ci->bi.min_rate=hi->bitrate_min;
  849|      0|    ci->bi.max_rate=hi->bitrate_max;
  850|       |
  851|      0|    ci->bi.reservoir_bits=hi->bitrate_reservoir;
  852|      0|    ci->bi.reservoir_bias=
  853|      0|      hi->bitrate_reservoir_bias;
  854|       |
  855|      0|    ci->bi.slew_damp=hi->bitrate_av_damp;
  856|       |
  857|      0|  }
  858|       |
  859|  2.27k|  return(0);
  860|       |
  861|  2.27k|}
vorbis_encode_setup_vbr:
  907|  2.27k|                            float quality){
  908|  2.27k|  codec_setup_info *ci;
  909|  2.27k|  highlevel_encode_setup *hi;
  910|  2.27k|  if(rate<=0) return OV_EINVAL;
  ------------------
  |  |  228|      0|#define OV_EINVAL     -131
  ------------------
  |  Branch (910:6): [True: 0, False: 2.27k]
  ------------------
  911|       |
  912|  2.27k|  ci=vi->codec_setup;
  913|  2.27k|  hi=&ci->hi;
  914|       |
  915|  2.27k|  quality+=.0000001;
  916|  2.27k|  if(quality>=1.)quality=.9999;
  ------------------
  |  Branch (916:6): [True: 81, False: 2.18k]
  ------------------
  917|       |
  918|  2.27k|  hi->req=quality;
  919|  2.27k|  hi->setup=get_setup_template(channels,rate,quality,0,&hi->base_setting);
  920|  2.27k|  if(!hi->setup)return OV_EIMPL;
  ------------------
  |  |  227|      0|#define OV_EIMPL      -130
  ------------------
  |  Branch (920:6): [True: 0, False: 2.27k]
  ------------------
  921|       |
  922|  2.27k|  vorbis_encode_setup_setting(vi,channels,rate);
  923|  2.27k|  hi->managed=0;
  924|  2.27k|  hi->coupling_p=1;
  925|       |
  926|  2.27k|  return 0;
  927|  2.27k|}
vorbis_encode_init_vbr:
  934|  2.27k|                           ){
  935|  2.27k|  int ret=0;
  936|       |
  937|  2.27k|  ret=vorbis_encode_setup_vbr(vi,channels,rate,base_quality);
  938|       |
  939|  2.27k|  if(ret){
  ------------------
  |  Branch (939:6): [True: 0, False: 2.27k]
  ------------------
  940|      0|    vorbis_info_clear(vi);
  941|      0|    return ret;
  942|      0|  }
  943|  2.27k|  ret=vorbis_encode_setup_init(vi);
  944|  2.27k|  if(ret)
  ------------------
  |  Branch (944:6): [True: 0, False: 2.27k]
  ------------------
  945|      0|    vorbis_info_clear(vi);
  946|  2.27k|  return(ret);
  947|  2.27k|}
vorbisenc.c:vorbis_encode_blocksize_setup:
  444|  2.27k|                                         const int *shortb,const int *longb){
  445|       |
  446|  2.27k|  codec_setup_info *ci=vi->codec_setup;
  447|  2.27k|  int is=s;
  448|       |
  449|  2.27k|  int blockshort=shortb[is];
  450|  2.27k|  int blocklong=longb[is];
  451|  2.27k|  ci->blocksizes[0]=blockshort;
  452|  2.27k|  ci->blocksizes[1]=blocklong;
  453|       |
  454|  2.27k|}
vorbisenc.c:vorbis_encode_floor_setup:
  193|  4.26k|                                     const int *x){
  194|  4.26k|  int i,k,is=s;
  195|  4.26k|  vorbis_info_floor1 *f=_ogg_calloc(1,sizeof(*f));
  ------------------
  |  |   22|  4.26k|#define _ogg_calloc  calloc
  ------------------
  196|  4.26k|  codec_setup_info *ci=vi->codec_setup;
  197|       |
  198|  4.26k|  memcpy(f,in+x[is],sizeof(*f));
  199|       |
  200|       |  /* books */
  201|  4.26k|  {
  202|  4.26k|    int partitions=f->partitions;
  203|  4.26k|    int maxclass=-1;
  204|  4.26k|    int maxbook=-1;
  205|  27.1k|    for(i=0;i<partitions;i++)
  ------------------
  |  Branch (205:13): [True: 22.9k, False: 4.26k]
  ------------------
  206|  22.9k|      if(f->partitionclass[i]>maxclass)maxclass=f->partitionclass[i];
  ------------------
  |  Branch (206:10): [True: 15.3k, False: 7.51k]
  ------------------
  207|  19.6k|    for(i=0;i<=maxclass;i++){
  ------------------
  |  Branch (207:13): [True: 15.3k, False: 4.26k]
  ------------------
  208|  15.3k|      if(f->class_book[i]>maxbook)maxbook=f->class_book[i];
  ------------------
  |  Branch (208:10): [True: 1.23k, False: 14.1k]
  ------------------
  209|  15.3k|      f->class_book[i]+=ci->books;
  210|  58.6k|      for(k=0;k<(1<<f->class_subs[i]);k++){
  ------------------
  |  Branch (210:15): [True: 43.2k, False: 15.3k]
  ------------------
  211|  43.2k|        if(f->class_subbook[i][k]>maxbook)maxbook=f->class_subbook[i][k];
  ------------------
  |  Branch (211:12): [True: 36.2k, False: 6.94k]
  ------------------
  212|  43.2k|        if(f->class_subbook[i][k]>=0)f->class_subbook[i][k]+=ci->books;
  ------------------
  |  Branch (212:12): [True: 36.2k, False: 6.94k]
  ------------------
  213|  43.2k|      }
  214|  15.3k|    }
  215|       |
  216|  52.8k|    for(i=0;i<=maxbook;i++)
  ------------------
  |  Branch (216:13): [True: 48.6k, False: 4.26k]
  ------------------
  217|  48.6k|      ci->book_param[ci->books++]=(static_codebook *)books[x[is]][i];
  218|  4.26k|  }
  219|       |
  220|       |  /* for now, we're only using floor 1 */
  221|  4.26k|  ci->floor_type[ci->floors]=1;
  222|  4.26k|  ci->floor_param[ci->floors]=f;
  223|  4.26k|  ci->floors++;
  224|       |
  225|  4.26k|  return;
  226|  4.26k|}
vorbisenc.c:vorbis_encode_global_psych_setup:
  230|  2.27k|                                            const double *x){
  231|  2.27k|  int i,is=s;
  232|  2.27k|  double ds=s-is;
  233|  2.27k|  codec_setup_info *ci=vi->codec_setup;
  234|  2.27k|  vorbis_info_psy_global *g=&ci->psy_g_param;
  235|       |
  236|  2.27k|  memcpy(g,in+(int)x[is],sizeof(*g));
  237|       |
  238|  2.27k|  ds=x[is]*(1.-ds)+x[is+1]*ds;
  239|  2.27k|  is=(int)ds;
  240|  2.27k|  ds-=is;
  241|  2.27k|  if(ds==0 && is>0){
  ------------------
  |  Branch (241:6): [True: 918, False: 1.35k]
  |  Branch (241:15): [True: 918, False: 0]
  ------------------
  242|    918|    is--;
  243|    918|    ds=1.;
  244|    918|  }
  245|       |
  246|       |  /* interpolate the trigger threshholds */
  247|  11.3k|  for(i=0;i<4;i++){
  ------------------
  |  Branch (247:11): [True: 9.08k, False: 2.27k]
  ------------------
  248|  9.08k|    g->preecho_thresh[i]=in[is].preecho_thresh[i]*(1.-ds)+in[is+1].preecho_thresh[i]*ds;
  249|  9.08k|    g->postecho_thresh[i]=in[is].postecho_thresh[i]*(1.-ds)+in[is+1].postecho_thresh[i]*ds;
  250|  9.08k|  }
  251|  2.27k|  g->ampmax_att_per_sec=ci->hi.amplitude_track_dBpersec;
  252|  2.27k|  return;
  253|  2.27k|}
vorbisenc.c:vorbis_encode_global_stereo:
  257|  2.27k|                                        const adj_stereo *p){
  258|  2.27k|  float s=hi->stereo_point_setting;
  259|  2.27k|  int i,is=s;
  260|  2.27k|  double ds=s-is;
  261|  2.27k|  codec_setup_info *ci=vi->codec_setup;
  262|  2.27k|  vorbis_info_psy_global *g=&ci->psy_g_param;
  263|       |
  264|  2.27k|  if(p){
  ------------------
  |  Branch (264:6): [True: 1.41k, False: 856]
  ------------------
  265|  1.41k|    memcpy(g->coupling_prepointamp,p[is].pre,sizeof(*p[is].pre)*PACKETBLOBS);
  ------------------
  |  |   28|  1.41k|#define PACKETBLOBS 15
  ------------------
  266|  1.41k|    memcpy(g->coupling_postpointamp,p[is].post,sizeof(*p[is].post)*PACKETBLOBS);
  ------------------
  |  |   28|  1.41k|#define PACKETBLOBS 15
  ------------------
  267|       |
  268|  1.41k|    if(hi->managed){
  ------------------
  |  Branch (268:8): [True: 0, False: 1.41k]
  ------------------
  269|       |      /* interpolate the kHz threshholds */
  270|      0|      for(i=0;i<PACKETBLOBS;i++){
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  |  Branch (270:15): [True: 0, False: 0]
  ------------------
  271|      0|        float kHz=p[is].kHz[i]*(1.-ds)+p[is+1].kHz[i]*ds;
  272|      0|        g->coupling_pointlimit[0][i]=kHz*1000./vi->rate*ci->blocksizes[0];
  273|      0|        g->coupling_pointlimit[1][i]=kHz*1000./vi->rate*ci->blocksizes[1];
  274|      0|        g->coupling_pkHz[i]=kHz;
  275|       |
  276|      0|        kHz=p[is].lowpasskHz[i]*(1.-ds)+p[is+1].lowpasskHz[i]*ds;
  277|      0|        g->sliding_lowpass[0][i]=kHz*1000./vi->rate*ci->blocksizes[0];
  278|      0|        g->sliding_lowpass[1][i]=kHz*1000./vi->rate*ci->blocksizes[1];
  279|       |
  280|      0|      }
  281|  1.41k|    }else{
  282|  1.41k|      float kHz=p[is].kHz[PACKETBLOBS/2]*(1.-ds)+p[is+1].kHz[PACKETBLOBS/2]*ds;
  ------------------
  |  |   28|  1.41k|#define PACKETBLOBS 15
  ------------------
                    float kHz=p[is].kHz[PACKETBLOBS/2]*(1.-ds)+p[is+1].kHz[PACKETBLOBS/2]*ds;
  ------------------
  |  |   28|  1.41k|#define PACKETBLOBS 15
  ------------------
  283|  22.6k|      for(i=0;i<PACKETBLOBS;i++){
  ------------------
  |  |   28|  22.6k|#define PACKETBLOBS 15
  ------------------
  |  Branch (283:15): [True: 21.2k, False: 1.41k]
  ------------------
  284|  21.2k|        g->coupling_pointlimit[0][i]=kHz*1000./vi->rate*ci->blocksizes[0];
  285|  21.2k|        g->coupling_pointlimit[1][i]=kHz*1000./vi->rate*ci->blocksizes[1];
  286|  21.2k|        g->coupling_pkHz[i]=kHz;
  287|  21.2k|      }
  288|       |
  289|  1.41k|      kHz=p[is].lowpasskHz[PACKETBLOBS/2]*(1.-ds)+p[is+1].lowpasskHz[PACKETBLOBS/2]*ds;
  ------------------
  |  |   28|  1.41k|#define PACKETBLOBS 15
  ------------------
                    kHz=p[is].lowpasskHz[PACKETBLOBS/2]*(1.-ds)+p[is+1].lowpasskHz[PACKETBLOBS/2]*ds;
  ------------------
  |  |   28|  1.41k|#define PACKETBLOBS 15
  ------------------
  290|  22.6k|      for(i=0;i<PACKETBLOBS;i++){
  ------------------
  |  |   28|  22.6k|#define PACKETBLOBS 15
  ------------------
  |  Branch (290:15): [True: 21.2k, False: 1.41k]
  ------------------
  291|  21.2k|        g->sliding_lowpass[0][i]=kHz*1000./vi->rate*ci->blocksizes[0];
  292|  21.2k|        g->sliding_lowpass[1][i]=kHz*1000./vi->rate*ci->blocksizes[1];
  293|  21.2k|      }
  294|  1.41k|    }
  295|  1.41k|  }else{
  296|  13.6k|    for(i=0;i<PACKETBLOBS;i++){
  ------------------
  |  |   28|  13.6k|#define PACKETBLOBS 15
  ------------------
  |  Branch (296:13): [True: 12.8k, False: 856]
  ------------------
  297|  12.8k|      g->sliding_lowpass[0][i]=ci->blocksizes[0];
  298|  12.8k|      g->sliding_lowpass[1][i]=ci->blocksizes[1];
  299|  12.8k|    }
  300|    856|  }
  301|  2.27k|  return;
  302|  2.27k|}
vorbisenc.c:vorbis_encode_psyset_setup:
  308|  8.29k|                                       int block){
  309|  8.29k|  codec_setup_info *ci=vi->codec_setup;
  310|  8.29k|  vorbis_info_psy *p=ci->psy_param[block];
  311|  8.29k|  highlevel_encode_setup *hi=&ci->hi;
  312|  8.29k|  int is=s;
  313|       |
  314|  8.29k|  if(block>=ci->psys)
  ------------------
  |  Branch (314:6): [True: 8.29k, False: 0]
  ------------------
  315|  8.29k|    ci->psys=block+1;
  316|  8.29k|  if(!p){
  ------------------
  |  Branch (316:6): [True: 8.29k, False: 0]
  ------------------
  317|  8.29k|    p=_ogg_calloc(1,sizeof(*p));
  ------------------
  |  |   22|  8.29k|#define _ogg_calloc  calloc
  ------------------
  318|  8.29k|    ci->psy_param[block]=p;
  319|  8.29k|  }
  320|       |
  321|  8.29k|  memcpy(p,&_psy_info_template,sizeof(*p));
  322|  8.29k|  p->blockflag=block>>1;
  323|       |
  324|  8.29k|  if(hi->noise_normalize_p){
  ------------------
  |  Branch (324:6): [True: 8.29k, False: 0]
  ------------------
  325|  8.29k|    p->normal_p=1;
  326|  8.29k|    p->normal_start=nn_start[is];
  327|  8.29k|    p->normal_partition=nn_partition[is];
  328|  8.29k|    p->normal_thresh=nn_thresh[is];
  329|  8.29k|  }
  330|       |
  331|  8.29k|  return;
  332|  8.29k|}
vorbisenc.c:vorbis_encode_tonemask_setup:
  337|  8.29k|                                         const vp_adjblock *in){
  338|  8.29k|  int i,is=s;
  339|  8.29k|  double ds=s-is;
  340|  8.29k|  codec_setup_info *ci=vi->codec_setup;
  341|  8.29k|  vorbis_info_psy *p=ci->psy_param[block];
  342|       |
  343|       |  /* 0 and 2 are only used by bitmanagement, but there's no harm to always
  344|       |     filling the values in here */
  345|  8.29k|  p->tone_masteratt[0]=att[is].att[0]*(1.-ds)+att[is+1].att[0]*ds;
  346|  8.29k|  p->tone_masteratt[1]=att[is].att[1]*(1.-ds)+att[is+1].att[1]*ds;
  347|  8.29k|  p->tone_masteratt[2]=att[is].att[2]*(1.-ds)+att[is+1].att[2]*ds;
  348|  8.29k|  p->tone_centerboost=att[is].boost*(1.-ds)+att[is+1].boost*ds;
  349|  8.29k|  p->tone_decay=att[is].decay*(1.-ds)+att[is+1].decay*ds;
  350|       |
  351|  8.29k|  p->max_curve_dB=max[is]*(1.-ds)+max[is+1]*ds;
  352|       |
  353|   149k|  for(i=0;i<P_BANDS;i++)
  ------------------
  |  |   29|   149k|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
  |  Branch (353:11): [True: 141k, False: 8.29k]
  ------------------
  354|   141k|    p->toneatt[i]=in[is].block[i]*(1.-ds)+in[is+1].block[i]*ds;
  355|  8.29k|  return;
  356|  8.29k|}
vorbisenc.c:vorbis_encode_compand_setup:
  361|  8.29k|                                        const double *x){
  362|  8.29k|  int i,is=s;
  363|  8.29k|  double ds=s-is;
  364|  8.29k|  codec_setup_info *ci=vi->codec_setup;
  365|  8.29k|  vorbis_info_psy *p=ci->psy_param[block];
  366|       |
  367|  8.29k|  ds=x[is]*(1.-ds)+x[is+1]*ds;
  368|  8.29k|  is=(int)ds;
  369|  8.29k|  ds-=is;
  370|  8.29k|  if(ds==0 && is>0){
  ------------------
  |  Branch (370:6): [True: 6.08k, False: 2.21k]
  |  Branch (370:15): [True: 6.08k, False: 0]
  ------------------
  371|  6.08k|    is--;
  372|  6.08k|    ds=1.;
  373|  6.08k|  }
  374|       |
  375|       |  /* interpolate the compander settings */
  376|   340k|  for(i=0;i<NOISE_COMPAND_LEVELS;i++)
  ------------------
  |  |   34|   340k|#define NOISE_COMPAND_LEVELS 40
  ------------------
  |  Branch (376:11): [True: 331k, False: 8.29k]
  ------------------
  377|   331k|    p->noisecompand[i]=in[is].data[i]*(1.-ds)+in[is+1].data[i]*ds;
  378|  8.29k|  return;
  379|  8.29k|}
vorbisenc.c:vorbis_encode_peak_setup:
  382|  8.29k|                                    const int *suppress){
  383|  8.29k|  int is=s;
  384|  8.29k|  double ds=s-is;
  385|  8.29k|  codec_setup_info *ci=vi->codec_setup;
  386|  8.29k|  vorbis_info_psy *p=ci->psy_param[block];
  387|       |
  388|  8.29k|  p->tone_abs_limit=suppress[is]*(1.-ds)+suppress[is+1]*ds;
  389|       |
  390|  8.29k|  return;
  391|  8.29k|}
vorbisenc.c:vorbis_encode_noisebias_setup:
  397|  8.29k|                                         double userbias){
  398|  8.29k|  int i,is=s,j;
  399|  8.29k|  double ds=s-is;
  400|  8.29k|  codec_setup_info *ci=vi->codec_setup;
  401|  8.29k|  vorbis_info_psy *p=ci->psy_param[block];
  402|       |
  403|  8.29k|  p->noisemaxsupp=suppress[is]*(1.-ds)+suppress[is+1]*ds;
  404|  8.29k|  p->noisewindowlomin=guard[block].lo;
  405|  8.29k|  p->noisewindowhimin=guard[block].hi;
  406|  8.29k|  p->noisewindowfixed=guard[block].fixed;
  407|       |
  408|  33.1k|  for(j=0;j<P_NOISECURVES;j++)
  ------------------
  |  |   32|  33.1k|#define P_NOISECURVES 3
  ------------------
  |  Branch (408:11): [True: 24.8k, False: 8.29k]
  ------------------
  409|   448k|    for(i=0;i<P_BANDS;i++)
  ------------------
  |  |   29|   448k|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
  |  Branch (409:13): [True: 423k, False: 24.8k]
  ------------------
  410|   423k|      p->noiseoff[j][i]=in[is].data[j][i]*(1.-ds)+in[is+1].data[j][i]*ds;
  411|       |
  412|       |  /* impulse blocks may take a user specified bias to boost the
  413|       |     nominal/high noise encoding depth */
  414|  33.1k|  for(j=0;j<P_NOISECURVES;j++){
  ------------------
  |  |   32|  33.1k|#define P_NOISECURVES 3
  ------------------
  |  Branch (414:11): [True: 24.8k, False: 8.29k]
  ------------------
  415|  24.8k|    float min=p->noiseoff[j][0]+6; /* the lowest it can go */
  416|   448k|    for(i=0;i<P_BANDS;i++){
  ------------------
  |  |   29|   448k|#define P_BANDS 17      /* 62Hz to 16kHz */
  ------------------
  |  Branch (416:13): [True: 423k, False: 24.8k]
  ------------------
  417|   423k|      p->noiseoff[j][i]+=userbias;
  418|   423k|      if(p->noiseoff[j][i]<min)p->noiseoff[j][i]=min;
  ------------------
  |  Branch (418:10): [True: 193k, False: 229k]
  ------------------
  419|   423k|    }
  420|  24.8k|  }
  421|       |
  422|  8.29k|  return;
  423|  8.29k|}
vorbisenc.c:vorbis_encode_ath_setup:
  425|  8.29k|static void vorbis_encode_ath_setup(vorbis_info *vi,int block){
  426|  8.29k|  codec_setup_info *ci=vi->codec_setup;
  427|  8.29k|  vorbis_info_psy *p=ci->psy_param[block];
  428|       |
  429|  8.29k|  p->ath_adjatt=ci->hi.ath_floating_dB;
  430|  8.29k|  p->ath_maxatt=ci->hi.ath_absolute_dB;
  431|  8.29k|  return;
  432|  8.29k|}
vorbisenc.c:vorbis_encode_map_n_res_setup:
  590|  2.27k|                                          const vorbis_mapping_template *maps){
  591|       |
  592|  2.27k|  codec_setup_info *ci=vi->codec_setup;
  593|  2.27k|  int i,j,is=s,modes=2;
  594|  2.27k|  const vorbis_info_mapping0 *map=maps[is].map;
  595|  2.27k|  const vorbis_info_mode *mode=_mode_template;
  596|  2.27k|  const vorbis_residue_template *res=maps[is].res;
  597|       |
  598|  2.27k|  if(ci->blocksizes[0]==ci->blocksizes[1])modes=1;
  ------------------
  |  Branch (598:6): [True: 391, False: 1.87k]
  ------------------
  599|       |
  600|  6.41k|  for(i=0;i<modes;i++){
  ------------------
  |  Branch (600:11): [True: 4.14k, False: 2.27k]
  ------------------
  601|       |
  602|  4.14k|    ci->map_param[i]=_ogg_calloc(1,sizeof(*map));
  ------------------
  |  |   22|  4.14k|#define _ogg_calloc  calloc
  ------------------
  603|  4.14k|    ci->mode_param[i]=_ogg_calloc(1,sizeof(*mode));
  ------------------
  |  |   22|  4.14k|#define _ogg_calloc  calloc
  ------------------
  604|       |
  605|  4.14k|    memcpy(ci->mode_param[i],mode+i,sizeof(*_mode_template));
  606|  4.14k|    if(i>=ci->modes)ci->modes=i+1;
  ------------------
  |  Branch (606:8): [True: 4.14k, False: 0]
  ------------------
  607|       |
  608|  4.14k|    ci->map_type[i]=0;
  609|  4.14k|    memcpy(ci->map_param[i],map+i,sizeof(*map));
  610|  4.14k|    if(i>=ci->maps)ci->maps=i+1;
  ------------------
  |  Branch (610:8): [True: 4.14k, False: 0]
  ------------------
  611|       |
  612|  8.29k|    for(j=0;j<map[i].submaps;j++)
  ------------------
  |  Branch (612:13): [True: 4.14k, False: 4.14k]
  ------------------
  613|  4.14k|      vorbis_encode_residue_setup(vi,map[i].residuesubmap[j],i
  614|  4.14k|                                  ,res+map[i].residuesubmap[j]);
  615|  4.14k|  }
  616|  2.27k|}
vorbisenc.c:vorbis_encode_residue_setup:
  458|  4.14k|                                        const vorbis_residue_template *res){
  459|       |
  460|  4.14k|  codec_setup_info *ci=vi->codec_setup;
  461|  4.14k|  int i;
  462|       |
  463|  4.14k|  vorbis_info_residue0 *r=ci->residue_param[number]=
  464|  4.14k|    _ogg_malloc(sizeof(*r));
  ------------------
  |  |   21|  4.14k|#define _ogg_malloc  malloc
  ------------------
  465|       |
  466|  4.14k|  memcpy(r,res->res,sizeof(*r));
  467|  4.14k|  if(ci->residues<=number)ci->residues=number+1;
  ------------------
  |  Branch (467:6): [True: 4.14k, False: 0]
  ------------------
  468|       |
  469|  4.14k|  r->grouping=res->grouping;
  470|  4.14k|  ci->residue_type[number]=res->res_type;
  471|       |
  472|       |  /* fill in all the books */
  473|  4.14k|  {
  474|  4.14k|    int booklist=0,k;
  475|       |
  476|  4.14k|    if(ci->hi.managed){
  ------------------
  |  Branch (476:8): [True: 0, False: 4.14k]
  ------------------
  477|      0|      for(i=0;i<r->partitions;i++)
  ------------------
  |  Branch (477:15): [True: 0, False: 0]
  ------------------
  478|      0|        for(k=0;k<4;k++)
  ------------------
  |  Branch (478:17): [True: 0, False: 0]
  ------------------
  479|      0|          if(res->books_base_managed->books[i][k])
  ------------------
  |  Branch (479:14): [True: 0, False: 0]
  ------------------
  480|      0|            r->secondstages[i]|=(1<<k);
  481|       |
  482|      0|      r->groupbook=book_dup_or_new(ci,res->book_aux_managed);
  483|      0|      ci->book_param[r->groupbook]=(static_codebook *)res->book_aux_managed;
  484|       |
  485|      0|      for(i=0;i<r->partitions;i++){
  ------------------
  |  Branch (485:15): [True: 0, False: 0]
  ------------------
  486|      0|        for(k=0;k<4;k++){
  ------------------
  |  Branch (486:17): [True: 0, False: 0]
  ------------------
  487|      0|          if(res->books_base_managed->books[i][k]){
  ------------------
  |  Branch (487:14): [True: 0, False: 0]
  ------------------
  488|      0|            int bookid=book_dup_or_new(ci,res->books_base_managed->books[i][k]);
  489|      0|            r->booklist[booklist++]=bookid;
  490|      0|            ci->book_param[bookid]=(static_codebook *)res->books_base_managed->books[i][k];
  491|      0|          }
  492|      0|        }
  493|      0|      }
  494|       |
  495|  4.14k|    }else{
  496|       |
  497|  42.9k|      for(i=0;i<r->partitions;i++)
  ------------------
  |  Branch (497:15): [True: 38.7k, False: 4.14k]
  ------------------
  498|   193k|        for(k=0;k<4;k++)
  ------------------
  |  Branch (498:17): [True: 155k, False: 38.7k]
  ------------------
  499|   155k|          if(res->books_base->books[i][k])
  ------------------
  |  Branch (499:14): [True: 52.8k, False: 102k]
  ------------------
  500|  52.8k|            r->secondstages[i]|=(1<<k);
  501|       |
  502|  4.14k|      r->groupbook=book_dup_or_new(ci,res->book_aux);
  503|  4.14k|      ci->book_param[r->groupbook]=(static_codebook *)res->book_aux;
  504|       |
  505|  42.9k|      for(i=0;i<r->partitions;i++){
  ------------------
  |  Branch (505:15): [True: 38.7k, False: 4.14k]
  ------------------
  506|   193k|        for(k=0;k<4;k++){
  ------------------
  |  Branch (506:17): [True: 155k, False: 38.7k]
  ------------------
  507|   155k|          if(res->books_base->books[i][k]){
  ------------------
  |  Branch (507:14): [True: 52.8k, False: 102k]
  ------------------
  508|  52.8k|            int bookid=book_dup_or_new(ci,res->books_base->books[i][k]);
  509|  52.8k|            r->booklist[booklist++]=bookid;
  510|  52.8k|            ci->book_param[bookid]=(static_codebook *)res->books_base->books[i][k];
  511|  52.8k|          }
  512|   155k|        }
  513|  38.7k|      }
  514|  4.14k|    }
  515|  4.14k|  }
  516|       |
  517|       |  /* lowpass setup/pointlimit */
  518|  4.14k|  {
  519|  4.14k|    double freq=ci->hi.lowpass_kHz*1000.;
  520|  4.14k|    vorbis_info_floor1 *f=ci->floor_param[block]; /* by convention */
  521|  4.14k|    double nyq=vi->rate/2.;
  522|  4.14k|    long blocksize=ci->blocksizes[block]>>1;
  523|       |
  524|       |    /* lowpass needs to be set in the floor and the residue. */
  525|  4.14k|    if(freq>nyq)freq=nyq;
  ------------------
  |  Branch (525:8): [True: 2.09k, False: 2.05k]
  ------------------
  526|       |    /* in the floor, the granularity can be very fine; it doesn't alter
  527|       |       the encoding structure, only the samples used to fit the floor
  528|       |       approximation */
  529|  4.14k|    f->n=freq/nyq*blocksize;
  530|       |
  531|       |    /* this res may by limited by the maximum pointlimit of the mode,
  532|       |       not the lowpass. the floor is always lowpass limited. */
  533|  4.14k|    switch(res->limit_type){
  534|      0|    case 1: /* point stereo limited */
  ------------------
  |  Branch (534:5): [True: 0, False: 4.14k]
  ------------------
  535|      0|      if(ci->hi.managed)
  ------------------
  |  Branch (535:10): [True: 0, False: 0]
  ------------------
  536|      0|        freq=ci->psy_g_param.coupling_pkHz[PACKETBLOBS-1]*1000.;
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  537|      0|      else
  538|      0|        freq=ci->psy_g_param.coupling_pkHz[PACKETBLOBS/2]*1000.;
  ------------------
  |  |   28|      0|#define PACKETBLOBS 15
  ------------------
  539|      0|      if(freq>nyq)freq=nyq;
  ------------------
  |  Branch (539:10): [True: 0, False: 0]
  ------------------
  540|      0|      break;
  541|      0|    case 2: /* LFE channel; lowpass at ~ 250Hz */
  ------------------
  |  Branch (541:5): [True: 0, False: 4.14k]
  ------------------
  542|      0|      freq=250;
  543|      0|      break;
  544|  4.14k|    default:
  ------------------
  |  Branch (544:5): [True: 4.14k, False: 0]
  ------------------
  545|       |      /* already set */
  546|  4.14k|      break;
  547|  4.14k|    }
  548|       |
  549|       |    /* in the residue, we're constrained, physically, by partition
  550|       |       boundaries.  We still lowpass 'wherever', but we have to round up
  551|       |       here to next boundary, or the vorbis spec will round it *down* to
  552|       |       previous boundary in encode/decode */
  553|  4.14k|    if(ci->residue_type[number]==2){
  ------------------
  |  Branch (553:8): [True: 906, False: 3.24k]
  ------------------
  554|       |      /* residue 2 bundles together multiple channels; used by stereo
  555|       |         and surround.  Count the channels in use */
  556|       |      /* Multiple maps/submaps can point to the same residue.  In the case
  557|       |         of residue 2, they all better have the same number of
  558|       |         channels/samples. */
  559|    906|      int j,k,ch=0;
  560|  2.23k|      for(i=0;i<ci->maps&&ch==0;i++){
  ------------------
  |  Branch (560:15): [True: 1.32k, False: 906]
  |  Branch (560:27): [True: 1.32k, False: 0]
  ------------------
  561|  1.32k|        vorbis_info_mapping0 *mi=(vorbis_info_mapping0 *)ci->map_param[i];
  562|  2.65k|        for(j=0;j<mi->submaps && ch==0;j++)
  ------------------
  |  Branch (562:17): [True: 1.32k, False: 1.32k]
  |  Branch (562:34): [True: 1.32k, False: 0]
  ------------------
  563|  1.32k|          if(mi->residuesubmap[j]==number) /* we found a submap referencing theis residue backend */
  ------------------
  |  Branch (563:14): [True: 906, False: 423]
  ------------------
  564|  2.71k|            for(k=0;k<vi->channels;k++)
  ------------------
  |  Branch (564:21): [True: 1.81k, False: 906]
  ------------------
  565|  1.81k|              if(mi->chmuxlist[k]==j) /* this channel belongs to the submap */
  ------------------
  |  Branch (565:18): [True: 1.81k, False: 0]
  ------------------
  566|  1.81k|                ch++;
  567|  1.32k|      }
  568|       |
  569|    906|      r->end=(int)((freq/nyq*blocksize*ch)/r->grouping+.9)* /* round up only if we're well past */
  570|    906|        r->grouping;
  571|       |      /* the blocksize and grouping may disagree at the end */
  572|    906|      if(r->end>blocksize*ch)r->end=blocksize*ch/r->grouping*r->grouping;
  ------------------
  |  Branch (572:10): [True: 0, False: 906]
  ------------------
  573|       |
  574|  3.24k|    }else{
  575|       |
  576|  3.24k|      r->end=(int)((freq/nyq*blocksize)/r->grouping+.9)* /* round up only if we're well past */
  577|  3.24k|        r->grouping;
  578|       |      /* the blocksize and grouping may disagree at the end */
  579|  3.24k|      if(r->end>blocksize)r->end=blocksize/r->grouping*r->grouping;
  ------------------
  |  Branch (579:10): [True: 0, False: 3.24k]
  ------------------
  580|       |
  581|  3.24k|    }
  582|       |
  583|  4.14k|    if(r->end==0)r->end=r->grouping; /* LFE channel */
  ------------------
  |  Branch (583:8): [True: 0, False: 4.14k]
  ------------------
  584|       |
  585|  4.14k|  }
  586|  4.14k|}
vorbisenc.c:book_dup_or_new:
  435|  57.0k|static int book_dup_or_new(codec_setup_info *ci,const static_codebook *book){
  436|  57.0k|  int i;
  437|  1.74M|  for(i=0;i<ci->books;i++)
  ------------------
  |  Branch (437:11): [True: 1.71M, False: 32.9k]
  ------------------
  438|  1.71M|    if(ci->book_param[i]==book)return(i);
  ------------------
  |  Branch (438:8): [True: 24.0k, False: 1.69M]
  ------------------
  439|       |
  440|  32.9k|  return(ci->books++);
  441|  57.0k|}
vorbisenc.c:setting_to_approx_bitrate:
  618|  2.27k|static double setting_to_approx_bitrate(vorbis_info *vi){
  619|  2.27k|  codec_setup_info *ci=vi->codec_setup;
  620|  2.27k|  highlevel_encode_setup *hi=&ci->hi;
  621|  2.27k|  ve_setup_data_template *setup=(ve_setup_data_template *)hi->setup;
  622|  2.27k|  int is=hi->base_setting;
  623|  2.27k|  double ds=hi->base_setting-is;
  624|  2.27k|  int ch=vi->channels;
  625|  2.27k|  const double *r=setup->rate_mapping;
  626|       |
  627|  2.27k|  if(r==NULL)
  ------------------
  |  Branch (627:6): [True: 0, False: 2.27k]
  ------------------
  628|      0|    return(-1);
  629|       |
  630|  2.27k|  return((r[is]*(1.-ds)+r[is+1]*ds)*ch);
  631|  2.27k|}
vorbisenc.c:get_setup_template:
  635|  2.27k|                                      double *base_setting){
  636|  2.27k|  int i=0,j;
  637|  2.27k|  if(q_or_bitrate)req/=ch;
  ------------------
  |  Branch (637:6): [True: 0, False: 2.27k]
  ------------------
  638|       |
  639|  19.5k|  while(setup_list[i]){
  ------------------
  |  Branch (639:9): [True: 19.5k, False: 0]
  ------------------
  640|  19.5k|    if(setup_list[i]->coupling_restriction==-1 ||
  ------------------
  |  Branch (640:8): [True: 8.45k, False: 11.0k]
  ------------------
  641|  11.0k|       setup_list[i]->coupling_restriction==ch){
  ------------------
  |  Branch (641:8): [True: 1.60k, False: 9.48k]
  ------------------
  642|  10.0k|      if(srate>=setup_list[i]->samplerate_min_restriction &&
  ------------------
  |  Branch (642:10): [True: 6.68k, False: 3.37k]
  ------------------
  643|  6.68k|         srate<=setup_list[i]->samplerate_max_restriction){
  ------------------
  |  Branch (643:10): [True: 2.27k, False: 4.41k]
  ------------------
  644|  2.27k|        int mappings=setup_list[i]->mappings;
  645|  2.27k|        const double *map=(q_or_bitrate?
  ------------------
  |  Branch (645:28): [True: 0, False: 2.27k]
  ------------------
  646|      0|                     setup_list[i]->rate_mapping:
  647|  2.27k|                     setup_list[i]->quality_mapping);
  648|       |
  649|       |        /* the template matches.  Does the requested quality mode
  650|       |           fall within this template's modes? */
  651|  2.27k|        if(req<map[0]){++i;continue;}
  ------------------
  |  Branch (651:12): [True: 0, False: 2.27k]
  ------------------
  652|  2.27k|        if(req>map[setup_list[i]->mappings]){++i;continue;}
  ------------------
  |  Branch (652:12): [True: 0, False: 2.27k]
  ------------------
  653|  12.2k|        for(j=0;j<mappings;j++)
  ------------------
  |  Branch (653:17): [True: 12.2k, False: 0]
  ------------------
  654|  12.2k|          if(req>=map[j] && req<map[j+1])break;
  ------------------
  |  Branch (654:14): [True: 12.2k, False: 0]
  |  Branch (654:29): [True: 2.27k, False: 9.98k]
  ------------------
  655|       |        /* an all-points match */
  656|  2.27k|        if(j==mappings)
  ------------------
  |  Branch (656:12): [True: 0, False: 2.27k]
  ------------------
  657|      0|          *base_setting=j-.001;
  658|  2.27k|        else{
  659|  2.27k|          float low=map[j];
  660|  2.27k|          float high=map[j+1];
  661|  2.27k|          float del=(req-low)/(high-low);
  662|  2.27k|          if(del>1-FLT_EPSILON)del=1-FLT_EPSILON;
  ------------------
  |  Branch (662:14): [True: 1, False: 2.26k]
  ------------------
  663|  2.27k|          *base_setting=j+(double)del;
  664|  2.27k|        }
  665|       |
  666|  2.27k|        return(setup_list[i]);
  667|  2.27k|      }
  668|  10.0k|    }
  669|  17.2k|    i++;
  670|  17.2k|  }
  671|       |
  672|      0|  return NULL;
  673|  2.27k|}
vorbisenc.c:vorbis_encode_setup_setting:
  865|  2.27k|                                       long  rate){
  866|  2.27k|  int i,is;
  867|  2.27k|  codec_setup_info *ci=vi->codec_setup;
  868|  2.27k|  highlevel_encode_setup *hi=&ci->hi;
  869|  2.27k|  const ve_setup_data_template *setup=hi->setup;
  870|  2.27k|  double ds;
  871|       |
  872|  2.27k|  vi->version=0;
  873|  2.27k|  vi->channels=channels;
  874|  2.27k|  vi->rate=rate;
  875|       |
  876|  2.27k|  hi->impulse_block_p=1;
  877|  2.27k|  hi->noise_normalize_p=1;
  878|       |
  879|  2.27k|  is=hi->base_setting;
  880|  2.27k|  ds=hi->base_setting-is;
  881|       |
  882|  2.27k|  hi->stereo_point_setting=hi->base_setting;
  883|       |
  884|  2.27k|  if(!hi->lowpass_altered)
  ------------------
  |  Branch (884:6): [True: 2.27k, False: 0]
  ------------------
  885|  2.27k|    hi->lowpass_kHz=
  886|  2.27k|      setup->psy_lowpass[is]*(1.-ds)+setup->psy_lowpass[is+1]*ds;
  887|       |
  888|  2.27k|  hi->ath_floating_dB=setup->psy_ath_float[is]*(1.-ds)+
  889|  2.27k|    setup->psy_ath_float[is+1]*ds;
  890|  2.27k|  hi->ath_absolute_dB=setup->psy_ath_abs[is]*(1.-ds)+
  891|  2.27k|    setup->psy_ath_abs[is+1]*ds;
  892|       |
  893|  2.27k|  hi->amplitude_track_dBpersec=-6.;
  894|  2.27k|  hi->trigger_setting=hi->base_setting;
  895|       |
  896|  11.3k|  for(i=0;i<4;i++){
  ------------------
  |  Branch (896:11): [True: 9.08k, False: 2.27k]
  ------------------
  897|  9.08k|    hi->block[i].tone_mask_setting=hi->base_setting;
  898|  9.08k|    hi->block[i].tone_peaklimit_setting=hi->base_setting;
  899|  9.08k|    hi->block[i].noise_bias_setting=hi->base_setting;
  900|  9.08k|    hi->block[i].noise_compand_setting=hi->base_setting;
  901|  9.08k|  }
  902|  2.27k|}

_vorbis_apply_window:
 2103|   103k|                          int lW,int W,int nW){
 2104|   103k|  lW=(W?lW:0);
  ------------------
  |  Branch (2104:7): [True: 5.59k, False: 98.0k]
  ------------------
 2105|   103k|  nW=(W?nW:0);
  ------------------
  |  Branch (2105:7): [True: 5.59k, False: 98.0k]
  ------------------
 2106|       |
 2107|   103k|  {
 2108|   103k|    const float *windowLW=vwin[winno[lW]];
 2109|   103k|    const float *windowNW=vwin[winno[nW]];
 2110|       |
 2111|   103k|    long n=blocksizes[W];
 2112|   103k|    long ln=blocksizes[lW];
 2113|   103k|    long rn=blocksizes[nW];
 2114|       |
 2115|   103k|    long leftbegin=n/4-ln/4;
 2116|   103k|    long leftend=leftbegin+ln/2;
 2117|       |
 2118|   103k|    long rightbegin=n/2+n/4-rn/4;
 2119|   103k|    long rightend=rightbegin+rn/2;
 2120|       |
 2121|   103k|    int i,p;
 2122|       |
 2123|  1.12M|    for(i=0;i<leftbegin;i++)
  ------------------
  |  Branch (2123:13): [True: 1.02M, False: 103k]
  ------------------
 2124|  1.02M|      d[i]=0.f;
 2125|       |
 2126|  18.1M|    for(p=0;i<leftend;i++,p++)
  ------------------
  |  Branch (2126:13): [True: 18.0M, False: 103k]
  ------------------
 2127|  18.0M|      d[i]*=windowLW[p];
 2128|       |
 2129|  19.1M|    for(i=rightbegin,p=rn/2-1;i<rightend;i++,p--)
  ------------------
  |  Branch (2129:31): [True: 19.0M, False: 103k]
  ------------------
 2130|  19.0M|      d[i]*=windowNW[p];
 2131|       |
 2132|   619k|    for(;i<n;i++)
  ------------------
  |  Branch (2132:10): [True: 516k, False: 103k]
  ------------------
 2133|   516k|      d[i]=0.f;
 2134|   103k|  }
 2135|   103k|}

