Exemplo n.º 1
0
int exist_dtable::create(int dfd, const char * file, const params & config, dtable::iter * source, const ktable * shadow)
{
	int e_dfd, r;
	params base_config, dnebase_config;
	const dtable_factory * base = dtable_factory::lookup(config, "base");
	const dtable_factory * dnebase = dtable_factory::lookup(config, "dnebase");
	if(!base || !dnebase)
		return -ENOENT;
	if(!config.get("base_config", &base_config, params()))
		return -EINVAL;
	if(!config.get("dnebase_config", &dnebase_config, params()))
		return -EINVAL;
	
	if(!source_shadow_ok(source, shadow))
		return -EINVAL;
	
	r = mkdirat(dfd, file, 0755);
	if(r < 0)
		return r;
	e_dfd = openat(dfd, file, O_RDONLY);
	if(e_dfd < 0)
		goto fail_open;
	
	/* just to be sure */
	source->first();
	{
		dtable_skip_iter<dne_skip_test> base_source(source);
		r = base->create(e_dfd, "base", base_config, &base_source, NULL);
		if(r < 0)
			goto fail_base;
	}
	
	source->first();
	{
		full_ktable full_shadow(source);
		nonshadow_skip_test skip_test(shadow);
		dtable_skip_iter<nonshadow_skip_test> dnebase_source(source, skip_test);
		r = dnebase->create(e_dfd, "dnebase", dnebase_config, &dnebase_source, &full_shadow);
		if(r < 0)
			goto fail_dnebase;
	}
	
	close(e_dfd);
	return 0;
	
fail_dnebase:
	util::rm_r(e_dfd, "base");
fail_base:
	close(e_dfd);
fail_open:
	unlinkat(dfd, file, AT_REMOVEDIR);
	return (r < 0) ? r : -1;
}
Exemplo n.º 2
0
static void motion_estimate_bi(mv_data_t* mv_data, mv_data_t** guide_mv_data, int num_guides, yuv_frame_t* indata0, yuv_frame_t* indata1, int k)
{
  // Estimate indata0 from indata1 and vice-versa


  const int bw=mv_data->bw;
  const int bh=mv_data->bh;

  if (num_guides==0) {
    memset(mv_data->mv[0], 0, sizeof(mv_t)*bw*bh);
    memset(mv_data->mv[1], 0, sizeof(mv_t)*bw*bh);
  }
  memset(mv_data->bgmap, 0, sizeof(int)*bw*bh);

  const int step=mv_data->step;
  mv_t cand_list[MAX_CANDS];


  yuv_frame_t* pic[2];
  pic[0] = mv_data->reversed ? indata1 : indata0;
  pic[1] = mv_data->reversed ? indata0 : indata1;

  for (int i=0; i<bh; i+=step) {
    for (int j=0; j<bw; j+=step) {
      make_skip_vector(mv_data, j, i, step, step);
      skip_test(mv_data, pic, j, i);
      int pos=i*bw+j;
      if (mv_data->bgmap[pos]==0) {

        int num_cands=get_cands(mv_data, cand_list, guide_mv_data, num_guides, j, i, MAX_CANDS, step, step);
        adaptive_search_v2(mv_data, num_guides!=0, cand_list, num_cands, pic, j, i, step, step);
      }
      // propagate
      const mv_t mv0=mv_data->mv[0][pos];
      const mv_t mv1=mv_data->mv[1][pos];
      int bgval=mv_data->bgmap[pos];
      for (int q=0; q<step; ++q) {
        for (int p=0; p<step; ++p) {
          mv_data->mv[0][pos+q*bw+p]=mv0;
          mv_data->mv[1][pos+q*bw+p]=mv1;
          mv_data->bgmap[pos+q*bw+p]=bgval;
        }
      }
    }
  }

  mv_t * mv0 = (mv_t*) thor_alloc(bw*bh*sizeof(mv_t), 16);
  mv_t * mv1 = (mv_t*) thor_alloc(bw*bh*sizeof(mv_t), 16);

  for (int i=0; i<bh; i++) {
    for (int j=0; j<bw; j++) {
      int num_cands=get_merge_cands(mv_data, cand_list, 1, j, i, MAX_CANDS);
      if (num_cands>1){
        merge_candidate_search(cand_list, num_cands, mv_data, mv0, mv1, pic, j, i);
      } else {
        mv0[i*bw+j]=mv_data->mv[0][i*bw+j];
        mv1[i*bw+j]=mv_data->mv[1][i*bw+j];
      }
    }
  }

  memcpy(mv_data->mv[0], mv0, bw*bh*sizeof(mv_t));
  memcpy(mv_data->mv[1], mv1, bw*bh*sizeof(mv_t));

  thor_free(mv0);
  thor_free(mv1);
}