avf_showspectrum.c File Reference

audio to spectrum (video) transmedia filter, based on ffplay rdft showmode (by Michael Niedermayer) and lavfi/avf_showwaves (by Stefano Sabatini). More...

#include <math.h>
#include "libavcodec/avfft.h"
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "internal.h"
Include dependency graph for avf_showspectrum.c:

Go to the source code of this file.

Data Structures

struct  ShowSpectrumContext
 

Macros

#define OFFSET(x)   offsetof(ShowSpectrumContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define RE(y, ch)   showspectrum->rdft_data[ch][2 * y + 0]
 
#define IM(y, ch)   showspectrum->rdft_data[ch][2 * y + 1]
 
#define MAGNITUDE(y, ch)   hypot(RE(y, ch), IM(y, ch))
 

Enumerations

enum  DisplayMode { COMBINED, SEPARATE, NB_MODES }
 
enum  DisplayScale {
  LINEAR, SQRT, CBRT, LOG,
  NB_SCALES
}
 
enum  ColorMode {
  CHANNEL, INTENSITY, NB_CLMODES, COLOR_MODE_NONE = -1,
  COLOR_MODE_BT709, COLOR_MODE_FCC, COLOR_MODE_BT601, COLOR_MODE_SMPTE240M,
  COLOR_MODE_COUNT
}
 

Functions

 AVFILTER_DEFINE_CLASS (showspectrum)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_output (AVFilterLink *outlink)
 
static int push_frame (AVFilterLink *outlink)
 
static int request_frame (AVFilterLink *outlink)
 
static int plot_spectrum_column (AVFilterLink *inlink, AVFrame *insamples, int nb_samples)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *insamples)
 

Variables

static const AVOption showspectrum_options []
 
struct {
   float   a
 
   float   y
 
   float   u
 
   float   v
 
intensity_color_table []
 
static const AVFilterPad showspectrum_inputs []
 
static const AVFilterPad showspectrum_outputs []
 
AVFilter avfilter_avf_showspectrum
 

Detailed Description

audio to spectrum (video) transmedia filter, based on ffplay rdft showmode (by Michael Niedermayer) and lavfi/avf_showwaves (by Stefano Sabatini).

Definition in file avf_showspectrum.c.

Macro Definition Documentation

Definition at line 64 of file avf_showspectrum.c.

#define IM (   y,
  ch 
)    showspectrum->rdft_data[ch][2 * y + 1]
#define MAGNITUDE (   y,
  ch 
)    hypot(RE(y, ch), IM(y, ch))

Referenced by plot_spectrum_column().

#define OFFSET (   x)    offsetof(ShowSpectrumContext, x)

Definition at line 63 of file avf_showspectrum.c.

#define RE (   y,
  ch 
)    showspectrum->rdft_data[ch][2 * y + 0]

Enumeration Type Documentation

enum ColorMode
Enumerator
CHANNEL 
INTENSITY 
NB_CLMODES 
COLOR_MODE_NONE 
COLOR_MODE_BT709 
COLOR_MODE_FCC 
COLOR_MODE_BT601 
COLOR_MODE_SMPTE240M 
COLOR_MODE_COUNT 

Definition at line 39 of file avf_showspectrum.c.

Enumerator
COMBINED 
SEPARATE 
NB_MODES 

Definition at line 37 of file avf_showspectrum.c.

Enumerator
LINEAR 
SQRT 
CBRT 
LOG 
NB_SCALES 

Definition at line 38 of file avf_showspectrum.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( showspectrum  )
static int config_output ( AVFilterLink outlink)
static

Definition at line 148 of file avf_showspectrum.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame insamples 
)
static

Definition at line 453 of file avf_showspectrum.c.

static int plot_spectrum_column ( AVFilterLink inlink,
AVFrame insamples,
int  nb_samples 
)
static

Definition at line 260 of file avf_showspectrum.c.

