• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
21 #ifndef AVFILTER_SHOWCQT_H
22 #define AVFILTER_SHOWCQT_H
23 
24 #include "libavutil/tx.h"
25 #include "avfilter.h"
26 #include "internal.h"
27 
28 typedef struct Coeffs {
29     float *val;
30     int start, len;
31 } Coeffs;
32 
33 typedef struct RGBFloat {
34     float r, g, b;
35 } RGBFloat;
36 
37 typedef struct YUVFloat {
38     float y, u, v;
39 } YUVFloat;
40 
41 typedef union {
42     RGBFloat rgb;
43     YUVFloat yuv;
44 } ColorFloat;
45 
46 typedef struct ShowCQTContext {
47     const AVClass       *class;
48     AVFilterContext     *ctx;
49     AVFrame             *axis_frame;
50     AVFrame             *sono_frame;
51     enum AVPixelFormat  format;
52     int                 sono_idx;
53     int                 sono_count;
54     int                 step;
55     AVRational          step_frac;
56     int                 remaining_frac;
57     int                 remaining_fill;
58     int                 remaining_fill_max;
59     int64_t             next_pts;
60     double              *freq;
61     AVTXContext         *fft_ctx;
62     av_tx_fn            tx_fn;
63     Coeffs              *coeffs;
64     AVComplexFloat      *fft_data;
65     AVComplexFloat      *fft_input;
66     AVComplexFloat      *fft_result;
67     AVComplexFloat      *cqt_result;
68     float               *attack_data;
69     int                 fft_bits;
70     int                 fft_len;
71     int                 cqt_len;
72     int                 cqt_align;
73     ColorFloat          *c_buf;
74     float               *h_buf;
75     float               *rcp_h_buf;
76     float               *sono_v_buf;
77     float               *bar_v_buf;
78     float               cmatrix[3][3];
79     float               cscheme_v[6];
80     /* callback */
81     void                (*cqt_calc)(AVComplexFloat *dst, const AVComplexFloat *src, const Coeffs *coeffs,
82                                     int len, int fft_len);
83     void                (*permute_coeffs)(float *v, int len);
84     void                (*draw_bar)(AVFrame *out, const float *h, const float *rcp_h,
85                                     const ColorFloat *c, int bar_h, float bar_t);
86     void                (*draw_axis)(AVFrame *out, AVFrame *axis, const ColorFloat *c, int off);
87     void                (*draw_sono)(AVFrame *out, AVFrame *sono, int off, int idx);
88     void                (*update_sono)(AVFrame *sono, const ColorFloat *c, int idx);
89     /* performance debugging */
90     int64_t             fft_time;
91     int64_t             cqt_time;
92     int64_t             process_cqt_time;
93     int64_t             update_sono_time;
94     int64_t             alloc_time;
95     int64_t             bar_time;
96     int64_t             axis_time;
97     int64_t             sono_time;
98     /* option */
99     int                 width, height;
100     AVRational          rate;
101     int                 bar_h;
102     int                 axis_h;
103     int                 sono_h;
104     int                 fullhd; /* deprecated */
105     char                *sono_v;
106     char                *bar_v;
107     float               sono_g;
108     float               bar_g;
109     float               bar_t;
110     double              timeclamp;
111     double              attack;
112     double              basefreq;
113     double              endfreq;
114     float               coeffclamp; /* deprecated - ignored */
115     char                *tlength;
116     int                 count;
117     int                 fcount;
118     char                *fontfile;
119     char                *font;
120     char                *fontcolor;
121     char                *axisfile;
122     int                 axis;
123     int                 csp;
124     char                *cscheme;
125 } ShowCQTContext;
126 
127 void ff_showcqt_init_x86(ShowCQTContext *s);
128 
129 #endif
130