summaryrefslogtreecommitdiff
path: root/libavfilter/avf_showvolume.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavfilter/avf_showvolume.c')
-rw-r--r--libavfilter/avf_showvolume.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/libavfilter/avf_showvolume.c b/libavfilter/avf_showvolume.c
index 401b65ca69..1c072a16a6 100644
--- a/libavfilter/avf_showvolume.c
+++ b/libavfilter/avf_showvolume.c
@@ -166,15 +166,15 @@ static int config_input(AVFilterLink *inlink)
ShowVolumeContext *s = ctx->priv;
s->nb_samples = FFMAX(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
- s->values = av_calloc(inlink->channels * VAR_VARS_NB, sizeof(double));
+ s->values = av_calloc(inlink->ch_layout.nb_channels * VAR_VARS_NB, sizeof(double));
if (!s->values)
return AVERROR(ENOMEM);
- s->color_lut = av_calloc(s->w, sizeof(*s->color_lut) * inlink->channels);
+ s->color_lut = av_calloc(s->w, sizeof(*s->color_lut) * inlink->ch_layout.nb_channels);
if (!s->color_lut)
return AVERROR(ENOMEM);
- s->max = av_calloc(inlink->channels, sizeof(*s->max));
+ s->max = av_calloc(inlink->ch_layout.nb_channels, sizeof(*s->max));
if (!s->max)
return AVERROR(ENOMEM);
@@ -188,8 +188,8 @@ static int config_input(AVFilterLink *inlink)
if (s->draw_persistent_duration > 0.) {
s->persistent_max_frames = (int) FFMAX(av_q2d(s->frame_rate) * s->draw_persistent_duration, 1.);
- s->max_persistent = av_calloc(inlink->channels * s->persistent_max_frames, sizeof(*s->max_persistent));
- s->nb_frames_max_display = av_calloc(inlink->channels * s->persistent_max_frames, sizeof(*s->nb_frames_max_display));
+ s->max_persistent = av_calloc(inlink->ch_layout.nb_channels * s->persistent_max_frames, sizeof(*s->max_persistent));
+ s->nb_frames_max_display = av_calloc(inlink->ch_layout.nb_channels * s->persistent_max_frames, sizeof(*s->nb_frames_max_display));
}
return 0;
}
@@ -202,16 +202,16 @@ static int config_output(AVFilterLink *outlink)
if (s->orientation) {
outlink->h = s->w;
- outlink->w = s->h * inlink->channels + (inlink->channels - 1) * s->b;
+ outlink->w = s->h * inlink->ch_layout.nb_channels + (inlink->ch_layout.nb_channels - 1) * s->b;
} else {
outlink->w = s->w;
- outlink->h = s->h * inlink->channels + (inlink->channels - 1) * s->b;
+ outlink->h = s->h * inlink->ch_layout.nb_channels + (inlink->ch_layout.nb_channels - 1) * s->b;
}
outlink->sample_aspect_ratio = (AVRational){1,1};
outlink->frame_rate = s->frame_rate;
- for (ch = 0; ch < inlink->channels; ch++) {
+ for (ch = 0; ch < inlink->ch_layout.nb_channels; ch++) {
int i;
for (i = 0; i < s->w; i++) {
@@ -322,6 +322,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
ShowVolumeContext *s = ctx->priv;
const int step = s->step;
int c, j, k, max_draw;
+ char channel_name[64];
AVFrame *out;
if (!s->out || s->out->width != outlink->w ||
@@ -353,7 +354,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
}
if (s->orientation) { /* vertical */
- for (c = 0; c < inlink->channels; c++) {
+ for (c = 0; c < inlink->ch_layout.nb_channels; c++) {
float *src = (float *)insamples->extended_data[c];
uint32_t *lut = s->color_lut + s->w * c;
float max;
@@ -375,8 +376,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
}
if (s->h >= 8 && s->draw_text) {
- const char *channel_name = av_get_channel_name(av_channel_layout_extract_channel(insamples->channel_layout, c));
- if (!channel_name)
+ int ret = av_channel_name(channel_name, sizeof(channel_name), av_channel_layout_channel_from_index(&insamples->ch_layout, c));
+ if (ret < 0)
continue;
drawtext(s->out, c * (s->h + s->b) + (s->h - 10) / 2, outlink->h - 35, channel_name, 1);
}
@@ -388,7 +389,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
}
}
} else { /* horizontal */
- for (c = 0; c < inlink->channels; c++) {
+ for (c = 0; c < inlink->ch_layout.nb_channels; c++) {
float *src = (float *)insamples->extended_data[c];
uint32_t *lut = s->color_lut + s->w * c;
float max;
@@ -411,8 +412,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
}
if (s->h >= 8 && s->draw_text) {
- const char *channel_name = av_get_channel_name(av_channel_layout_extract_channel(insamples->channel_layout, c));
- if (!channel_name)
+ int ret = av_channel_name(channel_name, sizeof(channel_name), av_channel_layout_channel_from_index(&insamples->ch_layout, c));
+ if (ret < 0)
continue;
drawtext(s->out, 2, c * (s->h + s->b) + (s->h - 8) / 2, channel_name, 0);
}
@@ -432,7 +433,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
av_frame_make_writable(out);
/* draw volume level */
- for (c = 0; c < inlink->channels && s->h >= 8 && s->draw_volume; c++) {
+ for (c = 0; c < inlink->ch_layout.nb_channels && s->h >= 8 && s->draw_volume; c++) {
char buf[16];
if (s->orientation) { /* vertical */