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 "scene_sad.h" |
25 |
|
|
|
26 |
|
89 |
void ff_scene_sad16_c(SCENE_SAD_PARAMS) |
27 |
|
|
{ |
28 |
|
89 |
uint64_t sad = 0; |
29 |
|
89 |
const uint16_t *src1w = (const uint16_t *)src1; |
30 |
|
89 |
const uint16_t *src2w = (const uint16_t *)src2; |
31 |
|
|
int x, y; |
32 |
|
|
|
33 |
|
89 |
stride1 /= 2; |
34 |
|
89 |
stride2 /= 2; |
35 |
|
|
|
36 |
✓✓ |
21449 |
for (y = 0; y < height; y++) { |
37 |
✓✓ |
6856560 |
for (x = 0; x < width; x++) |
38 |
✓✓ |
6835200 |
sad += FFABS(src1w[x] - src2w[x]); |
39 |
|
21360 |
src1w += stride1; |
40 |
|
21360 |
src2w += stride2; |
41 |
|
|
} |
42 |
|
89 |
*sum = sad; |
43 |
|
89 |
} |
44 |
|
|
|
45 |
|
3370 |
void ff_scene_sad_c(SCENE_SAD_PARAMS) |
46 |
|
|
{ |
47 |
|
3370 |
uint64_t sad = 0; |
48 |
|
|
int x, y; |
49 |
|
|
|
50 |
✓✓ |
888170 |
for (y = 0; y < height; y++) { |
51 |
✓✓ |
1345600 |
for (x = 0; x < width; x++) |
52 |
✓✓ |
460800 |
sad += FFABS(src1[x] - src2[x]); |
53 |
|
884800 |
src1 += stride1; |
54 |
|
884800 |
src2 += stride2; |
55 |
|
|
} |
56 |
|
3370 |
*sum = sad; |
57 |
|
3370 |
} |
58 |
|
|
|
59 |
|
9 |
ff_scene_sad_fn ff_scene_sad_get_fn(int depth) |
60 |
|
|
{ |
61 |
|
9 |
ff_scene_sad_fn sad = NULL; |
62 |
|
|
if (ARCH_X86) |
63 |
|
9 |
sad = ff_scene_sad_get_fn_x86(depth); |
64 |
✓✓ |
9 |
if (!sad) { |
65 |
✓✓ |
6 |
if (depth == 8) |
66 |
|
4 |
sad = ff_scene_sad_c; |
67 |
✓✓ |
6 |
if (depth == 16) |
68 |
|
2 |
sad = ff_scene_sad16_c; |
69 |
|
|
} |
70 |
|
9 |
return sad; |
71 |
|
|
} |
72 |
|
|
|