62 int16_t
sample, int16_t *prev_y,
int intensity);
72 #define OFFSET(x) offsetof(ShowWavesContext, x)
73 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
162 outlink->
w = showwaves->
w;
163 outlink->
h = showwaves->
h;
201 const int ch_height = showwaves->
split_channels ? outlink->
h / nb_channels : outlink->
h;
202 const int linesize = out->
linesize[0];
204 int64_t *sum = showwaves->
sum;
206 av_log(ctx,
AV_LOG_DEBUG,
"Create frame averaging %"PRId64
" samples per column\n", max_samples);
208 memset(sum, 0, nb_channels);
213 const int16_t *p = (
const int16_t *)frame->
data[0];
219 sum[ch] += abs(p[ch + i*nb_channels]) << 1;
220 if (n++ == max_samples) {
222 int16_t
sample = sum[ch] / max_samples;
225 buf += ch*ch_height*linesize;
262 int16_t
sample, int16_t *prev_y,
int intensity)
264 const int h = height/2 -
av_rescale(sample, height/2, INT16_MAX);
265 if (h >= 0 && h < height)
266 buf[h * linesize] += intensity;
270 int16_t
sample, int16_t *prev_y,
int intensity)
273 const int h = height/2 -
av_rescale(sample, height/2, INT16_MAX);
274 int start = height/2;
275 int end = av_clip(h, 0, height-1);
277 FFSWAP(int16_t, start, end);
278 for (k = start; k <
end; k++)
279 buf[k * linesize] += intensity;
283 int16_t
sample, int16_t *prev_y,
int intensity)
286 const int h = height/2 -
av_rescale(sample, height/2, INT16_MAX);
287 if (h >= 0 && h < height) {
288 buf[h * linesize] += intensity;
289 if (*prev_y && h != *prev_y) {
291 int end = av_clip(h, 0, height-1);
293 FFSWAP(int16_t, start, end);
294 for (k = start + 1; k <
end; k++)
295 buf[k * linesize] += intensity;
302 int16_t
sample, int16_t *prev_y,
int intensity)
305 const int h =
av_rescale(abs(sample), height, INT16_MAX);
306 const int start = (height -
h) / 2;
307 const int end = start +
h;
308 for (k = start; k <
end; k++)
309 buf[k * linesize] += intensity;
327 for (j = 0; j < outlink->
h; j++)
337 if (!strcmp(ctx->
filter->
name,
"showwavespic")) {
342 switch (showwaves->
mode) {
353 #if CONFIG_SHOWWAVES_FILTER
362 int16_t *p = (int16_t *)insamples->
data[0];
365 const int n = showwaves->
n;
370 for (i = 0; i < nb_samples; i++) {
379 const int linesize = outpicref->
linesize[0];
381 buf += j*ch_height*linesize;
382 showwaves->
draw_sample(buf, ch_height, linesize, *p++,
391 if (showwaves->
buf_idx == showwaves->
w)
406 .filter_frame = showwaves_filter_frame,
428 .
inputs = showwaves_inputs,
430 .priv_class = &showwaves_class,
433 #endif // CONFIG_SHOWWAVES_FILTER
435 #if CONFIG_SHOWWAVESPIC_FILTER
437 #define OFFSET(x) offsetof(ShowWavesContext, x)
438 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
440 static const AVOption showwavespic_options[] = {
449 static int showwavespic_config_input(
AVFilterLink *inlink)
468 int16_t *p = (int16_t *)insamples->
data[0];
484 f->
frame = insamples;
507 .config_props = showwavespic_config_input,
508 .filter_frame = showwavespic_filter_frame,
513 static const AVFilterPad showwavespic_outputs[] = {
524 .
name =
"showwavespic",
530 .
inputs = showwavespic_inputs,
531 .
outputs = showwavespic_outputs,
532 .priv_class = &showwavespic_class,
535 #endif // CONFIG_SHOWWAVESPIC_FILTER
This structure describes decoded (raw) audio or video data.
static void draw_sample_p2p(uint8_t *buf, int height, int linesize, int16_t sample, int16_t *prev_y, int intensity)
static int alloc_out_frame(ShowWavesContext *showwaves, const int16_t *p, const AVFilterLink *inlink, AVFilterLink *outlink, const AVFrame *in)
static const AVFilterPad outputs[]
Main libavfilter public API header.
int h
agreed upon image height
static enum AVSampleFormat formats[]
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static AVRational av_make_q(int num, int den)
Create a rational.
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static av_cold int end(AVCodecContext *avctx)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static av_cold void uninit(AVFilterContext *ctx)
static double av_q2d(AVRational a)
Convert rational to double.
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
static void draw_sample_cline(uint8_t *buf, int height, int linesize, int16_t sample, int16_t *prev_y, int intensity)
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown; if left to 0/0, will be automatically be cop...
int sample_rate
samples per second
struct frame_node * last_frame
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
void * priv
private data for use by the filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert().
struct AVFilterChannelLayouts * out_channel_layouts
AVFilterFormats * in_formats
Lists of formats and channel layouts supported by the input and output filters respectively.
void(* draw_sample)(uint8_t *buf, int height, int linesize, int16_t sample, int16_t *prev_y, int intensity)
int w
agreed upon image width
audio channel layout utility functions
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
struct frame_node * audio_frames
static int push_single_pic(AVFilterLink *outlink)
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
AVFilterContext * src
source filter
AVFilterFormats * out_samplerates
A list of supported channel layouts.
AVSampleFormat
Audio sample formats.
static int config_output(AVFilterLink *outlink)
static int push_frame(AVFilterLink *outlink)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int request_frame(AVFilterLink *outlink)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
AVFILTER_DEFINE_CLASS(showwaves)
BYTE int const BYTE int int int height
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
rational number numerator/denominator
static int query_formats(AVFilterContext *ctx)
offset must point to AVRational
const char * name
Filter name.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
offset must point to two consecutive integers
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int channels
Number of channels.
AVFilterContext * dst
dest filter
static void draw_sample_point(uint8_t *buf, int height, int linesize, int16_t sample, int16_t *prev_y, int intensity)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
static void * av_mallocz_array(size_t nmemb, size_t size)
static enum AVSampleFormat sample_fmts[]
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
#define FFSWAP(type, a, b)
static const AVOption showwaves_options[]
static av_cold int init(AVFilterContext *ctx)
AVPixelFormat
Pixel format.
int nb_samples
number of audio samples (per channel) described by this frame
const AVFilter * filter
the AVFilter of which this is an instance
AVFilterFormats * out_formats
static void draw_sample_line(uint8_t *buf, int height, int linesize, int16_t sample, int16_t *prev_y, int intensity)