示例#1
0
文件: Tn2Sampler.cpp 项目: Hkey1/boom
 void Tn2Sampler::add_point(double z){
   if(z > x.back()){
     report_error("z out of bounds (too large) in Tn2Sampler::add_point");
   }
   if(z < x[0]){
     report_error("z out of bounds (too small) in Tn2Sampler::add_point");
   }
   IT it = std::lower_bound(x.begin(), x.end(), z);
   int k = it - x.begin();
   x.insert(it, z);
   logf.insert(logf.begin()+k, f(z));
   dlogf.insert(dlogf.begin() + k, df(z));
   refresh_knots();
   update_cdf();
 }
 void DBARS::add_point(double z){
   if(z > x.back()){
     throw_exception<std::runtime_error>("z out of bounds (too large) in DBARS::add_point");
   }
   if(z < x[0]){
     throw_exception<std::runtime_error>("z out of bounds (too small) in DBARS::add_point");
   }
   IT it = std::lower_bound(x.begin(), x.end(), z);
   int k = it - x.begin();
   x.insert(it, z);
   logf.insert(logf.begin()+k, f(z));
   dlogf.insert(dlogf.begin() + k, df(z));
   refresh_knots();
   update_cdf();
 }
示例#3
0
文件: Tn2Sampler.cpp 项目: Hkey1/boom
 Tn2Sampler::Tn2Sampler(double lo, double hi)
     : x(2),
       logf(2),
       dlogf(2),
       knots(3),
       cdf(2)
  {
    x[0] = lo;
    x[1] = hi;
    logf[0] = f(lo);
    logf[1] = f(hi);
    dlogf[0] = df(lo);
    dlogf[1] = df(hi);
    refresh_knots();
    update_cdf();
  }
示例#4
0
static int cost_and_tokenize_map(Av1ColorMapParam *param, TOKENEXTRA **t,
                                 int plane, int calc_rate, int allow_update_cdf,
                                 FRAME_COUNTS *counts, MapCdf map_pb_cdf) {
  const uint8_t *const color_map = param->color_map;
  MapCdf map_cdf = param->map_cdf;
  ColorCost color_cost = param->color_cost;
  const int plane_block_width = param->plane_width;
  const int rows = param->rows;
  const int cols = param->cols;
  const int n = param->n_colors;
  const int palette_size_idx = n - PALETTE_MIN_SIZE;
  int this_rate = 0;
  uint8_t color_order[PALETTE_MAX_SIZE];

  (void)plane;
  (void)counts;

  for (int k = 1; k < rows + cols - 1; ++k) {
    for (int j = AOMMIN(k, cols - 1); j >= AOMMAX(0, k - rows + 1); --j) {
      int i = k - j;
      int color_new_idx;
      const int color_ctx = av1_get_palette_color_index_context(
          color_map, plane_block_width, i, j, n, color_order, &color_new_idx);
      assert(color_new_idx >= 0 && color_new_idx < n);
      if (calc_rate) {
        this_rate += (*color_cost)[palette_size_idx][color_ctx][color_new_idx];
      } else {
        (*t)->token = color_new_idx;
        (*t)->color_map_cdf = map_pb_cdf[palette_size_idx][color_ctx];
        ++(*t);
        if (allow_update_cdf)
          update_cdf(map_cdf[palette_size_idx][color_ctx], color_new_idx, n);
#if CONFIG_ENTROPY_STATS
        if (plane) {
          ++counts->palette_uv_color_index[palette_size_idx][color_ctx]
                                          [color_new_idx];
        } else {
          ++counts->palette_y_color_index[palette_size_idx][color_ctx]
                                         [color_new_idx];
        }
#endif
      }
    }
  }
  if (calc_rate) return this_rate;
  return 0;
}
 DBARS::DoublyBoundedAdaptiveRejectionSampler(double lo, double hi,
                                              Fun Logf, Fun Dlogf)
     : logf_(Logf),
       dlogf_(Dlogf),
       x(2),
       logf(2),
       dlogf(2),
       knots(3),
       cdf(2)
  {
    x[0] = lo;
    x[1] = hi;
    logf[0] = f(lo);
    logf[1] = f(hi);
    dlogf[0] = df(lo);
    dlogf[1] = df(hi);
    refresh_knots();
    update_cdf();
  }