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
6be5b05f
Commit
6be5b05f
authored
Aug 23, 2015
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_histogram: levels: support more input pixel formats
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
b4d68e7c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
62 deletions
+117
-62
vf_histogram.c
libavfilter/vf_histogram.c
+67
-12
filter-histogram-levels
tests/ref/fate/filter-histogram-levels
+50
-50
No files found.
libavfilter/vf_histogram.c
View file @
6be5b05f
...
@@ -49,8 +49,10 @@ typedef struct HistogramContext {
...
@@ -49,8 +49,10 @@ typedef struct HistogramContext {
int
waveform_mirror
;
int
waveform_mirror
;
int
display_mode
;
int
display_mode
;
int
levels_mode
;
int
levels_mode
;
const
AVPixFmtDescriptor
*
desc
;
const
AVPixFmtDescriptor
*
desc
,
*
odesc
;
int
components
;
int
components
;
int
planewidth
[
4
];
int
planeheight
[
4
];
}
HistogramContext
;
}
HistogramContext
;
#define OFFSET(x) offsetof(HistogramContext, x)
#define OFFSET(x) offsetof(HistogramContext, x)
...
@@ -86,9 +88,25 @@ static const enum AVPixelFormat color_pix_fmts[] = {
...
@@ -86,9 +88,25 @@ static const enum AVPixelFormat color_pix_fmts[] = {
AV_PIX_FMT_NONE
AV_PIX_FMT_NONE
};
};
static
const
enum
AVPixelFormat
levels_pix_fmts
[]
=
{
static
const
enum
AVPixelFormat
levels_in_pix_fmts
[]
=
{
AV_PIX_FMT_YUV444P
,
AV_PIX_FMT_YUVA444P
,
AV_PIX_FMT_YUVJ444P
,
AV_PIX_FMT_YUVA420P
,
AV_PIX_FMT_YUV420P
,
AV_PIX_FMT_YUVJ420P
,
AV_PIX_FMT_GRAY8
,
AV_PIX_FMT_GBRP
,
AV_PIX_FMT_GBRAP
,
AV_PIX_FMT_NONE
AV_PIX_FMT_YUVA422P
,
AV_PIX_FMT_YUV422P
,
AV_PIX_FMT_YUVJ422P
,
AV_PIX_FMT_YUV411P
,
AV_PIX_FMT_YUVJ411P
,
AV_PIX_FMT_YUV440P
,
AV_PIX_FMT_YUV410P
,
AV_PIX_FMT_YUVA444P
,
AV_PIX_FMT_YUV444P
,
AV_PIX_FMT_YUVJ444P
,
AV_PIX_FMT_GBRAP
,
AV_PIX_FMT_GBRP
,
AV_PIX_FMT_GRAY8
,
AV_PIX_FMT_NONE
};
static
const
enum
AVPixelFormat
levels_out_yuv_pix_fmts
[]
=
{
AV_PIX_FMT_YUVA444P
,
AV_PIX_FMT_YUV444P
,
AV_PIX_FMT_NONE
};
static
const
enum
AVPixelFormat
levels_out_rgb_pix_fmts
[]
=
{
AV_PIX_FMT_GBRAP
,
AV_PIX_FMT_GBRP
,
AV_PIX_FMT_NONE
};
};
static
const
enum
AVPixelFormat
waveform_pix_fmts
[]
=
{
static
const
enum
AVPixelFormat
waveform_pix_fmts
[]
=
{
...
@@ -114,7 +132,36 @@ static int query_formats(AVFilterContext *ctx)
...
@@ -114,7 +132,36 @@ static int query_formats(AVFilterContext *ctx)
pix_fmts
=
waveform_pix_fmts
;
pix_fmts
=
waveform_pix_fmts
;
break
;
break
;
case
MODE_LEVELS
:
case
MODE_LEVELS
:
pix_fmts
=
levels_pix_fmts
;
{
AVFilterFormats
*
avff
;
const
AVPixFmtDescriptor
*
desc
;
const
enum
AVPixelFormat
*
out_pix_fmts
;
int
rgb
,
i
;
if
(
!
ctx
->
inputs
[
0
]
->
in_formats
||
!
ctx
->
inputs
[
0
]
->
in_formats
->
nb_formats
)
{
return
AVERROR
(
EAGAIN
);
}
if
(
!
ctx
->
inputs
[
0
]
->
out_formats
)
ff_formats_ref
(
ff_make_format_list
(
levels_in_pix_fmts
),
&
ctx
->
inputs
[
0
]
->
out_formats
);
avff
=
ctx
->
inputs
[
0
]
->
in_formats
;
desc
=
av_pix_fmt_desc_get
(
avff
->
formats
[
0
]);
rgb
=
desc
->
flags
&
AV_PIX_FMT_FLAG_RGB
;
for
(
i
=
1
;
i
<
avff
->
nb_formats
;
i
++
)
{
desc
=
av_pix_fmt_desc_get
(
avff
->
formats
[
i
]);
if
(
rgb
!=
desc
->
flags
&
AV_PIX_FMT_FLAG_RGB
)
return
AVERROR
(
EAGAIN
);
}
if
(
rgb
)
out_pix_fmts
=
levels_out_rgb_pix_fmts
;
else
out_pix_fmts
=
levels_out_yuv_pix_fmts
;
ff_formats_ref
(
ff_make_format_list
(
out_pix_fmts
),
&
ctx
->
outputs
[
0
]
->
in_formats
);
return
0
;
}
break
;
break
;
case
MODE_COLOR
:
case
MODE_COLOR
:
case
MODE_COLOR2
:
case
MODE_COLOR2
:
...
@@ -153,6 +200,11 @@ static int config_input(AVFilterLink *inlink)
...
@@ -153,6 +200,11 @@ static int config_input(AVFilterLink *inlink)
h
->
fg_color
=
white_yuva_color
;
h
->
fg_color
=
white_yuva_color
;
}
}
h
->
planeheight
[
1
]
=
h
->
planeheight
[
2
]
=
FF_CEIL_RSHIFT
(
inlink
->
h
,
h
->
desc
->
log2_chroma_h
);
h
->
planeheight
[
0
]
=
h
->
planeheight
[
3
]
=
inlink
->
h
;
h
->
planewidth
[
1
]
=
h
->
planewidth
[
2
]
=
FF_CEIL_RSHIFT
(
inlink
->
w
,
h
->
desc
->
log2_chroma_w
);
h
->
planewidth
[
0
]
=
h
->
planewidth
[
3
]
=
inlink
->
w
;
return
0
;
return
0
;
}
}
...
@@ -187,6 +239,7 @@ static int config_output(AVFilterLink *outlink)
...
@@ -187,6 +239,7 @@ static int config_output(AVFilterLink *outlink)
av_assert0
(
0
);
av_assert0
(
0
);
}
}
h
->
odesc
=
av_pix_fmt_desc_get
(
outlink
->
format
);
outlink
->
sample_aspect_ratio
=
(
AVRational
){
1
,
1
};
outlink
->
sample_aspect_ratio
=
(
AVRational
){
1
,
1
};
return
0
;
return
0
;
...
@@ -257,13 +310,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
...
@@ -257,13 +310,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
out
->
pts
=
in
->
pts
;
out
->
pts
=
in
->
pts
;
for
(
k
=
0
;
k
<
h
->
ncomp
;
k
++
)
{
for
(
k
=
0
;
k
<
4
&&
out
->
data
[
k
]
;
k
++
)
{
const
int
is_chroma
=
(
k
==
1
||
k
==
2
);
const
int
is_chroma
=
(
k
==
1
||
k
==
2
);
const
int
dst_h
=
FF_CEIL_RSHIFT
(
outlink
->
h
,
(
is_chroma
?
h
->
desc
->
log2_chroma_h
:
0
));
const
int
dst_h
=
FF_CEIL_RSHIFT
(
outlink
->
h
,
(
is_chroma
?
h
->
o
desc
->
log2_chroma_h
:
0
));
const
int
dst_w
=
FF_CEIL_RSHIFT
(
outlink
->
w
,
(
is_chroma
?
h
->
desc
->
log2_chroma_w
:
0
));
const
int
dst_w
=
FF_CEIL_RSHIFT
(
outlink
->
w
,
(
is_chroma
?
h
->
o
desc
->
log2_chroma_w
:
0
));
for
(
i
=
0
;
i
<
dst_h
;
i
++
)
for
(
i
=
0
;
i
<
dst_h
;
i
++
)
memset
(
out
->
data
[
h
->
desc
->
comp
[
k
].
plane
]
+
memset
(
out
->
data
[
h
->
o
desc
->
comp
[
k
].
plane
]
+
i
*
out
->
linesize
[
h
->
desc
->
comp
[
k
].
plane
],
i
*
out
->
linesize
[
h
->
o
desc
->
comp
[
k
].
plane
],
h
->
bg_color
[
k
],
dst_w
);
h
->
bg_color
[
k
],
dst_w
);
}
}
...
@@ -271,6 +324,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
...
@@ -271,6 +324,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
case
MODE_LEVELS
:
case
MODE_LEVELS
:
for
(
m
=
0
,
k
=
0
;
k
<
h
->
ncomp
;
k
++
)
{
for
(
m
=
0
,
k
=
0
;
k
<
h
->
ncomp
;
k
++
)
{
const
int
p
=
h
->
desc
->
comp
[
k
].
plane
;
const
int
p
=
h
->
desc
->
comp
[
k
].
plane
;
const
int
height
=
h
->
planeheight
[
p
];
const
int
width
=
h
->
planewidth
[
p
];
int
start
;
int
start
;
double
max_hval_log
;
double
max_hval_log
;
unsigned
max_hval
=
0
;
unsigned
max_hval
=
0
;
...
@@ -279,9 +334,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
...
@@ -279,9 +334,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
continue
;
continue
;
start
=
m
++
*
(
h
->
level_height
+
h
->
scale_height
)
*
h
->
display_mode
;
start
=
m
++
*
(
h
->
level_height
+
h
->
scale_height
)
*
h
->
display_mode
;
for
(
i
=
0
;
i
<
in
->
height
;
i
++
)
{
for
(
i
=
0
;
i
<
height
;
i
++
)
{
src
=
in
->
data
[
p
]
+
i
*
in
->
linesize
[
p
];
src
=
in
->
data
[
p
]
+
i
*
in
->
linesize
[
p
];
for
(
j
=
0
;
j
<
in
->
width
;
j
++
)
for
(
j
=
0
;
j
<
width
;
j
++
)
h
->
histogram
[
src
[
j
]]
++
;
h
->
histogram
[
src
[
j
]]
++
;
}
}
...
...
tests/ref/fate/filter-histogram-levels
View file @
6be5b05f
#tb 0: 1/25
#tb 0: 1/25
0, 0, 0, 1, 488448, 0x
0d7343b9
0, 0, 0, 1, 488448, 0x
c27a6cac
0, 1, 1, 1, 488448, 0x
118e3ad
e
0, 1, 1, 1, 488448, 0x
f00a152
e
0, 2, 2, 1, 488448, 0x
778f1ba9
0, 2, 2, 1, 488448, 0x
060b8c70
0, 3, 3, 1, 488448, 0x
153bf44e
0, 3, 3, 1, 488448, 0x
f75d6ee2
0, 4, 4, 1, 488448, 0x
2d83c1ab
0, 4, 4, 1, 488448, 0x
d7a7f06e
0, 5, 5, 1, 488448, 0x
a3e95f8f
0, 5, 5, 1, 488448, 0x
585281a5
0, 6, 6, 1, 488448, 0x
91aad31b
0, 6, 6, 1, 488448, 0x
b06e3ee8
0, 7, 7, 1, 488448, 0x
90b92c09
0, 7, 7, 1, 488448, 0x
201d0b8c
0, 8, 8, 1, 488448, 0x
1e4c9f41
0, 8, 8, 1, 488448, 0x
4e14e319
0, 9, 9, 1, 488448, 0x
a88c1882
0, 9, 9, 1, 488448, 0x
5aef5cca
0, 10, 10, 1, 488448, 0x
1aa04274
0, 10, 10, 1, 488448, 0x
57018668
0, 11, 11, 1, 488448, 0x
49c45de8
0, 11, 11, 1, 488448, 0x
2ad45b3f
0, 12, 12, 1, 488448, 0x
e799c29f
0, 12, 12, 1, 488448, 0x
62cc36b8
0, 13, 13, 1, 488448, 0x
789e233f
0, 13, 13, 1, 488448, 0x
9e84585e
0, 14, 14, 1, 488448, 0x
9f753404
0, 14, 14, 1, 488448, 0x
e6552e42
0, 15, 15, 1, 488448, 0x
8305
0c2c
0, 15, 15, 1, 488448, 0x
13b9
0c2c
0, 16, 16, 1, 488448, 0x
ddf7ccbf
0, 16, 16, 1, 488448, 0x
f9557145
0, 17, 17, 1, 488448, 0x
e3128531
0, 17, 17, 1, 488448, 0x
818340bc
0, 18, 18, 1, 488448, 0x
cc6596af
0, 18, 18, 1, 488448, 0x
5112c6e1
0, 19, 19, 1, 488448, 0x
6e19754f
0, 19, 19, 1, 488448, 0x
5d5b8f43
0, 20, 20, 1, 488448, 0x
c3b32c7c
0, 20, 20, 1, 488448, 0x
f2101ea6
0, 21, 21, 1, 488448, 0x4
0b4853f
0, 21, 21, 1, 488448, 0x4
266af4d
0, 22, 22, 1, 488448, 0x
6e492674
0, 22, 22, 1, 488448, 0x
b358806e
0, 23, 23, 1, 488448, 0x
7f867236
0, 23, 23, 1, 488448, 0x
e336aa60
0, 24, 24, 1, 488448, 0x
22094365
0, 24, 24, 1, 488448, 0x
64fcc339
0, 25, 25, 1, 488448, 0x
45f30fc3
0, 25, 25, 1, 488448, 0x
86e4b729
0, 26, 26, 1, 488448, 0x
e6cbad09
0, 26, 26, 1, 488448, 0x
48c380d0
0, 27, 27, 1, 488448, 0x
0c44836b
0, 27, 27, 1, 488448, 0x
aee36fd3
0, 28, 28, 1, 488448, 0x
a7f04271
0, 28, 28, 1, 488448, 0x
20b84429
0, 29, 29, 1, 488448, 0x
d222ba88
0, 29, 29, 1, 488448, 0x
84d85542
0, 30, 30, 1, 488448, 0x
c96a974
9
0, 30, 30, 1, 488448, 0x
94aea16
9
0, 31, 31, 1, 488448, 0x
82e25bbd
0, 31, 31, 1, 488448, 0x
6278fa2c
0, 32, 32, 1, 488448, 0x
f79d1882
0, 32, 32, 1, 488448, 0x
aadf998d
0, 33, 33, 1, 488448, 0x
6d7fdd68
0, 33, 33, 1, 488448, 0x
29bba90d
0, 34, 34, 1, 488448, 0xe
b5c9b1b
0, 34, 34, 1, 488448, 0xe
f1117ad
0, 35, 35, 1, 488448, 0x
9014f9f4
0, 35, 35, 1, 488448, 0x
d961e36d
0, 36, 36, 1, 488448, 0x
96c6ab5f
0, 36, 36, 1, 488448, 0x
ff53296e
0, 37, 37, 1, 488448, 0x
03911af0
0, 37, 37, 1, 488448, 0x
41f381f9
0, 38, 38, 1, 488448, 0x
bf9dd8eb
0, 38, 38, 1, 488448, 0x
66fcfc2a
0, 39, 39, 1, 488448, 0x7
3509963
0, 39, 39, 1, 488448, 0x7
58bb472
0, 40, 40, 1, 488448, 0x
f2ecb068
0, 40, 40, 1, 488448, 0x
efc6dc9e
0, 41, 41, 1, 488448, 0x
ec2fb311
0, 41, 41, 1, 488448, 0x
77fccb69
0, 42, 42, 1, 488448, 0x
f4c7ba26
0, 42, 42, 1, 488448, 0x
7a1d82a4
0, 43, 43, 1, 488448, 0x
23f56543
0, 43, 43, 1, 488448, 0x
c9d61a1b
0, 44, 44, 1, 488448, 0x
25f8c48c
0, 44, 44, 1, 488448, 0x
8e689deb
0, 45, 45, 1, 488448, 0x
f1ccd38b
0, 45, 45, 1, 488448, 0x
52133e75
0, 46, 46, 1, 488448, 0x
10780667
0, 46, 46, 1, 488448, 0x
cc0a098e
0, 47, 47, 1, 488448, 0x
beb70431
0, 47, 47, 1, 488448, 0x
045cd17f
0, 48, 48, 1, 488448, 0x
bc950678
0, 48, 48, 1, 488448, 0x
97f89963
0, 49, 49, 1, 488448, 0x
fedf5d83
0, 49, 49, 1, 488448, 0x
a1f835ff
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