FFmpeg
Loading...
Searching...
No Matches
vf_blackdetect.h
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef AVFILTER_BLACKDETECT_H
20#define AVFILTER_BLACKDETECT_H
21
22#include <stddef.h>
23#include <stdint.h>
24
25#include "config.h"
26
27typedef unsigned (*ff_blackdetect_fn)(const uint8_t *src, ptrdiff_t stride,
28 ptrdiff_t width, ptrdiff_t height,
29 unsigned threshold);
30
33
34static unsigned count_pixels8_c(const uint8_t *src, ptrdiff_t stride,
35 ptrdiff_t width, ptrdiff_t height,
36 unsigned threshold)
37{
38 unsigned int counter = 0;
39 while (height--) {
40 for (int x = 0; x < width; x++)
41 counter += src[x] <= threshold;
42 src += stride;
43 }
44 return counter;
45}
46
47static unsigned count_pixels16_c(const uint8_t *src, ptrdiff_t stride,
48 ptrdiff_t width, ptrdiff_t height,
49 unsigned threshold)
50{
51 unsigned int counter = 0;
52 while (height--) {
53 const uint16_t *src16 = (const uint16_t *) src;
54 for (int x = 0; x < width; x++)
55 counter += src16[x] <= threshold;
56 src += stride;
57 }
58 return counter;
59}
60
61
63{
65
66#if ARCH_RISCV
68#elif ARCH_X86 && HAVE_X86ASM
70#else
71 fn = NULL;
72#endif
73
74 if (!fn)
75 fn = depth == 8 ? count_pixels8_c : count_pixels16_c;
76 return fn;
77}
78
79#endif /* AVFILTER_BLACKDETECT_H */
#define fn(a)
#define NULL
Definition coverity.c:32
#define stride
#define src
Definition vp8dsp.c:248
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89
static unsigned count_pixels16_c(const uint8_t *src, ptrdiff_t stride, ptrdiff_t width, ptrdiff_t height, unsigned threshold)
static unsigned count_pixels8_c(const uint8_t *src, ptrdiff_t stride, ptrdiff_t width, ptrdiff_t height, unsigned threshold)
ff_blackdetect_fn ff_blackdetect_get_fn_x86(int depth)
ff_blackdetect_fn ff_blackdetect_get_fn_riscv(int depth)
static ff_blackdetect_fn ff_blackdetect_get_fn(int depth)
unsigned(* ff_blackdetect_fn)(const uint8_t *src, ptrdiff_t stride, ptrdiff_t width, ptrdiff_t height, unsigned threshold)