Exemplo n.º 1
0
dy_queue *dy_queue_new(void) {
  dy_queue *q = jd_alloc(sizeof(dy_queue));
  jd_set_array(&q->queue, 10);
  pthread_mutex_init(&q->mutex, NULL);
  pthread_cond_init(&q->cond, NULL);
  return q;
}
Exemplo n.º 2
0
jd_closure *jd__closure_new(jd_closure_func f) {
  jd_var ctx = JD_INIT;
  jd_closure *jdc = jd_alloc(sizeof(jd_closure));
  jdc->ctx = ctx;
  jdc->hdr.refs = 1;
  jdc->f = f;
  return jdc;
}
Exemplo n.º 3
0
static void merge__frame(filter *filt, const y4m2_parameters *parms,
                         y4m2_frame *frame) {
  merge__work *wrk = filt->ctx;
  unsigned frames = model_get_int(&filt->config, 10, "$.options.frames");
  if (!wrk->avg)
    wrk->avg = jd_alloc(frame->i.size * sizeof(uint32_t));
  merge__add(wrk->avg, frame);
  if (++wrk->phase == frames) {
    merge__scale(frame, wrk->avg, frames);
    y4m2_emit_frame(filt->out, parms, frame);
    memset(wrk->avg, 0, frame->i.size * sizeof(uint32_t));
    wrk->phase = 0;
  }
}
Exemplo n.º 4
0
static void peak__frame(filter *filt, const y4m2_parameters *parms,
                        y4m2_frame *frame) {
  peak__work *wrk = filt->ctx;

  if (!wrk->acc) {
    wrk->acc = jd_alloc(frame->i.size * sizeof(double));
    for (unsigned p = 0; p < Y4M2_N_PLANE; p++)
      wrk->scale[p] = 1;
  }

  uint8_t *fp = frame->buf;
  double *ap = wrk->acc;
  double *sp = wrk->scale;

  for (unsigned p = 0; p < Y4M2_N_PLANE; p++) {
    if (model_get_int(&filt->config, 0, "$.options.%s.disabled",
                      plane_key[p])) {
      ap += frame->i.plane[p].size;
      fp += frame->i.plane[p].size;
      sp++;
    } else {
      double decay =
          model_get_real(&filt->config, 0, "$.options.%s.decay", plane_key[p]);
      double scale = *sp;
      for (unsigned i = 0; i < frame->i.plane[p].size; i++) {
        double sample = *fp;
        double next = (*ap = *ap * decay + sample) / scale;
        ap++;
        *fp++ = (uint8_t)(sample > next ? sample : next);
      }
      *sp++ = scale * decay + 1;
    }
  }

  y4m2_emit_frame(filt->out, parms, frame);
}
Exemplo n.º 5
0
jd_array *jd_array_new(size_t size) {
  jd_array *jda = jd_alloc(sizeof(jd_array));
  jd_string_init(&jda->s, size * sizeof(jd_var));
  return jda;
}
Exemplo n.º 6
0
static void merge__start(filter *filt, const y4m2_parameters *parms) {
  if (!filt->ctx)
    filt->ctx = jd_alloc(sizeof(merge__work));
  y4m2_emit_start(filt->out, parms);
}
Exemplo n.º 7
0
static filter *filter__clone(filter *f) {
  filter *nf = jd_alloc(sizeof(filter));
  *nf = *f;
  jd_assign(&nf->config, &f->config);
  return nf;
}