Signed-off-by: Paul B Mahol <onemda@gmail.com>
Paul B Mahol authored on 2015/12/30 05:22:26... | ... |
@@ -13282,6 +13282,84 @@ tools. |
13282 | 13282 |
|
13283 | 13283 |
Below is a description of the currently available multimedia filters. |
13284 | 13284 |
|
13285 |
+@section ahistogram |
|
13286 |
+ |
|
13287 |
+Convert input audio to a video output, displaying the volume histogram. |
|
13288 |
+ |
|
13289 |
+The filter accepts the following options: |
|
13290 |
+ |
|
13291 |
+@table @option |
|
13292 |
+@item dmode |
|
13293 |
+Specify how histogram is calculated. |
|
13294 |
+ |
|
13295 |
+It accepts the following values: |
|
13296 |
+@table @samp |
|
13297 |
+@item single |
|
13298 |
+Use single histogram for all channels. |
|
13299 |
+@item separate |
|
13300 |
+Use separate histogram for each channel. |
|
13301 |
+@end table |
|
13302 |
+Default is @code{single}. |
|
13303 |
+ |
|
13304 |
+@item rate, r |
|
13305 |
+Set frame rate, expressed as number of frames per second. Default |
|
13306 |
+value is "25". |
|
13307 |
+ |
|
13308 |
+@item size, s |
|
13309 |
+Specify the video size for the output. For the syntax of this option, check the |
|
13310 |
+@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}. |
|
13311 |
+Default value is @code{hd720}. |
|
13312 |
+ |
|
13313 |
+@item scale |
|
13314 |
+Set display scale. |
|
13315 |
+ |
|
13316 |
+It accepts the following values: |
|
13317 |
+@table @samp |
|
13318 |
+@item log |
|
13319 |
+logarithmic |
|
13320 |
+@item sqrt |
|
13321 |
+square root |
|
13322 |
+@item cbrt |
|
13323 |
+cubic root |
|
13324 |
+@item lin |
|
13325 |
+linear |
|
13326 |
+@item rlog |
|
13327 |
+reverse logarithmic |
|
13328 |
+@end table |
|
13329 |
+Default is @code{log}. |
|
13330 |
+ |
|
13331 |
+@item ascale |
|
13332 |
+Set amplitude scale. |
|
13333 |
+ |
|
13334 |
+It accepts the following values: |
|
13335 |
+@table @samp |
|
13336 |
+@item log |
|
13337 |
+logarithmic |
|
13338 |
+@item lin |
|
13339 |
+linear |
|
13340 |
+@end table |
|
13341 |
+Default is @code{log}. |
|
13342 |
+ |
|
13343 |
+@item acount |
|
13344 |
+Set how much frames to accumulate in histogram. |
|
13345 |
+Defauls is 1. Setting this to -1 accumulates all frames. |
|
13346 |
+ |
|
13347 |
+@item rheight |
|
13348 |
+Set histogram ratio of window height. |
|
13349 |
+ |
|
13350 |
+@item slide |
|
13351 |
+Set sonogram sliding. |
|
13352 |
+ |
|
13353 |
+It accepts the following values: |
|
13354 |
+@table @samp |
|
13355 |
+@item replace |
|
13356 |
+replace old rows with new ones. |
|
13357 |
+@item scroll |
|
13358 |
+scroll from top to bottom. |
|
13359 |
+@end table |
|
13360 |
+Default is @code{replace}. |
|
13361 |
+@end table |
|
13362 |
+ |
|
13285 | 13363 |
@section aphasemeter |
13286 | 13364 |
|
13287 | 13365 |
Convert input audio to a video output, displaying the audio phase. |
... | ... |
@@ -280,6 +280,7 @@ OBJS-$(CONFIG_NULLSINK_FILTER) += vsink_nullsink.o |
280 | 280 |
|
281 | 281 |
# multimedia filters |
282 | 282 |
OBJS-$(CONFIG_ADRAWGRAPH_FILTER) += f_drawgraph.o |
283 |
+OBJS-$(CONFIG_AHISTOGRAM_FILTER) += avf_ahistogram.o |
|
283 | 284 |
OBJS-$(CONFIG_APHASEMETER_FILTER) += avf_aphasemeter.o |
284 | 285 |
OBJS-$(CONFIG_AVECTORSCOPE_FILTER) += avf_avectorscope.o |
285 | 286 |
OBJS-$(CONFIG_CONCAT_FILTER) += avf_concat.o |
... | ... |
@@ -300,6 +300,7 @@ void avfilter_register_all(void) |
300 | 300 |
|
301 | 301 |
/* multimedia filters */ |
302 | 302 |
REGISTER_FILTER(ADRAWGRAPH, adrawgraph, avf); |
303 |
+ REGISTER_FILTER(AHISTOGRAM, ahistogram, avf); |
|
303 | 304 |
REGISTER_FILTER(APHASEMETER, aphasemeter, avf); |
304 | 305 |
REGISTER_FILTER(AVECTORSCOPE, avectorscope, avf); |
305 | 306 |
REGISTER_FILTER(CONCAT, concat, avf); |
306 | 307 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,411 @@ |
0 |
+/* |
|
1 |
+ * Copyright (c) 2015 Paul B Mahol |
|
2 |
+ * |
|
3 |
+ * This file is part of FFmpeg. |
|
4 |
+ * |
|
5 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
6 |
+ * modify it under the terms of the GNU Lesser General Public |
|
7 |
+ * License as published by the Free Software Foundation; either |
|
8 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
9 |
+ * |
|
10 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
11 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
+ * Lesser General Public License for more details. |
|
14 |
+ * |
|
15 |
+ * You should have received a copy of the GNU Lesser General Public |
|
16 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
17 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
+ */ |
|
19 |
+ |
|
20 |
+#include "libavutil/avassert.h" |
|
21 |
+#include "libavutil/opt.h" |
|
22 |
+#include "libavutil/parseutils.h" |
|
23 |
+#include "avfilter.h" |
|
24 |
+#include "formats.h" |
|
25 |
+#include "audio.h" |
|
26 |
+#include "video.h" |
|
27 |
+#include "internal.h" |
|
28 |
+ |
|
29 |
+enum DisplayScale { LINEAR, SQRT, CBRT, LOG, RLOG, NB_SCALES }; |
|
30 |
+enum AmplitudeScale { ALINEAR, ALOG, NB_ASCALES }; |
|
31 |
+enum SlideMode { REPLACE, SCROLL, NB_SLIDES }; |
|
32 |
+enum DisplayMode { SINGLE, SEPARATE, NB_DMODES }; |
|
33 |
+enum HistogramMode { ACCUMULATE, CURRENT, NB_HMODES }; |
|
34 |
+ |
|
35 |
+typedef struct AudioHistogramContext { |
|
36 |
+ const AVClass *class; |
|
37 |
+ AVFrame *out; |
|
38 |
+ int w, h; |
|
39 |
+ AVRational frame_rate; |
|
40 |
+ uint64_t *achistogram; |
|
41 |
+ uint64_t *shistogram; |
|
42 |
+ int ascale; |
|
43 |
+ int scale; |
|
44 |
+ float phisto; |
|
45 |
+ int histogram_h; |
|
46 |
+ int apos; |
|
47 |
+ int ypos; |
|
48 |
+ int slide; |
|
49 |
+ int dmode; |
|
50 |
+ int dchannels; |
|
51 |
+ int count; |
|
52 |
+ int frame_count; |
|
53 |
+ float *combine_buffer; |
|
54 |
+ AVFrame *in[101]; |
|
55 |
+ int first; |
|
56 |
+} AudioHistogramContext; |
|
57 |
+ |
|
58 |
+#define OFFSET(x) offsetof(AudioHistogramContext, x) |
|
59 |
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM |
|
60 |
+ |
|
61 |
+static const AVOption ahistogram_options[] = { |
|
62 |
+ { "dmode", "set method to display channels", OFFSET(dmode), AV_OPT_TYPE_INT, {.i64=SINGLE}, 0, NB_DMODES-1, FLAGS, "dmode" }, |
|
63 |
+ { "single", "all channels use single histogram", 0, AV_OPT_TYPE_CONST, {.i64=SINGLE}, 0, 0, FLAGS, "dmode" }, |
|
64 |
+ { "separate", "each channel have own histogram", 0, AV_OPT_TYPE_CONST, {.i64=SEPARATE}, 0, 0, FLAGS, "dmode" }, |
|
65 |
+ { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, 0, FLAGS }, |
|
66 |
+ { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, 0, FLAGS }, |
|
67 |
+ { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS }, |
|
68 |
+ { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS }, |
|
69 |
+ { "scale", "set display scale", OFFSET(scale), AV_OPT_TYPE_INT, {.i64=LOG}, LINEAR, NB_SCALES-1, FLAGS, "scale" }, |
|
70 |
+ { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=LOG}, 0, 0, FLAGS, "scale" }, |
|
71 |
+ { "sqrt", "square root", 0, AV_OPT_TYPE_CONST, {.i64=SQRT}, 0, 0, FLAGS, "scale" }, |
|
72 |
+ { "cbrt", "cubic root", 0, AV_OPT_TYPE_CONST, {.i64=CBRT}, 0, 0, FLAGS, "scale" }, |
|
73 |
+ { "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=LINEAR}, 0, 0, FLAGS, "scale" }, |
|
74 |
+ { "rlog", "reverse logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=RLOG}, 0, 0, FLAGS, "scale" }, |
|
75 |
+ { "ascale", "set amplitude scale", OFFSET(ascale), AV_OPT_TYPE_INT, {.i64=ALOG}, LINEAR, NB_ASCALES-1, FLAGS, "ascale" }, |
|
76 |
+ { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=ALOG}, 0, 0, FLAGS, "ascale" }, |
|
77 |
+ { "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=ALINEAR}, 0, 0, FLAGS, "ascale" }, |
|
78 |
+ { "acount", "how much frames to accumulate", OFFSET(count), AV_OPT_TYPE_INT, {.i64=1}, -1, 100, FLAGS }, |
|
79 |
+ { "rheight", "set histogram ratio of window height", OFFSET(phisto), AV_OPT_TYPE_FLOAT, {.dbl=0.10}, 0, 1, FLAGS }, |
|
80 |
+ { "slide", "set sonogram sliding", OFFSET(slide), AV_OPT_TYPE_INT, {.i64=REPLACE}, 0, NB_SLIDES-1, FLAGS, "slide" }, |
|
81 |
+ { "replace", "replace old rows with new", 0, AV_OPT_TYPE_CONST, {.i64=REPLACE}, 0, 0, FLAGS, "slide" }, |
|
82 |
+ { "scroll", "scroll from top to bottom", 0, AV_OPT_TYPE_CONST, {.i64=SCROLL}, 0, 0, FLAGS, "slide" }, |
|
83 |
+ { NULL } |
|
84 |
+}; |
|
85 |
+ |
|
86 |
+AVFILTER_DEFINE_CLASS(ahistogram); |
|
87 |
+ |
|
88 |
+static int query_formats(AVFilterContext *ctx) |
|
89 |
+{ |
|
90 |
+ AVFilterFormats *formats = NULL; |
|
91 |
+ AVFilterChannelLayouts *layouts = NULL; |
|
92 |
+ AVFilterLink *inlink = ctx->inputs[0]; |
|
93 |
+ AVFilterLink *outlink = ctx->outputs[0]; |
|
94 |
+ static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }; |
|
95 |
+ static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUVA444P, AV_PIX_FMT_NONE }; |
|
96 |
+ int ret = AVERROR(EINVAL); |
|
97 |
+ |
|
98 |
+ formats = ff_make_format_list(sample_fmts); |
|
99 |
+ if ((ret = ff_formats_ref (formats, &inlink->out_formats )) < 0 || |
|
100 |
+ (layouts = ff_all_channel_counts()) == NULL || |
|
101 |
+ (ret = ff_channel_layouts_ref (layouts, &inlink->out_channel_layouts)) < 0) |
|
102 |
+ return ret; |
|
103 |
+ |
|
104 |
+ formats = ff_all_samplerates(); |
|
105 |
+ if ((ret = ff_formats_ref(formats, &inlink->out_samplerates)) < 0) |
|
106 |
+ return ret; |
|
107 |
+ |
|
108 |
+ formats = ff_make_format_list(pix_fmts); |
|
109 |
+ if ((ret = ff_formats_ref(formats, &outlink->in_formats)) < 0) |
|
110 |
+ return ret; |
|
111 |
+ |
|
112 |
+ return 0; |
|
113 |
+} |
|
114 |
+ |
|
115 |
+static int config_input(AVFilterLink *inlink) |
|
116 |
+{ |
|
117 |
+ AVFilterContext *ctx = inlink->dst; |
|
118 |
+ AudioHistogramContext *s = ctx->priv; |
|
119 |
+ int nb_samples; |
|
120 |
+ |
|
121 |
+ nb_samples = FFMAX(1024, ((double)inlink->sample_rate / av_q2d(s->frame_rate)) + 0.5); |
|
122 |
+ inlink->partial_buf_size = |
|
123 |
+ inlink->min_samples = |
|
124 |
+ inlink->max_samples = nb_samples; |
|
125 |
+ |
|
126 |
+ s->dchannels = s->dmode == SINGLE ? 1 : inlink->channels; |
|
127 |
+ s->shistogram = av_calloc(s->w, s->dchannels * sizeof(*s->shistogram)); |
|
128 |
+ if (!s->shistogram) |
|
129 |
+ return AVERROR(ENOMEM); |
|
130 |
+ |
|
131 |
+ s->achistogram = av_calloc(s->w, s->dchannels * sizeof(*s->achistogram)); |
|
132 |
+ if (!s->achistogram) |
|
133 |
+ return AVERROR(ENOMEM); |
|
134 |
+ |
|
135 |
+ return 0; |
|
136 |
+} |
|
137 |
+ |
|
138 |
+static int config_output(AVFilterLink *outlink) |
|
139 |
+{ |
|
140 |
+ AudioHistogramContext *s = outlink->src->priv; |
|
141 |
+ |
|
142 |
+ outlink->w = s->w; |
|
143 |
+ outlink->h = s->h; |
|
144 |
+ outlink->sample_aspect_ratio = (AVRational){1,1}; |
|
145 |
+ outlink->frame_rate = s->frame_rate; |
|
146 |
+ |
|
147 |
+ s->histogram_h = s->h * s->phisto; |
|
148 |
+ s->ypos = s->h * s->phisto; |
|
149 |
+ |
|
150 |
+ if (s->dmode == SEPARATE) { |
|
151 |
+ s->combine_buffer = av_malloc_array(outlink->w * 3, sizeof(*s->combine_buffer)); |
|
152 |
+ if (!s->combine_buffer) |
|
153 |
+ return AVERROR(ENOMEM); |
|
154 |
+ } |
|
155 |
+ |
|
156 |
+ return 0; |
|
157 |
+} |
|
158 |
+ |
|
159 |
+static int filter_frame(AVFilterLink *inlink, AVFrame *in) |
|
160 |
+{ |
|
161 |
+ AVFilterContext *ctx = inlink->dst; |
|
162 |
+ AVFilterLink *outlink = ctx->outputs[0]; |
|
163 |
+ AudioHistogramContext *s = ctx->priv; |
|
164 |
+ const int H = s->histogram_h; |
|
165 |
+ const int w = s->w; |
|
166 |
+ int c, y, n, p, bin; |
|
167 |
+ uint64_t acmax = 0; |
|
168 |
+ |
|
169 |
+ if (!s->out || s->out->width != outlink->w || |
|
170 |
+ s->out->height != outlink->h) { |
|
171 |
+ av_frame_free(&s->out); |
|
172 |
+ s->out = ff_get_video_buffer(outlink, outlink->w, outlink->h); |
|
173 |
+ if (!s->out) { |
|
174 |
+ av_frame_free(&in); |
|
175 |
+ return AVERROR(ENOMEM); |
|
176 |
+ } |
|
177 |
+ for (n = H; n < s->h; n++) { |
|
178 |
+ memset(s->out->data[0] + n * s->out->linesize[0], 0, w); |
|
179 |
+ memset(s->out->data[1] + n * s->out->linesize[0], 127, w); |
|
180 |
+ memset(s->out->data[2] + n * s->out->linesize[0], 127, w); |
|
181 |
+ memset(s->out->data[3] + n * s->out->linesize[0], 0, w); |
|
182 |
+ } |
|
183 |
+ } |
|
184 |
+ |
|
185 |
+ if (s->dmode == SEPARATE) { |
|
186 |
+ for (y = 0; y < w; y++) { |
|
187 |
+ s->combine_buffer[3 * y ] = 0; |
|
188 |
+ s->combine_buffer[3 * y + 1] = 127.5; |
|
189 |
+ s->combine_buffer[3 * y + 2] = 127.5; |
|
190 |
+ } |
|
191 |
+ } |
|
192 |
+ |
|
193 |
+ for (n = 0; n < H; n++) { |
|
194 |
+ memset(s->out->data[0] + n * s->out->linesize[0], 0, w); |
|
195 |
+ memset(s->out->data[1] + n * s->out->linesize[0], 127, w); |
|
196 |
+ memset(s->out->data[2] + n * s->out->linesize[0], 127, w); |
|
197 |
+ memset(s->out->data[3] + n * s->out->linesize[0], 0, w); |
|
198 |
+ } |
|
199 |
+ s->out->pts = in->pts; |
|
200 |
+ |
|
201 |
+ s->first = s->frame_count; |
|
202 |
+ |
|
203 |
+ switch (s->ascale) { |
|
204 |
+ case ALINEAR: |
|
205 |
+ for (c = 0; c < inlink->channels; c++) { |
|
206 |
+ const float *src = (const float *)in->extended_data[c]; |
|
207 |
+ uint64_t *achistogram = &s->achistogram[(s->dmode == SINGLE ? 0: c) * w]; |
|
208 |
+ |
|
209 |
+ for (n = 0; n < in->nb_samples; n++) { |
|
210 |
+ bin = lrint(av_clipf(fabsf(src[n]), 0, 1) * (w - 1)); |
|
211 |
+ |
|
212 |
+ achistogram[bin]++; |
|
213 |
+ } |
|
214 |
+ |
|
215 |
+ if (s->in[s->first] && s->count >= 0) { |
|
216 |
+ uint64_t *shistogram = &s->shistogram[(s->dmode == SINGLE ? 0: c) * w]; |
|
217 |
+ const float *src2 = (const float *)s->in[s->first]->extended_data[c]; |
|
218 |
+ |
|
219 |
+ for (n = 0; n < in->nb_samples; n++) { |
|
220 |
+ bin = lrint(av_clipf(fabsf(src2[n]), 0, 1) * (w - 1)); |
|
221 |
+ |
|
222 |
+ shistogram[bin]++; |
|
223 |
+ } |
|
224 |
+ } |
|
225 |
+ } |
|
226 |
+ break; |
|
227 |
+ case ALOG: |
|
228 |
+ for (c = 0; c < inlink->channels; c++) { |
|
229 |
+ const float *src = (const float *)in->extended_data[c]; |
|
230 |
+ uint64_t *achistogram = &s->achistogram[(s->dmode == SINGLE ? 0: c) * w]; |
|
231 |
+ |
|
232 |
+ for (n = 0; n < in->nb_samples; n++) { |
|
233 |
+ bin = lrint(av_clipf(1 + log10(fabsf(src[n])) / 6, 0, 1) * (w - 1)); |
|
234 |
+ |
|
235 |
+ achistogram[bin]++; |
|
236 |
+ } |
|
237 |
+ |
|
238 |
+ if (s->in[s->first] && s->count >= 0) { |
|
239 |
+ uint64_t *shistogram = &s->shistogram[(s->dmode == SINGLE ? 0: c) * w]; |
|
240 |
+ const float *src2 = (const float *)s->in[s->first]->extended_data[c]; |
|
241 |
+ |
|
242 |
+ for (n = 0; n < in->nb_samples; n++) { |
|
243 |
+ bin = lrint(av_clipf(1 + log10(fabsf(src2[n])) / 6, 0, 1) * (w - 1)); |
|
244 |
+ |
|
245 |
+ shistogram[bin]++; |
|
246 |
+ } |
|
247 |
+ } |
|
248 |
+ } |
|
249 |
+ break; |
|
250 |
+ } |
|
251 |
+ |
|
252 |
+ av_frame_free(&s->in[s->frame_count]); |
|
253 |
+ s->in[s->frame_count] = in; |
|
254 |
+ s->frame_count++; |
|
255 |
+ if (s->frame_count > s->count) |
|
256 |
+ s->frame_count = 0; |
|
257 |
+ |
|
258 |
+ for (n = 0; n < w * s->dchannels; n++) { |
|
259 |
+ acmax = FFMAX(s->achistogram[n] - s->shistogram[n], acmax); |
|
260 |
+ } |
|
261 |
+ |
|
262 |
+ for (c = 0; c < s->dchannels; c++) { |
|
263 |
+ uint64_t *shistogram = &s->shistogram[c * w]; |
|
264 |
+ uint64_t *achistogram = &s->achistogram[c * w]; |
|
265 |
+ float yf, uf, vf; |
|
266 |
+ |
|
267 |
+ if (s->dmode == SEPARATE) { |
|
268 |
+ yf = 256.0f / s->dchannels; |
|
269 |
+ uf = yf * M_PI; |
|
270 |
+ vf = yf * M_PI; |
|
271 |
+ uf *= 0.5 * sin((2 * M_PI * c) / s->dchannels); |
|
272 |
+ vf *= 0.5 * cos((2 * M_PI * c) / s->dchannels); |
|
273 |
+ } |
|
274 |
+ |
|
275 |
+ for (n = 0; n < w; n++) { |
|
276 |
+ double a, aa; |
|
277 |
+ int h; |
|
278 |
+ |
|
279 |
+ a = achistogram[n] - shistogram[n]; |
|
280 |
+ |
|
281 |
+ switch (s->scale) { |
|
282 |
+ case LINEAR: |
|
283 |
+ aa = a / (double)acmax; |
|
284 |
+ break; |
|
285 |
+ case SQRT: |
|
286 |
+ aa = sqrt(a) / sqrt(acmax); |
|
287 |
+ break; |
|
288 |
+ case CBRT: |
|
289 |
+ aa = cbrt(a) / cbrt(acmax); |
|
290 |
+ break; |
|
291 |
+ case LOG: |
|
292 |
+ aa = log2(a + 1) / log2(acmax + 1); |
|
293 |
+ break; |
|
294 |
+ case RLOG: |
|
295 |
+ aa = 1. - log2(a + 1) / log2(acmax + 1); |
|
296 |
+ if (aa == 1.) |
|
297 |
+ aa = 0; |
|
298 |
+ break; |
|
299 |
+ } |
|
300 |
+ |
|
301 |
+ h = aa * (H - 1); |
|
302 |
+ |
|
303 |
+ if (s->dmode == SINGLE) { |
|
304 |
+ |
|
305 |
+ for (y = H - h; y < H; y++) { |
|
306 |
+ s->out->data[0][y * s->out->linesize[0] + n] = 255; |
|
307 |
+ s->out->data[3][y * s->out->linesize[0] + n] = 255; |
|
308 |
+ } |
|
309 |
+ |
|
310 |
+ if (s->h - H > 0) { |
|
311 |
+ h = aa * 255; |
|
312 |
+ |
|
313 |
+ s->out->data[0][s->ypos * s->out->linesize[0] + n] = h; |
|
314 |
+ s->out->data[1][s->ypos * s->out->linesize[1] + n] = 127; |
|
315 |
+ s->out->data[2][s->ypos * s->out->linesize[2] + n] = 127; |
|
316 |
+ s->out->data[3][s->ypos * s->out->linesize[3] + n] = 255; |
|
317 |
+ } |
|
318 |
+ } else if (s->dmode == SEPARATE) { |
|
319 |
+ float *out = &s->combine_buffer[3 * n]; |
|
320 |
+ int old; |
|
321 |
+ |
|
322 |
+ old = s->out->data[0][(H - h) * s->out->linesize[0] + n]; |
|
323 |
+ for (y = H - h; y < H; y++) { |
|
324 |
+ if (s->out->data[0][y * s->out->linesize[0] + n] != old) |
|
325 |
+ break; |
|
326 |
+ old = s->out->data[0][y * s->out->linesize[0] + n]; |
|
327 |
+ s->out->data[0][y * s->out->linesize[0] + n] = yf; |
|
328 |
+ s->out->data[1][y * s->out->linesize[1] + n] = 128+uf; |
|
329 |
+ s->out->data[2][y * s->out->linesize[2] + n] = 128+vf; |
|
330 |
+ s->out->data[3][y * s->out->linesize[3] + n] = 255; |
|
331 |
+ } |
|
332 |
+ |
|
333 |
+ out[0] += aa * yf; |
|
334 |
+ out[1] += aa * uf; |
|
335 |
+ out[2] += aa * vf; |
|
336 |
+ } |
|
337 |
+ } |
|
338 |
+ } |
|
339 |
+ |
|
340 |
+ if (s->h - H > 0) { |
|
341 |
+ if (s->dmode == SEPARATE) { |
|
342 |
+ for (n = 0; n < w; n++) { |
|
343 |
+ float *cb = &s->combine_buffer[3 * n]; |
|
344 |
+ |
|
345 |
+ s->out->data[0][s->ypos * s->out->linesize[0] + n] = cb[0]; |
|
346 |
+ s->out->data[1][s->ypos * s->out->linesize[1] + n] = cb[1]; |
|
347 |
+ s->out->data[2][s->ypos * s->out->linesize[2] + n] = cb[2]; |
|
348 |
+ s->out->data[3][s->ypos * s->out->linesize[3] + n] = 255; |
|
349 |
+ } |
|
350 |
+ } |
|
351 |
+ |
|
352 |
+ if (s->slide == SCROLL) { |
|
353 |
+ for (p = 0; p < 4; p++) { |
|
354 |
+ for (y = s->h; y >= H + 1; y--) { |
|
355 |
+ memmove(s->out->data[p] + (y ) * s->out->linesize[p], |
|
356 |
+ s->out->data[p] + (y-1) * s->out->linesize[p], w); |
|
357 |
+ } |
|
358 |
+ } |
|
359 |
+ } |
|
360 |
+ |
|
361 |
+ s->ypos++; |
|
362 |
+ if (s->slide == SCROLL || s->ypos >= s->h) |
|
363 |
+ s->ypos = H; |
|
364 |
+ } |
|
365 |
+ |
|
366 |
+ return ff_filter_frame(outlink, av_frame_clone(s->out)); |
|
367 |
+} |
|
368 |
+ |
|
369 |
+static av_cold void uninit(AVFilterContext *ctx) |
|
370 |
+{ |
|
371 |
+ AudioHistogramContext *s = ctx->priv; |
|
372 |
+ int i; |
|
373 |
+ |
|
374 |
+ av_frame_free(&s->out); |
|
375 |
+ av_freep(&s->shistogram); |
|
376 |
+ av_freep(&s->achistogram); |
|
377 |
+ av_freep(&s->combine_buffer); |
|
378 |
+ for (i = 0; i < 101; i++) |
|
379 |
+ av_frame_free(&s->in[i]); |
|
380 |
+} |
|
381 |
+ |
|
382 |
+static const AVFilterPad audiovectorscope_inputs[] = { |
|
383 |
+ { |
|
384 |
+ .name = "default", |
|
385 |
+ .type = AVMEDIA_TYPE_AUDIO, |
|
386 |
+ .config_props = config_input, |
|
387 |
+ .filter_frame = filter_frame, |
|
388 |
+ }, |
|
389 |
+ { NULL } |
|
390 |
+}; |
|
391 |
+ |
|
392 |
+static const AVFilterPad audiovectorscope_outputs[] = { |
|
393 |
+ { |
|
394 |
+ .name = "default", |
|
395 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
396 |
+ .config_props = config_output, |
|
397 |
+ }, |
|
398 |
+ { NULL } |
|
399 |
+}; |
|
400 |
+ |
|
401 |
+AVFilter ff_avf_ahistogram = { |
|
402 |
+ .name = "ahistogram", |
|
403 |
+ .description = NULL_IF_CONFIG_SMALL("Convert input audio to histogram video output."), |
|
404 |
+ .uninit = uninit, |
|
405 |
+ .query_formats = query_formats, |
|
406 |
+ .priv_size = sizeof(AudioHistogramContext), |
|
407 |
+ .inputs = audiovectorscope_inputs, |
|
408 |
+ .outputs = audiovectorscope_outputs, |
|
409 |
+ .priv_class = &ahistogram_class, |
|
410 |
+}; |
... | ... |
@@ -30,7 +30,7 @@ |
30 | 30 |
#include "libavutil/version.h" |
31 | 31 |
|
32 | 32 |
#define LIBAVFILTER_VERSION_MAJOR 6 |
33 |
-#define LIBAVFILTER_VERSION_MINOR 24 |
|
33 |
+#define LIBAVFILTER_VERSION_MINOR 25 |
|
34 | 34 |
#define LIBAVFILTER_VERSION_MICRO 100 |
35 | 35 |
|
36 | 36 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |