FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
tests
checkasm
vf_blend.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2016 Tiancheng "Timothy" Gu
3
*
4
* This file is part of FFmpeg.
5
*
6
* FFmpeg is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (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
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along
17
* with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
*/
20
21
#include <string.h>
22
#include "
checkasm.h
"
23
#include "
libavfilter/blend.h
"
24
#include "
libavutil/common.h
"
25
#include "
libavutil/internal.h
"
26
#include "
libavutil/intreadwrite.h
"
27
28
#define WIDTH 256
29
#define HEIGHT 256
30
#define BUF_UNITS 3
31
#define SIZE_PER_UNIT (WIDTH * HEIGHT)
32
#define BUF_SIZE (BUF_UNITS * SIZE_PER_UNIT)
33
34
#define randomize_buffers() \
35
do { \
36
int i, j; \
37
for (i = 0; i < HEIGHT; i++) { \
38
for (j = 0; j < WIDTH; j++) { \
39
top1[i * WIDTH + j] = \
40
top2[i * WIDTH + j] = i; \
41
bot1[i * WIDTH + j] = \
42
bot2[i * WIDTH + j] = j; \
43
} \
44
} \
45
for (i = 0; i < SIZE_PER_UNIT; i += 4) { \
46
uint32_t r = rnd(); \
47
AV_WN32A(dst1 + i, r); \
48
AV_WN32A(dst2 + i, r); \
49
} \
50
for (; i < BUF_SIZE; i += 4) { \
51
uint32_t r = rnd(); \
52
AV_WN32A(top1 + i, r); \
53
AV_WN32A(top2 + i, r); \
54
r = rnd(); \
55
AV_WN32A(bot1 + i, r); \
56
AV_WN32A(bot2 + i, r); \
57
r = rnd(); \
58
AV_WN32A(dst1 + i, r); \
59
AV_WN32A(dst2 + i, r); \
60
} \
61
} while (0)
62
63
#define check_blend_func() \
64
do { \
65
int i; \
66
declare_func(void, const uint8_t *top, ptrdiff_t top_linesize, \
67
const uint8_t *bottom, ptrdiff_t bottom_linesize, \
68
uint8_t *dst, ptrdiff_t dst_linesize, \
69
ptrdiff_t width, ptrdiff_t height, \
70
struct FilterParams *param, double *values); \
71
\
72
for (i = 0; i < BUF_UNITS - 1; i++) { \
73
int src_offset = i * SIZE_PER_UNIT + i;
/* Test various alignments */
\
74
int dst_offset = i * SIZE_PER_UNIT;
/* dst must be aligned */
\
75
randomize_buffers(); \
76
call_ref(top1 + src_offset, WIDTH, bot1 + src_offset, WIDTH, \
77
dst1 + dst_offset, WIDTH, WIDTH, HEIGHT, ¶m, NULL); \
78
call_new(top2 + src_offset, WIDTH, bot2 + src_offset, WIDTH, \
79
dst2 + dst_offset, WIDTH, WIDTH, HEIGHT, ¶m, NULL); \
80
if (memcmp(top1, top2, BUF_SIZE) || memcmp(bot1, bot2, BUF_SIZE) || memcmp(dst1, dst2, BUF_SIZE)) \
81
fail(); \
82
} \
83
bench_new(top2, WIDTH / 4, bot2, WIDTH / 4, dst2, WIDTH / 4, \
84
WIDTH / 4, HEIGHT / 4, ¶m, NULL); \
85
} while (0)
86
87
void
checkasm_check_blend
(
void
)
88
{
89
uint8_t
*top1 =
av_malloc
(
BUF_SIZE
);
90
uint8_t
*top2 =
av_malloc
(
BUF_SIZE
);
91
uint8_t
*bot1 =
av_malloc
(
BUF_SIZE
);
92
uint8_t
*bot2 =
av_malloc
(
BUF_SIZE
);
93
uint8_t
*dst1 =
av_malloc
(
BUF_SIZE
);
94
uint8_t
*dst2 =
av_malloc
(
BUF_SIZE
);
95
FilterParams
param = {
96
.
opacity
= 1.0,
97
};
98
99
#define check_and_report(name, val) \
100
param.mode = val; \
101
ff_blend_init(¶m, 0); \
102
if (check_func(param.blend, #name)) \
103
check_blend_func();
104
105
check_and_report
(addition,
BLEND_ADDITION
)
106
check_and_report
(addition128,
BLEND_ADDITION128
)
107
check_and_report
(and,
BLEND_AND
)
108
check_and_report
(average,
BLEND_AVERAGE
)
109
check_and_report
(darken,
BLEND_DARKEN
)
110
check_and_report
(difference128,
BLEND_DIFFERENCE128
)
111
check_and_report
(hardmix,
BLEND_HARDMIX
)
112
check_and_report
(lighten,
BLEND_LIGHTEN
)
113
check_and_report
(
multiply
,
BLEND_MULTIPLY
)
114
check_and_report
(or,
BLEND_OR
)
115
check_and_report
(phoenix,
BLEND_PHOENIX
)
116
check_and_report
(screen,
BLEND_SCREEN
)
117
check_and_report
(subtract,
BLEND_SUBTRACT
)
118
check_and_report
(xor,
BLEND_XOR
)
119
check_and_report
(difference,
BLEND_DIFFERENCE
)
120
check_and_report
(negation,
BLEND_NEGATION
)
121
122
report
(
"8bit"
);
123
124
av_freep
(&top1);
125
av_freep
(&top2);
126
av_freep
(&bot1);
127
av_freep
(&bot2);
128
av_freep
(&dst1);
129
av_freep
(&dst2);
130
}
FilterParams::opacity
double opacity
Definition:
blend.h:66
BLEND_DIFFERENCE
Definition:
blend.h:35
BLEND_PHOENIX
Definition:
blend.h:46
check_and_report
#define check_and_report(name, val)
BLEND_DIFFERENCE128
Definition:
blend.h:36
BLEND_NEGATION
Definition:
blend.h:43
report
#define report
Definition:
checkasm.h:92
uint8_t
uint8_t
Definition:
audio_convert.c:194
av_malloc
#define av_malloc(s)
Definition:
tableprint_vlc.h:31
BLEND_AND
Definition:
blend.h:31
checkasm.h
BLEND_DARKEN
Definition:
blend.h:34
multiply
static SoftFloat_IEEE754 multiply(SoftFloat_IEEE754 a, SoftFloat_IEEE754 b)
multiply two softfloats and handle the rounding off
Definition:
alsdec.c:1372
internal.h
common internal API header
BLEND_HARDMIX
Definition:
blend.h:54
intreadwrite.h
BLEND_ADDITION128
Definition:
blend.h:57
BLEND_MULTIPLY
Definition:
blend.h:42
BLEND_LIGHTEN
Definition:
blend.h:41
BLEND_SCREEN
Definition:
blend.h:49
FilterParams
filter data
Definition:
mlp.h:74
checkasm_check_blend
void checkasm_check_blend(void)
Definition:
vf_blend.c:87
common.h
common internal and external API header
BLEND_ADDITION
Definition:
blend.h:30
BLEND_AVERAGE
Definition:
blend.h:32
blend.h
BUF_SIZE
#define BUF_SIZE
Definition:
vf_blend.c:32
BLEND_OR
Definition:
blend.h:44
BLEND_SUBTRACT
Definition:
blend.h:51
av_freep
#define av_freep(p)
Definition:
tableprint_vlc.h:35
BLEND_XOR
Definition:
blend.h:53
Generated on Fri Jan 12 2018 01:45:53 for FFmpeg by
1.8.6