Skip to content

Commit 11e3753

Browse files
committed
avfilter/vf_threshold: Move ff_threshold_init into a header
This removes a dependency of checkasm on lavfi/vf_threshold.o and also allows to inline ff_threshold_init() irrespectively of interposing. With this patch checkasm no longer pulls all of lavfi and lavf in. Signed-off-by: Andreas Rheinhardt <[email protected]>
1 parent c499f9b commit 11e3753

File tree

4 files changed

+93
-67
lines changed

4 files changed

+93
-67
lines changed

libavfilter/threshold.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ typedef struct ThresholdContext {
4646
FFFrameSync fs;
4747
} ThresholdContext;
4848

49-
void ff_threshold_init(ThresholdContext *s);
5049
void ff_threshold_init_x86(ThresholdContext *s);
5150

5251
#endif /* AVFILTER_THRESHOLD_H */

libavfilter/vf_threshold.c

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "internal.h"
3333
#include "video.h"
3434
#include "threshold.h"
35+
#include "vf_threshold_init.h"
3536

3637
#define OFFSET(x) offsetof(ThresholdContext, x)
3738
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
@@ -150,57 +151,6 @@ static int process_frame(FFFrameSync *fs)
150151
return ff_filter_frame(outlink, out);
151152
}
152153

153-
static void threshold8(const uint8_t *in, const uint8_t *threshold,
154-
const uint8_t *min, const uint8_t *max,
155-
uint8_t *out,
156-
ptrdiff_t ilinesize, ptrdiff_t tlinesize,
157-
ptrdiff_t flinesize, ptrdiff_t slinesize,
158-
ptrdiff_t olinesize,
159-
int w, int h)
160-
{
161-
int x, y;
162-
163-
for (y = 0; y < h; y++) {
164-
for (x = 0; x < w; x++) {
165-
out[x] = in[x] < threshold[x] ? min[x] : max[x];
166-
}
167-
168-
in += ilinesize;
169-
threshold += tlinesize;
170-
min += flinesize;
171-
max += slinesize;
172-
out += olinesize;
173-
}
174-
}
175-
176-
static void threshold16(const uint8_t *iin, const uint8_t *tthreshold,
177-
const uint8_t *ffirst, const uint8_t *ssecond,
178-
uint8_t *oout,
179-
ptrdiff_t ilinesize, ptrdiff_t tlinesize,
180-
ptrdiff_t flinesize, ptrdiff_t slinesize,
181-
ptrdiff_t olinesize,
182-
int w, int h)
183-
{
184-
const uint16_t *in = (const uint16_t *)iin;
185-
const uint16_t *threshold = (const uint16_t *)tthreshold;
186-
const uint16_t *min = (const uint16_t *)ffirst;
187-
const uint16_t *max = (const uint16_t *)ssecond;
188-
uint16_t *out = (uint16_t *)oout;
189-
int x, y;
190-
191-
for (y = 0; y < h; y++) {
192-
for (x = 0; x < w; x++) {
193-
out[x] = in[x] < threshold[x] ? min[x] : max[x];
194-
}
195-
196-
in += ilinesize / 2;
197-
threshold += tlinesize / 2;
198-
min += flinesize / 2;
199-
max += slinesize / 2;
200-
out += olinesize / 2;
201-
}
202-
}
203-
204154
static int config_input(AVFilterLink *inlink)
205155
{
206156
AVFilterContext *ctx = inlink->dst;
@@ -223,20 +173,6 @@ static int config_input(AVFilterLink *inlink)
223173
return 0;
224174
}
225175

226-
void ff_threshold_init(ThresholdContext *s)
227-
{
228-
if (s->depth == 8) {
229-
s->threshold = threshold8;
230-
s->bpc = 1;
231-
} else {
232-
s->threshold = threshold16;
233-
s->bpc = 2;
234-
}
235-
236-
if (ARCH_X86)
237-
ff_threshold_init_x86(s);
238-
}
239-
240176
static int config_output(AVFilterLink *outlink)
241177
{
242178
AVFilterContext *ctx = outlink->src;

libavfilter/vf_threshold_init.h

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Copyright (c) 2016 Paul B Mahol
3+
*
4+
* This file is part of FFmpeg.
5+
*
6+
* FFmpeg is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 2.1 of the License, or (at your option) any later version.
10+
*
11+
* FFmpeg is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with FFmpeg; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
21+
#ifndef AVFILTER_THRESHOLD_INIT_H
22+
#define AVFILTER_THRESHOLD_INIT_H
23+
24+
#include <stdint.h>
25+
#include <stddef.h>
26+
27+
#include "config.h"
28+
#include "libavutil/attributes.h"
29+
#include "threshold.h"
30+
31+
static void threshold8(const uint8_t *in, const uint8_t *threshold,
32+
const uint8_t *min, const uint8_t *max,
33+
uint8_t *out,
34+
ptrdiff_t ilinesize, ptrdiff_t tlinesize,
35+
ptrdiff_t flinesize, ptrdiff_t slinesize,
36+
ptrdiff_t olinesize,
37+
int w, int h)
38+
{
39+
for (int y = 0; y < h; y++) {
40+
for (int x = 0; x < w; x++)
41+
out[x] = in[x] < threshold[x] ? min[x] : max[x];
42+
43+
in += ilinesize;
44+
threshold += tlinesize;
45+
min += flinesize;
46+
max += slinesize;
47+
out += olinesize;
48+
}
49+
}
50+
51+
static void threshold16(const uint8_t *iin, const uint8_t *tthreshold,
52+
const uint8_t *ffirst, const uint8_t *ssecond,
53+
uint8_t *oout,
54+
ptrdiff_t ilinesize, ptrdiff_t tlinesize,
55+
ptrdiff_t flinesize, ptrdiff_t slinesize,
56+
ptrdiff_t olinesize,
57+
int w, int h)
58+
{
59+
const uint16_t *in = (const uint16_t *)iin;
60+
const uint16_t *threshold = (const uint16_t *)tthreshold;
61+
const uint16_t *min = (const uint16_t *)ffirst;
62+
const uint16_t *max = (const uint16_t *)ssecond;
63+
uint16_t *out = (uint16_t *)oout;
64+
65+
for (int y = 0; y < h; y++) {
66+
for (int x = 0; x < w; x++)
67+
out[x] = in[x] < threshold[x] ? min[x] : max[x];
68+
69+
in += ilinesize / 2;
70+
threshold += tlinesize / 2;
71+
min += flinesize / 2;
72+
max += slinesize / 2;
73+
out += olinesize / 2;
74+
}
75+
}
76+
77+
static av_unused void ff_threshold_init(ThresholdContext *s)
78+
{
79+
if (s->depth == 8) {
80+
s->threshold = threshold8;
81+
s->bpc = 1;
82+
} else {
83+
s->threshold = threshold16;
84+
s->bpc = 2;
85+
}
86+
87+
if (ARCH_X86)
88+
ff_threshold_init_x86(s);
89+
}
90+
91+
#endif /* AVFILTER_THRESHOLD_INIT_H */

tests/checkasm/vf_threshold.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include <string.h>
2020
#include "checkasm.h"
21-
#include "libavfilter/threshold.h"
21+
#include "libavfilter/vf_threshold_init.h"
2222
#include "libavutil/intreadwrite.h"
2323
#include "libavutil/mem_internal.h"
2424

0 commit comments

Comments
 (0)