Go to the documentation of this file.
61 #define OFFSET(x) offsetof(AudioHistogramContext, x)
62 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
125 s->shistogram =
av_calloc(
s->w,
s->dchannels *
sizeof(*
s->shistogram));
129 s->achistogram =
av_calloc(
s->w,
s->dchannels *
sizeof(*
s->achistogram));
145 s->histogram_h =
s->h *
s->phisto;
146 s->ypos =
s->h *
s->phisto;
150 if (!
s->combine_buffer)
162 const int H =
s->histogram_h;
167 if (!
s->out ||
s->out->width != outlink->
w ||
168 s->out->height != outlink->
h) {
175 for (
n =
H;
n <
s->h;
n++) {
176 memset(
s->out->data[0] +
n *
s->out->linesize[0], 0,
w);
177 memset(
s->out->data[1] +
n *
s->out->linesize[0], 127,
w);
178 memset(
s->out->data[2] +
n *
s->out->linesize[0], 127,
w);
179 memset(
s->out->data[3] +
n *
s->out->linesize[0], 0,
w);
184 for (y = 0; y <
w; y++) {
185 s->combine_buffer[3 * y ] = 0;
186 s->combine_buffer[3 * y + 1] = 127.5;
187 s->combine_buffer[3 * y + 2] = 127.5;
191 for (
n = 0;
n <
H;
n++) {
192 memset(
s->out->data[0] +
n *
s->out->linesize[0], 0,
w);
193 memset(
s->out->data[1] +
n *
s->out->linesize[0], 127,
w);
194 memset(
s->out->data[2] +
n *
s->out->linesize[0], 127,
w);
195 memset(
s->out->data[3] +
n *
s->out->linesize[0], 0,
w);
197 s->out->pts =
in->pts;
199 s->first =
s->frame_count;
204 const float *
src = (
const float *)
in->extended_data[
c];
205 uint64_t *achistogram = &
s->achistogram[(
s->dmode ==
SINGLE ? 0:
c) *
w];
207 for (
n = 0;
n <
in->nb_samples;
n++) {
208 bin =
lrint(av_clipf(fabsf(
src[
n]), 0, 1) * (
w - 1));
213 if (
s->in[
s->first] &&
s->count >= 0) {
214 uint64_t *shistogram = &
s->shistogram[(
s->dmode ==
SINGLE ? 0:
c) *
w];
215 const float *src2 = (
const float *)
s->in[
s->first]->extended_data[
c];
217 for (
n = 0;
n <
in->nb_samples;
n++) {
218 bin =
lrint(av_clipf(fabsf(src2[
n]), 0, 1) * (
w - 1));
227 const float *
src = (
const float *)
in->extended_data[
c];
228 uint64_t *achistogram = &
s->achistogram[(
s->dmode ==
SINGLE ? 0:
c) *
w];
230 for (
n = 0;
n <
in->nb_samples;
n++) {
231 bin =
lrint(av_clipf(1 + log10(fabsf(
src[
n])) / 6, 0, 1) * (
w - 1));
236 if (
s->in[
s->first] &&
s->count >= 0) {
237 uint64_t *shistogram = &
s->shistogram[(
s->dmode ==
SINGLE ? 0:
c) *
w];
238 const float *src2 = (
const float *)
s->in[
s->first]->extended_data[
c];
240 for (
n = 0;
n <
in->nb_samples;
n++) {
241 bin =
lrint(av_clipf(1 + log10(fabsf(src2[
n])) / 6, 0, 1) * (
w - 1));
251 s->in[
s->frame_count] =
in;
253 if (
s->frame_count >
s->count)
256 for (
n = 0;
n <
w *
s->dchannels;
n++) {
257 acmax =
FFMAX(
s->achistogram[
n] -
s->shistogram[
n], acmax);
260 for (
c = 0;
c <
s->dchannels;
c++) {
261 uint64_t *shistogram = &
s->shistogram[
c *
w];
262 uint64_t *achistogram = &
s->achistogram[
c *
w];
266 yf = 256.0f /
s->dchannels;
269 uf *= 0.5 * sin((2 *
M_PI *
c) /
s->dchannels);
270 vf *= 0.5 * cos((2 *
M_PI *
c) /
s->dchannels);
273 for (
n = 0;
n <
w;
n++) {
277 a = achistogram[
n] - shistogram[
n];
281 aa =
a / (double)acmax;
284 aa = sqrt(
a) / sqrt(acmax);
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;
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;
319 float *
out = &
s->combine_buffer[3 *
n];
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)
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;
342 for (
n = 0;
n <
w;
n++) {
343 float *
cb = &
s->combine_buffer[3 *
n];
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;
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);
362 if (
s->slide ==
SCROLL ||
s->ypos >=
s->h)
400 for (
i = 0;
i < 101;
i++)
423 .
name =
"ahistogram",
431 .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.
AVFilter ff_avf_ahistogram
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
AVFilterFormats * in_formats
Lists of formats and channel layouts supported by the input and output filters respectively.
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.
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 av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad ahistogram_outputs[]
A filter pad used for either input or output.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static const AVFilterPad outputs[]
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.
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.
Rational number (pair of numerator and denominator).
F H1 F F H1 F F F F H1<-F-------F-------F v v v H2 H3 H2 ^ ^ ^ F-------F-------F-> H1<-F-------F-------F|||||||||F H1 F|||||||||F H1 Funavailable fullpel samples(outside the picture for example) shall be equalto the closest available fullpel sampleSmaller pel interpolation:--------------------------if diag_mc is set then points which lie on a line between 2 vertically, horizontally or diagonally adjacent halfpel points shall be interpolatedlinearly with rounding to nearest and halfway values rounded up.points which lie on 2 diagonals at the same time should only use the onediagonal not containing the fullpel point F--> O q O<--h1-> O q O<--F v \/v \/v O O O O O O O|/|\|q q q q q|/|\|O O O O O O O ^/\ ^/\ ^ h2--> O q O<--h3-> O q O<--h2 v \/v \/v O O O O O O O|\|/|q q q q q|\|/|O O O O O O O ^/\ ^/\ ^ F--> O q O<--h1-> O q O<--Fthe remaining points shall be bilinearly interpolated from theup to 4 surrounding halfpel and fullpel points, again rounding should be tonearest and halfway values rounded upcompliant Snow decoders MUST support 1-1/8 pel luma and 1/2-1/16 pel chromainterpolation at leastOverlapped block motion compensation:-------------------------------------FIXMELL band prediction:===================Each sample in the LL0 subband is predicted by the median of the left, top andleft+top-topleft samples, samples outside the subband shall be considered tobe 0. To reverse this prediction in the decoder apply the following.for(y=0;y< height;y++){ for(x=0;x< width;x++){ sample[y][x]+=median(sample[y-1][x], sample[y][x-1], sample[y-1][x]+sample[y][x-1]-sample[y-1][x-1]);}}sample[-1][ *]=sample[ *][-1]=0;width, height here are the width and height of the LL0 subband not of the finalvideoDequantization:===============FIXMEWavelet Transform:==================Snow supports 2 wavelet transforms, the symmetric biorthogonal 5/3 integertransform and an integer approximation of the symmetric biorthogonal 9/7daubechies wavelet.2D IDWT(inverse discrete wavelet transform) --------------------------------------------The 2D IDWT applies a 2D filter recursively, each time combining the4 lowest frequency subbands into a single subband until only 1 subbandremains.The 2D filter is done by first applying a 1D filter in the vertical directionand then applying it in the horizontal one. --------------- --------------- --------------- ---------------|LL0|HL0|||||||||||||---+---|HL1||L0|H0|HL1||LL1|HL1|||||LH0|HH0|||||||||||||-------+-------|-> L1 H1 LH1 HH1 LH1 HH1 LH1 HH1 this can end with a L or a H
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
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
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
AVFilterContext * src
source filter
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)
AVFILTER_DEFINE_CLASS(ahistogram)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
#define i(width, name, range_min, range_max)
int w
agreed upon image width
#define av_malloc_array(a, b)
AVSampleFormat
Audio sample formats.
const char * name
Pad name.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static const AVFilterPad ahistogram_inputs[]
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
int h
agreed upon image height
static int query_formats(AVFilterContext *ctx)
FF_FILTER_FORWARD_STATUS(inlink, outlink)
static const AVOption ahistogram_options[]
static int activate(AVFilterContext *ctx)