Unified · Split
| @@ -74,6 +74,7 @@ typedef struct AudioSurroundContext { · 73 unmodified lines | ||
| 74 | 74 | float focus; |
| 75 | 75 | int win_size; |
| 76 | 76 | int win_func; |
| 77 | + float win_gain; | |
| 77 | 78 | float overlap; |
| 78 | 79 | |
| 79 | 80 | float all_x; |
| @@ -637,7 +638,7 @@ static void upmix_7_1_5_0_side(AVFilterContext *ctx, · 557 unmodified lines | ||
| 637 | 638 | { |
| 638 | 639 | float fl_mag, fr_mag, ls_mag, rs_mag, lb_mag, rb_mag; |
| 639 | 640 | float *dstc, *dstl, *dstr, *dstls, *dstrs, *dstlb, *dstrb, *dstlfe; |
| 640 | − float lfe_mag, c_phase, mag_total = (mag_totall + mag_totalr) * 0.5; | |
| 641 | + float lfe_mag, c_phase, mag_total = (mag_totall + mag_totalr) * 0.5f; | |
| 641 | 642 | AudioSurroundContext *s = ctx->priv; |
| 642 | 643 | |
| 643 | 644 | dstl = (float *)s->output->extended_data[0]; |
| @@ -1197,6 +1198,23 @@ fail: · 553 unmodified lines | ||
| 1197 | 1198 | s->window_func_lut[i] = sqrtf(s->window_func_lut[i] / s->win_size); |
| 1198 | 1199 | s->hop_size = FFMAX(1, s->win_size * (1. - s->overlap)); |
| 1199 | 1200 | |
| 1201 | + { | |
| 1202 | + float max = 0.f, *temp_lut = av_calloc(s->win_size, sizeof(*temp_lut)); | |
| 1203 | + if (!temp_lut) | |
| 1204 | + return AVERROR(ENOMEM); | |
| 1205 | + | |
| 1206 | + for (int j = 0; j < s->win_size; j += s->hop_size) { | |
| 1207 | + for (int i = 0; i < s->win_size; i++) | |
| 1208 | + temp_lut[(i + j) % s->win_size] += s->window_func_lut[i]; | |
| 1209 | + } | |
| 1210 | + | |
| 1211 | + for (int i = 0; i < s->win_size; i++) | |
| 1212 | + max = fmaxf(temp_lut[i], max); | |
| 1213 | + av_freep(&temp_lut); | |
| 1214 | + | |
| 1215 | + s->win_gain = 1.f / (max * sqrtf(s->win_size)); | |
| 1216 | + } | |
| 1217 | + | |
| 1200 | 1218 | allchannels_spread(ctx); |
| 1201 | 1219 | |
| 1202 | 1220 | return 0; |
| @@ -1237,7 +1255,7 @@ static int fft_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) · 34 unmodified lines | ||
| 1237 | 1255 | static int ifft_channel(AVFilterContext *ctx, AVFrame *out, int ch) |
| 1238 | 1256 | { |
| 1239 | 1257 | AudioSurroundContext *s = ctx->priv; |
| 1240 | − const float level_out = s->output_levels[ch]; | |
| 1258 | + const float level_out = s->output_levels[ch] * s->win_gain; | |
| 1241 | 1259 | float *dst, *ptr; |
| 1242 | 1260 | |
| 1243 | 1261 | dst = (float *)s->output_out->extended_data[ch]; |