]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - compress.c
mp3_afh.c: set bitrate, frequency and channels of struct audio_file_info
[paraslash.git] / compress.c
index de5448fb9eb9f5ebb33f7dffaf58ec246e270a31..685c3ba902b3ac9251c519fa0d047c1f830dfbe6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2006 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2007 Andre Noll <maan@systemlinux.org>
  *
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 #include "para.h"
 #include "compress_filter.cmdline.h"
 #include "list.h"
+#include "sched.h"
 #include "filter.h"
 #include "string.h"
 
@@ -49,7 +50,8 @@ struct private_compress_data {
 
 static ssize_t compress(char *inbuf, size_t inbuf_len, struct filter_node *fn)
 {
-       size_t i, length = MIN((inbuf_len / 2) * 2, (fn->bufsize - fn->loaded) / 2 * 2);
+       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,
@@ -66,8 +68,8 @@ static ssize_t compress(char *inbuf, size_t inbuf_len, struct filter_node *fn)
                                >> gain_shift;
                        if (unlikely(adjusted_sample > 32767)) {
                                adjusted_sample = 32767;
-                               pcd->current_gain = (pcd->current_gain +
-                                       (1 << pcd->conf->inertia_arg)) / 2;
+                               pcd->current_gain = (3 * pcd->current_gain +
+                                       (1 << pcd->conf->inertia_arg)) / 4;
                                pcd->peak = 0;
                        } else
                                if (adjusted_sample > pcd->peak)
@@ -77,8 +79,8 @@ static ssize_t compress(char *inbuf, size_t inbuf_len, struct filter_node *fn)
                                >> gain_shift);
                        if (unlikely(adjusted_sample < -32768)) {
                                adjusted_sample = -32768;
-                               pcd->current_gain = (pcd->current_gain +
-                                       (1 << pcd->conf->inertia_arg)) / 2;
+                               pcd->current_gain = (3 * pcd->current_gain +
+                                       (1 << pcd->conf->inertia_arg)) / 4;
                                pcd->peak = 0;
                        } else
                                if (-adjusted_sample > pcd->peak)
@@ -131,7 +133,11 @@ static void open_compress(struct filter_node *fn)
        pcd->max_gain = 1 << (pcd->conf->inertia_arg + pcd->conf->aggressiveness_arg);
 }
 
-/** the init function of the compress filter */
+/**
+ * the init function of the compress filter
+ *
+ * \param f pointer to the struct to initialize
+ */
 void compress_init(struct filter *f)
 {
        f->open = open_compress;