Referenced by filter_frame().

static int push_frame ( AVFilterLink outlink)
inlinestatic

Definition at line 231 of file avf_showspectrum.c.

Referenced by plot_spectrum_column(), and request_frame().

static int query_formats ( AVFilterContext ctx)
static

Definition at line 114 of file avf_showspectrum.c.

static int request_frame ( AVFilterLink outlink)
static

Definition at line 244 of file avf_showspectrum.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 100 of file avf_showspectrum.c.

Variable Documentation

float a

Definition at line 88 of file avf_showspectrum.c.

Referenced by plot_spectrum_column().

AVFilter avfilter_avf_showspectrum
Initial value:
= {
.name = "showspectrum",
.description = NULL_IF_CONFIG_SMALL("Convert input audio to a spectrum video output."),
.uninit = uninit,
.query_formats = query_formats,
.priv_size = sizeof(ShowSpectrumContext),
.priv_class = &showspectrum_class,
}
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
static int query_formats(AVFilterContext *ctx)
static const AVFilterPad showspectrum_outputs[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static const AVFilterPad showspectrum_inputs[]
static av_cold void uninit(AVFilterContext *ctx)
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

Definition at line 491 of file avf_showspectrum.c.

const { ... } intensity_color_table[]
Initial value:
= {
{ 0, 0, 0, 0 },
{ 0.13, .03587126228984074, .1573300977624594, -.02548747583751842 },
{ 0.30, .18572281794568020, .1772436246393981, .17475554840414750 },
{ 0.60, .28184980583656130, -.1593064119945782, .47132074554608920 },
{ 0.73, .65830621175547810, -.3716070802232764, .24352759331252930 },
{ 0.78, .76318535758242900, -.4307467689263783, .16866496622310430 },
{ 0.91, .95336363636363640, -.2045454545454546, .03313636363636363 },
{ 1, 1, 0, 0 }
}

Referenced by plot_spectrum_column().

const AVFilterPad showspectrum_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
{ NULL }
}
NULL
Definition: eval.c:55
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)

Definition at line 472 of file avf_showspectrum.c.

const AVOption showspectrum_options[]
static
Initial value:
= {
{ "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x512"}, 0, 0, FLAGS },
{ "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x512"}, 0, 0, FLAGS },
{ "slide", "set sliding mode", OFFSET(sliding), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, FLAGS },
{ "mode", "set channel display mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=COMBINED}, COMBINED, NB_MODES-1, FLAGS, "mode" },
{ "combined", "combined mode", 0, AV_OPT_TYPE_CONST, {.i64=COMBINED}, 0, 0, FLAGS, "mode" },
{ "separate", "separate mode", 0, AV_OPT_TYPE_CONST, {.i64=SEPARATE}, 0, 0, FLAGS, "mode" },
{ "color", "set channel coloring", OFFSET(color_mode), AV_OPT_TYPE_INT, {.i64=CHANNEL}, CHANNEL, NB_CLMODES-1, FLAGS, "color" },
{ "channel", "separate color for each channel", 0, AV_OPT_TYPE_CONST, {.i64=CHANNEL}, 0, 0, FLAGS, "color" },
{ "intensity", "intensity based coloring", 0, AV_OPT_TYPE_CONST, {.i64=INTENSITY}, 0, 0, FLAGS, "color" },
{ "scale", "set display scale", OFFSET(scale), AV_OPT_TYPE_INT, {.i64=SQRT}, LINEAR, NB_SCALES-1, FLAGS, "scale" },
{ "sqrt", "square root", 0, AV_OPT_TYPE_CONST, {.i64=SQRT}, 0, 0, FLAGS, "scale" },
{ "cbrt", "cubic root", 0, AV_OPT_TYPE_CONST, {.i64=CBRT}, 0, 0, FLAGS, "scale" },
{ "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=LOG}, 0, 0, FLAGS, "scale" },
{ "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=LINEAR}, 0, 0, FLAGS, "scale" },
{ "saturation", "color saturation multiplier", OFFSET(saturation), AV_OPT_TYPE_FLOAT, {.dbl = 1}, -10, 10, FLAGS },
{ NULL },
}
output residual component w
mode
Definition: f_perms.c:27
#define FLAGS
NULL
Definition: eval.c:55
offset must point to two consecutive integers
Definition: opt.h:230
Same thing on a dB scale
#define OFFSET(x)

Definition at line 66 of file avf_showspectrum.c.

const AVFilterPad showspectrum_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
.request_frame = request_frame,
},
{ NULL }
}
static int request_frame(AVFilterLink *outlink)
NULL
Definition: eval.c:55
static int config_output(AVFilterLink *outlink)

