X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=compress_filter.c;h=f98fb413b2498311d25299fe9dfabfcad87af823;hb=6b966e1df730ab787014b4bd5dd08214d3722bfe;hp=d26fe233a85d062f839615e12f04367b582a2d85;hpb=d31995b3074bb19aa4da66ce5c4774ca9ed101a1;p=paraslash.git diff --git a/compress_filter.c b/compress_filter.c index d26fe233..f98fb413 100644 --- a/compress_filter.c +++ b/compress_filter.c @@ -49,7 +49,7 @@ static int compress_post_select(__a_unused struct sched *s, void *context) int16_t *ip, *op; uint32_t inertia = U32_OPTVAL(INERTIA, fn->lpr); unsigned gain_shift = inertia + U32_OPTVAL(DAMP, fn->lpr), - mask = (1 << U32_OPTVAL(BLOCKSIZE, fn->lpr)) - 1; + mask = (1U << U32_OPTVAL(BLOCKSIZE, fn->lpr)) - 1U; //inplace = false; next_buffer: ret = btr_node_status(btrn, fn->min_iqs, BTR_NT_INTERNAL); @@ -80,6 +80,7 @@ next_buffer: sample *= pcd->current_gain; sample >>= gain_shift; if (sample > 32767) { /* clip */ + PARA_WARNING_LOG("clip: %d\n", sample); sample = 32767; pcd->current_gain = (3 * pcd->current_gain + (1 << inertia)) / 4; @@ -124,7 +125,45 @@ static void compress_open(struct filter_node *fn) pcd->max_gain = 1U << (inertia + aggressiveness); } +static void *compress_setup(const struct lls_parse_result *lpr) +{ + uint32_t val; + + val = U32_OPTVAL(BLOCKSIZE, lpr); + if (val == 0 || val > 31) { + PARA_EMERG_LOG("blocksize (%u) out of range\n", val); + exit(EXIT_FAILURE); + } + val = U32_OPTVAL(AGGRESSIVENESS, lpr); + if (val == 0 || val > 15) { + PARA_EMERG_LOG("aggressiveness (%u) out of range\n", val); + exit(EXIT_FAILURE); + } + val = U32_OPTVAL(INERTIA, lpr); + if (val == 0 || val > 15) { + PARA_EMERG_LOG("inertia (%u) out of range\n", val); + exit(EXIT_FAILURE); + } + val = U32_OPTVAL(AGGRESSIVENESS, lpr) + U32_OPTVAL(INERTIA, lpr); + if (val > 16) { + PARA_EMERG_LOG("inertia + aggressiveness (%u) > 16\n", val); + exit(EXIT_FAILURE); + } + val = U32_OPTVAL(TARGET_LEVEL, lpr); + if (val > 32767) { + PARA_EMERG_LOG("target-level (%u) out of range\n", val); + exit(EXIT_FAILURE); + } + val = U32_OPTVAL(DAMP, lpr); + if (val > 16) { + PARA_EMERG_LOG("damp (%u) out of range\n", val); + exit(EXIT_FAILURE); + } + return NULL; /* no need for a config structure */ +} + const struct filter lsg_filter_cmd_com_compress_user_data = { + .setup = compress_setup, .open = compress_open, .close = compress_close, .pre_select = generic_filter_pre_select,