コード例 #1
0
ファイル: esql_misc.c プロジェクト: dong1/testsize
/*
 * pp_finish() - Global teardown to be called after parsing a file.
 * return : void
 */
void
pp_finish (void)
{
  vs_free (&pp_subscript_buf);
  vs_free (&pp_host_var_buf);
  pp_hv_finish ();
  pp_decl_finish ();
  pp_cursor_finish ();
  pp_symbol_finish ();
  pp_symbol_stats (esql_yyout);
}
コード例 #2
0
ファイル: motiondetect.c プロジェクト: UIKit0/vid.stab
void vsMotionDetectionCleanup(VSMotionDetect* md) {
  if(md->fieldscoarse.fields) {
    vs_free(md->fieldscoarse.fields);
    md->fieldscoarse.fields=0;
  }
  if(md->fieldsfine.fields) {
    vs_free(md->fieldsfine.fields);
    md->fieldsfine.fields=0;
  }
  vsFrameFree(&md->prev);
  vsFrameFree(&md->curr);
  vsFrameFree(&md->currtmp);

  md->initialized = 0;
}
コード例 #3
0
ファイル: rl_subscription.c プロジェクト: 4N7HR4X/kamailio
void rls_free(rl_subscription_t *s)
{
	int i, cnt;
	virtual_subscription_t *vs;
	
	if (!s) return;

	if (use_db) rls_db_remove(s);
	
	cnt = ptr_vector_size(&s->vs);
	for (i = 0; i < cnt; i++) {
		vs = ptr_vector_get(&s->vs, i);
		if (!vs) continue;
		vs_free(vs);
	}

	if (s->type == rls_external_subscription) {
		sm_release_subscription_nolock(rls_manager, &s->u.external);
		
		/* free ONLY for external subscriptions */
		free_xcap_params_content(&s->xcap_params);
	}
	else {
		/* release_internal_subscription(s); */
		/* don't free xcap_params */
	}

	ptr_vector_destroy(&s->vs);
	str_free_content(&s->from_uid);
	mem_free(s);
}
コード例 #4
0
ファイル: vsvector.c プロジェクト: FastSociety/vid.stab
int vs_vector_fini(VSVector *V){
  assert(V);
  if(V->data) vs_free(V->data);
  V->data = 0;
  V->buffersize=0;
  V->nelems=0;
  return VS_OK;
}
コード例 #5
0
ファイル: vsvector.c プロジェクト: FastSociety/vid.stab
int vs_vector_zero(VSVector *V){
  assert(V);
  assert(V->nelems < 1 || V->data);
  int i;
  for(i=0; i < V->nelems; i++){
    if(V->data[i])
      vs_free(V->data[i]);
  }
  V->nelems=0;
  return VS_OK;

}
コード例 #6
0
/**
 * cleanmean_localmotions: calulcates the cleaned mean of a vector
 * of local motions considering
 *
 * Parameters:
 *    localmotions : vs_vector of local motions
 * Return value:
 *     A localmotion with vec with x and y being the cleaned mean
 *     (meaning upper and lower pentile are removed) of
 *     all local motions. all other fields are 0.
 * Preconditions:
 *     size of vector >0
 * Side effects:
 *     None
 */
LocalMotion cleanmean_localmotions(const LocalMotions* localmotions)
{
  int len = vs_vector_size(localmotions);
  int i, cut = len / 5;
  int* xs = localmotions_getx(localmotions);
  int* ys = localmotions_gety(localmotions);
  LocalMotion m = null_localmotion();
  m.v.x=0; m.v.y=0;
  qsort(xs,len, sizeof(int), cmp_int);
  for (i = cut; i < len - cut; i++){ // all but cutted
    m.v.x += xs[i];
  }
  qsort(ys, len, sizeof(int), cmp_int);
  for (i = cut; i < len - cut; i++){ // all but cutted
    m.v.y += ys[i];
  }
  vs_free(xs);
  vs_free(ys);
  m.v.x/=(len - (2.0 * cut));
  m.v.y/=(len - (2.0 * cut));
  return m;
}
コード例 #7
0
Transform simpleMotionsToTransform(TransformData* td,
                                   const LocalMotions* motions){
  int center_x = 0;
  int center_y = 0;
	Transform t = null_transform();
  if(motions==0) return t;
  int num_motions=vs_vector_size(motions);
  double *angles = (double*) vs_malloc(sizeof(double) * num_motions);
  LocalMotion meanmotion;
  int i;
  if(num_motions < 1)
    return t;

  // calc center point of all remaining fields
  for (i = 0; i < num_motions; i++) {
    center_x += LMGet(motions,i)->f.x;
    center_y += LMGet(motions,i)->f.y;
  }
  center_x /= num_motions;
  center_y /= num_motions;

  // cleaned mean
  meanmotion = cleanmean_localmotions(motions);

  // figure out angle
  if (num_motions < 6) {
    // the angle calculation is inaccurate for 5 and less fields
    t.alpha = 0;
  } else {
    for (i = 0; i < num_motions; i++) {
      // substract avg and calc angle
      LocalMotion m = sub_localmotion(LMGet(motions,i),&meanmotion);
      angles[i] = calcAngle(&m, center_x, center_y);
    }
    double min, max;
    t.alpha = -cleanmean(angles, num_motions, &min, &max);
    if (max - min > td->maxAngleVariation) {
      t.alpha = 0;
      vs_log_info(td->modName, "too large variation in angle(%f)\n",
		  max-min);
    }
  }
  vs_free(angles);
  // compensate for off-center rotation
  double p_x = (center_x - td->fiSrc.width / 2);
  double p_y = (center_y - td->fiSrc.height / 2);
  t.x = meanmotion.v.x + (cos(t.alpha) - 1) * p_x - sin(t.alpha) * p_y;
  t.y = meanmotion.v.y + sin(t.alpha) * p_x + (cos(t.alpha) - 1) * p_y;

  return t;
}
コード例 #8
0
/**
 * calulcates the cleaned maximum and minimum of an array of transforms,
 * considerung only x and y
 * It cuts off the upper and lower x-th percentil
 *
 * Parameters:
 *    transforms: array of transforms.
 *           len: length  of array
 *     percentil: the x-th percentil to cut off
 *           min: pointer to min (return value)
 *           max: pointer to max (return value)
 * Return value:
 *     call by reference in min and max
 * Preconditions:
 *     len>0, 0<=percentil<50
 * Side effects:
 *     only on min and max
 */
