| @@ -164,6 +164,7 @@ typedef struct MixContext { · 163 unmodified lines |
| 164 | 164 | int duration_mode; /**< mode for determining duration */ |
| 165 | 165 | float dropout_transition; /**< transition time when an input drops out */ |
| 166 | 166 | char *weights_str; /**< string for custom weights for every input */ |
| 167 | + int sum; /**< inputs are not scaled, only added */ |
| 167 | 168 | |
| 168 | 169 | int nb_channels; /**< number of channels */ |
| 169 | 170 | int sample_rate; /**< sample rate */ |
| @@ -195,6 +196,8 @@ static const AVOption amix_options[] = { · 25 unmodified lines |
| 195 | 196 | OFFSET(dropout_transition), AV_OPT_TYPE_FLOAT, { .dbl = 2.0 }, 0, INT_MAX, A|F }, |
| 196 | 197 | { "weights", "Set weight for each input.", |
| 197 | 198 | OFFSET(weights_str), AV_OPT_TYPE_STRING, {.str="1 1"}, 0, 0, A|F|T }, |
| 199 | + { "sum", "Do not scale inputs instead do only sum", |
| 200 | + OFFSET(sum), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, A|F|T }, |
| 198 | 201 | { NULL } |
| 199 | 202 | }; |
| 200 | 203 | |
| @@ -227,10 +230,14 @@ static void calculate_scales(MixContext *s, int nb_samples) · 26 unmodified lines |
| 227 | 230 | } |
| 228 | 231 | |
| 229 | 232 | for (i = 0; i < s->nb_inputs; i++) { |
| 230 | | − if (s->input_state[i] & INPUT_ON) |
| 231 | | − s->input_scale[i] = 1.0f / s->scale_norm[i] * FFSIGN(s->weights[i]); |
| 232 | | − else |
| 233 | + if (s->input_state[i] & INPUT_ON) { |
| 234 | + if (s->sum) |
| 235 | + s->input_scale[i] = 1.0f; |
| 236 | + else |
| 237 | + s->input_scale[i] = 1.0f / s->scale_norm[i] * FFSIGN(s->weights[i]); |
| 238 | + } else { |
| 233 | 239 | s->input_scale[i] = 0.0f; |
| 240 | + } |
| 234 | 241 | } |
| 235 | 242 | } |
| 236 | 243 | |