static int fill_queue(struct af_instance *af, struct mp_audio *data, int offset) { af_scaletempo_t *s = af->priv; int bytes_in = mp_audio_psize(data) - offset; int offset_unchanged = offset; if (s->bytes_to_slide > 0) { if (s->bytes_to_slide < s->bytes_queued) { int bytes_move = s->bytes_queued - s->bytes_to_slide; memmove(s->buf_queue, s->buf_queue + s->bytes_to_slide, bytes_move); s->bytes_to_slide = 0; s->bytes_queued = bytes_move; } else { int bytes_skip; s->bytes_to_slide -= s->bytes_queued; bytes_skip = MPMIN(s->bytes_to_slide, bytes_in); s->bytes_queued = 0; s->bytes_to_slide -= bytes_skip; offset += bytes_skip; bytes_in -= bytes_skip; } } if (bytes_in > 0) { int bytes_copy = MPMIN(s->bytes_queue - s->bytes_queued, bytes_in); assert(bytes_copy >= 0); memcpy(s->buf_queue + s->bytes_queued, (int8_t *)data->planes[0] + offset, bytes_copy); s->bytes_queued += bytes_copy; offset += bytes_copy; } return offset - offset_unchanged; }
// Filter data through filter static int filter(struct af_instance* af, struct mp_audio* data, int flags) { struct mp_audio* c = data; // Current working data af_delay_t* s = af->priv; // Setup for this instance int nch = c->nch; // Number of channels int len = mp_audio_psize(c)/c->bps; // Number of sample in data chunk int ri = 0; int ch,i; for(ch=0;ch<nch;ch++){ switch(c->bps){ case 1:{ int8_t* a = c->planes[0]; int8_t* q = s->q[ch]; int wi = s->wi[ch]; ri = s->ri; for(i=ch;i<len;i+=nch){ q[wi] = a[i]; a[i] = q[ri]; UPDATEQI(wi); UPDATEQI(ri); } s->wi[ch] = wi; break; } case 2:{ int16_t* a = c->planes[0]; int16_t* q = s->q[ch]; int wi = s->wi[ch]; ri = s->ri; for(i=ch;i<len;i+=nch){ q[wi] = a[i]; a[i] = q[ri]; UPDATEQI(wi); UPDATEQI(ri); } s->wi[ch] = wi; break; } case 4:{ int32_t* a = c->planes[0]; int32_t* q = s->q[ch]; int wi = s->wi[ch]; ri = s->ri; for(i=ch;i<len;i+=nch){ q[wi] = a[i]; a[i] = q[ri]; UPDATEQI(wi); UPDATEQI(ri); } s->wi[ch] = wi; break; } } } s->ri = ri; return 0; }
static void extra_output_conversion(struct af_instance *af, struct mp_audio *mpa) { if (mpa->format == AF_FORMAT_S32 && af->data->format == AF_FORMAT_S24) { size_t len = mp_audio_psize(mpa) / mpa->bps; for (int s = 0; s < len; s++) { uint32_t val = *((uint32_t *)mpa->planes[0] + s); uint8_t *ptr = (uint8_t *)mpa->planes[0] + s * 3; ptr[0] = val >> SHIFT24(0); ptr[1] = val >> SHIFT24(1); ptr[2] = val >> SHIFT24(2); } mp_audio_set_format(mpa, AF_FORMAT_S24); }
// Filter data through filter static int filter(struct af_instance* af, struct mp_audio* data, int flags) { struct mp_audio* c = data; // Current working data struct mp_audio* l = af->data; // Local data af_channels_t* s = af->priv; int i; mp_audio_realloc_min(af->data, data->samples); // Reset unused channels memset(l->planes[0],0,mp_audio_psize(c) / c->nch * l->nch); if(AF_OK == check_routes(af,c->nch,l->nch)) for(i=0;i<s->nr;i++) copy(af, c->planes[0],l->planes[0],c->nch,s->route[i][FR], l->nch,s->route[i][TO],mp_audio_psize(c),c->bps); // Set output data c->planes[0] = l->planes[0]; mp_audio_set_channels(c, &l->channels); return 0; }
static int filter(struct af_instance *af, struct mp_audio *data) { if (!data) return 0; struct mp_audio *out = mp_audio_pool_get(af->out_pool, af->data, data->samples); if (!out) { talloc_free(data); return -1; } mp_audio_copy_attributes(out, data); size_t len = mp_audio_psize(data) / data->bps; if (data->bps == 4) { for (int s = 0; s < len; s++) { uint32_t val = *((uint32_t *)data->planes[0] + s); uint8_t *ptr = (uint8_t *)out->planes[0] + s * 3; ptr[0] = val >> SHIFT(0); ptr[1] = val >> SHIFT(1); ptr[2] = val >> SHIFT(2); } } else { for (int s = 0; s < len; s++) {