Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
6be5b05f
Commit
6be5b05f
authored
9 years ago
by
Paul B Mahol
Browse files
Options
Downloads
Patches
Plain Diff
avfilter/vf_histogram: levels: support more input pixel formats
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
b4d68e7c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libavfilter/vf_histogram.c
+67
-12
67 additions, 12 deletions
libavfilter/vf_histogram.c
tests/ref/fate/filter-histogram-levels
+50
-50
50 additions, 50 deletions
tests/ref/fate/filter-histogram-levels
with
117 additions
and
62 deletions
libavfilter/vf_histogram.c
+
67
−
12
View file @
6be5b05f
...
...
@@ -49,8 +49,10 @@ typedef struct HistogramContext {
int
waveform_mirror
;
int
display_mode
;
int
levels_mode
;
const
AVPixFmtDescriptor
*
desc
;
const
AVPixFmtDescriptor
*
desc
,
*
odesc
;
int
components
;
int
planewidth
[
4
];
int
planeheight
[
4
];
}
HistogramContext
;
#define OFFSET(x) offsetof(HistogramContext, x)
...
...
@@ -86,9 +88,25 @@ static const enum AVPixelFormat color_pix_fmts[] = {
AV_PIX_FMT_NONE
};
static
const
enum
AVPixelFormat
levels_pix_fmts
[]
=
{
AV_PIX_FMT_YUV444P
,
AV_PIX_FMT_YUVA444P
,
AV_PIX_FMT_YUVJ444P
,
AV_PIX_FMT_GRAY8
,
AV_PIX_FMT_GBRP
,
AV_PIX_FMT_GBRAP
,
AV_PIX_FMT_NONE
static
const
enum
AVPixelFormat
levels_in_pix_fmts
[]
=
{
AV_PIX_FMT_YUVA420P
,
AV_PIX_FMT_YUV420P
,
AV_PIX_FMT_YUVJ420P
,
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
[]
=
{
...
...
@@ -114,7 +132,36 @@ static int query_formats(AVFilterContext *ctx)
pix_fmts
=
waveform_pix_fmts
;
break
;
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
;
case
MODE_COLOR
:
case
MODE_COLOR2
:
...
...
@@ -153,6 +200,11 @@ static int config_input(AVFilterLink *inlink)
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
;
}
...
...
@@ -187,6 +239,7 @@ static int config_output(AVFilterLink *outlink)
av_assert0
(
0
);
}
h
->
odesc
=
av_pix_fmt_desc_get
(
outlink
->
format
);
outlink
->
sample_aspect_ratio
=
(
AVRational
){
1
,
1
};
return
0
;
...
...
@@ -257,13 +310,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
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
dst_h
=
FF_CEIL_RSHIFT
(
outlink
->
h
,
(
is_chroma
?
h
->
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_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
->
o
desc
->
log2_chroma_w
:
0
));
for
(
i
=
0
;
i
<
dst_h
;
i
++
)
memset
(
out
->
data
[
h
->
desc
->
comp
[
k
].
plane
]
+
i
*
out
->
linesize
[
h
->
desc
->
comp
[
k
].
plane
],
memset
(
out
->
data
[
h
->
o
desc
->
comp
[
k
].
plane
]
+
i
*
out
->
linesize
[
h
->
o
desc
->
comp
[
k
].
plane
],
h
->
bg_color
[
k
],
dst_w
);
}
...
...
@@ -271,6 +324,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
case
MODE_LEVELS
:
for
(
m
=
0
,
k
=
0
;
k
<
h
->
ncomp
;
k
++
)
{
const
int
p
=
h
->
desc
->
comp
[
k
].
plane
;
const
int
height
=
h
->
planeheight
[
p
];
const
int
width
=
h
->
planewidth
[
p
];
int
start
;
double
max_hval_log
;
unsigned
max_hval
=
0
;
...
...
@@ -279,9 +334,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
continue
;
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
];
for
(
j
=
0
;
j
<
in
->
width
;
j
++
)
for
(
j
=
0
;
j
<
width
;
j
++
)
h
->
histogram
[
src
[
j
]]
++
;
}
...
...
This diff is collapsed.
Click to expand it.
tests/ref/fate/filter-histogram-levels
+
50
−
50
View file @
6be5b05f
#tb 0: 1/25
0, 0, 0, 1, 488448, 0x
0d7343b9
0, 1, 1, 1, 488448, 0x
118e3ad
e
0, 2, 2, 1, 488448, 0x
778f1ba9
0, 3, 3, 1, 488448, 0x
153bf44e
0, 4, 4, 1, 488448, 0x
2d83c1ab
0, 5, 5, 1, 488448, 0x
a3e95f8f
0, 6, 6, 1, 488448, 0x
91aad31b
0, 7, 7, 1, 488448, 0x
90b92c09
0, 8, 8, 1, 488448, 0x
1e4c9f41
0, 9, 9, 1, 488448, 0x
a88c1882
0, 10, 10, 1, 488448, 0x
1aa04274
0, 11, 11, 1, 488448, 0x
49c45de8
0, 12, 12, 1, 488448, 0x
e799c29f
0, 13, 13, 1, 488448, 0x
789e233f
0, 14, 14, 1, 488448, 0x
9f753404
0, 15, 15, 1, 488448, 0x
8305
0c2c
0, 16, 16, 1, 488448, 0x
ddf7ccbf
0, 17, 17, 1, 488448, 0x
e3128531
0, 18, 18, 1, 488448, 0x
cc6596af
0, 19, 19, 1, 488448, 0x
6e19754f
0, 20, 20, 1, 488448, 0x
c3b32c7c
0, 21, 21, 1, 488448, 0x4
0b4853f
0, 22, 22, 1, 488448, 0x
6e492674
0, 23, 23, 1, 488448, 0x
7f867236
0, 24, 24, 1, 488448, 0x
22094365
0, 25, 25, 1, 488448, 0x
45f30fc3
0, 26, 26, 1, 488448, 0x
e6cba
d0
9
0, 27, 27, 1, 488448, 0x
0c44836b
0, 28, 28, 1, 488448, 0x
a7f04271
0, 29, 29, 1, 488448, 0x
d222ba88
0, 30, 30, 1, 488448, 0x
c96a974
9
0, 31, 31, 1, 488448, 0x
82e25bbd
0, 32, 32, 1, 488448, 0x
f79d1882
0, 33, 33, 1, 488448, 0x
6d7fdd68
0, 34, 34, 1, 488448, 0xe
b5c9b1b
0, 35, 35, 1, 488448, 0x
9014f9f4
0, 36, 36, 1, 488448, 0x
96c6ab5f
0, 37, 37, 1, 488448, 0x
03911af0
0, 38, 38, 1, 488448, 0x
bf9dd8eb
0, 39, 39, 1, 488448, 0x7
3509963
0, 40, 40, 1, 488448, 0x
f2ecb068
0, 41, 41, 1, 488448, 0x
ec2fb311
0, 42, 42, 1, 488448, 0x
f4c7ba26
0, 43, 43, 1, 488448, 0x
23f56543
0, 44, 44, 1, 488448, 0x
25f8c48c
0, 45, 45, 1, 488448, 0x
f1ccd38b
0, 46, 46, 1, 488448, 0x
10780667
0, 47, 47, 1, 488448, 0x
beb70431
0, 48, 48, 1, 488448, 0x
bc950678
0, 49, 49, 1, 488448, 0x
fedf5d83
0, 0, 0, 1, 488448, 0x
c27a6cac
0, 1, 1, 1, 488448, 0x
f00a152
e
0, 2, 2, 1, 488448, 0x
060b8c70
0, 3, 3, 1, 488448, 0x
f75d6ee2
0, 4, 4, 1, 488448, 0x
d7a7f06e
0, 5, 5, 1, 488448, 0x
585281a5
0, 6, 6, 1, 488448, 0x
b06e3ee8
0, 7, 7, 1, 488448, 0x
201d0b8c
0, 8, 8, 1, 488448, 0x
4e14e319
0, 9, 9, 1, 488448, 0x
5aef5cca
0, 10, 10, 1, 488448, 0x
57018668
0, 11, 11, 1, 488448, 0x
2ad45b3f
0, 12, 12, 1, 488448, 0x
62cc36b8
0, 13, 13, 1, 488448, 0x
9e84585e
0, 14, 14, 1, 488448, 0x
e6552e42
0, 15, 15, 1, 488448, 0x
13b9
0c2c
0, 16, 16, 1, 488448, 0x
f9557145
0, 17, 17, 1, 488448, 0x
818340bc
0, 18, 18, 1, 488448, 0x
5112c6e1
0, 19, 19, 1, 488448, 0x
5d5b8f43
0, 20, 20, 1, 488448, 0x
f2101ea6
0, 21, 21, 1, 488448, 0x4
266af4d
0, 22, 22, 1, 488448, 0x
b358806e
0, 23, 23, 1, 488448, 0x
e336aa60
0, 24, 24, 1, 488448, 0x
64fcc339
0, 25, 25, 1, 488448, 0x
86e4b729
0, 26, 26, 1, 488448, 0x
48c380
d0
0, 27, 27, 1, 488448, 0x
aee36fd3
0, 28, 28, 1, 488448, 0x
20b84429
0, 29, 29, 1, 488448, 0x
84d85542
0, 30, 30, 1, 488448, 0x
94aea16
9
0, 31, 31, 1, 488448, 0x
6278fa2c
0, 32, 32, 1, 488448, 0x
aadf998d
0, 33, 33, 1, 488448, 0x
29bba90d
0, 34, 34, 1, 488448, 0xe
f1117ad
0, 35, 35, 1, 488448, 0x
d961e36d
0, 36, 36, 1, 488448, 0x
ff53296e
0, 37, 37, 1, 488448, 0x
41f381f9
0, 38, 38, 1, 488448, 0x
66fcfc2a
0, 39, 39, 1, 488448, 0x7
58bb472
0, 40, 40, 1, 488448, 0x
efc6dc9e
0, 41, 41, 1, 488448, 0x
77fccb69
0, 42, 42, 1, 488448, 0x
7a1d82a4
0, 43, 43, 1, 488448, 0x
c9d61a1b
0, 44, 44, 1, 488448, 0x
8e689deb
0, 45, 45, 1, 488448, 0x
52133e75
0, 46, 46, 1, 488448, 0x
cc0a098e
0, 47, 47, 1, 488448, 0x
045cd17f
0, 48, 48, 1, 488448, 0x
97f89963
0, 49, 49, 1, 488448, 0x
a1f835ff
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment