avf_showcqt.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright (c) 2015 Muhammad Faiz <mfcc64@gmail.com>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVFILTER_SHOWCQT_H
  21. #define AVFILTER_SHOWCQT_H
  22. #include "libavcodec/avfft.h"
  23. #include "avfilter.h"
  24. #include "internal.h"
  25. typedef struct Coeffs {
  26. FFTSample *val;
  27. int start, len;
  28. } Coeffs;
  29. typedef struct RGBFloat {
  30. float r, g, b;
  31. } RGBFloat;
  32. typedef struct YUVFloat {
  33. float y, u, v;
  34. } YUVFloat;
  35. typedef union {
  36. RGBFloat rgb;
  37. YUVFloat yuv;
  38. } ColorFloat;
  39. typedef struct ShowCQTContext {
  40. const AVClass *class;
  41. AVFilterContext *ctx;
  42. AVFrame *axis_frame;
  43. AVFrame *sono_frame;
  44. enum AVPixelFormat format;
  45. int sono_idx;
  46. int sono_count;
  47. int step;
  48. AVRational step_frac;
  49. int remaining_frac;
  50. int remaining_fill;
  51. int remaining_fill_max;
  52. int64_t next_pts;
  53. double *freq;
  54. FFTContext *fft_ctx;
  55. Coeffs *coeffs;
  56. FFTComplex *fft_data;
  57. FFTComplex *fft_result;
  58. FFTComplex *cqt_result;
  59. float *attack_data;
  60. int fft_bits;
  61. int fft_len;
  62. int cqt_len;
  63. int cqt_align;
  64. ColorFloat *c_buf;
  65. float *h_buf;
  66. float *rcp_h_buf;
  67. float *sono_v_buf;
  68. float *bar_v_buf;
  69. float cmatrix[3][3];
  70. float cscheme_v[6];
  71. /* callback */
  72. void (*cqt_calc)(FFTComplex *dst, const FFTComplex *src, const Coeffs *coeffs,
  73. int len, int fft_len);
  74. void (*permute_coeffs)(float *v, int len);
  75. void (*draw_bar)(AVFrame *out, const float *h, const float *rcp_h,
  76. const ColorFloat *c, int bar_h, float bar_t);
  77. void (*draw_axis)(AVFrame *out, AVFrame *axis, const ColorFloat *c, int off);
  78. void (*draw_sono)(AVFrame *out, AVFrame *sono, int off, int idx);
  79. void (*update_sono)(AVFrame *sono, const ColorFloat *c, int idx);
  80. /* performance debugging */
  81. int64_t fft_time;
  82. int64_t cqt_time;
  83. int64_t process_cqt_time;
  84. int64_t update_sono_time;
  85. int64_t alloc_time;
  86. int64_t bar_time;
  87. int64_t axis_time;
  88. int64_t sono_time;
  89. /* option */
  90. int width, height;
  91. AVRational rate;
  92. int bar_h;
  93. int axis_h;
  94. int sono_h;
  95. int fullhd; /* deprecated */
  96. char *sono_v;
  97. char *bar_v;
  98. float sono_g;
  99. float bar_g;
  100. float bar_t;
  101. double timeclamp;
  102. double attack;
  103. double basefreq;
  104. double endfreq;
  105. float coeffclamp; /* deprecated - ignored */
  106. char *tlength;
  107. int count;
  108. int fcount;
  109. char *fontfile;
  110. char *font;
  111. char *fontcolor;
  112. char *axisfile;
  113. int axis;
  114. int csp;
  115. char *cscheme;
  116. } ShowCQTContext;
  117. void ff_showcqt_init_x86(ShowCQTContext *s);
  118. #endif