aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2013-05-15 12:36:41 +0000
committerPaul B Mahol <onemda@gmail.com>2013-05-15 12:38:39 +0000
commitc45b823bf80fdb5dd6dedb67cd56935b83c17ba5 (patch)
tree579105e00b74f3389b55aa85b628cb907ca30fd0 /libavfilter
parentfa23f94eaca3bbbd2f2b7b6e42a52077be59b77e (diff)
downloadffmpeg-c45b823bf80fdb5dd6dedb67cd56935b83c17ba5.tar.gz
lavfi/histogram: logarithmic mode for levels
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_histogram.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavfilter/vf_histogram.c b/libavfilter/vf_histogram.c
index f3fc9ff321..40afe1f327 100644
--- a/libavfilter/vf_histogram.c
+++ b/libavfilter/vf_histogram.c
@@ -48,6 +48,7 @@ typedef struct HistogramContext {
int step;
int waveform_mode;
int display_mode;
+ int levels_mode;
} HistogramContext;
#define OFFSET(x) offsetof(HistogramContext, x)
@@ -68,6 +69,9 @@ static const AVOption histogram_options[] = {
{ "display_mode", "set display mode", OFFSET(display_mode), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "display_mode"},
{ "parade", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "display_mode" },
{ "overlay", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "display_mode" },
+ { "levels_mode", "set levels mode", OFFSET(levels_mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "levels_mode"},
+ { "linear", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "levels_mode" },
+ { "logarithmic", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "levels_mode" },
{ NULL },
};
@@ -198,7 +202,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
h->max_hval = FFMAX(h->max_hval, h->histogram[i]);
for (i = 0; i < outlink->w; i++) {
- int col_height = h->level_height - (h->histogram[i] * (int64_t)h->level_height + h->max_hval - 1) / h->max_hval;
+ int col_height;
+
+ if (h->levels_mode)
+ col_height = round(h->level_height * (1. - (log2(h->histogram[i] + 1) / log2(h->max_hval + 1))));
+ else
+ col_height = h->level_height - (h->histogram[i] * (int64_t)h->level_height + h->max_hval - 1) / h->max_hval;
for (j = h->level_height - 1; j >= col_height; j--) {
if (h->display_mode) {