Browse Source

avfilter/avf_showvolume: make it possible to use current channel number in color expression

Signed-off-by: Paul B Mahol <onemda@gmail.com>
tags/n2.8
Paul B Mahol 10 years ago
parent
commit
e658b1036c
2 changed files with 6 additions and 2 deletions
  1. +3
    -0
      doc/filters.texi
  2. +3
    -2
      libavfilter/avf_showvolume.c

+ 3
- 0
doc/filters.texi View File

@@ -12158,6 +12158,9 @@ The expression can use the following variables:
@table @option @table @option
@item VOLUME @item VOLUME
Current max volume of channel in dB. Current max volume of channel in dB.

@item CHANNEL
Current channel number, starting from 0.
@end table @end table


@item t @item t


+ 3
- 2
libavfilter/avf_showvolume.c View File

@@ -59,8 +59,8 @@ static const AVOption showvolume_options[] = {


AVFILTER_DEFINE_CLASS(showvolume); AVFILTER_DEFINE_CLASS(showvolume);


static const char *const var_names[] = { "VOLUME", NULL };
enum { VAR_VOLUME, VAR_VARS_NB };
static const char *const var_names[] = { "VOLUME", "CHANNEL", NULL };
enum { VAR_VOLUME, VAR_CHANNEL, VAR_VARS_NB };


static av_cold int init(AVFilterContext *ctx) static av_cold int init(AVFilterContext *ctx)
{ {
@@ -201,6 +201,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)


max = av_clipf(max, 0, 1); max = av_clipf(max, 0, 1);
values[VAR_VOLUME] = 20.0 * log(max) / M_LN10; values[VAR_VOLUME] = 20.0 * log(max) / M_LN10;
values[VAR_CHANNEL] = c;
color = av_expr_eval(s->c_expr, values, NULL); color = av_expr_eval(s->c_expr, values, NULL);


for (j = 0; j < s->h; j++) { for (j = 0; j < s->h; j++) {


Loading…
Cancel
Save