Пример #1
0
Cfimage mw_new_cfimage()
{
  Cfimage image;

  if(!(image = (Cfimage) (malloc(sizeof(struct cfimage)))))
    {
      mwerror(ERROR, 0, "[mw_new_cfimage] Not enough memory\n");
      return(NULL);
    }

  image->nrow = image->ncol = 0;
  image->allocsize = 0;
  image->model = MODEL_RGB;
  image->firstcol = image->lastcol = image->firstrow = image->lastrow = 0.0;

  image->scale = 0.0;
  strcpy(image->cmt,"?");
  strcpy(image->name,"?");

  image->red = image->green = image->blue = NULL;

  image->previous = NULL;
  image->next = NULL;

  return (image);
}
Пример #2
0
Cimage mw_new_cimage()
{
  Cimage image;

  if(!(image = (Cimage) (malloc(sizeof(struct cimage)))))
    {
      mwerror(ERROR, 0, "[mw_new_cimage] Not enough memory\n");
      return(NULL);
    }

  image->nrow = image->ncol = 0;
  image->allocsize = 0;
  image->firstcol = image->lastcol = image->firstrow = image->lastrow = 0.0;

  image->scale = 1.0;
  strcpy(image->cmt,"?");
  strcpy(image->name,"?");

  image->gray = NULL;

  image->previous = NULL;
  image->next = NULL;

  return (image);
}
Пример #3
0
Fsignal mw_new_fsignal()
{
    Fsignal signal;

    if (!(signal = (Fsignal) (malloc(sizeof(struct fsignal)))))
    {
        mwerror(ERROR, 0, "[mw_new_fsignal] Not enough memory\n");
        return (NULL);
    }

    signal->size = 0;
    signal->allocsize = 0;
    signal->firstp = signal->lastp = 0;
    signal->param = 0.0;

    signal->scale = 1.0;
    signal->shift = 0.0;
    signal->gain = 1.0;
    signal->sgrate = 1.0;
    signal->bpsample = 8 * sizeof(float);

    strcpy(signal->cmt, "?");
    strcpy(signal->name, "?");

    signal->values = NULL;

    return (signal);
}
Пример #4
0
Fsignal mw_alloc_fsignal(Fsignal signal, int N)
{
    int mem_size;

    if (signal == NULL)
    {
        mwerror(ERROR, 0,
                "[mw_alloc_fsignal] cannot alloc array : "
                "fsignal structure is NULL\n");
        return (NULL);
    }

    mem_size = N * sizeof(float);
    if (mem_size <= 0)
    {
        mwerror(ERROR, 0,
                "[mw_alloc_fsignal] Attempts to alloc a fsignal "
                "with null size\n");
        return NULL;
    }

    if (signal->values != NULL)
    {
        mwerror(ERROR, 0,
                "[mw_alloc_fsignal] Attempts to alloc a fsignal "
                "which is already allocated\n");
        return (NULL);
    }

    signal->values = (float *) malloc(mem_size);
    if (signal->values == NULL)
    {
        signal->size = 0;
        signal->allocsize = 0;
        mwerror(ERROR, 0, "[mw_alloc_fsignal] Not enough memory\n");
        return (NULL);
    }

    signal->size = N;
    signal->allocsize = mem_size;
    return (signal);
}
Пример #5
0
void mw_copy_fsignal_values(Fsignal in, Fsignal out)
{
    if ((!in) || (!out) || (!in->values) || (!out->values)
        || (in->size != out->size))
    {
        mwerror(ERROR, 0,
                "[mw_copy_fsignal_values] NULL input or output "
                "signal or signals of different sizes !\n");
        return;
    }

    memcpy(out->values, in->values, sizeof(float) * in->size);
}
Пример #6
0
Rawdata mw_new_rawdata()
{
  Rawdata rd;

  if(!(rd = (Rawdata) (malloc(sizeof(struct rawdata)))))
    {
      mwerror(ERROR, 0, "[mw_new_rawdata] Not enough memory\n");
      return(NULL);
    }

  rd->size = 0;
  rd->data = NULL;
  return (rd);
}
Пример #7
0
Flist mw_new_flist()
{
  Flist l;

  if(!(l = (Flist) (malloc(sizeof(struct flist))))) {
    mwerror(ERROR,0,"[mw_new_flist] Not enough memory\n");
    return(NULL);
  }
  l->size = l->max_size = l->dim = l->data_size = 0;
  l->values = NULL;
  l->data = NULL;

  return (l);
}
Пример #8
0
void mw_clear_fsignal(Fsignal signal, float v)
{
    register float *ptr;
    register int l;

    if ((!signal) || (!signal->values))
    {
        mwerror(ERROR, 0,
                "[mw_clear_fsignal] NULL signal struct or NULL values array\n");
        return;
    }

    for (l = 1, ptr = signal->values; l <= signal->size; l++, ptr++)
        *ptr = v;
}
Пример #9
0
void mw_delete_fsignal(Fsignal signal)
{
    if (signal == NULL)
    {
        mwerror(ERROR, 0,
                "[mw_delete_fsignal] cannot delete : "
                "fsignal structure is NULL\n");
        return;
    }

    if (signal->values != NULL)
        free(signal->values);
    signal->values = NULL;
    free(signal);
    signal = NULL;
}
Пример #10
0
Module mw_new_module()

