avf_showcqt.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 {
  26. FFTSample *val;
  27. int start, len;
  28. } Coeffs;
  29. typedef struct {
  30. float r, g, b;
  31. } RGBFloat;
  32. typedef struct {
  33. float y, u, v;
  34. } YUVFloat;
  35. typedef union {
  36. RGBFloat rgb;
  37. YUVFloat yuv;
  38. } ColorFloat;
  39. typedef struct {
  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. int64_t next_pts;
  52. double *freq;
  53. FFTContext *fft_ctx;
  54. Coeffs *coeffs;
  55. FFTComplex *fft_data;
  56. FFTComplex *fft_result;
  57. FFTComplex *cqt_result;
  58. int fft_bits;
  59. int fft_len;
  60. int cqt_len;
  61. int cqt_align;
  62. ColorFloat *c_buf;
  63. float *h_buf;
  64. float *rcp_h_buf;
  65. float *sono_v_buf;
  66. float *bar_v_buf;
  67. /* callback */
  68. void (*cqt_calc)(FFTComplex *dst, const FFTComplex *src, const Coeffs *coeffs,
  69. int len, int fft_len);
  70. void (*permute_coeffs)(float *v, int len);
  71. void (*draw_bar)(AVFrame *out, const float *h, const float *rcp_h,
  72. const ColorFloat *c, int bar_h);
  73. void (*draw_axis)(AVFrame *out, AVFrame *axis, const ColorFloat *c, int off);
  74. void (*draw_sono)(AVFrame *out, AVFrame *sono, int off, int idx);
  75. void (*update_sono)(AVFrame *sono, const ColorFloat *c, int idx);
  76. /* performance debugging */
  77. int64_t fft_time;
  78. int64_t cqt_time;
  79. int64_t process_cqt_time;
  80. int64_t update_sono_time;
  81. int64_t alloc_time;
  82. int64_t bar_time;
  83. int64_t axis_time;
  84. int64_t sono_time;
  85. /* option */
  86. int width, height;
  87. AVRational rate;
  88. int bar_h;
  89. int axis_h;
  90. int sono_h;
  91. int fullhd; /* deprecated */
  92. char *sono_v;
  93. char *bar_v;
  94. float sono_g;
  95. float bar_g;
  96. double timeclamp;
  97. double basefreq;
  98. double endfreq;
  99. float coeffclamp; /* deprecated - ignored */
  100. char *tlength;
  101. int count;
  102. int fcount;
  103. char *fontfile;
  104. char *fontcolor;
  105. char *axisfile;
  106. int axis;
  107. } ShowCQTContext;
  108. void ff_showcqt_init_x86(ShowCQTContext *s);
  109. #endif