Definition at line 481 of file avf_showspectrum.c.

float u

Definition at line 88 of file avf_showspectrum.c.

Referenced by adpcm_compress_trellis(), adpcm_decode_frame(), avui_decode_frame(), aw_pulse_set2(), blend_subrect(), build_diff_map(), build_huff(), calc_combed_score(), calculate_codes(), cinepak_decode_codebook(), cpia_decode_frame(), dca_downmix(), decode_frame(), decode_mb_mode(), decode_subband_slice_buffered(), dv_decode_ac(), dxt1_decode_pixels(), encode_422_bitstream(), encode_frame(), ff_h264_decode_picture_parameter_set(), ff_print_debug_info2(), ff_rtjpeg_decode_frame_yuv420(), ff_yuv2rgb_c_init_tables(), filter_frame(), frame_block_to_cell(), generate_joint_tables(), get_bits(), get_s16l(), getutime(), hl_decode_mb_predict_luma(), hls_read_header(), if(), ilog2(), ilpack(), initPv(), intra_predict(), lcg_random(), model256_update(), model2_update(), model_update(), mss2_blit_wmv9_template(), pack_li_1_C(), plot_spectrum_column(), pow_m1_4(), print_option(), process_chrominance(), process_frame_uyvy422(), process_frame_yuv420p(), process_frame_yuv422p(), resampleCubic(), resampleLinear(), reverse_dc_prediction(), rgb16_32ToUV_c_template(), rso_write_header(), rv34_pred_4x4_block(), rv40_weak_loop_filter(), sign_extend(), ssd_int8_vs_int16_altivec(), subtitle_thread(), svq3_decode_mb(), sws_scale(), tm2_decode_blocks(), uninit_options(), utvideo_encode_frame(), v308_decode_frame(), v308_encode_frame(), v408_decode_frame(), v408_encode_frame(), v410_decode_frame(), v410_encode_frame(), wv_get_value_float(), y216_decode_frame(), y41p_decode_frame(), y41p_encode_frame(), yuv2nv12cX_c(), yuv4_decode_frame(), yuv4_encode_frame(), and zero12v_decode_frame().

float v

Definition at line 88 of file avf_showspectrum.c.