{
    Module module;
    int i;

    if(!(module = (Module) (malloc(sizeof(struct module)))))
    {
        mwerror(ERROR, 0, "[mw_new_module] Not enough memory\n");
        return(NULL);
    }

    module->next = module->previous = module->down = module->up = NULL;
    strcpy(module->name,"?");
    module->type='?';
    return(module);
}
Пример #11
0
Ccmovie mw_new_ccmovie()
{
  Ccmovie movie;

  if(!(movie = (Ccmovie) (malloc(sizeof(struct ccmovie)))))
    {
      mwerror(ERROR, 0, "[mw_new_ccmovie] Not enough memory\n");
      return(NULL);
    }

  movie->scale = 1.0;
  strcpy(movie->cmt,"?");
  strcpy(movie->name,"?");
  movie->first = NULL;

  return (movie);
}
Пример #12
0
void mw_copy_fsignal_header(Fsignal in, Fsignal out)
{
    if ((!in) || (!out))
    {
        mwerror(ERROR, 0,
                "[mw_copy_fsignal_header] NULL input or output signal !\n");
        return;
    }
    out->firstp = in->firstp;
    out->lastp = in->lastp;
    out->param = in->param;
    out->scale = in->scale;
    out->shift = in->shift;
    out->gain = in->gain;
    out->sgrate = in->sgrate;
    out->bpsample = in->bpsample;
    strcpy(out->cmt, in->cmt);
}
Пример #13
0
static int 
READ_BIT_FIMAGE()

{
  int           bit;              /* Value of read and returned bit */

  if (bits_to_go == 0) {
    if (ncwreadfi == sizecomp) 
      mwerror(FATAL, 1, "Buffer ended to soon while readind header for image!\n");
    else 
      {
	ptrc++;
	buffer = *ptrc;
	bits_to_go = 8;
	ncwreadfi += 1;
      }
  }

  bit = buffer&1;
  buffer >>= 1;
  bits_to_go -= 1;
  return bit;
}
Пример #14
0
Vpoint_wmax mw_new_vpoint_wmax()
{
  Vpoint_wmax vpoint;
  int n;

  if(!(vpoint = (Vpoint_wmax) (malloc(sizeof(struct vpoint_wmax)))))
    {
      mwerror(ERROR, 0, "[mw_new_vpoint_wmax] Not enough memory\n");
      return(NULL);
    }
  vpoint->x = vpoint->y = -1;
  vpoint->previous = NULL;
  vpoint->next = NULL;

  for (n=0;n<mw_max_nlevel;n++) 
    {
      vpoint->mag[n] = mw_not_a_magnitude;
      vpoint->arg[n] = mw_not_an_argument;
    }
  vpoint->argp = mw_not_an_argument;

  return(vpoint);
}