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
a130165e
Commit
a130165e
authored
Aug 11, 2016
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/avf_avectorscope: add scale option
parent
369fdfaf
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
59 deletions
+84
-59
filters.texi
doc/filters.texi
+19
-0
avf_avectorscope.c
libavfilter/avf_avectorscope.c
+65
-59
No files found.
doc/filters.texi
View file @
a130165e
...
...
@@ -15060,6 +15060,25 @@ Draw line between previous and current sample.
@end table
Default value is @samp{dot}.
@item scale
Specify amplitude scale of audio samples.
Available values are:
@table @samp
@item lin
Linear.
@item sqrt
Square root.
@item cbrt
Cubic root.
@item log
Logarithmic.
@end table
@end table
@subsection Examples
...
...
libavfilter/avf_avectorscope.c
View file @
a130165e
...
...
@@ -46,6 +46,14 @@ enum VectorScopeDraw {
DRAW_NB
,
};
enum
VectorScopeScale
{
LIN
,
SQRT
,
CBRT
,
LOG
,
SCALE_NB
,
};
typedef
struct
AudioVectorScopeContext
{
const
AVClass
*
class
;
AVFrame
*
outpicref
;
...
...
@@ -53,6 +61,7 @@ typedef struct AudioVectorScopeContext {
int
hw
,
hh
;
int
mode
;
int
draw
;
int
scale
;
int
contrast
[
4
];
int
fade
[
4
];
double
zoom
;
...
...
@@ -85,6 +94,11 @@ static const AVOption avectorscope_options[] = {
{
"draw"
,
"set draw mode"
,
OFFSET
(
draw
),
AV_OPT_TYPE_INT
,
{.
i64
=
DOT
},
0
,
DRAW_NB
-
1
,
FLAGS
,
"draw"
},
{
"dot"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
DOT
}
,
0
,
0
,
FLAGS
,
"draw"
},
{
"line"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
LINE
},
0
,
0
,
FLAGS
,
"draw"
},
{
"scale"
,
"set amplitude scale mode"
,
OFFSET
(
scale
),
AV_OPT_TYPE_INT
,
{.
i64
=
LIN
},
0
,
SCALE_NB
-
1
,
FLAGS
,
"scale"
},
{
"lin"
,
"linear"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
LIN
},
0
,
0
,
FLAGS
,
"scale"
},
{
"sqrt"
,
"square root"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SQRT
},
0
,
0
,
FLAGS
,
"scale"
},
{
"cbrt"
,
"cube root"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
CBRT
},
0
,
0
,
FLAGS
,
"scale"
},
{
"log"
,
"logarithmic"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
LOG
},
0
,
0
,
FLAGS
,
"scale"
},
{
NULL
}
};
...
...
@@ -239,45 +253,41 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
fade
(
s
);
switch
(
insamples
->
format
)
{
case
AV_SAMPLE_FMT_S16
:
for
(
i
=
0
;
i
<
insamples
->
nb_samples
;
i
++
)
{
int16_t
*
src
=
(
int16_t
*
)
insamples
->
data
[
0
]
+
i
*
2
;
if
(
s
->
mode
==
LISSAJOUS
)
{
x
=
((
src
[
1
]
-
src
[
0
])
*
zoom
/
(
float
)(
UINT16_MAX
)
+
1
)
*
hw
;
y
=
(
1
.
0
-
(
src
[
0
]
+
src
[
1
])
*
zoom
/
(
float
)
UINT16_MAX
)
*
hh
;
}
else
if
(
s
->
mode
==
LISSAJOUS_XY
)
{
x
=
(
src
[
1
]
*
zoom
/
(
float
)
INT16_MAX
+
1
)
*
hw
;
y
=
(
src
[
0
]
*
zoom
/
(
float
)
INT16_MAX
+
1
)
*
hh
;
}
else
{
float
sx
,
sy
,
cx
,
cy
;
int16_t
*
samples
=
(
int16_t
*
)
insamples
->
data
[
0
]
+
i
*
2
;
float
*
samplesf
=
(
float
*
)
insamples
->
data
[
0
]
+
i
*
2
;
float
src
[
2
];
sx
=
src
[
1
]
*
zoom
/
(
float
)
INT16_MAX
;
sy
=
src
[
0
]
*
zoom
/
(
float
)
INT16_MAX
;
cx
=
sx
*
sqrtf
(
1
-
0
.
5
*
sy
*
sy
);
cy
=
sy
*
sqrtf
(
1
-
0
.
5
*
sx
*
sx
);
x
=
hw
+
hw
*
FFSIGN
(
cx
+
cy
)
*
(
cx
-
cy
)
*
.
7
;
y
=
s
->
h
-
s
->
h
*
fabsf
(
cx
+
cy
)
*
.
7
;
switch
(
insamples
->
format
)
{
case
AV_SAMPLE_FMT_S16
:
src
[
0
]
=
samples
[
0
]
/
(
float
)
INT16_MAX
;
src
[
1
]
=
samples
[
1
]
/
(
float
)
INT16_MAX
;
break
;
case
AV_SAMPLE_FMT_FLT
:
src
[
0
]
=
samplesf
[
0
];
src
[
1
]
=
samplesf
[
1
];
break
;
}
if
(
s
->
draw
==
DOT
)
{
draw_dot
(
s
,
x
,
y
);
}
else
{
draw_line
(
s
,
x
,
y
,
prev_x
,
prev_y
);
}
prev_x
=
x
;
prev_y
=
y
;
}
switch
(
s
->
scale
)
{
case
SQRT
:
src
[
0
]
=
FFSIGN
(
src
[
0
])
*
sqrtf
(
FFABS
(
src
[
0
]));
src
[
1
]
=
FFSIGN
(
src
[
1
])
*
sqrtf
(
FFABS
(
src
[
1
]));
break
;
case
AV_SAMPLE_FMT_FLT
:
for
(
i
=
0
;
i
<
insamples
->
nb_samples
;
i
++
)
{
float
*
src
=
(
float
*
)
insamples
->
data
[
0
]
+
i
*
2
;
case
CBRT
:
src
[
0
]
=
FFSIGN
(
src
[
0
])
*
cbrtf
(
FFABS
(
src
[
0
]));
src
[
1
]
=
FFSIGN
(
src
[
1
])
*
cbrtf
(
FFABS
(
src
[
1
]));
break
;
case
LOG
:
src
[
0
]
=
FFSIGN
(
src
[
0
])
*
logf
(
1
+
FFABS
(
src
[
0
]))
/
logf
(
2
);
src
[
1
]
=
FFSIGN
(
src
[
1
])
*
logf
(
1
+
FFABS
(
src
[
1
]))
/
logf
(
2
);
break
;
}
if
(
s
->
mode
==
LISSAJOUS
)
{
x
=
((
src
[
1
]
-
src
[
0
])
*
zoom
/
2
+
1
)
*
hw
;
y
=
(
1
.
0
-
(
src
[
0
]
+
src
[
1
])
*
zoom
/
2
)
*
hh
;
}
else
if
(
s
->
mode
==
LISSAJOUS_XY
)
{
}
else
if
(
s
->
mode
==
LISSAJOUS_XY
)
{
x
=
(
src
[
1
]
*
zoom
+
1
)
*
hw
;
y
=
(
src
[
0
]
*
zoom
+
1
)
*
hh
;
}
else
{
...
...
@@ -299,10 +309,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
prev_x
=
x
;
prev_y
=
y
;
}
break
;
default:
av_assert0
(
0
);
}
s
->
prev_x
=
x
,
s
->
prev_y
=
y
;
av_frame_free
(
&
insamples
);
...
...
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