summaryrefslogtreecommitdiffstats
path: root/libavfilter/avf_showwaves.c
diff options
context:
space:
mode:
authorClément Bœsch <clement@stupeflix.com>2013-12-26 13:39:49 +0100
committerClément Bœsch <u@pkh.me>2014-08-20 22:18:38 +0200
commite35fb5add45ca27ab0568f3e0c2828246e8ff5c9 (patch)
treea68a238e0a6abcc2c36dfb6838f06dd67425b916 /libavfilter/avf_showwaves.c
parentba29746feb541f5cde4154795041ff2faa15bedf (diff)
downloadffmpeg-streaming-e35fb5add45ca27ab0568f3e0c2828246e8ff5c9.zip
ffmpeg-streaming-e35fb5add45ca27ab0568f3e0c2828246e8ff5c9.tar.gz
avfilter/showwaves: add split_channels option
Diffstat (limited to 'libavfilter/avf_showwaves.c')
-rw-r--r--libavfilter/avf_showwaves.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libavfilter/avf_showwaves.c b/libavfilter/avf_showwaves.c
index 3ffc4a2..804badd 100644
--- a/libavfilter/avf_showwaves.c
+++ b/libavfilter/avf_showwaves.c
@@ -51,6 +51,7 @@ typedef struct {
int n;
int sample_count_mod;
enum ShowWavesMode mode;
+ int split_channels;
void (*draw_sample)(uint8_t *buf, int height, int linesize,
int16_t sample, int16_t *prev_y, int intensity);
} ShowWavesContext;
@@ -69,6 +70,7 @@ static const AVOption showwaves_options[] = {
{ "n", "set how many samples to show in the same point", OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
{ "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
{ "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
+ { "split_channels", "draw channels separately", OFFSET(split_channels), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, FLAGS },
{ NULL }
};
@@ -241,7 +243,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
int nb_channels = inlink->channels;
int i, j, ret = 0;
const int n = showwaves->n;
- const int x = 255 / (nb_channels * n); /* multiplication factor, pre-computed to avoid in-loop divisions */
+ const int x = 255 / ((showwaves->split_channels ? 1 : nb_channels) * n); /* multiplication factor, pre-computed to avoid in-loop divisions */
+ const int ch_height = showwaves->split_channels ? outlink->h / nb_channels : outlink->h;
/* draw data in the buffer */
for (i = 0; i < nb_samples; i++) {
@@ -260,10 +263,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
for (j = 0; j < outlink->h; j++)
memset(outpicref->data[0] + j * linesize, 0, outlink->w);
}
- for (j = 0; j < nb_channels; j++)
- showwaves->draw_sample(outpicref->data[0] + showwaves->buf_idx,
- outlink->h, linesize, *p++,
+ for (j = 0; j < nb_channels; j++) {
+ uint8_t *buf = outpicref->data[0] + showwaves->buf_idx;
+ if (showwaves->split_channels)
+ buf += j*ch_height*linesize;
+ showwaves->draw_sample(buf, ch_height, linesize, *p++,
&showwaves->buf_idy[j], x);
+ }
showwaves->sample_count_mod++;
if (showwaves->sample_count_mod == n) {
OpenPOWER on IntegriCloud