Go to the documentation of this file.
64 #define OFFSET(x) offsetof(AudioHistogramContext, x)
65 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
130 s->dchannels =
s->dmode ==
SINGLE ? 1 :
inlink->ch_layout.nb_channels;
131 s->shistogram =
av_calloc(
s->w,
s->dchannels *
sizeof(*
s->shistogram));
135 s->achistogram =
av_calloc(
s->w,
s->dchannels *
sizeof(*
s->achistogram));
172 s->histogram_h =
s->h *
s->phisto;
173 s->ypos =
s->h *
s->phisto;
198 if (!
s->combine_buffer)
211 const int H =
s->histogram_h;
213 int c, y, n, p, bin,
ret;
217 if (!
s->out ||
s->out->width != outlink->
w ||
218 s->out->height != outlink->
h) {
225 for (n =
H; n <
s->h; n++) {
226 memset(
s->out->data[0] + n *
s->out->linesize[0], 0,
w);
227 memset(
s->out->data[1] + n *
s->out->linesize[0], 127,
w);
228 memset(
s->out->data[2] + n *
s->out->linesize[0], 127,
w);
229 memset(
s->out->data[3] + n *
s->out->linesize[0], 0,
w);
240 for (y = 0; y <
w; y++) {
241 s->combine_buffer[3 * y ] = 0;
242 s->combine_buffer[3 * y + 1] = 127.5;
243 s->combine_buffer[3 * y + 2] = 127.5;
247 for (n = 0; n <
H; n++) {
248 memset(
s->out->data[0] + n *
s->out->linesize[0], 0,
w);
249 memset(
s->out->data[1] + n *
s->out->linesize[0], 127,
w);
250 memset(
s->out->data[2] + n *
s->out->linesize[0], 127,
w);
251 memset(
s->out->data[3] + n *
s->out->linesize[0], 0,
w);
254 s->out->duration = 1;
256 s->first =
s->frame_count;
260 for (
c = 0;
c <
inlink->ch_layout.nb_channels;
c++) {
262 uint64_t *achistogram = &
s->achistogram[(
s->dmode ==
SINGLE ? 0:
c) *
w];
264 for (n = 0; n < nb_samples; n++) {
265 bin =
s->get_bin(
src[n],
w);
270 if (
s->in[
s->first] &&
s->count >= 0) {
271 uint64_t *shistogram = &
s->shistogram[(
s->dmode ==
SINGLE ? 0:
c) *
w];
272 const float *
src2 = (
const float *)
s->in[
s->first]->extended_data[
c];
274 for (n = 0; n < nb_samples; n++) {
275 bin =
s->get_bin(
src2[n],
w);
283 for (
c = 0;
c <
inlink->ch_layout.nb_channels;
c++) {
285 uint64_t *achistogram = &
s->achistogram[(
s->dmode ==
SINGLE ? 0:
c) *
w];
287 for (n = 0; n < nb_samples; n++) {
288 bin =
s->get_bin(
src[n],
w);
293 if (
s->in[
s->first] &&
s->count >= 0) {
294 uint64_t *shistogram = &
s->shistogram[(
s->dmode ==
SINGLE ? 0:
c) *
w];
295 const float *
src2 = (
const float *)
s->in[
s->first]->extended_data[
c];
297 for (n = 0; n < nb_samples; n++) {
298 bin =
s->get_bin(
src2[n],
w);
308 s->in[
s->frame_count] = in;
310 if (
s->frame_count >
s->count)
313 for (n = 0; n <
w *
s->dchannels; n++) {
314 acmax =
FFMAX(
s->achistogram[n] -
s->shistogram[n], acmax);
317 for (
c = 0;
c <
s->dchannels;
c++) {
318 uint64_t *shistogram = &
s->shistogram[
c *
w];
319 uint64_t *achistogram = &
s->achistogram[
c *
w];
323 yf = 255.0f /
s->dchannels;
326 uf *= 0.5 * sin((2 *
M_PI *
c) /
s->dchannels);
327 vf *= 0.5 * cos((2 *
M_PI *
c) /
s->dchannels);
330 for (n = 0; n <
w; n++) {
334 a = achistogram[n] - shistogram[n];
341 aa = sqrt(
a) / sqrt(acmax);
361 int start =
H -
h, end =
H;
362 const int linesizey =
s->out->linesize[0];
363 const int linesizea =
s->out->linesize[3];
364 uint8_t *dsty =
s->out->data[0] + start * linesizey;
365 uint8_t *dsta =
s->out->data[3] + start * linesizea;
367 for (y = start; y < end; y++, dsty += linesizey, dsta += linesizea) {
376 s->out->data[1][
s->ypos *
s->out->linesize[1] + n] = 127;
377 s->out->data[2][
s->ypos *
s->out->linesize[2] + n] = 127;
378 s->out->data[3][
s->ypos *
s->out->linesize[3] + n] = 255;
381 int start =
H -
h, end =
H;
382 float *
out = &
s->combine_buffer[3 * n];
383 const int linesizey =
s->out->linesize[0];
384 const int linesizeu =
s->out->linesize[1];
385 const int linesizev =
s->out->linesize[2];
386 const int linesizea =
s->out->linesize[3];
387 uint8_t *dsty =
s->out->data[0] + start * linesizey;
388 uint8_t *dstu =
s->out->data[1] + start * linesizeu;
389 uint8_t *dstv =
s->out->data[2] + start * linesizev;
390 uint8_t *dsta =
s->out->data[3] + start * linesizea;
394 for (y = start; y < end; y++) {
418 for (n = 0; n <
w; n++) {
419 float *
cb = &
s->combine_buffer[3 * n];
421 s->out->data[0][
s->ypos *
s->out->linesize[0] + n] =
cb[0];
422 s->out->data[1][
s->ypos *
s->out->linesize[1] + n] =
cb[1];
423 s->out->data[2][
s->ypos *
s->out->linesize[2] + n] =
cb[2];
424 s->out->data[3][
s->ypos *
s->out->linesize[3] + n] = 255;
429 for (p = 0; p < 4; p++) {
430 for (y =
s->h - 1; y >=
H + 1; y--) {
431 memmove(
s->out->data[p] + (y ) *
s->out->linesize[p],
432 s->out->data[p] + (y-1) *
s->out->linesize[p],
w);
438 if (
s->slide ==
SCROLL ||
s->ypos >=
s->h)
485 for (
i = 0;
i < 101;
i++)
506 .
name =
"ahistogram",
514 .priv_class = &ahistogram_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
@ AV_SAMPLE_FMT_FLTP
float, planar
A list of supported channel layouts.
AVPixelFormat
Pixel format.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static double cb(void *priv, double x, double y)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static enum AVSampleFormat sample_fmts[]
enum MovChannelLayoutTag * layouts
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
static int config_output(AVFilterLink *outlink)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define FILTER_QUERY_FUNC(func)
const char * name
Filter name.
A link between two filters.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
void * priv
private data for use by the filter
static int get_log_bin_abs(float in, int w)
static av_cold void uninit(AVFilterContext *ctx)
static __device__ float fabsf(float a)
static const AVFilterPad ahistogram_outputs[]
A filter pad used for either input or output.
int(* get_bin)(float in, int w)
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
static enum AVPixelFormat pix_fmts[]
static int config_input(AVFilterLink *inlink)
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define FILTER_INPUTS(array)
int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe)
Make sure a frame is writable.
Describe the class of an AVClass context structure.
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
static int get_log_bin_sign(float in, int w)
Rational number (pair of numerator and denominator).
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static void scale(int *out, const int *in, const int w, const int h, const int shift)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int get_lin_bin_abs(float in, int w)
AVFilterContext * src
source filter
AVFilterFormatsConfig incfg
Lists of supported formats / etc.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
FF_FILTER_FORWARD_WANTED(outlink, inlink)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int get_lin_bin_sign(float in, int w)
AVFILTER_DEFINE_CLASS(ahistogram)
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
int w
agreed upon image width
uint8_t ** extended_data
pointers to the data planes/channels.
#define av_malloc_array(a, b)
AVSampleFormat
Audio sample formats.
const AVFilter ff_avf_ahistogram
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
const char * name
Pad name.
int ff_inlink_queued_samples(AVFilterLink *link)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
void * av_calloc(size_t nmemb, size_t size)
static const AVFilterPad ahistogram_inputs[]
int h
agreed upon image height
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
static int query_formats(AVFilterContext *ctx)
FF_FILTER_FORWARD_STATUS(inlink, outlink)
#define FILTER_OUTPUTS(array)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
static const AVOption ahistogram_options[]
static int activate(AVFilterContext *ctx)
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.