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