summaryrefslogtreecommitdiff
path: root/libavfilter/vf_histogram.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2013-02-18 20:12:07 +0000
committerPaul B Mahol <onemda@gmail.com>2013-02-18 20:13:07 +0000
commit480ddf2bc9c0796493eb76203e255c4c84881947 (patch)
tree48866b0ec8fae3f1828fca848f8819a56fb4b841 /libavfilter/vf_histogram.c
parente39821a65e42722e81bf53bb44237f9bf8e4ce07 (diff)
lavfi/histogram: overlay display mode for levels histogram mode
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter/vf_histogram.c')
-rw-r--r--libavfilter/vf_histogram.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libavfilter/vf_histogram.c b/libavfilter/vf_histogram.c
index ee9689f5e6..279e44aba1 100644
--- a/libavfilter/vf_histogram.c
+++ b/libavfilter/vf_histogram.c
@@ -153,7 +153,7 @@ static int config_output(AVFilterLink *outlink)
switch (h->mode) {
case MODE_LEVELS:
outlink->w = 256;
- outlink->h = (h->level_height + h->scale_height) * h->ncomp;
+ outlink->h = (h->level_height + h->scale_height) * FFMAX(h->ncomp * h->display_mode, 1);
break;
case MODE_WAVEFORM:
if (h->waveform_mode)
@@ -200,7 +200,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in)
switch (h->mode) {
case MODE_LEVELS:
for (k = 0; k < h->ncomp; k++) {
- int start = k * (h->level_height + h->scale_height);
+ int start = k * (h->level_height + h->scale_height) * h->display_mode;
for (i = 0; i < in->video->h; i++) {
src = in->data[k] + i * in->linesize[k];
@@ -214,9 +214,14 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in)
for (i = 0; i < outlink->w; i++) {
int col_height = h->level_height - (float)h->histogram[i] / h->max_hval * h->level_height;
- for (j = h->level_height - 1; j >= col_height; j--)
- for (l = 0; l < h->ncomp; l++)
- out->data[l][(j + start) * out->linesize[l] + i] = h->fg_color[l];
+ for (j = h->level_height - 1; j >= col_height; j--) {
+ if (h->display_mode) {
+ for (l = 0; l < h->ncomp; l++)
+ out->data[l][(j + start) * out->linesize[l] + i] = h->fg_color[l];
+ } else {
+ out->data[k][(j + start) * out->linesize[k] + i] = 255;
+ }
+ }
for (j = h->level_height + h->scale_height - 1; j >= h->level_height; j--)
out->data[k][(j + start) * out->linesize[k] + i] = i;
}