62#define OFFSET(x) offsetof(AudioHistogramContext, x)
63#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
122 s->shistogram =
av_calloc(
s->w,
s->dchannels *
sizeof(*
s->shistogram));
126 s->achistogram =
av_calloc(
s->w,
s->dchannels *
sizeof(*
s->achistogram));
164 s->histogram_h =
s->h *
s->phisto;
165 s->ypos =
s->h *
s->phisto;
190 if (!
s->combine_buffer)
203 const int H =
s->histogram_h;
205 int c, y, n, p, bin, ret;
209 if (!
s->out ||
s->out->width != outlink->
w ||
210 s->out->height != outlink->
h) {
217 for (n =
H; n <
s->h; n++) {
218 memset(
s->out->data[0] + n *
s->out->linesize[0], 0,
w);
219 memset(
s->out->data[1] + n *
s->out->linesize[0], 127,
w);
220 memset(
s->out->data[2] + n *
s->out->linesize[0], 127,
w);
221 memset(
s->out->data[3] + n *
s->out->linesize[0], 0,
w);
232 for (y = 0; y <
w; y++) {
233 s->combine_buffer[3 * y ] = 0;
234 s->combine_buffer[3 * y + 1] = 127.5;
235 s->combine_buffer[3 * y + 2] = 127.5;
239 for (n = 0; n <
H; n++) {
240 memset(
s->out->data[0] + n *
s->out->linesize[0], 0,
w);
241 memset(
s->out->data[1] + n *
s->out->linesize[0], 127,
w);
242 memset(
s->out->data[2] + n *
s->out->linesize[0], 127,
w);
243 memset(
s->out->data[3] + n *
s->out->linesize[0], 0,
w);
246 s->out->duration = 1;
248 s->first =
s->frame_count;
254 uint64_t *achistogram = &
s->achistogram[(
s->dmode ==
SINGLE ? 0:
c) *
w];
256 for (n = 0; n < nb_samples; n++) {
257 bin =
s->get_bin(
src[n],
w);
262 if (
s->in[
s->first] &&
s->count >= 0) {
263 uint64_t *shistogram = &
s->shistogram[(
s->dmode ==
SINGLE ? 0:
c) *
w];
264 const float *
src2 = (
const float *)
s->in[
s->first]->extended_data[
c];
266 for (n = 0; n < nb_samples; n++) {
267 bin =
s->get_bin(
src2[n],
w);
277 uint64_t *achistogram = &
s->achistogram[(
s->dmode ==
SINGLE ? 0:
c) *
w];
279 for (n = 0; n < nb_samples; n++) {
280 bin =
s->get_bin(
src[n],
w);
285 if (
s->in[
s->first] &&
s->count >= 0) {
286 uint64_t *shistogram = &
s->shistogram[(
s->dmode ==
SINGLE ? 0:
c) *
w];
287 const float *
src2 = (
const float *)
s->in[
s->first]->extended_data[
c];
289 for (n = 0; n < nb_samples; n++) {
290 bin =
s->get_bin(
src2[n],
w);
300 s->in[
s->frame_count] = in;
302 if (
s->frame_count >
s->count)
305 for (n = 0; n <
w *
s->dchannels; n++) {
306 acmax =
FFMAX(
s->achistogram[n] -
s->shistogram[n], acmax);
309 for (
c = 0;
c <
s->dchannels;
c++) {
310 uint64_t *shistogram = &
s->shistogram[
c *
w];
311 uint64_t *achistogram = &
s->achistogram[
c *
w];
315 yf = 255.0f /
s->dchannels;
318 uf *= 0.5 * sin((2 *
M_PI *
c) /
s->dchannels);
319 vf *= 0.5 * cos((2 *
M_PI *
c) /
s->dchannels);
322 for (n = 0; n <
w; n++) {
326 a = achistogram[n] - shistogram[n];
333 aa = sqrt(
a) / sqrt(acmax);
353 int start =
H -
h, end =
H;
354 const int linesizey =
s->out->linesize[0];
355 const int linesizea =
s->out->linesize[3];
356 uint8_t *dsty =
s->out->data[0] + start * linesizey;
357 uint8_t *dsta =
s->out->data[3] + start * linesizea;
359 for (y = start; y < end; y++, dsty += linesizey, dsta += linesizea) {
368 s->out->data[1][
s->ypos *
s->out->linesize[1] + n] = 127;
369 s->out->data[2][
s->ypos *
s->out->linesize[2] + n] = 127;
370 s->out->data[3][
s->ypos *
s->out->linesize[3] + n] = 255;
373 int start =
H -
h, end =
H;
374 float *
out = &
s->combine_buffer[3 * n];
375 const int linesizey =
s->out->linesize[0];
376 const int linesizeu =
s->out->linesize[1];
377 const int linesizev =
s->out->linesize[2];
378 const int linesizea =
s->out->linesize[3];
379 uint8_t *dsty =
s->out->data[0] + start * linesizey;
380 uint8_t *dstu =
s->out->data[1] + start * linesizeu;
381 uint8_t *dstv =
s->out->data[2] + start * linesizev;
382 uint8_t *dsta =
s->out->data[3] + start * linesizea;
386 for (y = start; y < end; y++) {
410 for (n = 0; n <
w; n++) {
411 float *
cb = &
s->combine_buffer[3 * n];
413 s->out->data[0][
s->ypos *
s->out->linesize[0] + n] =
cb[0];
414 s->out->data[1][
s->ypos *
s->out->linesize[1] + n] =
cb[1];
415 s->out->data[2][
s->ypos *
s->out->linesize[2] + n] =
cb[2];
416 s->out->data[3][
s->ypos *
s->out->linesize[3] + n] = 255;
421 for (p = 0; p < 4; p++) {
422 for (y =
s->h - 1; y >=
H + 1; y--) {
423 memmove(
s->out->data[p] + (y ) *
s->out->linesize[p],
424 s->out->data[p] + (y-1) *
s->out->linesize[p],
w);
430 if (
s->slide ==
SCROLL ||
s->ypos >=
s->h)
477 for (
i = 0;
i < 101;
i++)
498 .p.name =
"ahistogram",
500 .p.priv_class = &ahistogram_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int const int8_t const int8_t * vf
static enum AVSampleFormat sample_fmts[]
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int config_input(AVFilterLink *inlink)
const FFFilter ff_avf_ahistogram
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int get_log_bin_abs(float in, int w)
static const AVOption ahistogram_options[]
static int config_input(AVFilterLink *inlink)
static const AVFilterPad ahistogram_outputs[]
static int get_lin_bin_sign(float in, int w)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int activate(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
static int get_lin_bin_abs(float in, int w)
static int config_output(AVFilterLink *outlink)
static int get_log_bin_sign(float in, int w)
static const AVFilterPad ahistogram_inputs[]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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.
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe)
Make sure a frame is writable.
int ff_inlink_queued_samples(AVFilterLink *link)
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
static __device__ float fabsf(float a)
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_FLTP
float, planar
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FORWARD_WANTED(outlink, inlink)
Forward the frame_wanted_out flag from an output link to an input link.
#define FF_FILTER_FORWARD_STATUS(inlink, outlink)
Acknowledge the status on an input link and forward it to an output link.
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
void * priv
private data for use by the filter
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
int sample_rate
samples per second
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t ** extended_data
pointers to the data planes/channels.
Rational number (pair of numerator and denominator).
int(* get_bin)(float in, int w)
Link properties exposed to filter code, but not external callers.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
#define av_malloc_array(a, b)
static AVFormatContext * ctx
static double cb(void *priv, double x, double y)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.