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
361e48f0
Commit
361e48f0
authored
Mar 03, 2016
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_waveform: add graticule support
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
f3c00be2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
187 additions
and
0 deletions
+187
-0
filters.texi
doc/filters.texi
+14
-0
vf_waveform.c
libavfilter/vf_waveform.c
+173
-0
No files found.
doc/filters.texi
View file @
361e48f0
...
...
@@ -13161,6 +13161,20 @@ Similar as above, but shows difference between blue and red chroma.
@item color
Displays actual color value on waveform.
@end table
@item graticule, g
Set which graticule to display.
@table @samp
@item none
Do not display graticule.
@item green
Display green graticule showing legal broadcast ranges.
@end table
@item opacity, o
Set graticule opacity.
@end table
@section xbr
...
...
libavfilter/vf_waveform.c
View file @
361e48f0
...
...
@@ -49,6 +49,8 @@ typedef struct WaveformContext {
int
mirror
;
int
display
;
int
envelope
;
int
graticule
;
float
opacity
;
int
estart
[
4
];
int
eend
[
4
];
int
*
emax
[
4
][
4
];
...
...
@@ -60,6 +62,7 @@ typedef struct WaveformContext {
int
size
;
void
(
*
waveform
)(
struct
WaveformContext
*
s
,
AVFrame
*
in
,
AVFrame
*
out
,
int
component
,
int
intensity
,
int
offset
,
int
column
);
void
(
*
graticulef
)(
struct
WaveformContext
*
s
,
AVFrame
*
out
);
const
AVPixFmtDescriptor
*
desc
;
}
WaveformContext
;
...
...
@@ -95,6 +98,12 @@ static const AVOption waveform_options[] = {
{
"chroma"
,
NULL
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
CHROMA
},
0
,
0
,
FLAGS
,
"filter"
},
{
"achroma"
,
NULL
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
ACHROMA
},
0
,
0
,
FLAGS
,
"filter"
},
{
"color"
,
NULL
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
COLOR
},
0
,
0
,
FLAGS
,
"filter"
},
{
"graticule"
,
"set graticule"
,
OFFSET
(
graticule
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
1
,
FLAGS
,
"graticule"
},
{
"g"
,
"set graticule"
,
OFFSET
(
graticule
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
1
,
FLAGS
,
"graticule"
},
{
"none"
,
NULL
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
0
},
0
,
0
,
FLAGS
,
"graticule"
},
{
"green"
,
NULL
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
1
},
0
,
0
,
FLAGS
,
"graticule"
},
{
"opacity"
,
"set graticule opacity"
,
OFFSET
(
opacity
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
0
.
75
},
0
,
1
,
FLAGS
},
{
"o"
,
"set graticule opacity"
,
OFFSET
(
opacity
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
0
.
75
},
0
,
1
,
FLAGS
},
{
NULL
}
};
...
...
@@ -1081,7 +1090,163 @@ static void color(WaveformContext *s, AVFrame *in, AVFrame *out,
}
static
const
uint8_t
black_yuva_color
[
4
]
=
{
0
,
127
,
127
,
255
};
static
const
uint8_t
green_yuva_color
[
4
]
=
{
255
,
0
,
0
,
255
};
static
const
uint8_t
black_gbrp_color
[
4
]
=
{
0
,
0
,
0
,
255
};
static
const
uint8_t
lines
[
4
][
2
]
=
{
{
16
,
235
},
{
16
,
240
},
{
16
,
240
},
{
0
,
255
}
};
static
void
blend_vline
(
uint8_t
*
dst
,
int
height
,
int
linesize
,
float
o1
,
float
o2
,
int
v
)
{
int
y
;
for
(
y
=
0
;
y
<
height
;
y
++
)
{
dst
[
0
]
=
v
*
o1
+
dst
[
0
]
*
o2
;
dst
+=
linesize
;
}
}
static
void
blend_vline16
(
uint16_t
*
dst
,
int
height
,
int
linesize
,
float
o1
,
float
o2
,
int
v
)
{
int
y
;
for
(
y
=
0
;
y
<
height
;
y
++
)
{
dst
[
0
]
=
v
*
o1
+
dst
[
0
]
*
o2
;
dst
+=
linesize
/
2
;
}
}
static
void
blend_hline
(
uint8_t
*
dst
,
int
width
,
float
o1
,
float
o2
,
int
v
)
{
int
x
;
for
(
x
=
0
;
x
<
width
;
x
++
)
{
dst
[
x
]
=
v
*
o1
+
dst
[
x
]
*
o2
;
}
}
static
void
blend_hline16
(
uint16_t
*
dst
,
int
width
,
float
o1
,
float
o2
,
int
v
)
{
int
x
;
for
(
x
=
0
;
x
<
width
;
x
++
)
{
dst
[
x
]
=
v
*
o1
+
dst
[
x
]
*
o2
;
}
}
static
void
graticule_none
(
WaveformContext
*
s
,
AVFrame
*
out
)
{
}
static
void
graticule_green_row
(
WaveformContext
*
s
,
AVFrame
*
out
)
{
const
float
o1
=
s
->
opacity
;
const
float
o2
=
1
.
-
o1
;
int
c
,
p
,
l
,
offset
=
0
;
for
(
c
=
0
;
c
<
s
->
ncomp
;
c
++
)
{
if
(
!
((
1
<<
c
)
&
s
->
pcomp
))
continue
;
for
(
p
=
0
;
p
<
s
->
ncomp
;
p
++
)
{
const
int
is_chroma
=
(
p
==
1
||
p
==
2
);
const
int
shift_w
=
(
is_chroma
?
s
->
desc
->
log2_chroma_w
:
0
);
const
int
shift_h
=
(
is_chroma
?
s
->
desc
->
log2_chroma_h
:
0
);
const
int
v
=
green_yuva_color
[
p
];
for
(
l
=
0
;
l
<
FF_ARRAY_ELEMS
(
lines
[
0
]);
l
++
)
{
int
x
=
offset
+
(
s
->
mirror
?
255
-
lines
[
c
][
l
]
:
lines
[
c
][
l
]);
uint8_t
*
dst
=
out
->
data
[
p
]
+
(
x
>>
shift_w
);
blend_vline
(
dst
,
out
->
height
>>
shift_h
,
out
->
linesize
[
p
],
o1
,
o2
,
v
);
}
}
offset
+=
256
*
s
->
display
;
}
}
static
void
graticule16_green_row
(
WaveformContext
*
s
,
AVFrame
*
out
)
{
const
float
o1
=
s
->
opacity
;
const
float
o2
=
1
.
-
o1
;
const
int
mult
=
s
->
size
/
256
;
int
c
,
p
,
l
,
offset
=
0
;
for
(
c
=
0
;
c
<
s
->
ncomp
;
c
++
)
{
if
(
!
((
1
<<
c
)
&
s
->
pcomp
))
continue
;
for
(
p
=
0
;
p
<
s
->
ncomp
;
p
++
)
{
const
int
is_chroma
=
(
p
==
1
||
p
==
2
);
const
int
shift_w
=
(
is_chroma
?
s
->
desc
->
log2_chroma_w
:
0
);
const
int
shift_h
=
(
is_chroma
?
s
->
desc
->
log2_chroma_h
:
0
);
const
int
v
=
green_yuva_color
[
p
]
*
mult
;
for
(
l
=
0
;
l
<
FF_ARRAY_ELEMS
(
lines
[
0
]);
l
++
)
{
int
x
=
offset
+
(
s
->
mirror
?
255
-
lines
[
c
][
l
]
:
lines
[
c
][
l
])
*
mult
;
uint16_t
*
dst
=
(
uint16_t
*
)(
out
->
data
[
p
])
+
(
x
>>
shift_w
);
blend_vline16
(
dst
,
out
->
height
>>
shift_h
,
out
->
linesize
[
p
],
o1
,
o2
,
v
);
}
}
offset
+=
s
->
size
*
s
->
display
;
}
}
static
void
graticule_green_column
(
WaveformContext
*
s
,
AVFrame
*
out
)
{
const
float
o1
=
s
->
opacity
;
const
float
o2
=
1
.
-
o1
;
int
c
,
p
,
l
,
offset
=
0
;
for
(
c
=
0
;
c
<
s
->
ncomp
;
c
++
)
{
if
(
!
((
1
<<
c
)
&
s
->
pcomp
))
continue
;
for
(
p
=
0
;
p
<
s
->
ncomp
;
p
++
)
{
const
int
is_chroma
=
(
p
==
1
||
p
==
2
);
const
int
shift_w
=
(
is_chroma
?
s
->
desc
->
log2_chroma_w
:
0
);
const
int
shift_h
=
(
is_chroma
?
s
->
desc
->
log2_chroma_h
:
0
);
const
int
v
=
green_yuva_color
[
p
];
for
(
l
=
0
;
l
<
FF_ARRAY_ELEMS
(
lines
[
0
]);
l
++
)
{
int
y
=
offset
+
(
s
->
mirror
?
255
-
lines
[
c
][
l
]
:
lines
[
c
][
l
]);
uint8_t
*
dst
=
out
->
data
[
p
]
+
(
y
>>
shift_h
)
*
out
->
linesize
[
p
];
blend_hline
(
dst
,
out
->
width
>>
shift_w
,
o1
,
o2
,
v
);
}
}
offset
+=
256
*
s
->
display
;
}
}
static
void
graticule16_green_column
(
WaveformContext
*
s
,
AVFrame
*
out
)
{
const
float
o1
=
s
->
opacity
;
const
float
o2
=
1
.
-
o1
;
const
int
mult
=
s
->
size
/
256
;
int
c
,
p
,
l
,
offset
=
0
;
for
(
c
=
0
;
c
<
s
->
ncomp
;
c
++
)
{
if
(
!
((
1
<<
c
)
&
s
->
pcomp
))
continue
;
for
(
p
=
0
;
p
<
s
->
ncomp
;
p
++
)
{
const
int
is_chroma
=
(
p
==
1
||
p
==
2
);
const
int
shift_w
=
(
is_chroma
?
s
->
desc
->
log2_chroma_w
:
0
);
const
int
shift_h
=
(
is_chroma
?
s
->
desc
->
log2_chroma_h
:
0
);
const
int
v
=
green_yuva_color
[
p
]
*
mult
;
for
(
l
=
0
;
l
<
FF_ARRAY_ELEMS
(
lines
[
0
]);
l
++
)
{
int
y
=
offset
+
(
s
->
mirror
?
255
-
lines
[
c
][
l
]
:
lines
[
c
][
l
])
*
mult
;
uint16_t
*
dst
=
(
uint16_t
*
)(
out
->
data
[
p
]
+
(
y
>>
shift_h
)
*
out
->
linesize
[
p
]);
blend_hline16
(
dst
,
out
->
width
>>
shift_w
,
o1
,
o2
,
v
);
}
}
offset
+=
s
->
size
*
s
->
display
;
}
}
static
int
config_input
(
AVFilterLink
*
inlink
)
{
...
...
@@ -1094,9 +1259,15 @@ static int config_input(AVFilterLink *inlink)
s
->
max
=
1
<<
s
->
bits
;
s
->
intensity
=
s
->
fintensity
*
(
s
->
max
-
1
);
s
->
graticulef
=
graticule_none
;
switch
(
s
->
filter
)
{
case
LOWPASS
:
s
->
size
=
256
;
if
(
s
->
graticule
&&
s
->
mode
==
1
)
s
->
graticulef
=
s
->
bits
>
8
?
graticule16_green_column
:
graticule_green_column
;
else
if
(
s
->
graticule
&&
s
->
mode
==
0
)
s
->
graticulef
=
s
->
bits
>
8
?
graticule16_green_row
:
graticule_green_row
;
s
->
waveform
=
s
->
bits
>
8
?
lowpass16
:
lowpass
;
break
;
case
FLAT
:
s
->
size
=
256
*
3
;
...
...
@@ -1124,6 +1295,7 @@ static int config_input(AVFilterLink *inlink)
case
AV_PIX_FMT_GBRP10
:
case
AV_PIX_FMT_GBRP12
:
s
->
bg_color
=
black_gbrp_color
;
s
->
graticulef
=
graticule_none
;
break
;
default:
s
->
bg_color
=
black_yuva_color
;
...
...
@@ -1233,6 +1405,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
s
->
waveform
(
s
,
in
,
out
,
k
,
s
->
intensity
,
offset
,
s
->
mode
);
}
}
s
->
graticulef
(
s
,
out
);
av_frame_free
(
&
in
);
return
ff_filter_frame
(
outlink
,
out
);
...
...
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