コード例 #1
0
ファイル: postfilter.c プロジェクト: McuMirror/4-codec2
void postfilter(
  MODEL *model,
  float *bg_est
)	
{
  int   m, uv;
  float e, thresh;

  /* determine average energy across spectrum */

  e = 1E-12;
  for(m=1; m<=model->L; m++)
      e += model->A[m]*model->A[m];
  
  assert(e > 0.0);
  e = 10.0*log10f(e/model->L);

  /* If beneath threhold, update bg estimate.  The idea
     of the threshold is to prevent updating during high level
     speech. */

  if ((e < BG_THRESH) && !model->voiced)
      *bg_est =  *bg_est*(1.0 - BG_BETA) + e*BG_BETA;

  /* now mess with phases during voiced frames to make any harmonics
     less then our background estimate unvoiced.
  */

  uv = 0;
  thresh = powf(10.0, (*bg_est + BG_MARGIN)/20.0);
  if (model->voiced)
      for(m=1; m<=model->L; m++)
	  if (model->A[m] < thresh) {
	      model->phi[m] = TWO_PI*(float)codec2_rand()/CODEC2_RAND_MAX;
	      uv++;
	  }

#ifdef DUMP
  dump_bg(e, *bg_est, 100.0*uv/model->L);
#endif

}
コード例 #2
0
ファイル: blitting.c プロジェクト: cfwprpht/ps3_vsh_menu
void init_graphic()
{
    memset(&ctx, 0, sizeof(DrawCtx));

    // alloc VSH Menu graphic buffers, generic based on canvas constants
    buf[0].addr = mem_alloc(CANVAS_W * CANVAS_H * sizeof(uint32_t));    // canvas buffer
    buf[1].addr = mem_alloc(CANVAS_W * CANVAS_H * sizeof(uint32_t));    // background buffer

    #ifdef HAVE_PNG_FONT
    // load font png
    Buffer font = load_png(PNG_FONT_PATH);
    ctx.font    = font.addr;
    #endif

    // set drawing context
    ctx.canvas   = buf[0].addr;
    ctx.bg       = buf[1].addr;
    ctx.bg_color = 0xFF000000;          // black, opaque
    ctx.fg_color = 0xFFFFFFFF;          // white, opaque

    // get current display values
    offset = *(uint32_t*)0x60201104;    // start offset of current framebuffer
    getDisplayPitch(&pitch, &unk1);     // framebuffer pitch size
    h = getDisplayHeight();             // display height
    w = getDisplayWidth();              // display width

    // get x/y start coordinates for our canvas, always center
    canvas_x = (w - CANVAS_W) /2;
    canvas_y = (h - CANVAS_H) /2;

    // dump background, for alpha blending
    dump_bg();

    // init first frame with background dump
    memcpy((uint8_t *)ctx.canvas, (uint8_t *)ctx.bg, CANVAS_W * CANVAS_H * sizeof(uint32_t));
}