]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
compress: Overhaul the meaning of --aggressiveness.
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 1 Sep 2018 19:07:54 +0000 (21:07 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 2 Sep 2018 15:42:54 +0000 (17:42 +0200)
Large values for the argument to --aggressiveless are next to useless
because they correspond to gain factors which are much too large. The
default value of four is already too large as it allows for a 16-fold
volume amplification.

This patch changes the meaning of the argument to be a multiplication
rather than a shift. Admissible values are restricted to the range
0..10, which allows for fine-grained control over the maximal gain
factor.

The maximal gain factor is four, so the inertia argument must not
exceed 14 to guarantee that no integer overflow can happen.

compress_filter.c
m4/lls/filter_cmd.suite.m4

index 0c76fd785123a83bd1b7fb660ecb6157da2a47eb..15bed6dfa33c896421ab17a89ec426669cf4b025 100644 (file)
@@ -123,7 +123,7 @@ static void compress_open(struct filter_node *fn)
        fn->private_data = pcd;
        fn->min_iqs = 2; /* 16 bit audio */
        pcd->current_gain = 1U << inertia;
        fn->private_data = pcd;
        fn->min_iqs = 2; /* 16 bit audio */
        pcd->current_gain = 1U << inertia;
-       pcd->max_gain = 1U << (inertia + aggressiveness);
+       pcd->max_gain = (1U << inertia) * (1.0 + 3.0 * aggressiveness / 10.0);
 }
 
 static void *compress_setup(const struct lls_parse_result *lpr)
 }
 
 static void *compress_setup(const struct lls_parse_result *lpr)
@@ -136,20 +136,15 @@ static void *compress_setup(const struct lls_parse_result *lpr)
                exit(EXIT_FAILURE);
        }
        val = U32_OPTVAL(AGGRESSIVENESS, lpr);
                exit(EXIT_FAILURE);
        }
        val = U32_OPTVAL(AGGRESSIVENESS, lpr);
-       if (val == 0 || val > 15) {
+       if (val > 10) {
                PARA_EMERG_LOG("aggressiveness (%u) out of range\n", val);
                exit(EXIT_FAILURE);
        }
        val = U32_OPTVAL(INERTIA, lpr);
                PARA_EMERG_LOG("aggressiveness (%u) out of range\n", val);
                exit(EXIT_FAILURE);
        }
        val = U32_OPTVAL(INERTIA, lpr);
-       if (val == 0 || val > 15) {
+       if (val == 0 || val > 14) {
                PARA_EMERG_LOG("inertia (%u) out of range\n", val);
                exit(EXIT_FAILURE);
        }
                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);
        val = U32_OPTVAL(TARGET_LEVEL, lpr);
        if (val > 32767) {
                PARA_EMERG_LOG("target-level (%u) out of range\n", val);
index dece6e6e54f9c90429c4fe14d070b8dea6cdb1de..c026a628acdda4adfdbf276ac8c5ca8d527e0d24 100644 (file)
@@ -35,25 +35,25 @@ caption = filters
                [/help]
        [option aggressiveness]
                short_opt = a
                [/help]
        [option aggressiveness]
                short_opt = a
-               summary = controls the maximum amount to amplify by (1-15)
+               summary = controls the maximum amount to amplify by (0-10)
                typestr = bits
                arg_info = required_arg
                arg_type = uint32
                default_val = 4
                [help]
                typestr = bits
                arg_info = required_arg
                arg_type = uint32
                default_val = 4
                [help]
-                       This caps the maximal gain factor to 2**bits. The sum of the arguments
-                       to --aggressiveness and --inertia (see below) must not exceed 16.
+                       This controls the maximal gain factor. Zero means to not amplify
+                       at all while the value 10 corresponds to maximal gain factor which
+                       results in a 4-fold increase in volume.
                [/help]
        [option inertia]
                short_opt = i
                [/help]
        [option inertia]
                short_opt = i
-               summary = how much inertia ramping has (1-15)
+               summary = how much inertia ramping has (1-14)
                typestr = bits
                arg_info = required_arg
                arg_type = uint32
                default_val = 6
                [help]
                typestr = bits
                arg_info = required_arg
                arg_type = uint32
                default_val = 6
                [help]
-                       Larger values cause smaller volume adjustments. See --aggressiveness
-                       above.
+                       Larger values cause smaller volume adjustments.
                [/help]
        [option target-level]
                short_opt = t
                [/help]
        [option target-level]
                short_opt = t