FFmpeg
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"
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 
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
89 #endif
90 }
91 
92 #endif /* AVFILTER_THRESHOLD_INIT_H */
out
FILE * out
Definition: movenc.c:55
threshold.h
av_unused
#define av_unused
Definition: attributes.h:131
w
uint8_t w
Definition: llviddspenc.c:38
max
#define max(a, b)
Definition: cuda_runtime.h:33
s
#define s(width, name)
Definition: cbs_vp9.c:198
ff_threshold_init_x86
void ff_threshold_init_x86(ThresholdContext *s)
Definition: vf_threshold_init.c:40
threshold16
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)
Definition: vf_threshold_init.h:51
ThresholdContext
Definition: threshold.h:27
attributes.h
threshold8
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)
Definition: vf_threshold_init.h:31
ff_threshold_init
static av_unused void ff_threshold_init(ThresholdContext *s)
Definition: vf_threshold_init.h:77
h
h
Definition: vp9dsp_template.c:2038
min
float min
Definition: vorbis_enc_data.h:429