Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
0068b3d0
Commit
0068b3d0
authored
Jul 27, 2021
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/avf_showcqt: switch to TX FFT from avutil
parent
925d41eb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
27 deletions
+29
-27
configure
configure
+2
-3
avf_showcqt.c
libavfilter/avf_showcqt.c
+17
-16
avf_showcqt.h
libavfilter/avf_showcqt.h
+9
-7
avf_showcqt_init.c
libavfilter/x86/avf_showcqt_init.c
+1
-1
No files found.
configure
View file @
0068b3d0
...
...
@@ -3652,9 +3652,8 @@ scale_qsv_filter_deps="libmfx"
scdet_filter_select
=
"scene_sad"
select_filter_select
=
"scene_sad"
sharpness_vaapi_filter_deps
=
"vaapi"
showcqt_filter_deps
=
"av
codec av
format swscale"
showcqt_filter_deps
=
"avformat swscale"
showcqt_filter_suggest
=
"libfontconfig libfreetype"
showcqt_filter_select
=
"fft"
showfreqs_filter_deps
=
"avcodec"
showfreqs_filter_select
=
"fft"
showspatial_filter_deps
=
"avcodec"
...
...
@@ -7281,7 +7280,7 @@ enabled removelogo_filter && prepend avfilter_deps "avformat avcodec swscale"
enabled sab_filter
&&
prepend avfilter_deps
"swscale"
enabled scale_filter
&&
prepend avfilter_deps
"swscale"
enabled scale2ref_filter
&&
prepend avfilter_deps
"swscale"
enabled showcqt_filter
&&
prepend avfilter_deps
"avformat
avcodec
swscale"
enabled showcqt_filter
&&
prepend avfilter_deps
"avformat swscale"
enabled showfreqs_filter
&&
prepend avfilter_deps
"avcodec"
enabled signature_filter
&&
prepend avfilter_deps
"avcodec avformat"
enabled smartblur_filter
&&
prepend avfilter_deps
"swscale"
...
...
libavfilter/avf_showcqt.c
View file @
0068b3d0
...
...
@@ -19,7 +19,7 @@
*/
#include "config.h"
#include "libav
codec/avfft
.h"
#include "libav
util/tx
.h"
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
#include "libavutil/xga_font_data.h"
...
...
@@ -144,13 +144,13 @@ static void common_uninit(ShowCQTContext *s)
av_frame_free
(
&
s
->
axis_frame
);
av_frame_free
(
&
s
->
sono_frame
);
av_fft_end
(
s
->
fft_ctx
);
s
->
fft_ctx
=
NULL
;
av_tx_uninit
(
&
s
->
fft_ctx
);
if
(
s
->
coeffs
)
for
(
k
=
0
;
k
<
s
->
cqt_len
;
k
++
)
av_freep
(
&
s
->
coeffs
[
k
].
val
);
av_freep
(
&
s
->
coeffs
);
av_freep
(
&
s
->
fft_data
);
av_freep
(
&
s
->
fft_input
);
av_freep
(
&
s
->
fft_result
);
av_freep
(
&
s
->
cqt_result
);
av_freep
(
&
s
->
attack_data
);
...
...
@@ -267,15 +267,15 @@ error:
return
ret
;
}
static
void
cqt_calc
(
FFTComplex
*
dst
,
const
FFTComplex
*
src
,
const
Coeffs
*
coeffs
,
static
void
cqt_calc
(
AVComplexFloat
*
dst
,
const
AVComplexFloat
*
src
,
const
Coeffs
*
coeffs
,
int
len
,
int
fft_len
)
{
int
k
,
x
,
i
,
j
;
for
(
k
=
0
;
k
<
len
;
k
++
)
{
FFTComplex
l
,
r
,
a
=
{
0
,
0
},
b
=
{
0
,
0
};
AVComplexFloat
l
,
r
,
a
=
{
0
,
0
},
b
=
{
0
,
0
};
for
(
x
=
0
;
x
<
coeffs
[
k
].
len
;
x
++
)
{
FFTSample
u
=
coeffs
[
k
].
val
[
x
];
float
u
=
coeffs
[
k
].
val
[
x
];
i
=
coeffs
[
k
].
start
+
x
;
j
=
fft_len
-
i
;
a
.
re
+=
u
*
src
[
i
].
re
;
...
...
@@ -730,7 +730,7 @@ static float calculate_gamma(float v, float g)
return
expf
(
logf
(
v
)
/
g
);
}
static
void
rgb_from_cqt
(
ColorFloat
*
c
,
const
FFTComplex
*
v
,
float
g
,
int
len
,
float
cscheme
[
6
])
static
void
rgb_from_cqt
(
ColorFloat
*
c
,
const
AVComplexFloat
*
v
,
float
g
,
int
len
,
float
cscheme
[
6
])
{
int
x
;
for
(
x
=
0
;
x
<
len
;
x
++
)
{
...
...
@@ -740,7 +740,7 @@ static void rgb_from_cqt(ColorFloat *c, const FFTComplex *v, float g, int len, f
}
}
static
void
yuv_from_cqt
(
ColorFloat
*
c
,
const
FFTComplex
*
v
,
float
gamma
,
int
len
,
float
cm
[
3
][
3
],
float
cscheme
[
6
])
static
void
yuv_from_cqt
(
ColorFloat
*
c
,
const
AVComplexFloat
*
v
,
float
gamma
,
int
len
,
float
cm
[
3
][
3
],
float
cscheme
[
6
])
{
int
x
;
for
(
x
=
0
;
x
<
len
;
x
++
)
{
...
...
@@ -1110,7 +1110,7 @@ static void process_cqt(ShowCQTContext *s)
if
(
s
->
fcount
>
1
)
{
float
rcp_fcount
=
1
.
0
f
/
s
->
fcount
;
for
(
x
=
0
;
x
<
s
->
width
;
x
++
)
{
FFTComplex
result
=
{
0
.
0
f
,
0
.
0
f
};
AVComplexFloat
result
=
{
0
.
0
f
,
0
.
0
f
};
for
(
i
=
0
;
i
<
s
->
fcount
;
i
++
)
{
result
.
re
+=
s
->
cqt_result
[
s
->
fcount
*
x
+
i
].
re
;
result
.
im
+=
s
->
cqt_result
[
s
->
fcount
*
x
+
i
].
im
;
...
...
@@ -1139,17 +1139,16 @@ static int plot_cqt(AVFilterContext *ctx, AVFrame **frameout)
last_time
=
av_gettime_relative
();
memcpy
(
s
->
fft_
resul
t
,
s
->
fft_data
,
s
->
fft_len
*
sizeof
(
*
s
->
fft_data
));
memcpy
(
s
->
fft_
inpu
t
,
s
->
fft_data
,
s
->
fft_len
*
sizeof
(
*
s
->
fft_data
));
if
(
s
->
attack_data
)
{
int
k
;
for
(
k
=
0
;
k
<
s
->
remaining_fill_max
;
k
++
)
{
s
->
fft_
resul
t
[
s
->
fft_len
/
2
+
k
].
re
*=
s
->
attack_data
[
k
];
s
->
fft_
resul
t
[
s
->
fft_len
/
2
+
k
].
im
*=
s
->
attack_data
[
k
];
s
->
fft_
inpu
t
[
s
->
fft_len
/
2
+
k
].
re
*=
s
->
attack_data
[
k
];
s
->
fft_
inpu
t
[
s
->
fft_len
/
2
+
k
].
im
*=
s
->
attack_data
[
k
];
}
}
av_fft_permute
(
s
->
fft_ctx
,
s
->
fft_result
);
av_fft_calc
(
s
->
fft_ctx
,
s
->
fft_result
);
s
->
tx_fn
(
s
->
fft_ctx
,
s
->
fft_result
,
s
->
fft_input
,
sizeof
(
float
));
s
->
fft_result
[
s
->
fft_len
]
=
s
->
fft_result
[
0
];
UPDATE_TIME
(
s
->
fft_time
);
...
...
@@ -1355,6 +1354,7 @@ static int config_output(AVFilterLink *outlink)
AVFilterContext
*
ctx
=
outlink
->
src
;
AVFilterLink
*
inlink
=
ctx
->
inputs
[
0
];
ShowCQTContext
*
s
=
ctx
->
priv
;
float
scale
;
int
ret
;
common_uninit
(
s
);
...
...
@@ -1380,9 +1380,10 @@ static int config_output(AVFilterLink *outlink)
s
->
fft_len
=
1
<<
s
->
fft_bits
;
av_log
(
ctx
,
AV_LOG_INFO
,
"fft_len = %d, cqt_len = %d.
\n
"
,
s
->
fft_len
,
s
->
cqt_len
);
s
->
fft_ctx
=
av_fft_init
(
s
->
fft_bits
,
0
);
ret
=
av_tx_init
(
&
s
->
fft_ctx
,
&
s
->
tx_fn
,
AV_TX_FLOAT_FFT
,
0
,
s
->
fft_len
,
&
scale
,
0
);
s
->
fft_data
=
av_calloc
(
s
->
fft_len
,
sizeof
(
*
s
->
fft_data
));
s
->
fft_result
=
av_calloc
(
s
->
fft_len
+
64
,
sizeof
(
*
s
->
fft_result
));
s
->
fft_input
=
av_calloc
(
FFALIGN
(
s
->
fft_len
+
64
,
256
),
sizeof
(
*
s
->
fft_input
));
s
->
fft_result
=
av_calloc
(
FFALIGN
(
s
->
fft_len
+
64
,
256
),
sizeof
(
*
s
->
fft_result
));
s
->
cqt_result
=
av_malloc_array
(
s
->
cqt_len
,
sizeof
(
*
s
->
cqt_result
));
if
(
!
s
->
fft_ctx
||
!
s
->
fft_data
||
!
s
->
fft_result
||
!
s
->
cqt_result
)
return
AVERROR
(
ENOMEM
);
...
...
libavfilter/avf_showcqt.h
View file @
0068b3d0
...
...
@@ -21,12 +21,12 @@
#ifndef AVFILTER_SHOWCQT_H
#define AVFILTER_SHOWCQT_H
#include "libav
codec/avfft
.h"
#include "libav
util/tx
.h"
#include "avfilter.h"
#include "internal.h"
typedef
struct
Coeffs
{
FFTSample
*
val
;
float
*
val
;
int
start
,
len
;
}
Coeffs
;
...
...
@@ -58,11 +58,13 @@ typedef struct ShowCQTContext {
int
remaining_fill_max
;
int64_t
next_pts
;
double
*
freq
;
FFTContext
*
fft_ctx
;
AVTXContext
*
fft_ctx
;
av_tx_fn
tx_fn
;
Coeffs
*
coeffs
;
FFTComplex
*
fft_data
;
FFTComplex
*
fft_result
;
FFTComplex
*
cqt_result
;
AVComplexFloat
*
fft_data
;
AVComplexFloat
*
fft_input
;
AVComplexFloat
*
fft_result
;
AVComplexFloat
*
cqt_result
;
float
*
attack_data
;
int
fft_bits
;
int
fft_len
;
...
...
@@ -76,7 +78,7 @@ typedef struct ShowCQTContext {
float
cmatrix
[
3
][
3
];
float
cscheme_v
[
6
];
/* callback */
void
(
*
cqt_calc
)(
FFTComplex
*
dst
,
const
FFTComplex
*
src
,
const
Coeffs
*
coeffs
,
void
(
*
cqt_calc
)(
AVComplexFloat
*
dst
,
const
AVComplexFloat
*
src
,
const
Coeffs
*
coeffs
,
int
len
,
int
fft_len
);
void
(
*
permute_coeffs
)(
float
*
v
,
int
len
);
void
(
*
draw_bar
)(
AVFrame
*
out
,
const
float
*
h
,
const
float
*
rcp_h
,
...
...
libavfilter/x86/avf_showcqt_init.c
View file @
0068b3d0
...
...
@@ -24,7 +24,7 @@
#include "libavfilter/avf_showcqt.h"
#define DECLARE_CQT_CALC(type) \
void ff_showcqt_cqt_calc_##type(
FFTComplex *dst, const FFTComplex
*src, \
void ff_showcqt_cqt_calc_##type(
AVComplexFloat *dst, const AVComplexFloat
*src, \
const Coeffs *coeffs, int len, int fft_len)
DECLARE_CQT_CALC
(
sse
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment