Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -56,6 +56,7 @@ typedef struct AudioSurroundContext { · 55 unmodified lines | |||
| 56 | float lfe_in; | 56 | float lfe_in; |
| 57 | float lfe_out; | 57 | float lfe_out; |
| 58 | int lfe_mode; | 58 | int lfe_mode; |
| 59 | float angle; | ||
| 59 | int win_size; | 60 | int win_size; |
| 60 | int win_func; | 61 | int win_func; |
| 61 | float overlap; | 62 | float overlap; |
| @@ -312,6 +313,26 @@ static int config_output(AVFilterLink *outlink) · 250 unmodified lines | |||
| 312 | return 0; | 313 | return 0; |
| 313 | } | 314 | } |
| 314 | 315 | ||
| 316 | static void stereo_transform(float *x, float *y, float angle) | ||
| 317 | { | ||
| 318 | float reference, r, a; | ||
| 319 | |||
| 320 | if (angle == 90.f) | ||
| 321 | return; | ||
| 322 | |||
| 323 | reference = angle * M_PI / 180.f; | ||
| 324 | r = hypotf(*x, *y); | ||
| 325 | a = atan2f(*x, *y); | ||
| 326 | |||
| 327 | if (fabsf(a) <= M_PI_4) | ||
| 328 | a *= reference / M_PI_2; | ||
| 329 | else | ||
| 330 | a = M_PI + 2 * (-2 * M_PI + reference) * (M_PI - fabsf(a)) * FFDIFFSIGN(a, 0) / (3 * M_PI); | ||
| 331 | |||
| 332 | *x = av_clipf(sinf(a) * r, -1, 1); | ||
| 333 | *y = av_clipf(cosf(a) * r, -1, 1); | ||
| 334 | } | ||
| 335 | |||
| 315 | static void stereo_position(float a, float p, float *x, float *y) | 336 | static void stereo_position(float a, float p, float *x, float *y) |
| 316 | { | 337 | { |
| 317 | *x = av_clipf(a+FFMAX(0, sinf(p-M_PI_2))*FFDIFFSIGN(a,0), -1, 1); | 338 | *x = av_clipf(a+FFMAX(0, sinf(p-M_PI_2))*FFDIFFSIGN(a,0), -1, 1); |
| @@ -1096,6 +1117,7 @@ static void filter_stereo(AVFilterContext *ctx) · 778 unmodified lines | |||
| 1096 | phase_dif = 2 * M_PI - phase_dif; | 1117 | phase_dif = 2 * M_PI - phase_dif; |
| 1097 | 1118 | ||
| 1098 | stereo_position(mag_dif, phase_dif, &x, &y); | 1119 | stereo_position(mag_dif, phase_dif, &x, &y); |
| 1120 | stereo_transform(&x, &y, s->angle); | ||
| 1099 | 1121 | ||
| 1100 | s->upmix_stereo(ctx, l_phase, r_phase, c_phase, mag_total, x, y, n); | 1122 | s->upmix_stereo(ctx, l_phase, r_phase, c_phase, mag_total, x, y, n); |
| 1101 | } | 1123 | } |
| @@ -1131,6 +1153,7 @@ static void filter_surround(AVFilterContext *ctx) · 29 unmodified lines | |||
| 1131 | phase_dif = 2 * M_PI - phase_dif; | 1153 | phase_dif = 2 * M_PI - phase_dif; |
| 1132 | 1154 | ||
| 1133 | stereo_position(mag_dif, phase_dif, &x, &y); | 1155 | stereo_position(mag_dif, phase_dif, &x, &y); |
| 1156 | stereo_transform(&x, &y, s->angle); | ||
| 1134 | 1157 | ||
| 1135 | s->upmix_3_0(ctx, l_phase, r_phase, c_phase, c_mag, mag_total, x, y, n); | 1158 | s->upmix_3_0(ctx, l_phase, r_phase, c_phase, c_mag, mag_total, x, y, n); |
| 1136 | } | 1159 | } |
| @@ -1165,6 +1188,7 @@ static void filter_2_1(AVFilterContext *ctx) · 28 unmodified lines | |||
| 1165 | phase_dif = 2 * M_PI - phase_dif; | 1188 | phase_dif = 2 * M_PI - phase_dif; |
| 1166 | 1189 | ||
| 1167 | stereo_position(mag_dif, phase_dif, &x, &y); | 1190 | stereo_position(mag_dif, phase_dif, &x, &y); |
| 1191 | stereo_transform(&x, &y, s->angle); | ||
| 1168 | 1192 | ||
| 1169 | s->upmix_2_1(ctx, l_phase, r_phase, c_phase, mag_total, lfe_re, lfe_im, x, y, n); | 1193 | s->upmix_2_1(ctx, l_phase, r_phase, c_phase, mag_total, lfe_re, lfe_im, x, y, n); |
| 1170 | } | 1194 | } |
| @@ -1674,6 +1698,7 @@ static const AVOption surround_options[] = { · 503 unmodified lines | |||
| 1674 | { "lfe_mode", "set LFE channel mode", OFFSET(lfe_mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "lfe_mode" }, | 1698 | { "lfe_mode", "set LFE channel mode", OFFSET(lfe_mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "lfe_mode" }, |
| 1675 | { "add", "just add LFE channel", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 1, FLAGS, "lfe_mode" }, | 1699 | { "add", "just add LFE channel", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 1, FLAGS, "lfe_mode" }, |
| 1676 | { "sub", "substract LFE channel with others", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 1, FLAGS, "lfe_mode" }, | 1700 | { "sub", "substract LFE channel with others", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 1, FLAGS, "lfe_mode" }, |
| 1701 | { "angle", "set soundfield transform angle", OFFSET(angle), AV_OPT_TYPE_FLOAT, {.dbl=90}, 0, 360, FLAGS }, | ||
| 1677 | { "fc_in", "set front center channel input level", OFFSET(fc_in), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 10, FLAGS }, | 1702 | { "fc_in", "set front center channel input level", OFFSET(fc_in), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 10, FLAGS }, |
| 1678 | { "fc_out", "set front center channel output level", OFFSET(fc_out), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 10, FLAGS }, | 1703 | { "fc_out", "set front center channel output level", OFFSET(fc_out), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 10, FLAGS }, |
| 1679 | { "fl_in", "set front left channel input level", OFFSET(fl_in), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 10, FLAGS }, | 1704 | { "fl_in", "set front left channel input level", OFFSET(fl_in), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 10, FLAGS }, |