Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
3841e451
Commit
3841e451
authored
May 16, 2013
by
Clément Bœsch
Committed by
Paul B Mahol
Oct 02, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/avf_showspectrum: use the name 's' for the pointer to the private context
parent
848a1e67
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
93 deletions
+93
-93
avf_showspectrum.c
libavfilter/avf_showspectrum.c
+93
-93
No files found.
libavfilter/avf_showspectrum.c
View file @
3841e451
...
@@ -99,16 +99,16 @@ static const struct {
...
@@ -99,16 +99,16 @@ static const struct {
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
{
{
ShowSpectrumContext
*
s
howspectrum
=
ctx
->
priv
;
ShowSpectrumContext
*
s
=
ctx
->
priv
;
int
i
;
int
i
;
av_freep
(
&
s
howspectrum
->
combine_buffer
);
av_freep
(
&
s
->
combine_buffer
);
av_rdft_end
(
s
howspectrum
->
rdft
);
av_rdft_end
(
s
->
rdft
);
for
(
i
=
0
;
i
<
s
howspectrum
->
nb_display_channels
;
i
++
)
for
(
i
=
0
;
i
<
s
->
nb_display_channels
;
i
++
)
av_freep
(
&
s
howspectrum
->
rdft_data
[
i
]);
av_freep
(
&
s
->
rdft_data
[
i
]);
av_freep
(
&
s
howspectrum
->
rdft_data
);
av_freep
(
&
s
->
rdft_data
);
av_freep
(
&
s
howspectrum
->
window_func_lut
);
av_freep
(
&
s
->
window_func_lut
);
av_frame_free
(
&
s
howspectrum
->
outpicref
);
av_frame_free
(
&
s
->
outpicref
);
}
}
static
int
query_formats
(
AVFilterContext
*
ctx
)
static
int
query_formats
(
AVFilterContext
*
ctx
)
...
@@ -149,64 +149,64 @@ static int config_output(AVFilterLink *outlink)
...
@@ -149,64 +149,64 @@ static int config_output(AVFilterLink *outlink)
{
{
AVFilterContext
*
ctx
=
outlink
->
src
;
AVFilterContext
*
ctx
=
outlink
->
src
;
AVFilterLink
*
inlink
=
ctx
->
inputs
[
0
];
AVFilterLink
*
inlink
=
ctx
->
inputs
[
0
];
ShowSpectrumContext
*
s
howspectrum
=
ctx
->
priv
;
ShowSpectrumContext
*
s
=
ctx
->
priv
;
int
i
,
rdft_bits
,
win_size
,
h
;
int
i
,
rdft_bits
,
win_size
,
h
;
outlink
->
w
=
s
howspectrum
->
w
;
outlink
->
w
=
s
->
w
;
outlink
->
h
=
s
howspectrum
->
h
;
outlink
->
h
=
s
->
h
;
h
=
(
s
howspectrum
->
mode
==
COMBINED
)
?
outlink
->
h
:
outlink
->
h
/
inlink
->
channels
;
h
=
(
s
->
mode
==
COMBINED
)
?
outlink
->
h
:
outlink
->
h
/
inlink
->
channels
;
s
howspectrum
->
channel_height
=
h
;
s
->
channel_height
=
h
;
/* RDFT window size (precision) according to the requested output frame height */
/* RDFT window size (precision) according to the requested output frame height */
for
(
rdft_bits
=
1
;
1
<<
rdft_bits
<
2
*
h
;
rdft_bits
++
);
for
(
rdft_bits
=
1
;
1
<<
rdft_bits
<
2
*
h
;
rdft_bits
++
);
win_size
=
1
<<
rdft_bits
;
win_size
=
1
<<
rdft_bits
;
/* (re-)configuration if the video output changed (or first init) */
/* (re-)configuration if the video output changed (or first init) */
if
(
rdft_bits
!=
s
howspectrum
->
rdft_bits
)
{
if
(
rdft_bits
!=
s
->
rdft_bits
)
{
size_t
rdft_size
,
rdft_listsize
;
size_t
rdft_size
,
rdft_listsize
;
AVFrame
*
outpicref
;
AVFrame
*
outpicref
;
av_rdft_end
(
s
howspectrum
->
rdft
);
av_rdft_end
(
s
->
rdft
);
s
howspectrum
->
rdft
=
av_rdft_init
(
rdft_bits
,
DFT_R2C
);
s
->
rdft
=
av_rdft_init
(
rdft_bits
,
DFT_R2C
);
s
howspectrum
->
rdft_bits
=
rdft_bits
;
s
->
rdft_bits
=
rdft_bits
;
/* RDFT buffers: x2 for each (display) channel buffer.
/* RDFT buffers: x2 for each (display) channel buffer.
* Note: we use free and malloc instead of a realloc-like function to
* Note: we use free and malloc instead of a realloc-like function to
* make sure the buffer is aligned in memory for the FFT functions. */
* make sure the buffer is aligned in memory for the FFT functions. */
for
(
i
=
0
;
i
<
s
howspectrum
->
nb_display_channels
;
i
++
)
for
(
i
=
0
;
i
<
s
->
nb_display_channels
;
i
++
)
av_freep
(
&
s
howspectrum
->
rdft_data
[
i
]);
av_freep
(
&
s
->
rdft_data
[
i
]);
av_freep
(
&
s
howspectrum
->
rdft_data
);
av_freep
(
&
s
->
rdft_data
);
s
howspectrum
->
nb_display_channels
=
inlink
->
channels
;
s
->
nb_display_channels
=
inlink
->
channels
;
if
(
av_size_mult
(
sizeof
(
*
s
howspectrum
->
rdft_data
),
if
(
av_size_mult
(
sizeof
(
*
s
->
rdft_data
),
s
howspectrum
->
nb_display_channels
,
&
rdft_listsize
)
<
0
)
s
->
nb_display_channels
,
&
rdft_listsize
)
<
0
)
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
if
(
av_size_mult
(
sizeof
(
**
s
howspectrum
->
rdft_data
),
if
(
av_size_mult
(
sizeof
(
**
s
->
rdft_data
),
win_size
,
&
rdft_size
)
<
0
)
win_size
,
&
rdft_size
)
<
0
)
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
s
howspectrum
->
rdft_data
=
av_malloc
(
rdft_listsize
);
s
->
rdft_data
=
av_malloc
(
rdft_listsize
);
if
(
!
s
howspectrum
->
rdft_data
)
if
(
!
s
->
rdft_data
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
for
(
i
=
0
;
i
<
s
howspectrum
->
nb_display_channels
;
i
++
)
{
for
(
i
=
0
;
i
<
s
->
nb_display_channels
;
i
++
)
{
s
howspectrum
->
rdft_data
[
i
]
=
av_malloc
(
rdft_size
);
s
->
rdft_data
[
i
]
=
av_malloc
(
rdft_size
);
if
(
!
s
howspectrum
->
rdft_data
[
i
])
if
(
!
s
->
rdft_data
[
i
])
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
}
}
s
howspectrum
->
filled
=
0
;
s
->
filled
=
0
;
/* pre-calc windowing function (hann here) */
/* pre-calc windowing function (hann here) */
s
howspectrum
->
window_func_lut
=
s
->
window_func_lut
=
av_realloc_f
(
s
howspectrum
->
window_func_lut
,
win_size
,
av_realloc_f
(
s
->
window_func_lut
,
win_size
,
sizeof
(
*
s
howspectrum
->
window_func_lut
));
sizeof
(
*
s
->
window_func_lut
));
if
(
!
s
howspectrum
->
window_func_lut
)
if
(
!
s
->
window_func_lut
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
for
(
i
=
0
;
i
<
win_size
;
i
++
)
for
(
i
=
0
;
i
<
win_size
;
i
++
)
s
howspectrum
->
window_func_lut
[
i
]
=
.
5
f
*
(
1
-
cos
(
2
*
M_PI
*
i
/
(
win_size
-
1
)));
s
->
window_func_lut
[
i
]
=
.
5
f
*
(
1
-
cos
(
2
*
M_PI
*
i
/
(
win_size
-
1
)));
/* prepare the initial picref buffer (black frame) */
/* prepare the initial picref buffer (black frame) */
av_frame_free
(
&
s
howspectrum
->
outpicref
);
av_frame_free
(
&
s
->
outpicref
);
s
howspectrum
->
outpicref
=
outpicref
=
s
->
outpicref
=
outpicref
=
ff_get_video_buffer
(
outlink
,
outlink
->
w
,
outlink
->
h
);
ff_get_video_buffer
(
outlink
,
outlink
->
w
,
outlink
->
h
);
if
(
!
outpicref
)
if
(
!
outpicref
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
...
@@ -218,43 +218,43 @@ static int config_output(AVFilterLink *outlink)
...
@@ -218,43 +218,43 @@ static int config_output(AVFilterLink *outlink)
}
}
}
}
if
(
s
howspectrum
->
xpos
>=
outlink
->
w
)
if
(
s
->
xpos
>=
outlink
->
w
)
s
howspectrum
->
xpos
=
0
;
s
->
xpos
=
0
;
s
howspectrum
->
combine_buffer
=
s
->
combine_buffer
=
av_realloc_f
(
s
howspectrum
->
combine_buffer
,
outlink
->
h
*
3
,
av_realloc_f
(
s
->
combine_buffer
,
outlink
->
h
*
3
,
sizeof
(
*
s
howspectrum
->
combine_buffer
));
sizeof
(
*
s
->
combine_buffer
));
av_log
(
ctx
,
AV_LOG_VERBOSE
,
"s:%dx%d RDFT window size:%d
\n
"
,
av_log
(
ctx
,
AV_LOG_VERBOSE
,
"s:%dx%d RDFT window size:%d
\n
"
,
s
howspectrum
->
w
,
showspectrum
->
h
,
win_size
);
s
->
w
,
s
->
h
,
win_size
);
return
0
;
return
0
;
}
}
inline
static
int
push_frame
(
AVFilterLink
*
outlink
)
inline
static
int
push_frame
(
AVFilterLink
*
outlink
)
{
{
ShowSpectrumContext
*
s
howspectrum
=
outlink
->
src
->
priv
;
ShowSpectrumContext
*
s
=
outlink
->
src
->
priv
;
s
howspectrum
->
xpos
++
;
s
->
xpos
++
;
if
(
s
howspectrum
->
xpos
>=
outlink
->
w
)
if
(
s
->
xpos
>=
outlink
->
w
)
s
howspectrum
->
xpos
=
0
;
s
->
xpos
=
0
;
s
howspectrum
->
filled
=
0
;
s
->
filled
=
0
;
s
howspectrum
->
req_fullfilled
=
1
;
s
->
req_fullfilled
=
1
;
return
ff_filter_frame
(
outlink
,
av_frame_clone
(
s
howspectrum
->
outpicref
));
return
ff_filter_frame
(
outlink
,
av_frame_clone
(
s
->
outpicref
));
}
}
static
int
request_frame
(
AVFilterLink
*
outlink
)
static
int
request_frame
(
AVFilterLink
*
outlink
)
{
{
ShowSpectrumContext
*
s
howspectrum
=
outlink
->
src
->
priv
;
ShowSpectrumContext
*
s
=
outlink
->
src
->
priv
;
AVFilterLink
*
inlink
=
outlink
->
src
->
inputs
[
0
];
AVFilterLink
*
inlink
=
outlink
->
src
->
inputs
[
0
];
int
ret
;
int
ret
;
s
howspectrum
->
req_fullfilled
=
0
;
s
->
req_fullfilled
=
0
;
do
{
do
{
ret
=
ff_request_frame
(
inlink
);
ret
=
ff_request_frame
(
inlink
);
}
while
(
!
s
howspectrum
->
req_fullfilled
&&
ret
>=
0
);
}
while
(
!
s
->
req_fullfilled
&&
ret
>=
0
);
if
(
ret
==
AVERROR_EOF
&&
s
howspectrum
->
outpicref
)
if
(
ret
==
AVERROR_EOF
&&
s
->
outpicref
)
push_frame
(
outlink
);
push_frame
(
outlink
);
return
ret
;
return
ret
;
}
}
...
@@ -264,60 +264,60 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb
...
@@ -264,60 +264,60 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb
int
ret
;
int
ret
;
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
ShowSpectrumContext
*
s
howspectrum
=
ctx
->
priv
;
ShowSpectrumContext
*
s
=
ctx
->
priv
;
AVFrame
*
outpicref
=
s
howspectrum
->
outpicref
;
AVFrame
*
outpicref
=
s
->
outpicref
;
/* nb_freq contains the power of two superior or equal to the output image
/* nb_freq contains the power of two superior or equal to the output image
* height (or half the RDFT window size) */
* height (or half the RDFT window size) */
const
int
nb_freq
=
1
<<
(
s
howspectrum
->
rdft_bits
-
1
);
const
int
nb_freq
=
1
<<
(
s
->
rdft_bits
-
1
);
const
int
win_size
=
nb_freq
<<
1
;
const
int
win_size
=
nb_freq
<<
1
;
const
double
w
=
1
.
/
(
sqrt
(
nb_freq
)
*
32768
.);
const
double
w
=
1
.
/
(
sqrt
(
nb_freq
)
*
32768
.);
int
ch
,
plane
,
n
,
y
;
int
ch
,
plane
,
n
,
y
;
const
int
start
=
s
howspectrum
->
filled
;
const
int
start
=
s
->
filled
;
const
int
add_samples
=
FFMIN
(
win_size
-
start
,
nb_samples
);
const
int
add_samples
=
FFMIN
(
win_size
-
start
,
nb_samples
);
/* fill RDFT input with the number of samples available */
/* fill RDFT input with the number of samples available */
for
(
ch
=
0
;
ch
<
s
howspectrum
->
nb_display_channels
;
ch
++
)
{
for
(
ch
=
0
;
ch
<
s
->
nb_display_channels
;
ch
++
)
{
const
int16_t
*
p
=
(
int16_t
*
)
insamples
->
extended_data
[
ch
];
const
int16_t
*
p
=
(
int16_t
*
)
insamples
->
extended_data
[
ch
];
p
+=
s
howspectrum
->
consumed
;
p
+=
s
->
consumed
;
for
(
n
=
0
;
n
<
add_samples
;
n
++
)
for
(
n
=
0
;
n
<
add_samples
;
n
++
)
s
howspectrum
->
rdft_data
[
ch
][
start
+
n
]
=
p
[
n
]
*
showspectrum
->
window_func_lut
[
start
+
n
];
s
->
rdft_data
[
ch
][
start
+
n
]
=
p
[
n
]
*
s
->
window_func_lut
[
start
+
n
];
}
}
s
howspectrum
->
filled
+=
add_samples
;
s
->
filled
+=
add_samples
;
/* complete RDFT window size? */
/* complete RDFT window size? */
if
(
s
howspectrum
->
filled
==
win_size
)
{
if
(
s
->
filled
==
win_size
)
{
/* channel height */
/* channel height */
int
h
=
s
howspectrum
->
channel_height
;
int
h
=
s
->
channel_height
;
/* run RDFT on each samples set */
/* run RDFT on each samples set */
for
(
ch
=
0
;
ch
<
s
howspectrum
->
nb_display_channels
;
ch
++
)
for
(
ch
=
0
;
ch
<
s
->
nb_display_channels
;
ch
++
)
av_rdft_calc
(
s
howspectrum
->
rdft
,
showspectrum
->
rdft_data
[
ch
]);
av_rdft_calc
(
s
->
rdft
,
s
->
rdft_data
[
ch
]);
/* fill a new spectrum column */
/* fill a new spectrum column */
#define RE(y, ch) s
howspectrum
->rdft_data[ch][2 * y + 0]
#define RE(y, ch) s->rdft_data[ch][2 * y + 0]
#define IM(y, ch) s
howspectrum
->rdft_data[ch][2 * y + 1]
#define IM(y, ch) s->rdft_data[ch][2 * y + 1]
#define MAGNITUDE(y, ch) hypot(RE(y, ch), IM(y, ch))
#define MAGNITUDE(y, ch) hypot(RE(y, ch), IM(y, ch))
/* initialize buffer for combining to black */
/* initialize buffer for combining to black */
for
(
y
=
0
;
y
<
outlink
->
h
;
y
++
)
{
for
(
y
=
0
;
y
<
outlink
->
h
;
y
++
)
{
s
howspectrum
->
combine_buffer
[
3
*
y
]
=
0
;
s
->
combine_buffer
[
3
*
y
]
=
0
;
s
howspectrum
->
combine_buffer
[
3
*
y
+
1
]
=
127
.
5
;
s
->
combine_buffer
[
3
*
y
+
1
]
=
127
.
5
;
s
howspectrum
->
combine_buffer
[
3
*
y
+
2
]
=
127
.
5
;
s
->
combine_buffer
[
3
*
y
+
2
]
=
127
.
5
;
}
}
for
(
ch
=
0
;
ch
<
s
howspectrum
->
nb_display_channels
;
ch
++
)
{
for
(
ch
=
0
;
ch
<
s
->
nb_display_channels
;
ch
++
)
{
float
yf
,
uf
,
vf
;
float
yf
,
uf
,
vf
;
/* decide color range */
/* decide color range */
switch
(
s
howspectrum
->
mode
)
{
switch
(
s
->
mode
)
{
case
COMBINED
:
case
COMBINED
:
// reduce range by channel count
// reduce range by channel count
yf
=
256
.
0
f
/
s
howspectrum
->
nb_display_channels
;
yf
=
256
.
0
f
/
s
->
nb_display_channels
;
switch
(
s
howspectrum
->
color_mode
)
{
switch
(
s
->
color_mode
)
{
case
INTENSITY
:
case
INTENSITY
:
uf
=
yf
;
uf
=
yf
;
vf
=
yf
;
vf
=
yf
;
...
@@ -342,28 +342,28 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb
...
@@ -342,28 +342,28 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb
av_assert0
(
0
);
av_assert0
(
0
);
}
}
if
(
s
howspectrum
->
color_mode
==
CHANNEL
)
{
if
(
s
->
color_mode
==
CHANNEL
)
{
if
(
s
howspectrum
->
nb_display_channels
>
1
)
{
if
(
s
->
nb_display_channels
>
1
)
{
uf
*=
0
.
5
*
sin
((
2
*
M_PI
*
ch
)
/
s
howspectrum
->
nb_display_channels
);
uf
*=
0
.
5
*
sin
((
2
*
M_PI
*
ch
)
/
s
->
nb_display_channels
);
vf
*=
0
.
5
*
cos
((
2
*
M_PI
*
ch
)
/
s
howspectrum
->
nb_display_channels
);
vf
*=
0
.
5
*
cos
((
2
*
M_PI
*
ch
)
/
s
->
nb_display_channels
);
}
else
{
}
else
{
uf
=
0
.
0
f
;
uf
=
0
.
0
f
;
vf
=
0
.
0
f
;
vf
=
0
.
0
f
;
}
}
}
}
uf
*=
s
howspectrum
->
saturation
;
uf
*=
s
->
saturation
;
vf
*=
s
howspectrum
->
saturation
;
vf
*=
s
->
saturation
;
/* draw the channel */
/* draw the channel */
for
(
y
=
0
;
y
<
h
;
y
++
)
{
for
(
y
=
0
;
y
<
h
;
y
++
)
{
int
row
=
(
s
howspectrum
->
mode
==
COMBINED
)
?
y
:
ch
*
h
+
y
;
int
row
=
(
s
->
mode
==
COMBINED
)
?
y
:
ch
*
h
+
y
;
float
*
out
=
&
s
howspectrum
->
combine_buffer
[
3
*
row
];
float
*
out
=
&
s
->
combine_buffer
[
3
*
row
];
/* get magnitude */
/* get magnitude */
float
a
=
w
*
MAGNITUDE
(
y
,
ch
);
float
a
=
w
*
MAGNITUDE
(
y
,
ch
);
/* apply scale */
/* apply scale */
switch
(
s
howspectrum
->
scale
)
{
switch
(
s
->
scale
)
{
case
LINEAR
:
case
LINEAR
:
break
;
break
;
case
SQRT
:
case
SQRT
:
...
@@ -379,7 +379,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb
...
@@ -379,7 +379,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb
av_assert0
(
0
);
av_assert0
(
0
);
}
}
if
(
s
howspectrum
->
color_mode
==
INTENSITY
)
{
if
(
s
->
color_mode
==
INTENSITY
)
{
float
y
,
u
,
v
;
float
y
,
u
,
v
;
int
i
;
int
i
;
...
@@ -420,7 +420,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb
...
@@ -420,7 +420,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb
}
}
/* copy to output */
/* copy to output */
if
(
s
howspectrum
->
sliding
)
{
if
(
s
->
sliding
)
{
for
(
plane
=
0
;
plane
<
3
;
plane
++
)
{
for
(
plane
=
0
;
plane
<
3
;
plane
++
)
{
for
(
y
=
0
;
y
<
outlink
->
h
;
y
++
)
{
for
(
y
=
0
;
y
<
outlink
->
h
;
y
++
)
{
uint8_t
*
p
=
outpicref
->
data
[
plane
]
+
uint8_t
*
p
=
outpicref
->
data
[
plane
]
+
...
@@ -428,20 +428,20 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb
...
@@ -428,20 +428,20 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb
memmove
(
p
,
p
+
1
,
outlink
->
w
-
1
);
memmove
(
p
,
p
+
1
,
outlink
->
w
-
1
);
}
}
}
}
s
howspectrum
->
xpos
=
outlink
->
w
-
1
;
s
->
xpos
=
outlink
->
w
-
1
;
}
}
for
(
plane
=
0
;
plane
<
3
;
plane
++
)
{
for
(
plane
=
0
;
plane
<
3
;
plane
++
)
{
uint8_t
*
p
=
outpicref
->
data
[
plane
]
+
uint8_t
*
p
=
outpicref
->
data
[
plane
]
+
(
outlink
->
h
-
1
)
*
outpicref
->
linesize
[
plane
]
+
(
outlink
->
h
-
1
)
*
outpicref
->
linesize
[
plane
]
+
s
howspectrum
->
xpos
;
s
->
xpos
;
for
(
y
=
0
;
y
<
outlink
->
h
;
y
++
)
{
for
(
y
=
0
;
y
<
outlink
->
h
;
y
++
)
{
*
p
=
rint
(
FFMAX
(
0
,
FFMIN
(
s
howspectrum
->
combine_buffer
[
3
*
y
+
plane
],
255
)));
*
p
=
rint
(
FFMAX
(
0
,
FFMIN
(
s
->
combine_buffer
[
3
*
y
+
plane
],
255
)));
p
-=
outpicref
->
linesize
[
plane
];
p
-=
outpicref
->
linesize
[
plane
];
}
}
}
}
outpicref
->
pts
=
insamples
->
pts
+
outpicref
->
pts
=
insamples
->
pts
+
av_rescale_q
(
s
howspectrum
->
consumed
,
av_rescale_q
(
s
->
consumed
,
(
AVRational
){
1
,
inlink
->
sample_rate
},
(
AVRational
){
1
,
inlink
->
sample_rate
},
outlink
->
time_base
);
outlink
->
time_base
);
ret
=
push_frame
(
outlink
);
ret
=
push_frame
(
outlink
);
...
@@ -455,15 +455,15 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb
...
@@ -455,15 +455,15 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples, int nb
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
insamples
)
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
insamples
)
{
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterContext
*
ctx
=
inlink
->
dst
;
ShowSpectrumContext
*
s
howspectrum
=
ctx
->
priv
;
ShowSpectrumContext
*
s
=
ctx
->
priv
;
int
ret
=
0
,
left_samples
=
insamples
->
nb_samples
;
int
ret
=
0
,
left_samples
=
insamples
->
nb_samples
;
s
howspectrum
->
consumed
=
0
;
s
->
consumed
=
0
;
while
(
left_samples
)
{
while
(
left_samples
)
{
int
ret
=
plot_spectrum_column
(
inlink
,
insamples
,
left_samples
);
int
ret
=
plot_spectrum_column
(
inlink
,
insamples
,
left_samples
);
if
(
ret
<
0
)
if
(
ret
<
0
)
break
;
break
;
s
howspectrum
->
consumed
+=
ret
;
s
->
consumed
+=
ret
;
left_samples
-=
ret
;
left_samples
-=
ret
;
}
}
...
...
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