34 #if CONFIG_LIBFREETYPE
36 #include FT_FREETYPE_H
39 #if CONFIG_LIBFONTCONFIG
40 #include <fontconfig/fontconfig.h>
45 #define BASEFREQ 20.01523126408007475
46 #define ENDFREQ 20495.59681441799654
47 #define TLENGTH "384*tc/(384+tc*f)"
48 #define TLENGTH_MIN 0.001
49 #define VOLUME_MAX 100.0
50 #define FONTCOLOR "st(0, (midi(f)-59.5)/12);" \
51 "st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));" \
52 "r(1-ld(1)) + b(ld(1))"
53 #define CSCHEME "1|0.5|0|0|0.5|1"
55 #define PTS_TOLERANCE 1
57 #define OFFSET(x) offsetof(ShowCQTContext, x)
58 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
133 av_log(s->
ctx, level,
"plot_time = %16.3f s.\n", plot_time * 1e-6);
140 for (k = 0; k < 4; k++)
149 for (k = 0; k < s->
cqt_len; k++)
165 double log_base, log_end;
166 double rcp_n = 1.0 /
n;
174 log_base = log(base);
176 for (x = 0; x <
n; x++) {
177 double log_freq = log_base + (x + 0.5) * (log_end - log_base) * rcp_n;
178 freq[x] =
exp(log_freq);
184 double val,
double min,
double max,
185 double nan_replace,
int idx)
189 av_log(log_ctx, level,
"[%d] %s is nan, setting it to %g.\n",
190 idx, name, nan_replace);
192 }
else if (val < min) {
193 av_log(log_ctx, level,
"[%d] %s is too low (%g), setting it to %g.\n",
194 idx, name, val, min);
196 }
else if (val > max) {
197 av_log(log_ctx, level,
"[%d] %s it too high (%g), setting it to %g.\n",
198 idx, name, val, max);
206 double ret = 12200.0*12200.0 * (f*f*f*f);
207 ret /= (f*f + 20.6*20.6) * (f*f + 12200.0*12200.0) *
208 sqrt((f*f + 107.7*107.7) * (f*f + 737.9*737.9));
214 double ret = 12200.0*12200.0 * (f*f*f);
215 ret /= (f*f + 20.6*20.6) * (f*f + 12200.0*12200.0) * sqrt(f*f + 158.5*158.5);
221 double ret = 12200.0*12200.0 * (f*f);
222 ret /= (f*f + 20.6*20.6) * (f*f + 12200.0*12200.0);
228 const char *func_names[] = {
"a_weighting",
"b_weighting",
"c_weighting",
NULL };
229 const char *sono_names[] = {
"timeclamp",
"tc",
"frequency",
"freq",
"f",
"bar_v",
NULL };
230 const char *bar_names[] = {
"timeclamp",
"tc",
"frequency",
"freq",
"f",
"sono_v",
NULL };
246 for (x = 0; x < s->
cqt_len; x++) {
269 int len,
int fft_len)
272 for (k = 0; k <
len; k++) {
275 for (x = 0; x < coeffs[k].
len; x++) {
277 i = coeffs[k].
start + x;
279 a.
re += u * src[i].
re;
280 a.
im += u * src[i].
im;
281 b.re += u * src[j].
re;
282 b.im += u * src[j].
im;
297 const char *
var_names[] = {
"timeclamp",
"tc",
"frequency",
"freq",
"f",
NULL };
300 int nb_cqt_coeffs = 0;
310 for (k = 0; k < s->
cqt_len; k++) {
312 double flen, center, tlength;
315 if (s->
freq[k] > 0.5 * rate)
320 flen = 8.0 * s->
fft_len / (tlength * rate);
322 start =
FFMAX(0, ceil(center - 0.5 * flen));
331 for (x = start; x <=
end; x++) {
332 int sign = (x & 1) ? (-1) : 1;
333 double y = 2.0 *
M_PI * (x - center) * (1.0 / flen);
335 double w = 0.355768 + 0.487396 * cos(y) + 0.144232 * cos(2*y) + 0.012604 * cos(3*y);
336 w *= sign * (1.0 / s->
fft_len);
351 for (k = 0; k < s->
cqt_len; k++)
406 int tmp_w, tmp_h, ret;
408 if ((ret =
ff_load_image(tmp_data, tmp_linesize, &tmp_w, &tmp_h, &tmp_format,
418 tmp_format, s->
ctx)) < 0)
433 static double midi(
void *p,
double f)
435 return log2(f/440.0) * 12.0 + 69.0;
440 x = av_clipd(x, 0.0, 1.0);
441 return lrint(x*255.0) << 16;
446 x = av_clipd(x, 0.0, 1.0);
447 return lrint(x*255.0) << 8;
452 x = av_clipd(x, 0.0, 1.0);
453 return lrint(x*255.0);
458 const char *
var_names[] = {
"timeclamp",
"tc",
"frequency",
"freq",
"f",
NULL };
459 const char *func_names[] = {
"midi",
"r",
"g",
"b",
NULL };
464 int width = half ? 1920/2 : 1920,
height = half ? 16 : 32;
465 int step = half ? 2 : 1;
469 " please use axisfile option instead.\n");
484 for (x = 0, xs = 0; x <
width; x++, xs += step) {
487 uint8_t r = (color >> 16) & 0xFF,
g = (color >> 8) & 0xFF,
b = color & 0xFF;
490 for (y = 0; y <
height; y++) {
491 data[linesize * y + 4 * x] =
r;
492 data[linesize * y + 4 * x + 1] =
g;
493 data[linesize * y + 4 * x + 2] =
b;
505 #if CONFIG_LIBFREETYPE
506 const char *str =
"EF G A BC D ";
509 FT_Library lib =
NULL;
511 int font_width = 16, font_height = 32;
512 int font_repeat = font_width * 12;
513 int linear_hori_advance = font_width * 65536;
514 int non_monospace_warning = 0;
520 if (FT_Init_FreeType(&lib))
523 if (FT_New_Face(lib, fontfile, 0, &face))
526 if (FT_Set_Char_Size(face, 16*64, 0, 0, 0))
529 if (FT_Load_Char(face,
'A', FT_LOAD_RENDER))
532 if (FT_Set_Char_Size(face, 16*64 * linear_hori_advance / face->glyph->linearHoriAdvance, 0, 0, 0))
535 for (x = 0; x < 12; x++) {
536 int sx, sy, rx, bx, by, dx, dy;
541 if (FT_Load_Char(face, str[x], FT_LOAD_RENDER))
544 if (face->glyph->advance.x != font_width*64 && !non_monospace_warning) {
546 non_monospace_warning = 1;
549 sy = font_height - 8 - face->glyph->bitmap_top;
550 for (rx = 0; rx < 10; rx++) {
551 sx = rx * font_repeat + x * font_width + face->glyph->bitmap_left;
552 for (by = 0; by < face->glyph->bitmap.rows; by++) {
556 if (dy >= font_height)
559 for (bx = 0; bx < face->glyph->bitmap.width; bx++) {
565 data[dy*linesize+4*dx+3] = face->glyph->bitmap.buffer[by*face->glyph->bitmap.width+bx];
572 FT_Done_FreeType(lib);
578 FT_Done_FreeType(lib);
589 #if CONFIG_LIBFONTCONFIG
590 FcConfig *fontconfig;
591 FcPattern *pat, *best;
592 FcResult result = FcResultMatch;
599 for (i = 0; font[i]; i++) {
604 if (!(fontconfig = FcInitLoadConfigAndFonts())) {
609 if (!(pat = FcNameParse((
uint8_t *)font))) {
611 FcConfigDestroy(fontconfig);
615 FcDefaultSubstitute(pat);
617 if (!FcConfigSubstitute(fontconfig, pat, FcMatchPattern)) {
619 FcPatternDestroy(pat);
620 FcConfigDestroy(fontconfig);
624 best = FcFontMatch(fontconfig, pat, &result);
625 FcPatternDestroy(pat);
628 if (!best || result != FcResultMatch) {
633 if (FcPatternGetString(best, FC_FILE, 0, (FcChar8 **)&filename) != FcResultMatch) {
641 FcPatternDestroy(best);
642 FcConfigDestroy(fontconfig);
653 const char *str =
"EF G A BC D ";
659 for (x = 0; x <
width; x += width/10) {
660 uint8_t *startptr = data + 4 * x;
661 for (u = 0; u < 12; u++) {
662 for (v = 0; v <
height; v++) {
663 uint8_t *p = startptr + v * linesize + height/2 * 4 *
u;
664 for (mask = 0x80;
mask; mask >>= 1, p += 4) {
682 int default_font = 0;
727 return sqrtf(sqrtf(v));
728 return expf(logf(v) / g);
734 for (x = 0; x <
len; x++) {
744 for (x = 0; x <
len; x++) {
749 c[x].
yuv.
y = cm[0][0] * r + cm[0][1] * g + cm[0][2] *
b;
750 c[x].
yuv.
u = cm[1][0] * r + cm[1][1] * g + cm[1][2] *
b;
751 c[x].
yuv.
v = cm[2][0] * r + cm[2][1] * g + cm[2][2] *
b;
758 int x, y, w = out->
width;
759 float mul, ht, rcp_bar_h = 1.0f / bar_h, rcp_bar_t = 1.0f / bar_t;
763 for (y = 0; y < bar_h; y++) {
764 ht = (bar_h - y) * rcp_bar_h;
766 for (x = 0; x < w; x++) {
772 mul = (h[x] - ht) * rcp_h[x];
773 mul = (mul < bar_t) ? (mul * rcp_bar_t) : 1.0f;
774 *lp++ =
lrintf(mul * c[x].rgb.r);
775 *lp++ =
lrintf(mul * c[x].rgb.g);
776 *lp++ =
lrintf(mul * c[x].rgb.b);
782 #define DRAW_BAR_WITH_CHROMA(x) \
789 mul = (h[x] - ht) * rcp_h[x]; \
790 mul = (mul < bar_t) ? (mul * rcp_bar_t) : 1.0f; \
791 *lpy++ = lrintf(mul * c[x].yuv.y + 16.0f); \
792 *lpu++ = lrintf(mul * c[x].yuv.u + 128.0f); \
793 *lpv++ = lrintf(mul * c[x].yuv.v + 128.0f); \
797 #define DRAW_BAR_WITHOUT_CHROMA(x) \
802 mul = (h[x] - ht) * rcp_h[x]; \
803 mul = (mul < bar_t) ? (mul * rcp_bar_t) : 1.0f; \
804 *lpy++ = lrintf(mul * c[x].yuv.y + 16.0f); \
811 int x, y, yh, w = out->
width;
812 float mul, ht, rcp_bar_h = 1.0f / bar_h, rcp_bar_t = 1.0f / bar_t;
818 for (y = 0; y < bar_h; y += 2) {
820 ht = (bar_h - y) * rcp_bar_h;
825 for (x = 0; x < w; x += 2) {
830 for (x = 0; x < w; x += 2) {
836 ht = (bar_h - (y+1)) * rcp_bar_h;
837 lpy = vy + (y+1) * lsy;
838 lpu = vu + (y+1) * lsu;
839 lpv = vv + (y+1) * lsv;
841 for (x = 0; x < w; x += 2) {
846 for (x = 0; x < w; x += 2) {
851 for (x = 0; x < w; x += 2) {
862 float a, rcp_255 = 1.0f / 255.0f;
865 for (y = 0; y <
h; y++) {
868 for (x = 0; x < w; x++) {
870 *lp++ =
lrintf(c[x].rgb.r);
871 *lp++ =
lrintf(c[x].rgb.g);
872 *lp++ =
lrintf(c[x].rgb.b);
873 }
else if (lpa[3] == 255) {
878 a = rcp_255 * lpa[3];
879 *lp++ =
lrintf(a * lpa[0] + (1.0f - a) * c[x].rgb.r);
880 *lp++ =
lrintf(a * lpa[1] + (1.0f - a) * c[x].rgb.g);
881 *lp++ =
lrintf(a * lpa[2] + (1.0f - a) * c[x].rgb.b);
888 #define BLEND_WITH_CHROMA(c) \
891 *lpy = lrintf(c.yuv.y + 16.0f); \
892 *lpu = lrintf(c.yuv.u + 128.0f); \
893 *lpv = lrintf(c.yuv.v + 128.0f); \
894 } else if (255 == *lpaa) { \
899 float a = (1.0f/255.0f) * (*lpaa); \
900 *lpy = lrintf(a * (*lpay) + (1.0f - a) * (c.yuv.y + 16.0f)); \
901 *lpu = lrintf(a * (*lpau) + (1.0f - a) * (c.yuv.u + 128.0f)); \
902 *lpv = lrintf(a * (*lpav) + (1.0f - a) * (c.yuv.v + 128.0f)); \
904 lpy++; lpu++; lpv++; \
905 lpay++; lpau++; lpav++; lpaa++; \
908 #define BLEND_WITHOUT_CHROMA(c, alpha_inc) \
911 *lpy = lrintf(c.yuv.y + 16.0f); \
912 } else if (255 == *lpaa) { \
915 float a = (1.0f/255.0f) * (*lpaa); \
916 *lpy = lrintf(a * (*lpay) + (1.0f - a) * (c.yuv.y + 16.0f)); \
919 lpay++; lpaa += alpha_inc; \
922 #define BLEND_CHROMA2(c) \
924 if (!lpaa[0] && !lpaa[1]) { \
925 *lpu = lrintf(c.yuv.u + 128.0f); \
926 *lpv = lrintf(c.yuv.v + 128.0f); \
927 } else if (255 == lpaa[0] && 255 == lpaa[1]) { \
928 *lpu = *lpau; *lpv = *lpav; \
930 float a0 = (0.5f/255.0f) * lpaa[0]; \
931 float a1 = (0.5f/255.0f) * lpaa[1]; \
932 float b = 1.0f - a0 - a1; \
933 *lpu = lrintf(a0 * lpau[0] + a1 * lpau[1] + b * (c.yuv.u + 128.0f)); \
934 *lpv = lrintf(a0 * lpav[0] + a1 * lpav[1] + b * (c.yuv.v + 128.0f)); \
936 lpau += 2; lpav += 2; lpaa++; lpu++; lpv++; \
939 #define BLEND_CHROMA2x2(c) \
941 if (!lpaa[0] && !lpaa[1] && !lpaa[lsaa] && !lpaa[lsaa+1]) { \
942 *lpu = lrintf(c.yuv.u + 128.0f); \
943 *lpv = lrintf(c.yuv.v + 128.0f); \
944 } else if (255 == lpaa[0] && 255 == lpaa[1] && \
945 255 == lpaa[lsaa] && 255 == lpaa[lsaa+1]) { \
946 *lpu = *lpau; *lpv = *lpav; \
948 float a0 = (0.25f/255.0f) * lpaa[0]; \
949 float a1 = (0.25f/255.0f) * lpaa[1]; \
950 float a2 = (0.25f/255.0f) * lpaa[lsaa]; \
951 float a3 = (0.25f/255.0f) * lpaa[lsaa+1]; \
952 float b = 1.0f - a0 - a1 - a2 - a3; \
953 *lpu = lrintf(a0 * lpau[0] + a1 * lpau[1] + a2 * lpau[lsau] + a3 * lpau[lsau+1] \
954 + b * (c.yuv.u + 128.0f)); \
955 *lpv = lrintf(a0 * lpav[0] + a1 * lpav[1] + a2 * lpav[lsav] + a3 * lpav[lsav+1] \
956 + b * (c.yuv.v + 128.0f)); \
958 lpau += 2; lpav += 2; lpaa++; lpu++; lpv++; \
969 uint8_t *lpy, *lpu, *lpv, *lpay, *lpau, *lpav, *lpaa;
971 for (y = 0; y <
h; y += 2) {
973 lpy = vy + (off + y) * lsy;
974 lpu = vu + (offh + yh) * lsu;
975 lpv = vv + (offh + yh) * lsv;
976 lpay = vay + y * lsay;
977 lpau = vau + y * lsau;
978 lpav = vav + y * lsav;
979 lpaa = vaa + y * lsaa;
981 for (x = 0; x < w; x += 2) {
986 for (x = 0; x < w; x += 2) {
992 for (x = 0; x < w; x += 2) {
999 lpy = vy + (off + y + 1) * lsy;
1000 lpu = vu + (off + y + 1) * lsu;
1001 lpv = vv + (off + y + 1) * lsv;
1002 lpay = vay + (y + 1) * lsay;
1003 lpau = vau + (y + 1) * lsau;
1004 lpav = vav + (y + 1) * lsav;
1005 lpaa = vaa + (y + 1) * lsaa;
1007 for (x = 0; x < w; x += 2) {
1012 for (x = 0; x < w; x += 2) {
1018 for (x = 0; x < w; x += 2) {
1035 for (y = 0; y <
h; y++) {
1037 sono->
data[0] + (idx + y) % h * sono->
linesize[0], ls);
1040 for (i = 1; i < nb_planes; i++) {
1042 for (y = 0; y <
h; y += inc) {
1045 sono->
data[i] + (idx + y) % h * sono->
linesize[i], ls);
1052 int x, w = sono->
width;
1055 for (x = 0; x < w; x++) {
1056 *lp++ =
lrintf(c[x].rgb.r);
1057 *lp++ =
lrintf(c[x].rgb.g);
1058 *lp++ =
lrintf(c[x].rgb.b);
1069 for (x = 0; x < w; x += 2) {
1070 *lpy++ =
lrintf(c[x].yuv.y + 16.0f);
1071 *lpu++ =
lrintf(c[x].yuv.u + 128.0f);
1072 *lpv++ =
lrintf(c[x].yuv.v + 128.0f);
1073 *lpy++ =
lrintf(c[x+1].yuv.y + 16.0f);
1075 *lpu++ =
lrintf(c[x+1].yuv.u + 128.0f);
1076 *lpv++ =
lrintf(c[x+1].yuv.v + 128.0f);
1085 for (x = 0; x < s->
cqt_len; x++) {
1089 float rcp_fcount = 1.0f / s->
fcount;
1090 for (x = 0; x < s->
width; x++) {
1092 for (i = 0; i < s->
fcount; i++)
1094 s->
h_buf[x] = rcp_fcount * h;
1097 for (x = 0; x < s->
width; x++) {
1103 for (x = 0; x < s->
cqt_len; x++) {
1109 float rcp_fcount = 1.0f / s->
fcount;
1110 for (x = 0; x < s->
width; x++) {
1112 for (i = 0; i < s->
fcount; i++) {
1133 #define UPDATE_TIME(t) \
1134 cur_time = av_gettime(); \
1135 t += cur_time - last_time; \
1136 last_time = cur_time
1201 kr = 0.299; kb = 0.114;
break;
1203 kr = 0.2126; kb = 0.0722;
break;
1205 kr = 0.30; kb = 0.11;
break;
1207 kr = 0.212; kb = 0.087;
break;
1209 kr = 0.2627; kb = 0.0593;
break;
1213 s->
cmatrix[0][0] = 219.0 * kr;
1214 s->
cmatrix[0][1] = 219.0 * kg;
1215 s->
cmatrix[0][2] = 219.0 * kb;
1216 s->
cmatrix[1][0] = -112.0 * kr / (1.0 - kb);
1217 s->
cmatrix[1][1] = -112.0 * kg / (1.0 - kb);
1220 s->
cmatrix[2][1] = -112.0 * kg / (1.0 - kr);
1221 s->
cmatrix[2][2] = -112.0 * kb / (1.0 - kr);
1229 if (sscanf(s->
cscheme,
" %f | %f | %f | %f | %f | %f %1s", &s->
cscheme_v[0],
1234 for (k = 0; k < 6; k++)
1358 av_log(ctx,
AV_LOG_INFO,
"video: %dx%d %s %d/%d fps, bar_h = %d, axis_h = %d, sono_h = %d.\n",
1461 int remaining, step, ret, x, i, j, m;
1474 for (x = 0; x < (s->
fft_len-step); x++)
1485 audio_data = (
float*) insamples->
data[0];
1506 av_log(ctx,
AV_LOG_DEBUG,
"changing pts from %"PRId64
" (%.3f) to %"PRId64
" (%.3f).\n",
1521 for (m = 0; m < s->
fft_len-step; m++)
1525 for (m = 0; m < remaining; m++) {
1569 .description =
NULL_IF_CONFIG_SMALL(
"Convert input audio to a CQT (Constant/Clamped Q Transform) spectrum video output."),
1574 .
inputs = showcqt_inputs,
1576 .priv_class = &showcqt_class,
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
const char const char void * val
static int render_fontconfig(ShowCQTContext *s, AVFrame *tmp, char *font)
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
This structure describes decoded (raw) audio or video data.
void(* update_sono)(AVFrame *sono, const ColorFloat *c, int idx)
ptrdiff_t const GLvoid * data
av_cold void av_fft_end(FFTContext *s)
static const AVOption showcqt_options[]
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
packed RGB 8:8:8, 24bpp, RGBRGB...
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
static int init_cqt(ShowCQTContext *s)
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
int h
agreed upon image height
static av_cold int init(AVFilterContext *ctx)
Miscellaneous utilities which make use of the libswscale library.
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
#define BLEND_CHROMA2x2(c)
static av_cold void uninit(AVFilterContext *ctx)
const uint8_t avpriv_vga16_font[4096]
void av_fft_permute(FFTContext *s, FFTComplex *z)
Do the permutation needed BEFORE calling ff_fft_calc().
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
static int render_default_font(AVFrame *tmp)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define AV_CH_LAYOUT_STEREO
functionally identical to above
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
#define DRAW_BAR_WITHOUT_CHROMA(x)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static int init_axis_empty(ShowCQTContext *s)
static void rgb_from_cqt(ColorFloat *c, const FFTComplex *v, float g, int len, float cscheme[6])
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 double a_weighting(void *p, double f)
static void yuv_from_cqt(ColorFloat *c, const FFTComplex *v, float gamma, int len, float cm[3][3], float cscheme[6])
int ff_scale_image(uint8_t *dst_data[4], int dst_linesize[4], int dst_w, int dst_h, enum AVPixelFormat dst_pix_fmt, uint8_t *const src_data[4], int src_linesize[4], int src_w, int src_h, enum AVPixelFormat src_pix_fmt, void *log_ctx)
Scale image using libswscale.
static void draw_bar_yuv(AVFrame *out, const float *h, const float *rcp_h, const ColorFloat *c, int bar_h, float bar_t)
static void draw_axis_rgb(AVFrame *out, AVFrame *axis, const ColorFloat *c, int off)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
static enum AVPixelFormat convert_axis_pixel_format(enum AVPixelFormat format)
#define AVERROR_EOF
End of file.
static const char *const var_names[]
static int render_freetype(ShowCQTContext *s, AVFrame *tmp, char *fontfile)
static double b_func(void *p, double x)
static void update_sono_rgb(AVFrame *sono, const ColorFloat *c, int idx)
void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val)
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.
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 or variable; if left to 0/0, will be automatically copied from the first input of the source filter if it exists.
int sample_rate
samples per second
static void draw_bar_rgb(AVFrame *out, const float *h, const float *rcp_h, const ColorFloat *c, int bar_h, float bar_t)
static const uint16_t mask[17]
#define BLEND_WITH_CHROMA(c)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
void av_frame_set_colorspace(AVFrame *frame, enum AVColorSpace val)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int init_axis_from_file(ShowCQTContext *s)
static double b_weighting(void *p, double f)
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
FFTContext * av_fft_init(int nbits, int inverse)
Set up a complex FFT.
static void cqt_calc(FFTComplex *dst, const FFTComplex *src, const Coeffs *coeffs, int len, int fft_len)
AVFilterFormats * in_formats
Lists of formats and channel layouts supported by the input and output filters respectively.
static const AVFilterPad showcqt_outputs[]
void(* cqt_calc)(FFTComplex *dst, const FFTComplex *src, const Coeffs *coeffs, int len, int fft_len)
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static const AVFilterPad showcqt_inputs[]
int w
agreed upon image width
static void init_colormatrix(ShowCQTContext *s)
static void update_sono_yuv(AVFrame *sono, const ColorFloat *c, int idx)
#define AV_CH_LAYOUT_STEREO_DOWNMIX
ITU-R BT2020 non-constant luminance system.
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
int ff_load_image(uint8_t *data[4], int linesize[4], int *w, int *h, enum AVPixelFormat *pix_fmt, const char *filename, void *log_ctx)
Load image from filename and put the resulting image in data.
static int init_axis_from_font(ShowCQTContext *s)
AVFilterContext * src
source filter
static double r_func(void *p, double x)
static const AVFilterPad outputs[]
AVFilterFormats * out_samplerates
static void error(const char *err)
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
static int init_axis_color(ShowCQTContext *s, AVFrame *tmp, int half)
int format
agreed upon media format
static double g_func(void *p, double x)
#define BLEND_WITHOUT_CHROMA(c, alpha_inc)
A list of supported channel layouts.
int64_t av_gettime(void)
Get the current time in microseconds.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
static const uint8_t vars[2][12]
static void draw_sono(AVFrame *out, AVFrame *sono, int off, int idx)
#define AV_LOG_INFO
Standard information.
static const AVFilterPad inputs[]
AVSampleFormat
Audio sample formats.
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static AVFrame * alloc_frame_empty(enum AVPixelFormat format, int w, int h)
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
static AVRational av_make_q(int num, int den)
Create an AVRational.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
AVFILTER_DEFINE_CLASS(showcqt)
static av_always_inline float cbrtf(float x)
static double * create_freq_table(double base, double end, int n)
static const char * format
static const uint16_t channel_layouts[7]
static double clip_with_log(void *log_ctx, const char *name, double val, double min, double max, double nan_replace, int idx)
static double midi(void *p, double f)
void ff_showcqt_init_x86(ShowCQTContext *s)
offset must point to AVRational
const char * name
Filter name.
static int init_cscheme(ShowCQTContext *s)
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
static void common_uninit(ShowCQTContext *s)
#define DRAW_BAR_WITH_CHROMA(x)
offset must point to two consecutive integers
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
static enum AVPixelFormat pix_fmts[]
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
static int config_output(AVFilterLink *outlink)
static int64_t pts
Global timestamp for the audio frames.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int request_frame(AVFilterLink *outlink)
the normal 219*2^(n-8) "MPEG" YUV ranges
static int plot_cqt(AVFilterContext *ctx, AVFrame **frameout)
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
enum AVPixelFormat format
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
static int query_formats(AVFilterContext *ctx)
static const int16_t coeffs[]
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
AVFilterContext * dst
dest filter
void(* permute_coeffs)(float *v, int len)
static int init_volume(ShowCQTContext *s)
static double c_weighting(void *p, double f)
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
static enum AVSampleFormat sample_fmts[]
static void draw_axis_yuv(AVFrame *out, AVFrame *axis, const ColorFloat *c, int off)
static float calculate_gamma(float v, float g)
static void process_cqt(ShowCQTContext *s)
void(* draw_sono)(AVFrame *out, AVFrame *sono, int off, int idx)
void(* draw_bar)(AVFrame *out, const float *h, const float *rcp_h, const ColorFloat *c, int bar_h, float bar_t)
#define av_malloc_array(a, b)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
void av_fft_calc(FFTContext *s, FFTComplex *z)
Do a complex FFT with the parameters defined in av_fft_init().
AVPixelFormat
Pixel format.
int nb_samples
number of audio samples (per channel) described by this frame
CGA/EGA/VGA ROM font data.
AVFilterFormats * out_formats
void(* draw_axis)(AVFrame *out, AVFrame *axis, const ColorFloat *c, int off)
Miscellaneous utilities which make use of the libavformat library.
simple arithmetic expression evaluator