Unified · Split
| @@ -26,6 +26,7 @@ · 25 unmodified lines | |||
| 26 | #include "libavutil/parseutils.h" | 26 | #include "libavutil/parseutils.h" |
| 27 | #include "libavutil/xga_font_data.h" | 27 | #include "libavutil/xga_font_data.h" |
| 28 | #include "avfilter.h" | 28 | #include "avfilter.h" |
| 29 | #include "filters.h" | ||
| 29 | #include "formats.h" | 30 | #include "formats.h" |
| 30 | #include "audio.h" | 31 | #include "audio.h" |
| 31 | #include "video.h" | 32 | #include "video.h" |
| @@ -47,6 +48,7 @@ typedef struct ShowVolumeContext { · 15 unmodified lines | |||
| 47 | float bgopacity; | 48 | float bgopacity; |
| 48 | int mode; | 49 | int mode; |
| 49 | 50 | ||
| 51 | int nb_samples; | ||
| 50 | AVFrame *out; | 52 | AVFrame *out; |
| 51 | AVExpr *c_expr; | 53 | AVExpr *c_expr; |
| 52 | int draw_text; | 54 | int draw_text; |
| @@ -162,12 +164,8 @@ static int config_input(AVFilterLink *inlink) · 109 unmodified lines | |||
| 162 | { | 164 | { |
| 163 | AVFilterContext *ctx = inlink->dst; | 165 | AVFilterContext *ctx = inlink->dst; |
| 164 | ShowVolumeContext *s = ctx->priv; | 166 | ShowVolumeContext *s = ctx->priv; |
| 165 | int nb_samples; | ||
| 166 | 167 | ||
| 167 | nb_samples = FFMAX(1024, ((double)inlink->sample_rate / av_q2d(s->frame_rate)) + 0.5); | 168 | s->nb_samples = FFMAX(1024, ((double)inlink->sample_rate / av_q2d(s->frame_rate)) + 0.5); |
| 168 | inlink->partial_buf_size = | ||
| 169 | inlink->min_samples = | ||
| 170 | inlink->max_samples = nb_samples; | ||
| 171 | s->values = av_calloc(inlink->channels * VAR_VARS_NB, sizeof(double)); | 169 | s->values = av_calloc(inlink->channels * VAR_VARS_NB, sizeof(double)); |
| 172 | if (!s->values) | 170 | if (!s->values) |
| 173 | return AVERROR(ENOMEM); | 171 | return AVERROR(ENOMEM); |
| @@ -449,6 +447,28 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 275 unmodified lines | |||
| 449 | return ff_filter_frame(outlink, out); | 447 | return ff_filter_frame(outlink, out); |
| 450 | } | 448 | } |
| 451 | 449 | ||
| 450 | static int activate(AVFilterContext *ctx) | ||
| 451 | { | ||
| 452 | AVFilterLink *inlink = ctx->inputs[0]; | ||
| 453 | AVFilterLink *outlink = ctx->outputs[0]; | ||
| 454 | ShowVolumeContext *s = ctx->priv; | ||
| 455 | AVFrame *in = NULL; | ||
| 456 | int ret; | ||
| 457 | |||
| 458 | FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); | ||
| 459 | |||
| 460 | ret = ff_inlink_consume_samples(inlink, s->nb_samples, s->nb_samples, &in); | ||
| 461 | if (ret < 0) | ||
| 462 | return ret; | ||
| 463 | if (ret > 0) | ||
| 464 | return filter_frame(inlink, in); | ||
| 465 | |||
| 466 | FF_FILTER_FORWARD_STATUS(inlink, outlink); | ||
| 467 | FF_FILTER_FORWARD_WANTED(outlink, inlink); | ||
| 468 | |||
| 469 | return FFERROR_NOT_READY; | ||
| 470 | } | ||
| 471 | |||
| 452 | static av_cold void uninit(AVFilterContext *ctx) | 472 | static av_cold void uninit(AVFilterContext *ctx) |
| 453 | { | 473 | { |
| 454 | ShowVolumeContext *s = ctx->priv; | 474 | ShowVolumeContext *s = ctx->priv; |
| @@ -465,7 +485,6 @@ static const AVFilterPad showvolume_inputs[] = { · 10 unmodified lines | |||
| 465 | .name = "default", | 485 | .name = "default", |
| 466 | .type = AVMEDIA_TYPE_AUDIO, | 486 | .type = AVMEDIA_TYPE_AUDIO, |
| 467 | .config_props = config_input, | 487 | .config_props = config_input, |
| 468 | .filter_frame = filter_frame, | ||
| 469 | }, | 488 | }, |
| 470 | { NULL } | 489 | { NULL } |
| 471 | }; | 490 | }; |
| @@ -483,6 +502,7 @@ AVFilter ff_avf_showvolume = { · 11 unmodified lines | |||
| 483 | .name = "showvolume", | 502 | .name = "showvolume", |
| 484 | .description = NULL_IF_CONFIG_SMALL("Convert input audio volume to video output."), | 503 | .description = NULL_IF_CONFIG_SMALL("Convert input audio volume to video output."), |
| 485 | .init = init, | 504 | .init = init, |
| 505 | .activate = activate, | ||
| 486 | .uninit = uninit, | 506 | .uninit = uninit, |
| 487 | .query_formats = query_formats, | 507 | .query_formats = query_formats, |
| 488 | .priv_size = sizeof(ShowVolumeContext), | 508 | .priv_size = sizeof(ShowVolumeContext), |