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
63c442e3
Commit
63c442e3
authored
Aug 04, 2015
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/avf_showspectrum: reindent
parent
087c0a0a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
134 additions
and
136 deletions
+134
-136
avf_showspectrum.c
libavfilter/avf_showspectrum.c
+134
-136
No files found.
libavfilter/avf_showspectrum.c
View file @
63c442e3
...
@@ -321,167 +321,165 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples)
...
@@ -321,167 +321,165 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples)
s
->
rdft_data
[
ch
][
n
]
=
p
[
n
]
*
s
->
window_func_lut
[
n
];
s
->
rdft_data
[
ch
][
n
]
=
p
[
n
]
*
s
->
window_func_lut
[
n
];
}
}
/* TODO reindent */
/* run RDFT on each samples set */
for
(
ch
=
0
;
ch
<
s
->
nb_display_channels
;
ch
++
)
av_rdft_calc
(
s
->
rdft
,
s
->
rdft_data
[
ch
]);
/* run RDFT on each samples set */
/* fill a new spectrum column */
for
(
ch
=
0
;
ch
<
s
->
nb_display_channels
;
ch
++
)
av_rdft_calc
(
s
->
rdft
,
s
->
rdft_data
[
ch
]);
/* fill a new spectrum column */
#define RE(y, ch) s->rdft_data[ch][2 * (y) + 0]
#define RE(y, ch) s->rdft_data[ch][2 * (y) + 0]
#define IM(y, ch) s->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
->
combine_buffer
[
3
*
y
]
=
0
;
s
->
combine_buffer
[
3
*
y
]
=
0
;
s
->
combine_buffer
[
3
*
y
+
1
]
=
127
.
5
;
s
->
combine_buffer
[
3
*
y
+
1
]
=
127
.
5
;
s
->
combine_buffer
[
3
*
y
+
2
]
=
127
.
5
;
s
->
combine_buffer
[
3
*
y
+
2
]
=
127
.
5
;
}
}
for
(
ch
=
0
;
ch
<
s
->
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
->
mode
)
{
switch
(
s
->
mode
)
{
case
COMBINED
:
case
COMBINED
:
// reduce range by channel count
// reduce range by channel count
yf
=
256
.
0
f
/
s
->
nb_display_channels
;
yf
=
256
.
0
f
/
s
->
nb_display_channels
;
switch
(
s
->
color_mode
)
{
switch
(
s
->
color_mode
)
{
case
INTENSITY
:
case
INTENSITY
:
uf
=
yf
;
uf
=
yf
;
vf
=
yf
;
vf
=
yf
;
break
;
case
CHANNEL
:
/* adjust saturation for mixed UV coloring */
/* this factor is correct for infinite channels, an approximation otherwise */
uf
=
yf
*
M_PI
;
vf
=
yf
*
M_PI
;
break
;
default:
av_assert0
(
0
);
}
break
;
break
;
case
SEPARATE
:
case
CHANNEL
:
/
/ full range
/
* adjust saturation for mixed UV coloring */
yf
=
256
.
0
f
;
/* this factor is correct for infinite channels, an approximation otherwise */
uf
=
256
.
0
f
;
uf
=
yf
*
M_PI
;
vf
=
256
.
0
f
;
vf
=
yf
*
M_PI
;
break
;
break
;
default:
default:
av_assert0
(
0
);
av_assert0
(
0
);
}
}
break
;
case
SEPARATE
:
// full range
yf
=
256
.
0
f
;
uf
=
256
.
0
f
;
vf
=
256
.
0
f
;
break
;
default:
av_assert0
(
0
);
}
if
(
s
->
color_mode
==
CHANNEL
)
{
if
(
s
->
color_mode
==
CHANNEL
)
{
if
(
s
->
nb_display_channels
>
1
)
{
if
(
s
->
nb_display_channels
>
1
)
{
uf
*=
0
.
5
*
sin
((
2
*
M_PI
*
ch
)
/
s
->
nb_display_channels
);
uf
*=
0
.
5
*
sin
((
2
*
M_PI
*
ch
)
/
s
->
nb_display_channels
);
vf
*=
0
.
5
*
cos
((
2
*
M_PI
*
ch
)
/
s
->
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
->
saturation
;
}
vf
*=
s
->
saturation
;
uf
*=
s
->
saturation
;
vf
*=
s
->
saturation
;
/* draw the channel */
for
(
y
=
0
;
y
<
h
;
y
++
)
{
int
row
=
(
s
->
mode
==
COMBINED
)
?
y
:
ch
*
h
+
y
;
float
*
out
=
&
s
->
combine_buffer
[
3
*
row
];
/* get magnitude */
float
a
=
w
*
MAGNITUDE
(
y
,
ch
);
/* apply scale */
switch
(
s
->
scale
)
{
case
LINEAR
:
break
;
case
SQRT
:
a
=
sqrt
(
a
);
break
;
case
CBRT
:
a
=
cbrt
(
a
);
break
;
case
LOG
:
a
=
1
-
log
(
FFMAX
(
FFMIN
(
1
,
a
),
1e-6
))
/
log
(
1e-6
);
// zero = -120dBFS
break
;
default:
av_assert0
(
0
);
}
if
(
s
->
color_mode
==
INTENSITY
)
{
/* draw the channel */
float
y
,
u
,
v
;
for
(
y
=
0
;
y
<
h
;
y
++
)
{
int
i
;
int
row
=
(
s
->
mode
==
COMBINED
)
?
y
:
ch
*
h
+
y
;
float
*
out
=
&
s
->
combine_buffer
[
3
*
row
];
for
(
i
=
1
;
i
<
sizeof
(
intensity_color_table
)
/
sizeof
(
*
intensity_color_table
)
-
1
;
i
++
)
if
(
intensity_color_table
[
i
].
a
>=
a
)
/* get magnitude */
break
;
float
a
=
w
*
MAGNITUDE
(
y
,
ch
);
// i now is the first item >= the color
// now we know to interpolate between item i - 1 and i
/* apply scale */
if
(
a
<=
intensity_color_table
[
i
-
1
].
a
)
{
switch
(
s
->
scale
)
{
y
=
intensity_color_table
[
i
-
1
].
y
;
case
LINEAR
:
u
=
intensity_color_table
[
i
-
1
].
u
;
break
;
v
=
intensity_color_table
[
i
-
1
].
v
;
case
SQRT
:
}
else
if
(
a
>=
intensity_color_table
[
i
].
a
)
{
a
=
sqrt
(
a
);
y
=
intensity_color_table
[
i
].
y
;
break
;
u
=
intensity_color_table
[
i
].
u
;
case
CBRT
:
v
=
intensity_color_table
[
i
].
v
;
a
=
cbrt
(
a
);
}
else
{
break
;
float
start
=
intensity_color_table
[
i
-
1
].
a
;
case
LOG
:
float
end
=
intensity_color_table
[
i
].
a
;
a
=
1
-
log
(
FFMAX
(
FFMIN
(
1
,
a
),
1e-6
))
/
log
(
1e-6
);
// zero = -120dBFS
float
lerpfrac
=
(
a
-
start
)
/
(
end
-
start
);
break
;
y
=
intensity_color_table
[
i
-
1
].
y
*
(
1
.
0
f
-
lerpfrac
)
default:
+
intensity_color_table
[
i
].
y
*
lerpfrac
;
av_assert0
(
0
);
u
=
intensity_color_table
[
i
-
1
].
u
*
(
1
.
0
f
-
lerpfrac
)
+
intensity_color_table
[
i
].
u
*
lerpfrac
;
v
=
intensity_color_table
[
i
-
1
].
v
*
(
1
.
0
f
-
lerpfrac
)
+
intensity_color_table
[
i
].
v
*
lerpfrac
;
}
out
[
0
]
+=
y
*
yf
;
out
[
1
]
+=
u
*
uf
;
out
[
2
]
+=
v
*
vf
;
}
else
{
out
[
0
]
+=
a
*
yf
;
out
[
1
]
+=
a
*
uf
;
out
[
2
]
+=
a
*
vf
;
}
}
}
}
/* copy to output */
if
(
s
->
color_mode
==
INTENSITY
)
{
if
(
s
->
sliding
==
SCROLL
)
{
float
y
,
u
,
v
;
for
(
plane
=
0
;
plane
<
3
;
plane
++
)
{
int
i
;
for
(
y
=
0
;
y
<
outlink
->
h
;
y
++
)
{
uint8_t
*
p
=
outpicref
->
data
[
plane
]
+
for
(
i
=
1
;
i
<
sizeof
(
intensity_color_table
)
/
sizeof
(
*
intensity_color_table
)
-
1
;
i
++
)
y
*
outpicref
->
linesize
[
plane
];
if
(
intensity_color_table
[
i
].
a
>=
a
)
memmove
(
p
,
p
+
1
,
outlink
->
w
-
1
);
break
;
// i now is the first item >= the color
// now we know to interpolate between item i - 1 and i
if
(
a
<=
intensity_color_table
[
i
-
1
].
a
)
{
y
=
intensity_color_table
[
i
-
1
].
y
;
u
=
intensity_color_table
[
i
-
1
].
u
;
v
=
intensity_color_table
[
i
-
1
].
v
;
}
else
if
(
a
>=
intensity_color_table
[
i
].
a
)
{
y
=
intensity_color_table
[
i
].
y
;
u
=
intensity_color_table
[
i
].
u
;
v
=
intensity_color_table
[
i
].
v
;
}
else
{
float
start
=
intensity_color_table
[
i
-
1
].
a
;
float
end
=
intensity_color_table
[
i
].
a
;
float
lerpfrac
=
(
a
-
start
)
/
(
end
-
start
);
y
=
intensity_color_table
[
i
-
1
].
y
*
(
1
.
0
f
-
lerpfrac
)
+
intensity_color_table
[
i
].
y
*
lerpfrac
;
u
=
intensity_color_table
[
i
-
1
].
u
*
(
1
.
0
f
-
lerpfrac
)
+
intensity_color_table
[
i
].
u
*
lerpfrac
;
v
=
intensity_color_table
[
i
-
1
].
v
*
(
1
.
0
f
-
lerpfrac
)
+
intensity_color_table
[
i
].
v
*
lerpfrac
;
}
}
out
[
0
]
+=
y
*
yf
;
out
[
1
]
+=
u
*
uf
;
out
[
2
]
+=
v
*
vf
;
}
else
{
out
[
0
]
+=
a
*
yf
;
out
[
1
]
+=
a
*
uf
;
out
[
2
]
+=
a
*
vf
;
}
}
s
->
xpos
=
outlink
->
w
-
1
;
}
}
}
/* copy to output */
if
(
s
->
sliding
==
SCROLL
)
{
for
(
plane
=
0
;
plane
<
3
;
plane
++
)
{
for
(
plane
=
0
;
plane
<
3
;
plane
++
)
{
uint8_t
*
p
=
outpicref
->
data
[
plane
]
+
(
outlink
->
h
-
1
)
*
outpicref
->
linesize
[
plane
]
+
s
->
xpos
;
for
(
y
=
0
;
y
<
outlink
->
h
;
y
++
)
{
for
(
y
=
0
;
y
<
outlink
->
h
;
y
++
)
{
*
p
=
rint
(
FFMAX
(
0
,
FFMIN
(
s
->
combine_buffer
[
3
*
y
+
plane
],
255
)));
uint8_t
*
p
=
outpicref
->
data
[
plane
]
+
p
-=
outpicref
->
linesize
[
plane
];
y
*
outpicref
->
linesize
[
plane
];
memmove
(
p
,
p
+
1
,
outlink
->
w
-
1
);
}
}
}
}
s
->
xpos
=
outlink
->
w
-
1
;
}
for
(
plane
=
0
;
plane
<
3
;
plane
++
)
{
uint8_t
*
p
=
outpicref
->
data
[
plane
]
+
(
outlink
->
h
-
1
)
*
outpicref
->
linesize
[
plane
]
+
s
->
xpos
;
for
(
y
=
0
;
y
<
outlink
->
h
;
y
++
)
{
*
p
=
rint
(
FFMAX
(
0
,
FFMIN
(
s
->
combine_buffer
[
3
*
y
+
plane
],
255
)));
p
-=
outpicref
->
linesize
[
plane
];
}
}
if
(
s
->
sliding
!=
FULLFRAME
||
s
->
xpos
==
0
)
if
(
s
->
sliding
!=
FULLFRAME
||
s
->
xpos
==
0
)
outpicref
->
pts
=
insamples
->
pts
;
outpicref
->
pts
=
insamples
->
pts
;
s
->
xpos
++
;
s
->
xpos
++
;
if
(
s
->
xpos
>=
outlink
->
w
)
if
(
s
->
xpos
>=
outlink
->
w
)
s
->
xpos
=
0
;
s
->
xpos
=
0
;
if
(
s
->
sliding
!=
FULLFRAME
||
s
->
xpos
==
0
)
{
if
(
s
->
sliding
!=
FULLFRAME
||
s
->
xpos
==
0
)
{
s
->
req_fullfilled
=
1
;
s
->
req_fullfilled
=
1
;
ret
=
ff_filter_frame
(
outlink
,
av_frame_clone
(
s
->
outpicref
));
ret
=
ff_filter_frame
(
outlink
,
av_frame_clone
(
s
->
outpicref
));
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
}
}
return
win_size
;
return
win_size
;
}
}
...
...
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