FFmpeg
Loading...
Searching...
No Matches
vf_threshold_init.h
Go to the documentation of this file.
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"
29#include "threshold.h"
30
31static 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
51static 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
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 && HAVE_X86ASM
89#endif
90}
91
92#endif /* AVFILTER_THRESHOLD_INIT_H */
static FILE * out
#define s(width, name)
Definition cbs_vp9.c:198
#define min(a, b)
#define max(a, b)
Macro definitions for various function/variable attributes.
#define av_unused
Definition attributes.h:164
uint8_t w
Definition llvidencdsp.c:39
void ff_threshold_init_x86(ThresholdContext *s)
static av_unused void ff_threshold_init(ThresholdContext *s)
static void threshold8(const uint8_t *in, const uint8_t *threshold, const uint8_t *min, const uint8_t *max, uint8_t *out, ptrdiff_t ilinesize, ptrdiff_t tlinesize, ptrdiff_t flinesize, ptrdiff_t slinesize, ptrdiff_t olinesize, int w, int h)
static void threshold16(const uint8_t *iin, const uint8_t *tthreshold, const uint8_t *ffirst, const uint8_t *ssecond, uint8_t *oout, ptrdiff_t ilinesize, ptrdiff_t tlinesize, ptrdiff_t flinesize, ptrdiff_t slinesize, ptrdiff_t olinesize, int w, int h)