Signed-off-by: Paul B Mahol <onemda@gmail.com>
Paul B Mahol authored on 2015/12/21 03:52:51... | ... |
@@ -14438,6 +14438,17 @@ Default is @code{1}, which means time averaging is disabled. |
14438 | 14438 |
Specify list of colors separated by space or by '|' which will be used to |
14439 | 14439 |
draw channel frequencies. Unrecognized or missing colors will be replaced |
14440 | 14440 |
by white color. |
14441 |
+ |
|
14442 |
+@item cmode |
|
14443 |
+Set channel display mode. |
|
14444 |
+ |
|
14445 |
+It accepts the following values: |
|
14446 |
+@table @samp |
|
14447 |
+@item combined |
|
14448 |
+@item separate |
|
14449 |
+@end table |
|
14450 |
+Default is @code{combined}. |
|
14451 |
+ |
|
14441 | 14452 |
@end table |
14442 | 14453 |
|
14443 | 14454 |
@section showspectrum |
... | ... |
@@ -34,6 +34,7 @@ |
34 | 34 |
#include "internal.h" |
35 | 35 |
|
36 | 36 |
enum DisplayMode { LINE, BAR, DOT, NB_MODES }; |
37 |
+enum ChannelMode { COMBINED, SEPARATE, NB_CMODES }; |
|
37 | 38 |
enum FrequencyScale { FS_LINEAR, FS_LOG, FS_RLOG, NB_FSCALES }; |
38 | 39 |
enum AmplitudeScale { AS_LINEAR, AS_SQRT, AS_CBRT, AS_LOG, NB_ASCALES }; |
39 | 40 |
enum WindowFunc { WFUNC_RECT, WFUNC_HANNING, WFUNC_HAMMING, WFUNC_BLACKMAN, |
... | ... |
@@ -45,6 +46,7 @@ typedef struct ShowFreqsContext { |
45 | 45 |
const AVClass *class; |
46 | 46 |
int w, h; |
47 | 47 |
int mode; |
48 |
+ int cmode; |
|
48 | 49 |
int fft_bits; |
49 | 50 |
int ascale, fscale; |
50 | 51 |
int avg; |
... | ... |
@@ -115,6 +117,9 @@ static const AVOption showfreqs_options[] = { |
115 | 115 |
{ "overlap", "set window overlap", OFFSET(overlap), AV_OPT_TYPE_FLOAT, {.dbl=1.}, 0., 1., FLAGS }, |
116 | 116 |
{ "averaging", "set time averaging", OFFSET(avg), AV_OPT_TYPE_INT, {.i64=1}, 0, INT32_MAX, FLAGS }, |
117 | 117 |
{ "colors", "set channels colors", OFFSET(colors), AV_OPT_TYPE_STRING, {.str = "red|green|blue|yellow|orange|lime|pink|magenta|brown" }, 0, 0, FLAGS }, |
118 |
+ { "cmode", "set channel mode", OFFSET(cmode), AV_OPT_TYPE_INT, {.i64=COMBINED}, 0, NB_CMODES-1, FLAGS, "cmode" }, |
|
119 |
+ { "combined", "show all channels in same window", 0, AV_OPT_TYPE_CONST, {.i64=COMBINED}, 0, 0, FLAGS, "cmode" }, |
|
120 |
+ { "separate", "show each channel in own window", 0, AV_OPT_TYPE_CONST, {.i64=SEPARATE}, 0, 0, FLAGS, "cmode" }, |
|
118 | 121 |
{ NULL } |
119 | 122 |
}; |
120 | 123 |
|
... | ... |
@@ -358,6 +363,7 @@ static inline void plot_freq(ShowFreqsContext *s, int ch, |
358 | 358 |
const float avg = s->avg_data[ch][f]; |
359 | 359 |
const float bsize = get_bsize(s, f); |
360 | 360 |
const int sx = get_sx(s, f); |
361 |
+ int end = outlink->h; |
|
361 | 362 |
int x, y, i; |
362 | 363 |
|
363 | 364 |
switch(s->ascale) { |
... | ... |
@@ -374,7 +380,16 @@ static inline void plot_freq(ShowFreqsContext *s, int ch, |
374 | 374 |
a = 1.0 - a; |
375 | 375 |
break; |
376 | 376 |
} |
377 |
- y = a * outlink->h - 1; |
|
377 |
+ |
|
378 |
+ switch (s->cmode) { |
|
379 |
+ case COMBINED: |
|
380 |
+ y = a * outlink->h - 1; |
|
381 |
+ break; |
|
382 |
+ case SEPARATE: |
|
383 |
+ end = (outlink->h / s->nb_channels) * (ch + 1); |
|
384 |
+ y = (outlink->h / s->nb_channels) * ch + a * (outlink->h / s->nb_channels) - 1; |
|
385 |
+ break; |
|
386 |
+ } |
|
378 | 387 |
if (y < 0) |
379 | 388 |
return; |
380 | 389 |
|
... | ... |
@@ -410,7 +425,7 @@ static inline void plot_freq(ShowFreqsContext *s, int ch, |
410 | 410 |
break; |
411 | 411 |
case BAR: |
412 | 412 |
for (x = sx; x < sx + bsize && x < w; x++) |
413 |
- for (i = y; i < outlink->h; i++) |
|
413 |
+ for (i = y; i < end; i++) |
|
414 | 414 |
draw_dot(out, x, i, fg); |
415 | 415 |
break; |
416 | 416 |
case DOT: |