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
a11757d7
Commit
a11757d7
authored
Oct 12, 2016
by
Muhammad Faiz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/showcqt: add csp option
from colorspace filter Signed-off-by:
Muhammad Faiz
<
mfcc64@gmail.com
>
parent
4599e116
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
5 deletions
+79
-5
filters.texi
doc/filters.texi
+26
-0
avf_showcqt.c
libavfilter/avf_showcqt.c
+51
-5
avf_showcqt.h
libavfilter/avf_showcqt.h
+2
-0
No files found.
doc/filters.texi
View file @
a11757d7
...
@@ -16884,6 +16884,32 @@ Enable/disable drawing text to the axis. If it is set to @code{0}, drawing to
...
@@ -16884,6 +16884,32 @@ Enable/disable drawing text to the axis. If it is set to @code{0}, drawing to
the axis is disabled, ignoring @var{fontfile} and @var{axisfile} option.
the axis is disabled, ignoring @var{fontfile} and @var{axisfile} option.
Default value is @code{1}.
Default value is @code{1}.
@item csp
Set colorspace. The accepted values are:
@table @samp
@item unspecified
Unspecified (default)
@item bt709
BT.709
@item fcc
FCC
@item bt470bg
BT.470BG or BT.601-6 625
@item smpte170m
SMPTE-170M or BT.601-6 525
@item smpte240m
SMPTE-240M
@item bt2020ncl
BT.2020 with non-constant luminance
@end table
@end table
@end table
@subsection Examples
@subsection Examples
...
...
libavfilter/avf_showcqt.c
View file @
a11757d7
...
@@ -83,6 +83,14 @@ static const AVOption showcqt_options[] = {
...
@@ -83,6 +83,14 @@ static const AVOption showcqt_options[] = {
{
"axisfile"
,
"set axis image"
,
OFFSET
(
axisfile
),
AV_OPT_TYPE_STRING
,
{
.
str
=
NULL
},
CHAR_MIN
,
CHAR_MAX
,
FLAGS
},
{
"axisfile"
,
"set axis image"
,
OFFSET
(
axisfile
),
AV_OPT_TYPE_STRING
,
{
.
str
=
NULL
},
CHAR_MIN
,
CHAR_MAX
,
FLAGS
},
{
"axis"
,
"draw axis"
,
OFFSET
(
axis
),
AV_OPT_TYPE_BOOL
,
{
.
i64
=
1
},
0
,
1
,
FLAGS
},
{
"axis"
,
"draw axis"
,
OFFSET
(
axis
),
AV_OPT_TYPE_BOOL
,
{
.
i64
=
1
},
0
,
1
,
FLAGS
},
{
"text"
,
"draw axis"
,
OFFSET
(
axis
),
AV_OPT_TYPE_BOOL
,
{
.
i64
=
1
},
0
,
1
,
FLAGS
},
{
"text"
,
"draw axis"
,
OFFSET
(
axis
),
AV_OPT_TYPE_BOOL
,
{
.
i64
=
1
},
0
,
1
,
FLAGS
},
{
"csp"
,
"set color space"
,
OFFSET
(
csp
),
AV_OPT_TYPE_INT
,
{
.
i64
=
AVCOL_SPC_UNSPECIFIED
},
0
,
INT_MAX
,
FLAGS
,
"csp"
},
{
"unspecified"
,
"unspecified"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
AVCOL_SPC_UNSPECIFIED
},
0
,
0
,
FLAGS
,
"csp"
},
{
"bt709"
,
"bt709"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
AVCOL_SPC_BT709
},
0
,
0
,
FLAGS
,
"csp"
},
{
"fcc"
,
"fcc"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
AVCOL_SPC_FCC
},
0
,
0
,
FLAGS
,
"csp"
},
{
"bt470bg"
,
"bt470bg"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
AVCOL_SPC_BT470BG
},
0
,
0
,
FLAGS
,
"csp"
},
{
"smpte170m"
,
"smpte170m"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
AVCOL_SPC_SMPTE170M
},
0
,
0
,
FLAGS
,
"csp"
},
{
"smpte240m"
,
"smpte240m"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
AVCOL_SPC_SMPTE240M
},
0
,
0
,
FLAGS
,
"csp"
},
{
"bt2020ncl"
,
"bt2020ncl"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
AVCOL_SPC_BT2020_NCL
},
0
,
0
,
FLAGS
,
"csp"
},
{
NULL
}
{
NULL
}
};
};
...
@@ -656,7 +664,7 @@ static void rgb_from_cqt(ColorFloat *c, const FFTComplex *v, float g, int len)
...
@@ -656,7 +664,7 @@ static void rgb_from_cqt(ColorFloat *c, const FFTComplex *v, float g, int len)
}
}
}
}
static
void
yuv_from_cqt
(
ColorFloat
*
c
,
const
FFTComplex
*
v
,
float
gamma
,
int
len
)
static
void
yuv_from_cqt
(
ColorFloat
*
c
,
const
FFTComplex
*
v
,
float
gamma
,
int
len
,
float
cm
[
3
][
3
]
)
{
{
int
x
;
int
x
;
for
(
x
=
0
;
x
<
len
;
x
++
)
{
for
(
x
=
0
;
x
<
len
;
x
++
)
{
...
@@ -664,9 +672,9 @@ static void yuv_from_cqt(ColorFloat *c, const FFTComplex *v, float gamma, int le
...
@@ -664,9 +672,9 @@ static void yuv_from_cqt(ColorFloat *c, const FFTComplex *v, float gamma, int le
r
=
calculate_gamma
(
FFMIN
(
1
.
0
f
,
v
[
x
].
re
),
gamma
);
r
=
calculate_gamma
(
FFMIN
(
1
.
0
f
,
v
[
x
].
re
),
gamma
);
g
=
calculate_gamma
(
FFMIN
(
1
.
0
f
,
0
.
5
f
*
(
v
[
x
].
re
+
v
[
x
].
im
)),
gamma
);
g
=
calculate_gamma
(
FFMIN
(
1
.
0
f
,
0
.
5
f
*
(
v
[
x
].
re
+
v
[
x
].
im
)),
gamma
);
b
=
calculate_gamma
(
FFMIN
(
1
.
0
f
,
v
[
x
].
im
),
gamma
);
b
=
calculate_gamma
(
FFMIN
(
1
.
0
f
,
v
[
x
].
im
),
gamma
);
c
[
x
].
yuv
.
y
=
65
.
481
f
*
r
+
128
.
553
f
*
g
+
24
.
966
f
*
b
;
c
[
x
].
yuv
.
y
=
cm
[
0
][
0
]
*
r
+
cm
[
0
][
1
]
*
g
+
cm
[
0
][
2
]
*
b
;
c
[
x
].
yuv
.
u
=
-
37
.
797
f
*
r
-
74
.
203
f
*
g
+
112
.
0
f
*
b
;
c
[
x
].
yuv
.
u
=
cm
[
1
][
0
]
*
r
+
cm
[
1
][
1
]
*
g
+
cm
[
1
][
2
]
*
b
;
c
[
x
].
yuv
.
v
=
112
.
0
f
*
r
-
93
.
786
f
*
g
-
18
.
214
*
b
;
c
[
x
].
yuv
.
v
=
cm
[
2
][
0
]
*
r
+
cm
[
2
][
1
]
*
g
+
cm
[
2
][
2
]
*
b
;
}
}
}
}
...
@@ -1036,7 +1044,7 @@ static void process_cqt(ShowCQTContext *s)
...
@@ -1036,7 +1044,7 @@ static void process_cqt(ShowCQTContext *s)
if
(
s
->
format
==
AV_PIX_FMT_RGB24
)
if
(
s
->
format
==
AV_PIX_FMT_RGB24
)
rgb_from_cqt
(
s
->
c_buf
,
s
->
cqt_result
,
s
->
sono_g
,
s
->
width
);
rgb_from_cqt
(
s
->
c_buf
,
s
->
cqt_result
,
s
->
sono_g
,
s
->
width
);
else
else
yuv_from_cqt
(
s
->
c_buf
,
s
->
cqt_result
,
s
->
sono_g
,
s
->
width
);
yuv_from_cqt
(
s
->
c_buf
,
s
->
cqt_result
,
s
->
sono_g
,
s
->
width
,
s
->
cmatrix
);
}
}
static
int
plot_cqt
(
AVFilterContext
*
ctx
,
AVFrame
**
frameout
)
static
int
plot_cqt
(
AVFilterContext
*
ctx
,
AVFrame
**
frameout
)
...
@@ -1075,6 +1083,7 @@ static int plot_cqt(AVFilterContext *ctx, AVFrame **frameout)
...
@@ -1075,6 +1083,7 @@ static int plot_cqt(AVFilterContext *ctx, AVFrame **frameout)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
out
->
sample_aspect_ratio
=
av_make_q
(
1
,
1
);
out
->
sample_aspect_ratio
=
av_make_q
(
1
,
1
);
av_frame_set_color_range
(
out
,
AVCOL_RANGE_MPEG
);
av_frame_set_color_range
(
out
,
AVCOL_RANGE_MPEG
);
av_frame_set_colorspace
(
out
,
s
->
csp
);
UPDATE_TIME
(
s
->
alloc_time
);
UPDATE_TIME
(
s
->
alloc_time
);
if
(
s
->
bar_h
)
{
if
(
s
->
bar_h
)
{
...
@@ -1100,6 +1109,41 @@ static int plot_cqt(AVFilterContext *ctx, AVFrame **frameout)
...
@@ -1100,6 +1109,41 @@ static int plot_cqt(AVFilterContext *ctx, AVFrame **frameout)
return
0
;
return
0
;
}
}
static
void
init_colormatrix
(
ShowCQTContext
*
s
)
{
double
kr
,
kg
,
kb
;
/* from vf_colorspace.c */
switch
(
s
->
csp
)
{
default:
av_log
(
s
->
ctx
,
AV_LOG_WARNING
,
"unsupported colorspace, setting it to unspecified.
\n
"
);
s
->
csp
=
AVCOL_SPC_UNSPECIFIED
;
case
AVCOL_SPC_UNSPECIFIED
:
case
AVCOL_SPC_BT470BG
:
case
AVCOL_SPC_SMPTE170M
:
kr
=
0
.
299
;
kb
=
0
.
114
;
break
;
case
AVCOL_SPC_BT709
:
kr
=
0
.
2126
;
kb
=
0
.
0722
;
break
;
case
AVCOL_SPC_FCC
:
kr
=
0
.
30
;
kb
=
0
.
11
;
break
;
case
AVCOL_SPC_SMPTE240M
:
kr
=
0
.
212
;
kb
=
0
.
087
;
break
;
case
AVCOL_SPC_BT2020_NCL
:
kr
=
0
.
2627
;
kb
=
0
.
05
93
;
break
;
}
kg
=
1
.
0
-
kr
-
kb
;
s
->
cmatrix
[
0
][
0
]
=
219
.
0
*
kr
;
s
->
cmatrix
[
0
][
1
]
=
219
.
0
*
kg
;
s
->
cmatrix
[
0
][
2
]
=
219
.
0
*
kb
;
s
->
cmatrix
[
1
][
0
]
=
-
112
.
0
*
kr
/
(
1
.
0
-
kb
);
s
->
cmatrix
[
1
][
1
]
=
-
112
.
0
*
kg
/
(
1
.
0
-
kb
);
s
->
cmatrix
[
1
][
2
]
=
112
.
0
;
s
->
cmatrix
[
2
][
0
]
=
112
.
0
;
s
->
cmatrix
[
2
][
1
]
=
-
112
.
0
*
kg
/
(
1
.
0
-
kr
);
s
->
cmatrix
[
2
][
2
]
=
-
112
.
0
*
kb
/
(
1
.
0
-
kr
);
}
/* main filter control */
/* main filter control */
static
av_cold
int
init
(
AVFilterContext
*
ctx
)
static
av_cold
int
init
(
AVFilterContext
*
ctx
)
{
{
...
@@ -1153,6 +1197,8 @@ static av_cold int init(AVFilterContext *ctx)
...
@@ -1153,6 +1197,8 @@ static av_cold int init(AVFilterContext *ctx)
}
while
(
s
->
fcount
*
s
->
width
<
1920
&&
s
->
fcount
<
10
);
}
while
(
s
->
fcount
*
s
->
width
<
1920
&&
s
->
fcount
<
10
);
}
}
init_colormatrix
(
s
);
return
0
;
return
0
;
}
}
...
...
libavfilter/avf_showcqt.h
View file @
a11757d7
...
@@ -71,6 +71,7 @@ typedef struct {
...
@@ -71,6 +71,7 @@ typedef struct {
float
*
rcp_h_buf
;
float
*
rcp_h_buf
;
float
*
sono_v_buf
;
float
*
sono_v_buf
;
float
*
bar_v_buf
;
float
*
bar_v_buf
;
float
cmatrix
[
3
][
3
];
/* callback */
/* callback */
void
(
*
cqt_calc
)(
FFTComplex
*
dst
,
const
FFTComplex
*
src
,
const
Coeffs
*
coeffs
,
void
(
*
cqt_calc
)(
FFTComplex
*
dst
,
const
FFTComplex
*
src
,
const
Coeffs
*
coeffs
,
int
len
,
int
fft_len
);
int
len
,
int
fft_len
);
...
@@ -111,6 +112,7 @@ typedef struct {
...
@@ -111,6 +112,7 @@ typedef struct {
char
*
fontcolor
;
char
*
fontcolor
;
char
*
axisfile
;
char
*
axisfile
;
int
axis
;
int
axis
;
int
csp
;
}
ShowCQTContext
;
}
ShowCQTContext
;
void
ff_showcqt_init_x86
(
ShowCQTContext
*
s
);
void
ff_showcqt_init_x86
(
ShowCQTContext
*
s
);
...
...
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