Rename filter source files.
[paraslash.git] / compress.c
diff --git a/compress.c b/compress.c
deleted file mode 100644 (file)
index d6f7520..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Andre Noll <maan@systemlinux.org>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
-
-/** \file compress.c Paraslash's dynamic audio range compressor. */
-
-/*
- * Uses ideas of AudioCompress, (C) 2002-2004  M. Hari Nezumi <magenta@trikuare.cx>
- */
-
-#include "para.h"
-#include "compress_filter.cmdline.h"
-#include "list.h"
-#include "sched.h"
-#include "filter.h"
-#include "string.h"
-#include "error.h"
-
-/** The size of the output data buffer. */
-#define COMPRESS_CHUNK_SIZE 40960
-
-extern char *stat_item_values[NUM_STAT_ITEMS];
-
-/** Data specific to the compress filter. */
-struct private_compress_data {
-       /** The current multiplier. */
-       unsigned current_gain;
-       /** Points to the configuration data for this instance of the compress filter. */
-       struct compress_filter_args_info *conf;
-       /** Maximal admissible gain. */
-       unsigned max_gain;
-       /** Number of samples already seen. */
-       unsigned num_samples;
-       /** Absolute value of the maximal sample in the current block. */
-       unsigned peak;
-};
-
-static ssize_t compress(char *inbuf, size_t inbuf_len, struct filter_node *fn)
-{
-       size_t i, length = PARA_MIN((inbuf_len / 2) * 2,
-               (fn->bufsize - fn->loaded) / 2 * 2);
-       struct private_compress_data *pcd = fn->private_data;
-       int16_t *ip = (int16_t *)inbuf, *op = (int16_t *)(fn->buf + fn->loaded);
-       unsigned gain_shift = pcd->conf->inertia_arg + pcd->conf->damp_arg,
-               mask = (1 << pcd->conf->blocksize_arg) - 1;
-
-       if (!length)
-               return 0;
-       for (i = 0; i < length / 2; i++) {
-               /* be careful in that heat, my dear */
-               int sample = *ip++, adjusted_sample = (PARA_ABS(sample) *
-                       pcd->current_gain) >> gain_shift;
-               if (unlikely(adjusted_sample > 32767)) { /* clip */
-                       PARA_NOTICE_LOG("clip: sample: %d, adjusted sample: %d\n",
-                               sample, adjusted_sample);
-                       adjusted_sample = 32767;
-                       pcd->current_gain = (3 * pcd->current_gain +
-                               (1 << pcd->conf->inertia_arg)) / 4;
-                       pcd->peak = 0;
-               } else
-                       pcd->peak = PARA_MAX(pcd->peak, adjusted_sample);
-               *op++ = sample >= 0? adjusted_sample : -adjusted_sample;
-               if (likely(++pcd->num_samples & mask))
-                       continue;
-//             PARA_DEBUG_LOG("gain: %u, peak: %u\n", pcd->current_gain,
-//                     pcd->peak);
-               if (pcd->peak < pcd->conf->target_level_arg) {
-                       if (pcd->current_gain < pcd->max_gain)
-                               pcd->current_gain++;
-               } else
-                       pcd->current_gain = PARA_MAX(pcd->current_gain - 2,
-                               1 << pcd->conf->inertia_arg);
-               pcd->peak = 0;
-       }
-       fn->loaded += length;
-       return length;
-}
-
-static void close_compress(struct filter_node *fn)
-{
-       free(fn->private_data);
-       free(fn->buf);
-}
-
-/** TODO: Add sanity checks */
-static int compress_parse_config(int argc, char **argv, void **config)
-{
-       int ret;
-       struct compress_filter_args_info *compress_conf
-               = para_calloc(sizeof(*compress_conf));
-
-       ret = -E_COMPRESS_SYNTAX;
-       if (compress_cmdline_parser(argc, argv, compress_conf))
-               goto err;
-       *config = compress_conf;
-       return 1;
-err:
-       free(compress_conf);
-       return  ret;
-}
-
-static void open_compress(struct filter_node *fn)
-{
-       struct private_compress_data *pcd = para_calloc(
-               sizeof(struct private_compress_data));
-       pcd->conf = fn->conf;
-       fn->private_data = pcd;
-       fn->bufsize = COMPRESS_CHUNK_SIZE;
-       fn->buf = para_malloc(fn->bufsize);
-       pcd->current_gain = 1 << pcd->conf->inertia_arg;
-       pcd->max_gain = 1 << (pcd->conf->inertia_arg + pcd->conf->aggressiveness_arg);
-}
-
-/**
- * The init function of the compress filter.
- *
- * \param f Pointer to the struct to initialize.
- */
-void compress_filter_init(struct filter *f)
-{
-       f->open = open_compress;
-       f->close = close_compress;
-       f->convert = compress;
-       f->print_help = compress_cmdline_parser_print_help;
-       f->parse_config = compress_parse_config;
-}