void cleanmaxmin_xy_transform(const Transform* transforms, int len,
                              int percentil,
                              Transform* min, Transform* max){
  Transform* ts = vs_malloc(sizeof(Transform) * len);
  int cut = len * percentil / 100;
  memcpy(ts, transforms, sizeof(Transform) * len);
  qsort(ts,len, sizeof(Transform), cmp_trans_x);
  min->x = ts[cut].x;
  max->x = ts[len-cut-1].x;
  qsort(ts, len, sizeof(Transform), cmp_trans_y);
  min->y = ts[cut].y;
  max->y = ts[len-cut-1].y;
  vs_free(ts);
}
コード例 #9
0
/**
 * median_xy_transform: calulcates the median of an array
 * of transforms, considering only x and y
 *
 * Parameters:
 *    transforms: array of transforms.
 *           len: length  of array
 * Return value:
 *     A new transform with x and y beeing the median of
 *     all transforms. alpha and other fields are 0.
 * Preconditions:
 *     len>0
 * Side effects:
 *     None
 */
Transform median_xy_transform(const Transform* transforms, int len)
{
  Transform* ts = vs_malloc(sizeof(Transform) * len);
  Transform t;
  memcpy(ts,transforms, sizeof(Transform)*len );
  int half = len/2;
  qsort(ts, len, sizeof(Transform), cmp_trans_x);
  t.x = len % 2 == 0 ? ts[half].x : (ts[half].x + ts[half+1].x)/2;
  qsort(ts, len, sizeof(Transform), cmp_trans_y);
  t.y = len % 2 == 0 ? ts[half].y : (ts[half].y + ts[half+1].y)/2;
  t.alpha = 0;
  t.zoom = 0;
  t.extra = 0;
  vs_free(ts);
  return t;
}
コード例 #10
0
/**
 * cleanmean_xy_transform: calulcates the cleaned mean of an array
 * of transforms, considering only x and y
 *
 * Parameters:
 *    transforms: array of transforms.
 *           len: length  of array
 * Return value:
 *     A new transform with x and y beeing the cleaned mean
 *     (meaning upper and lower pentile are removed) of
 *     all transforms. alpha and other fields are 0.
 * Preconditions:
 *     len>0
 * Side effects:
 *     None
 */
Transform cleanmean_xy_transform(const Transform* transforms, int len)
{
  Transform* ts = vs_malloc(sizeof(Transform) * len);
  Transform t = null_transform();
  int i, cut = len / 5;
  memcpy(ts, transforms, sizeof(Transform) * len);
  qsort(ts,len, sizeof(Transform), cmp_trans_x);
  for (i = cut; i < len - cut; i++){ // all but cutted
    t.x += ts[i].x;
  }
  qsort(ts, len, sizeof(Transform), cmp_trans_y);
  for (i = cut; i < len - cut; i++){ // all but cutted
    t.y += ts[i].y;
  }
  vs_free(ts);
  return mult_transform(&t, 1.0 / (len - (2.0 * cut)));
}
コード例 #11
0
ファイル: vsvector.c プロジェクト: FastSociety/vid.stab
void vs_array_free(VSArray a){
  vs_free(a.dat);
  a.dat=0;
  a.len=0;
}