Referenced by ac3_extract_exponents_c(), ac3_max_msb_abs_int16_c(), ac3_tables_init(), add_yblock(), adpcm_decode_frame(), adpcm_encode_frame(), apply_channel_coupling(), audiogen(), av_adler32_update(), av_base64_decode(), av_cmp_i(), av_des_mac(), av_fifo_drain(), av_free(), AV_RB16(), AV_RB24(), AV_RB32(), AV_RB64(), AV_RL16(), AV_RL24(), AV_RL32(), AV_RL64(), av_shr_i(), av_tree_enumerate(), av_tree_find(), av_tree_insert(), av_xiphlacing(), avs_array_elt(), avs_new_value_array(), avs_new_value_bool(), avs_new_value_clip(), avs_new_value_error(), avs_new_value_float(), avs_new_value_int(), avs_new_value_string(), avui_decode_frame(), aw_pulse_set1(), bessel(), bink_decode_plane(), binkb_decode_plane(), blend_subrect(), bs_get_v(), build_xlaw_table(), calc_coefficients(), calc_combed_score(), categorize(), check_mv(), cinepak_decode_codebook(), clip_f15(), commit_bitstream_and_slice_buffer(), compute_affinity(), compute_scale_factors(), cpia_decode_frame(), create_lut(), dca_downmix(), dct_error(), decode2x2(), decode4x4(), decode8x8(), decode_block(), decode_channel(), decode_dds1(), decode_dsw1(), decode_exp_vlc(), decode_frame(), decode_init(), decode_init_static(), decode_mb(), decode_mv_component(), decode_mvc1(), decode_mvc2(), decode_rbsp_trailing(), decode_run_2bit(), decode_sgirle8(), decode_slice(), decode_spectrum_and_dequant(), decode_subband_slice_buffered(), decode_subframe(), decode_tsw1(), decode_vol_header(), decode_wdlt(), decodeplane8(), decorrelate(), decouple_info(), dequant_lsp10i(), dequant_lsp10r(), dequant_lsp16i(), dequant_lsp16r(), dshow_add_device(), dshow_cycle_formats(), dvb_encode_rle2(), dvb_encode_rle4(), dxva2_vc1_decode_slice(), dxva2_vc1_end_frame(), dxva2_vc1_start_frame(), encode_422_bitstream(), encode_block(), encode_frame(), encode_picture_lossless(), encode_picture_ls(), encode_rgb_frame(), encode_subband_c0run(), escape_FF(), eval_expr(), evolve(), f_func(), ff_ac3_bit_alloc_calc_psd(), ff_acelp_interpolate(), ff_acelp_interpolatef(), ff_add_wav(), ff_audio_mix_set_matrix(), ff_bgmc_decode(), ff_ctz_c(), ff_eac3_decode_transform_coeffs_aht_ch(), ff_gradfun_blur_line_c(), ff_h263_decode_mb(), ff_h263_decode_picture_header(), ff_h264_decode_picture_parameter_set(), ff_h264_find_frame_end(), ff_hex_to_data(), ff_j_rev_dct(), ff_j_rev_dct4(), ff_log2_16bit_c(), ff_log2_c(), ff_mjpeg_decode_dht(), ff_mjpeg_decode_sos(), ff_mpa_synth_init(), ff_mpeg4_decode_picture_header(), ff_pca(), ff_print_AM_MEDIA_TYPE(), ff_print_debug_info2(), ff_rm_read_mdpr_codecdata(), ff_rtjpeg_decode_frame_yuv420(), ff_rtsp_open_transport_ctx(), ff_simple_idct_axp(), ff_snow_inner_add_yblock(), ff_srtp_decrypt(), ff_vc1_decode_blocks(), ff_vdpau_add_data_chunk(), ff_vorbis_comment(), fill16(), fill24(), fill32(), fill_picture_rgb(), fill_rectangle(), fill_slice(), fillPlane16(), filter(), filter_frame(), filter_line_c(), filter_line_c_16bit(), find_marker(), find_next_start_code(), find_smallest_bounding_rectangle(), flush_packet(), frame_block_to_cell(), g723_1_decode_frame(), gb_get_v(), get_amv(), get_audio_frame(), get_block_rd(), get_fourcc(), get_graph_color(), get_s(), get_s16l(), get_size(), get_sr_golomb(), get_sr_golomb_flac(), get_symbol2(), get_visual_weight(), get_vlc_symbol(), getnbctxno(), gif_image_write_header(), gif_image_write_image(), gif_read_header1(), h264_filter_mb_fast_internal(), hls_read_header(), horizontal_compose_fidelityi(), horizX1Filter(), huffman_decode(), idcin_decode_vlcs(), idct(), idct248_error(), idct248_ref(), ilpack(), init_exp(), init_h263_dc_for_msmpeg4(), init_qexp(), init_uni_dc_tab(), initFilter(), initPv(), int32_to_float_fmul_scalar_altivec(), int_cos(), int_pow(), inverse(), isinf(), isnan(), iso_clip(), lcg_random(), line_noise_c(), ljpeg_decode_yuv_scan(), load_matrix(), loco_get_rice(), lu_to_y(), main(), mirror(), mix_1_to_2_fltp_flt_c(), mjpeg_decode_scan(), mp3_parse_vbr_tags(), mp3_write_audio_packet(), mp_decode_layer1(), mp_decode_layer2(), MPA_encode_init(), mpeg1_decode_sequence(), mpeg1_encode_sequence_header(), mpeg4_encode_dc(), mpeg4_is_resync(), mss2_blit_wmv9_template(), multiswap_inv_step(), multiswap_step(), mv_read_header(), nelly_decode_block(), normalize_samples(), nsse16_c(), nsse8_c(), nsv_resync(), pack_li_1_C(), parse_dB(), parse_options(), parse_pcr(), parse_volume(), pcm_decode_frame(), pcm_encode_frame(), pcx_decode_frame(), pink_fill(), plot_spectrum_column(), pnm_decode_frame(), pow_m1_4(), pred4x4_horizontal_add(), pred4x4_vertical_add(), pred4x4_vertical_vp8_c(), pred8x8l_horizontal_add(), pred8x8l_vertical_add(), predict_slice(), predict_slice_buffered(), print_fps(), process_chrominance(), process_frame_uyvy422(), process_frame_yuv420p(), process_frame_yuv422p(), put_s(), put_vlc_symbol(), qmf_32_subbands(), quantize_mantissas_blk_ch(), radix_count(), radix_sort_pass(), read_and_decode_spectrum(), read_block_types(), read_colors(), read_data(), read_dcs(), read_extra_header(), read_header(), read_motion_values(), read_patterns(), read_quant_table(), read_runs(), recheck_discard_flags(), remove_wasted_bits(), request_frame(), resampleCubic(), resampleLinear(), rice_count_exact(), rv10_decode_packet(), rv10_write_header(), rv40_decode_intra_types(), sbr_qmf_synthesis(), set(), set_params(), set_sr_golomb(), set_sr_golomb_flac(), shuffle_bytes_2103(), shuffle_bytes_2103_c(), sign_extend(), skip_check(), smk_get_code(), srt_probe(), subtitle_thread(), swf_read_packet(), swf_write_header(), swri_get_dither(), swri_rematrix(), sws_scale(), sym_quant(), tget_long(), tget_short(), tm2_decode_blocks(), tm2_read_deltas(), txd_decode_frame(), unpack_coeffs(), update_md5_sum(), update_vlc_state(), utvideo_encode_frame(), v308_decode_frame(), v308_encode_frame(), v408_decode_frame(), v408_encode_frame(), v410_decode_frame(), v410_encode_frame(), vaapi_vc1_decode_slice(), vaapi_vc1_start_frame(), var_read_float(), var_read_int(), vble_restore_plane(), vc1_pack_bitplanes(), vc1_unescape_buffer(), vcr2_init_sequence(), vdpau_vc1_start_frame(), vertX1Filter(), vop_dquant_decoding(), vp56_rac_gets_nn(), vp5_adjust(), vp6_adjust(), vp8_rac_get_coeff(), vp8_rac_get_nn(), vp8_rac_get_sint(), wma_decode_block(), wma_lsp_to_curve(), wnv1_get_code(), worker(), write_extradata(), y216_decode_frame(), y41p_decode_frame(), y41p_encode_frame(), yuv2nv12cX_c(), yuv4_decode_frame(), yuv4_encode_frame(), and zero12v_decode_frame().

float y

Definition at line 88 of file avf_showspectrum.c.

Referenced by plot_spectrum_column().