Unified · Split
| @@ -74,6 +74,7 @@ typedef struct AudioSurroundContext { · 73 unmodified lines | |||
| 74 | float focus; | 74 | float focus; |
| 75 | int win_size; | 75 | int win_size; |
| 76 | int win_func; | 76 | int win_func; |
| 77 | float win_gain; | ||
| 77 | float overlap; | 78 | float overlap; |
| 78 | 79 | ||
| 79 | float all_x; | 80 | float all_x; |
| @@ -637,7 +638,7 @@ static void upmix_7_1_5_0_side(AVFilterContext *ctx, · 557 unmodified lines | |||
| 637 | { | 638 | { |
| 638 | float fl_mag, fr_mag, ls_mag, rs_mag, lb_mag, rb_mag; | 639 | float fl_mag, fr_mag, ls_mag, rs_mag, lb_mag, rb_mag; |
| 639 | float *dstc, *dstl, *dstr, *dstls, *dstrs, *dstlb, *dstrb, *dstlfe; | 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 | AudioSurroundContext *s = ctx->priv; | 642 | AudioSurroundContext *s = ctx->priv; |
| 642 | 643 | ||
| 643 | dstl = (float *)s->output->extended_data[0]; | 644 | dstl = (float *)s->output->extended_data[0]; |
| @@ -1197,6 +1198,23 @@ fail: · 553 unmodified lines | |||
| 1197 | s->window_func_lut[i] = sqrtf(s->window_func_lut[i] / s->win_size); | 1198 | s->window_func_lut[i] = sqrtf(s->window_func_lut[i] / s->win_size); |
| 1198 | s->hop_size = FFMAX(1, s->win_size * (1. - s->overlap)); | 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 | allchannels_spread(ctx); | 1218 | allchannels_spread(ctx); |
| 1201 | 1219 | ||
| 1202 | return 0; | 1220 | return 0; |
| @@ -1237,7 +1255,7 @@ static int fft_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) · 34 unmodified lines | |||
| 1237 | static int ifft_channel(AVFilterContext *ctx, AVFrame *out, int ch) | 1255 | static int ifft_channel(AVFilterContext *ctx, AVFrame *out, int ch) |
| 1238 | { | 1256 | { |
| 1239 | AudioSurroundContext *s = ctx->priv; | 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 | float *dst, *ptr; | 1259 | float *dst, *ptr; |
| 1242 | 1260 | ||
| 1243 | dst = (float *)s->output_out->extended_data[ch]; | 1261 | dst = (float *)s->output_out->extended_data[ch]; |