FFmpeg
Loading...
Searching...
No Matches
scene_sad.c
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/**
20 * @file
21 * Scene SAD functions
22 */
23
24#include "libavutil/bswap.h"
25#include "scene_sad.h"
26
28{
29 uint64_t sad = 0;
30 const uint16_t *src1w = (const uint16_t *)src1;
31 const uint16_t *src2w = (const uint16_t *)src2;
32 int x, y;
33
34 stride1 /= 2;
35 stride2 /= 2;
36
37 for (y = 0; y < height; y++) {
38 for (x = 0; x < width; x++)
39 sad += FFABS(src1w[x] - src2w[x]);
40 src1w += stride1;
41 src2w += stride2;
42 }
43 *sum = sad;
44}
45
47{
48 uint64_t sad = 0;
49 const uint16_t *src1w = (const uint16_t *)src1;
50 const uint16_t *src2w = (const uint16_t *)src2;
51 int x, y;
52
53 stride1 /= 2;
54 stride2 /= 2;
55
56 for (y = 0; y < height; y++) {
57 for (x = 0; x < width; x++)
58 sad += FFABS(av_bswap16(src1w[x]) - av_bswap16(src2w[x]));
59 src1w += stride1;
60 src2w += stride2;
61 }
62 *sum = sad;
63}
64
66{
67 uint64_t sad = 0;
68 int x, y;
69
70 for (y = 0; y < height; y++) {
71 for (x = 0; x < width; x++)
72 sad += FFABS(src1[x] - src2[x]);
73 src1 += stride1;
74 src2 += stride2;
75 }
76 *sum = sad;
77}
78
80{
82#if ARCH_X86 && HAVE_X86ASM
83 sad = ff_scene_sad_get_fn_x86(depth);
84#endif
85#if ARCH_RISCV
86 sad = ff_scene_sad_get_fn_riscv(depth);
87#endif
88 if (!sad) {
89 if (depth <= 8)
90 sad = ff_scene_sad_c;
91 else if (depth <= 16)
92 sad = ff_scene_sad16_c;
93 }
94 return sad;
95}
96
98{
100#if ARCH_X86 && HAVE_X86ASM
102#endif
103 return sad ? sad : ff_scene_sad16_bswap_c;
104}
byte swapping routines
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition common.h:74
#define NULL
Definition coverity.c:32
const pixel * src2
void ff_scene_sad_c(SCENE_SAD_PARAMS)
Definition scene_sad.c:65
void ff_scene_sad16_bswap_c(SCENE_SAD_PARAMS)
SAD of 9 to 16 bit samples stored in the byte order the CPU does not use.
Definition scene_sad.c:46
ff_scene_sad_fn ff_scene_sad_get_fn(int depth)
Definition scene_sad.c:79
void ff_scene_sad16_c(SCENE_SAD_PARAMS)
Definition scene_sad.c:27
ff_scene_sad_fn ff_scene_sad_bswap_get_fn(void)
Definition scene_sad.c:97
#define av_bswap16
Definition bswap.h:28
ff_scene_sad_fn ff_scene_sad_get_fn_riscv(int depth)
Scene SAD functions.
void(* ff_scene_sad_fn)(SCENE_SAD_PARAMS)
Definition scene_sad.h:34
ff_scene_sad_fn ff_scene_sad_get_fn_x86(int depth)
ff_scene_sad_fn ff_scene_sad_bswap_get_fn_x86(void)
#define SCENE_SAD_PARAMS
Definition scene_sad.h:29
#define src1
Definition h264pred.c:141
#define height
Definition dsp.h:99
#define width
Definition dsp.h:99