Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
b481bbc3
Commit
b481bbc3
authored
Jan 18, 2012
by
Gaurav Narula
Committed by
Diego Biurrun
Jan 18, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: K&R formatting cosmetics for test programs
parent
aa2e4bb0
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
264 additions
and
251 deletions
+264
-251
audiogen.c
tests/audiogen.c
+36
-36
base64.c
tests/base64.c
+5
-4
rotozoom.c
tests/rotozoom.c
+58
-55
tiny_psnr.c
tests/tiny_psnr.c
+90
-87
videogen.c
tests/videogen.c
+75
-69
No files found.
tests/audiogen.c
View file @
b481bbc3
...
@@ -139,45 +139,45 @@ int main(int argc, char **argv)
...
@@ -139,45 +139,45 @@ int main(int argc, char **argv)
/* 1 second of single freq sinus at 1000 Hz */
/* 1 second of single freq sinus at 1000 Hz */
a
=
0
;
a
=
0
;
for
(
i
=
0
;
i
<
1
*
sample_rate
;
i
++
)
{
for
(
i
=
0
;
i
<
1
*
sample_rate
;
i
++
)
{
v
=
(
int_cos
(
a
)
*
10000
)
>>
FRAC_BITS
;
v
=
(
int_cos
(
a
)
*
10000
)
>>
FRAC_BITS
;
for
(
j
=
0
;
j
<
nb_channels
;
j
++
)
for
(
j
=
0
;
j
<
nb_channels
;
j
++
)
put_sample
(
v
);
put_sample
(
v
);
a
+=
(
1000
*
FRAC_ONE
)
/
sample_rate
;
a
+=
(
1000
*
FRAC_ONE
)
/
sample_rate
;
}
}
/* 1 second of varing frequency between 100 and 10000 Hz */
/* 1 second of varing frequency between 100 and 10000 Hz */
a
=
0
;
a
=
0
;
for
(
i
=
0
;
i
<
1
*
sample_rate
;
i
++
)
{
for
(
i
=
0
;
i
<
1
*
sample_rate
;
i
++
)
{
v
=
(
int_cos
(
a
)
*
10000
)
>>
FRAC_BITS
;
v
=
(
int_cos
(
a
)
*
10000
)
>>
FRAC_BITS
;
for
(
j
=
0
;
j
<
nb_channels
;
j
++
)
for
(
j
=
0
;
j
<
nb_channels
;
j
++
)
put_sample
(
v
);
put_sample
(
v
);
f
=
100
+
(((
10000
-
100
)
*
i
)
/
sample_rate
);
f
=
100
+
(((
10000
-
100
)
*
i
)
/
sample_rate
);
a
+=
(
f
*
FRAC_ONE
)
/
sample_rate
;
a
+=
(
f
*
FRAC_ONE
)
/
sample_rate
;
}
}
/* 0.5 second of low amplitude white noise */
/* 0.5 second of low amplitude white noise */
for
(
i
=
0
;
i
<
sample_rate
/
2
;
i
++
)
{
for
(
i
=
0
;
i
<
sample_rate
/
2
;
i
++
)
{
v
=
myrnd
(
&
seed
,
20000
)
-
10000
;
v
=
myrnd
(
&
seed
,
20000
)
-
10000
;
for
(
j
=
0
;
j
<
nb_channels
;
j
++
)
for
(
j
=
0
;
j
<
nb_channels
;
j
++
)
put_sample
(
v
);
put_sample
(
v
);
}
}
/* 0.5 second of high amplitude white noise */
/* 0.5 second of high amplitude white noise */
for
(
i
=
0
;
i
<
sample_rate
/
2
;
i
++
)
{
for
(
i
=
0
;
i
<
sample_rate
/
2
;
i
++
)
{
v
=
myrnd
(
&
seed
,
65535
)
-
32768
;
v
=
myrnd
(
&
seed
,
65535
)
-
32768
;
for
(
j
=
0
;
j
<
nb_channels
;
j
++
)
for
(
j
=
0
;
j
<
nb_channels
;
j
++
)
put_sample
(
v
);
put_sample
(
v
);
}
}
/* 1 second of unrelated ramps for each channel */
/* 1 second of unrelated ramps for each channel */
for
(
j
=
0
;
j
<
nb_channels
;
j
++
)
{
for
(
j
=
0
;
j
<
nb_channels
;
j
++
)
{
taba
[
j
]
=
0
;
taba
[
j
]
=
0
;
tabf1
[
j
]
=
100
+
myrnd
(
&
seed
,
5000
);
tabf1
[
j
]
=
100
+
myrnd
(
&
seed
,
5000
);
tabf2
[
j
]
=
100
+
myrnd
(
&
seed
,
5000
);
tabf2
[
j
]
=
100
+
myrnd
(
&
seed
,
5000
);
}
}
for
(
i
=
0
;
i
<
1
*
sample_rate
;
i
++
)
{
for
(
i
=
0
;
i
<
1
*
sample_rate
;
i
++
)
{
for
(
j
=
0
;
j
<
nb_channels
;
j
++
)
{
for
(
j
=
0
;
j
<
nb_channels
;
j
++
)
{
v
=
(
int_cos
(
taba
[
j
])
*
10000
)
>>
FRAC_BITS
;
v
=
(
int_cos
(
taba
[
j
])
*
10000
)
>>
FRAC_BITS
;
put_sample
(
v
);
put_sample
(
v
);
f
=
tabf1
[
j
]
+
(((
tabf2
[
j
]
-
tabf1
[
j
])
*
i
)
/
sample_rate
);
f
=
tabf1
[
j
]
+
(((
tabf2
[
j
]
-
tabf1
[
j
])
*
i
)
/
sample_rate
);
...
@@ -188,8 +188,8 @@ int main(int argc, char **argv)
...
@@ -188,8 +188,8 @@ int main(int argc, char **argv)
/* 2 seconds of 500 Hz with varying volume */
/* 2 seconds of 500 Hz with varying volume */
a
=
0
;
a
=
0
;
ampa
=
0
;
ampa
=
0
;
for
(
i
=
0
;
i
<
2
*
sample_rate
;
i
++
)
{
for
(
i
=
0
;
i
<
2
*
sample_rate
;
i
++
)
{
for
(
j
=
0
;
j
<
nb_channels
;
j
++
)
{
for
(
j
=
0
;
j
<
nb_channels
;
j
++
)
{
amp
=
((
FRAC_ONE
+
int_cos
(
ampa
))
*
5000
)
>>
FRAC_BITS
;
amp
=
((
FRAC_ONE
+
int_cos
(
ampa
))
*
5000
)
>>
FRAC_BITS
;
if
(
j
&
1
)
if
(
j
&
1
)
amp
=
10000
-
amp
;
amp
=
10000
-
amp
;
...
...
tests/base64.c
View file @
b481bbc3
...
@@ -31,7 +31,8 @@ int main(void)
...
@@ -31,7 +31,8 @@ int main(void)
int
out_len
=
0
;
int
out_len
=
0
;
int
in
;
int
in
;
#define putb64() do { \
#define putb64() \
do { \
putchar(b64[(i_bits << 6 >> i_shift) & 0x3f]); \
putchar(b64[(i_bits << 6 >> i_shift) & 0x3f]); \
out_len++; \
out_len++; \
i_shift -= 6; \
i_shift -= 6; \
...
...
tests/rotozoom.c
View file @
b481bbc3
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#include <inttypes.h>
#include <inttypes.h>
#define FIXP (1 << 16)
#define FIXP (1 << 16)
#define MY_PI 205887 //(M_PI * FIX)
#define MY_PI 205887 //
(M_PI * FIX)
static
int64_t
int_pow
(
int64_t
a
,
int
p
)
static
int64_t
int_pow
(
int64_t
a
,
int
p
)
{
{
...
@@ -47,7 +47,7 @@ static int64_t int_sin(int64_t a)
...
@@ -47,7 +47,7 @@ static int64_t int_sin(int64_t a)
if
(
a
>=
MY_PI
*
3
/
2
)
if
(
a
>=
MY_PI
*
3
/
2
)
a
-=
2
*
MY_PI
;
// -PI / 2 .. 3PI / 2
a
-=
2
*
MY_PI
;
// -PI / 2 .. 3PI / 2
if
(
a
>=
MY_PI
/
2
)
if
(
a
>=
MY_PI
/
2
)
a
=
MY_PI
-
a
;
// -PI / 2 .. PI / 2
a
=
MY_PI
-
a
;
// -PI / 2 .. PI / 2
return
a
-
int_pow
(
a
,
3
)
/
6
+
int_pow
(
a
,
5
)
/
120
-
int_pow
(
a
,
7
)
/
5040
;
return
a
-
int_pow
(
a
,
3
)
/
6
+
int_pow
(
a
,
5
)
/
120
-
int_pow
(
a
,
7
)
/
5040
;
...
@@ -181,8 +181,8 @@ unsigned char tab_r[256 * 256];
...
@@ -181,8 +181,8 @@ unsigned char tab_r[256 * 256];
unsigned
char
tab_g
[
256
*
256
];
unsigned
char
tab_g
[
256
*
256
];
unsigned
char
tab_b
[
256
*
256
];
unsigned
char
tab_b
[
256
*
256
];
int
h_cos
[
360
];
int
h_cos
[
360
];
int
h_sin
[
360
];
int
h_sin
[
360
];
static
int
ipol
(
uint8_t
*
src
,
int
x
,
int
y
)
static
int
ipol
(
uint8_t
*
src
,
int
x
,
int
y
)
{
{
...
@@ -202,8 +202,8 @@ static int ipol(uint8_t *src, int x, int y)
...
@@ -202,8 +202,8 @@ static int ipol(uint8_t *src, int x, int y)
static
void
gen_image
(
int
num
,
int
w
,
int
h
)
static
void
gen_image
(
int
num
,
int
w
,
int
h
)
{
{
const
int
c
=
h_cos
[
num
%
360
];
const
int
c
=
h_cos
[
num
%
360
];
const
int
s
=
h_sin
[
num
%
360
];
const
int
s
=
h_sin
[
num
%
360
];
const
int
xi
=
-
(
w
/
2
)
*
c
;
const
int
xi
=
-
(
w
/
2
)
*
c
;
const
int
yi
=
(
w
/
2
)
*
s
;
const
int
yi
=
(
w
/
2
)
*
s
;
...
@@ -223,10 +223,13 @@ static void gen_image(int num, int w, int h)
...
@@ -223,10 +223,13 @@ static void gen_image(int num, int w, int h)
y
=
yprime
+
yi
+
FIXP
*
h
/
2
;
y
=
yprime
+
yi
+
FIXP
*
h
/
2
;
yprime
+=
c
;
yprime
+=
c
;
for
(
i
=
0
;
i
<
w
;
i
++
)
{
for
(
i
=
0
;
i
<
w
;
i
++
)
{
x
+=
c
;
x
+=
c
;
y
-=
s
;
y
-=
s
;
put_pixel
(
i
,
j
,
ipol
(
tab_r
,
x
,
y
),
ipol
(
tab_g
,
x
,
y
),
ipol
(
tab_b
,
x
,
y
));
put_pixel
(
i
,
j
,
ipol
(
tab_r
,
x
,
y
),
ipol
(
tab_g
,
x
,
y
),
ipol
(
tab_b
,
x
,
y
));
}
}
}
}
}
}
...
@@ -265,7 +268,7 @@ static int init_demo(const char *filename)
...
@@ -265,7 +268,7 @@ static int init_demo(const char *filename)
/* tables sin/cos */
/* tables sin/cos */
for
(
i
=
0
;
i
<
360
;
i
++
)
{
for
(
i
=
0
;
i
<
360
;
i
++
)
{
radian
=
2
*
i
*
MY_PI
/
360
;
radian
=
2
*
i
*
MY_PI
/
360
;
h
=
2
*
FIXP
+
int_sin
(
radian
);
h
=
2
*
FIXP
+
int_sin
(
radian
);
h_cos
[
i
]
=
h
*
int_sin
(
radian
+
MY_PI
/
2
)
/
2
/
FIXP
;
h_cos
[
i
]
=
h
*
int_sin
(
radian
+
MY_PI
/
2
)
/
2
/
FIXP
;
h_sin
[
i
]
=
h
*
int_sin
(
radian
)
/
2
/
FIXP
;
h_sin
[
i
]
=
h
*
int_sin
(
radian
)
/
2
/
FIXP
;
}
}
...
...
tests/tiny_psnr.c
View file @
b481bbc3
...
@@ -24,11 +24,11 @@
...
@@ -24,11 +24,11 @@
#include <inttypes.h>
#include <inttypes.h>
#include <assert.h>
#include <assert.h>
#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
#define FFMIN(a,
b) ((a) > (b) ? (b) : (a))
#define F 100
#define F 100
#define SIZE 2048
#define SIZE 2048
uint64_t
exp16_table
[
21
]
=
{
uint64_t
exp16_table
[
21
]
=
{
65537
,
65537
,
65538
,
65538
,
65540
,
65540
,
...
@@ -53,63 +53,66 @@ uint64_t exp16_table[21]={
...
@@ -53,63 +53,66 @@ uint64_t exp16_table[21]={
};
};
// 16.16 fixpoint log()
// 16.16 fixpoint log()
static
int64_t
log16
(
uint64_t
a
){
static
int64_t
log16
(
uint64_t
a
)
{
int
i
;
int
i
;
int
out
=
0
;
int
out
=
0
;
if
(
a
<
1
<<
16
)
if
(
a
<
1
<<
16
)
return
-
log16
((
1LL
<<
32
)
/
a
);
return
-
log16
((
1LL
<<
32
)
/
a
);
a
<<=
16
;
a
<<=
16
;
for
(
i
=
20
;
i
>=
0
;
i
--
){
for
(
i
=
20
;
i
>=
0
;
i
--
)
{
int64_t
b
=
exp16_table
[
i
];
int64_t
b
=
exp16_table
[
i
];
if
(
a
<
(
b
<<
16
))
continue
;
if
(
a
<
(
b
<<
16
))
out
|=
1
<<
i
;
continue
;
a
=
((
a
/
b
)
<<
16
)
+
(((
a
%
b
)
<<
16
)
+
b
/
2
)
/
b
;
out
|=
1
<<
i
;
a
=
((
a
/
b
)
<<
16
)
+
(((
a
%
b
)
<<
16
)
+
b
/
2
)
/
b
;
}
}
return
out
;
return
out
;
}
}
static
uint64_t
int_sqrt
(
uint64_t
a
)
static
uint64_t
int_sqrt
(
uint64_t
a
)
{
{
uint64_t
ret
=
0
;
uint64_t
ret
=
0
;
uint64_t
ret_sq
=
0
;
int
s
;
int
s
;
uint64_t
ret_sq
=
0
;
for
(
s
=
31
;
s
>=
0
;
s
--
)
{
for
(
s
=
31
;
s
>=
0
;
s
--
)
{
uint64_t
b
=
ret_sq
+
(
1ULL
<<
(
s
*
2
))
+
(
ret
<<
s
)
*
2
;
uint64_t
b
=
ret_sq
+
(
1ULL
<<
(
s
*
2
))
+
(
ret
<<
s
)
*
2
;
if
(
b
<=
a
)
{
if
(
b
<=
a
)
{
ret_sq
=
b
;
ret_sq
=
b
;
ret
+=
1ULL
<<
s
;
ret
+=
1ULL
<<
s
;
}
}
}
}
return
ret
;
return
ret
;
}
}
int
main
(
int
argc
,
char
*
argv
[]){
int
main
(
int
argc
,
char
*
argv
[])
{
int
i
,
j
;
int
i
,
j
;
uint64_t
sse
=
0
;
uint64_t
sse
=
0
;
uint64_t
dev
;
uint64_t
dev
;
FILE
*
f
[
2
];
FILE
*
f
[
2
];
uint8_t
buf
[
2
][
SIZE
];
uint8_t
buf
[
2
][
SIZE
];
uint64_t
psnr
;
uint64_t
psnr
;
int
len
=
argc
<
4
?
1
:
atoi
(
argv
[
3
]);
int
len
=
argc
<
4
?
1
:
atoi
(
argv
[
3
]);
int64_t
max
=
(
1
<<
(
8
*
len
))
-
1
;
int64_t
max
=
(
1
<<
(
8
*
len
))
-
1
;
int
shift
=
argc
<
5
?
0
:
atoi
(
argv
[
4
]);
int
shift
=
argc
<
5
?
0
:
atoi
(
argv
[
4
]);
int
skip_bytes
=
argc
<
6
?
0
:
atoi
(
argv
[
5
]);
int
skip_bytes
=
argc
<
6
?
0
:
atoi
(
argv
[
5
]);
int
size0
=
0
;
int
size0
=
0
;
int
size1
=
0
;
int
size1
=
0
;
int
maxdist
=
0
;
int
maxdist
=
0
;
if
(
argc
<
3
)
{
if
(
argc
<
3
)
{
printf
(
"tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]
\n
"
);
printf
(
"tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]
\n
"
);
printf
(
"WAV headers are skipped automatically.
\n
"
);
printf
(
"WAV headers are skipped automatically.
\n
"
);
return
1
;
return
1
;
}
}
f
[
0
]
=
fopen
(
argv
[
1
],
"rb"
);
f
[
0
]
=
fopen
(
argv
[
1
],
"rb"
);
f
[
1
]
=
fopen
(
argv
[
2
],
"rb"
);
f
[
1
]
=
fopen
(
argv
[
2
],
"rb"
);
if
(
!
f
[
0
]
||
!
f
[
1
])
{
if
(
!
f
[
0
]
||
!
f
[
1
])
{
fprintf
(
stderr
,
"Could not open input files.
\n
"
);
fprintf
(
stderr
,
"Could not open input files.
\n
"
);
return
1
;
return
1
;
}
}
...
@@ -119,11 +122,11 @@ int main(int argc,char* argv[]){
...
@@ -119,11 +122,11 @@ int main(int argc,char* argv[]){
if
(
fread
(
p
,
1
,
12
,
f
[
i
])
!=
12
)
if
(
fread
(
p
,
1
,
12
,
f
[
i
])
!=
12
)
return
1
;
return
1
;
if
(
!
memcmp
(
p
,
"RIFF"
,
4
)
&&
if
(
!
memcmp
(
p
,
"RIFF"
,
4
)
&&
!
memcmp
(
p
+
8
,
"WAVE"
,
4
))
{
!
memcmp
(
p
+
8
,
"WAVE"
,
4
))
{
if
(
fread
(
p
,
1
,
8
,
f
[
i
])
!=
8
)
if
(
fread
(
p
,
1
,
8
,
f
[
i
])
!=
8
)
return
1
;
return
1
;
while
(
memcmp
(
p
,
"data"
,
4
))
{
while
(
memcmp
(
p
,
"data"
,
4
))
{
int
s
=
p
[
4
]
|
p
[
5
]
<<
8
|
p
[
6
]
<<
16
|
p
[
7
]
<<
24
;
int
s
=
p
[
4
]
|
p
[
5
]
<<
8
|
p
[
6
]
<<
16
|
p
[
7
]
<<
24
;
fseek
(
f
[
i
],
s
,
SEEK_CUR
);
fseek
(
f
[
i
],
s
,
SEEK_CUR
);
if
(
fread
(
p
,
1
,
8
,
f
[
i
])
!=
8
)
if
(
fread
(
p
,
1
,
8
,
f
[
i
])
!=
8
)
return
1
;
return
1
;
...
@@ -133,47 +136,47 @@ int main(int argc,char* argv[]){
...
@@ -133,47 +136,47 @@ int main(int argc,char* argv[]){
}
}
}
}
fseek
(
f
[
shift
<
0
],
abs
(
shift
),
SEEK_CUR
);
fseek
(
f
[
shift
<
0
],
abs
(
shift
),
SEEK_CUR
);
fseek
(
f
[
0
],
skip_bytes
,
SEEK_CUR
);
fseek
(
f
[
0
],
skip_bytes
,
SEEK_CUR
);
fseek
(
f
[
1
],
skip_bytes
,
SEEK_CUR
);
fseek
(
f
[
1
],
skip_bytes
,
SEEK_CUR
);
for
(;;)
{
for
(;;)
{
int
s0
=
fread
(
buf
[
0
],
1
,
SIZE
,
f
[
0
]);
int
s0
=
fread
(
buf
[
0
],
1
,
SIZE
,
f
[
0
]);
int
s1
=
fread
(
buf
[
1
],
1
,
SIZE
,
f
[
1
]);
int
s1
=
fread
(
buf
[
1
],
1
,
SIZE
,
f
[
1
]);
for
(
j
=
0
;
j
<
FFMIN
(
s0
,
s1
);
j
++
)
{
for
(
j
=
0
;
j
<
FFMIN
(
s0
,
s1
);
j
++
)
{
int64_t
a
=
buf
[
0
][
j
];
int64_t
a
=
buf
[
0
][
j
];
int64_t
b
=
buf
[
1
][
j
];
int64_t
b
=
buf
[
1
][
j
];
int
dist
;
int
dist
;
if
(
len
==
2
)
{
if
(
len
==
2
)
{
a
=
(
int16_t
)(
a
|
(
buf
[
0
][
++
j
]
<<
8
));
a
=
(
int16_t
)(
a
|
(
buf
[
0
][
++
j
]
<<
8
));
b
=
(
int16_t
)(
b
|
(
buf
[
1
][
j
]
<<
8
));
b
=
(
int16_t
)(
b
|
(
buf
[
1
][
j
]
<<
8
));
}
}
sse
+=
(
a
-
b
)
*
(
a
-
b
);
sse
+=
(
a
-
b
)
*
(
a
-
b
);
dist
=
abs
(
a
-
b
);
dist
=
abs
(
a
-
b
);
if
(
dist
>
maxdist
)
maxdist
=
dist
;
if
(
dist
>
maxdist
)
maxdist
=
dist
;
}
}
size0
+=
s0
;
size0
+=
s0
;
size1
+=
s1
;
size1
+=
s1
;
if
(
s0
+
s1
<=
0
)
if
(
s0
+
s1
<=
0
)
break
;
break
;
}
}
i
=
FFMIN
(
size0
,
size1
)
/
len
;
i
=
FFMIN
(
size0
,
size1
)
/
len
;
if
(
!
i
)
i
=
1
;
if
(
!
i
)
dev
=
int_sqrt
(
((
sse
/
i
)
*
F
*
F
)
+
(((
sse
%
i
)
*
F
*
F
)
+
i
/
2
)
/
i
);
i
=
1
;
if
(
sse
)
dev
=
int_sqrt
(((
sse
/
i
)
*
F
*
F
)
+
(((
sse
%
i
)
*
F
*
F
)
+
i
/
2
)
/
i
);
psnr
=
((
2
*
log16
(
max
<<
16
)
+
log16
(
i
)
-
log16
(
sse
))
*
284619LL
*
F
+
(
1LL
<<
31
))
/
(
1LL
<<
32
);
if
(
sse
)
psnr
=
((
2
*
log16
(
max
<<
16
)
+
log16
(
i
)
-
log16
(
sse
))
*
284619LL
*
F
+
(
1LL
<<
31
))
/
(
1LL
<<
32
);
else
else
psnr
=
1000
*
F
-
1
;
//
floating point free infinity :)
psnr
=
1000
*
F
-
1
;
//
floating point free infinity :)
printf
(
"stddev:%5d.%02d PSNR:%3d.%02d MAXDIFF:%5d bytes:%9d/%9d
\n
"
,
printf
(
"stddev:%5d.%02d PSNR:%3d.%02d MAXDIFF:%5d bytes:%9d/%9d
\n
"
,
(
int
)(
dev
/
F
),
(
int
)(
dev
%
F
),
(
int
)(
dev
/
F
),
(
int
)(
dev
%
F
),
(
int
)(
psnr
/
F
),
(
int
)(
psnr
%
F
),
(
int
)(
psnr
/
F
),
(
int
)(
psnr
%
F
),
maxdist
,
maxdist
,
size0
,
size1
);
size0
,
size1
);
return
0
;
return
0
;
}
}
tests/videogen.c
View file @
b481bbc3
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#define SCALEBITS 8
#define SCALEBITS 8
#define ONE_HALF (1 << (SCALEBITS - 1))
#define ONE_HALF (1 << (SCALEBITS - 1))
#define FIX(x) ((int) ((x) * (1L
<<
SCALEBITS) + 0.5))
#define FIX(x) ((int) ((x) * (1L
<<
SCALEBITS) + 0.5))
static
void
rgb24_to_yuv420p
(
uint8_t
*
lum
,
uint8_t
*
cb
,
uint8_t
*
cr
,
static
void
rgb24_to_yuv420p
(
uint8_t
*
lum
,
uint8_t
*
cb
,
uint8_t
*
cr
,
uint8_t
*
src
,
int
width
,
int
height
)
uint8_t
*
src
,
int
width
,
int
height
)
...
@@ -39,8 +39,8 @@ static void rgb24_to_yuv420p(uint8_t *lum, uint8_t *cb, uint8_t *cr,
...
@@ -39,8 +39,8 @@ static void rgb24_to_yuv420p(uint8_t *lum, uint8_t *cb, uint8_t *cr,
wrap
=
width
;
wrap
=
width
;
wrap3
=
width
*
3
;
wrap3
=
width
*
3
;
p
=
src
;
p
=
src
;
for
(
y
=
0
;
y
<
height
;
y
+=
2
)
{
for
(
y
=
0
;
y
<
height
;
y
+=
2
)
{
for
(
x
=
0
;
x
<
width
;
x
+=
2
)
{
for
(
x
=
0
;
x
<
width
;
x
+=
2
)
{
r
=
p
[
0
];
r
=
p
[
0
];
g
=
p
[
1
];
g
=
p
[
1
];
b
=
p
[
2
];
b
=
p
[
2
];
...
@@ -77,10 +77,16 @@ static void rgb24_to_yuv420p(uint8_t *lum, uint8_t *cb, uint8_t *cr,
...
@@ -77,10 +77,16 @@ static void rgb24_to_yuv420p(uint8_t *lum, uint8_t *cb, uint8_t *cr,
lum
[
1
]
=
(
FIX
(
0
.
29900
)
*
r
+
FIX
(
0
.
58700
)
*
g
+
lum
[
1
]
=
(
FIX
(
0
.
29900
)
*
r
+
FIX
(
0
.
58700
)
*
g
+
FIX
(
0
.
11400
)
*
b
+
ONE_HALF
)
>>
SCALEBITS
;
FIX
(
0
.
11400
)
*
b
+
ONE_HALF
)
>>
SCALEBITS
;
cb
[
0
]
=
((
-
FIX
(
0
.
16874
)
*
r1
-
FIX
(
0
.
33126
)
*
g1
+
cb
[
0
]
=
128
+
((
-
FIX
(
0
.
16874
)
*
r1
-
FIX
(
0
.
50000
)
*
b1
+
4
*
ONE_HALF
-
1
)
>>
(
SCALEBITS
+
2
))
+
128
;
FIX
(
0
.
33126
)
*
g1
+
cr
[
0
]
=
((
FIX
(
0
.
50000
)
*
r1
-
FIX
(
0
.
41869
)
*
g1
-
FIX
(
0
.
50000
)
*
b1
+
FIX
(
0
.
08131
)
*
b1
+
4
*
ONE_HALF
-
1
)
>>
(
SCALEBITS
+
2
))
+
128
;
4
*
ONE_HALF
-
1
)
>>
(
SCALEBITS
+
2
));
cr
[
0
]
=
128
+
((
FIX
(
0
.
50000
)
*
r1
-
FIX
(
0
.
41869
)
*
g1
-
FIX
(
0
.
08131
)
*
b1
+
4
*
ONE_HALF
-
1
)
>>
(
SCALEBITS
+
2
));
cb
++
;
cb
++
;
cr
++
;
cr
++
;
...
@@ -111,14 +117,14 @@ static void pgmyuv_save(const char *filename, int w, int h,
...
@@ -111,14 +117,14 @@ static void pgmyuv_save(const char *filename, int w, int h,
rgb24_to_yuv420p
(
lum_tab
,
cb_tab
,
cr_tab
,
rgb_tab
,
w
,
h
);
rgb24_to_yuv420p
(
lum_tab
,
cb_tab
,
cr_tab
,
rgb_tab
,
w
,
h
);
f
=
fopen
(
filename
,
"wb"
);
f
=
fopen
(
filename
,
"wb"
);
fprintf
(
f
,
"P5
\n
%d %d
\n
%d
\n
"
,
w
,
(
h
*
3
)
/
2
,
255
);
fprintf
(
f
,
"P5
\n
%d %d
\n
%d
\n
"
,
w
,
(
h
*
3
)
/
2
,
255
);
fwrite
(
lum_tab
,
1
,
w
*
h
,
f
);
fwrite
(
lum_tab
,
1
,
w
*
h
,
f
);
h2
=
h
/
2
;
h2
=
h
/
2
;
w2
=
w
/
2
;
w2
=
w
/
2
;
cb
=
cb_tab
;
cb
=
cb_tab
;
cr
=
cr_tab
;
cr
=
cr_tab
;
for
(
i
=
0
;
i
<
h2
;
i
++
)
{
for
(
i
=
0
;
i
<
h2
;
i
++
)
{
fwrite
(
cb
,
1
,
w2
,
f
);
fwrite
(
cb
,
1
,
w2
,
f
);
fwrite
(
cr
,
1
,
w2
,
f
);
fwrite
(
cr
,
1
,
w2
,
f
);
cb
+=
w2
;
cb
+=
w2
;
...
@@ -204,7 +210,7 @@ static void gen_image(int num, int w, int h)
...
@@ -204,7 +210,7 @@ static void gen_image(int num, int w, int h)
unsigned
int
seed1
;
unsigned
int
seed1
;
if
(
num
==
0
)
{
if
(
num
==
0
)
{
for
(
i
=
0
;
i
<
NB_OBJS
;
i
++
)
{
for
(
i
=
0
;
i
<
NB_OBJS
;
i
++
)
{
objs
[
i
].
x
=
myrnd
(
&
seed
,
w
);
objs
[
i
].
x
=
myrnd
(
&
seed
,
w
);
objs
[
i
].
y
=
myrnd
(
&
seed
,
h
);
objs
[
i
].
y
=
myrnd
(
&
seed
,
h
);
objs
[
i
].
w
=
myrnd
(
&
seed
,
w
/
4
)
+
10
;
objs
[
i
].
w
=
myrnd
(
&
seed
,
w
/
4
)
+
10
;
...
@@ -219,8 +225,8 @@ static void gen_image(int num, int w, int h)
...
@@ -219,8 +225,8 @@ static void gen_image(int num, int w, int h)
/* test motion estimation */
/* test motion estimation */
dx
=
int_cos
(
num
*
FRAC_ONE
/
50
)
*
35
;
dx
=
int_cos
(
num
*
FRAC_ONE
/
50
)
*
35
;
dy
=
int_cos
(
num
*
FRAC_ONE
/
50
+
FRAC_ONE
/
10
)
*
30
;
dy
=
int_cos
(
num
*
FRAC_ONE
/
50
+
FRAC_ONE
/
10
)
*
30
;
for
(
y
=
0
;
y
<
h
;
y
++
)
{
for
(
y
=
0
;
y
<
h
;
y
++
)
{
for
(
x
=
0
;
x
<
w
;
x
++
)
{
for
(
x
=
0
;
x
<
w
;
x
++
)
{
x1
=
(
x
<<
FRAC_BITS
)
+
dx
;
x1
=
(
x
<<
FRAC_BITS
)
+
dx
;
y1
=
(
y
<<
FRAC_BITS
)
+
dy
;
y1
=
(
y
<<
FRAC_BITS
)
+
dy
;
r
=
((
y1
*
7
)
>>
FRAC_BITS
)
&
0xff
;
r
=
((
y1
*
7
)
>>
FRAC_BITS
)
&
0xff
;
...
@@ -232,8 +238,8 @@ static void gen_image(int num, int w, int h)
...
@@ -232,8 +238,8 @@ static void gen_image(int num, int w, int h)
/* then some noise with very high intensity to test saturation */
/* then some noise with very high intensity to test saturation */
seed1
=
num
;
seed1
=
num
;
for
(
y
=
0
;
y
<
NOISE_W
;
y
++
)
{
for
(
y
=
0
;
y
<
NOISE_W
;
y
++
)
{
for
(
x
=
0
;
x
<
NOISE_W
;
x
++
)
{
for
(
x
=
0
;
x
<
NOISE_W
;
x
++
)
{
r
=
myrnd
(
&
seed1
,
256
);
r
=
myrnd
(
&
seed1
,
256
);
g
=
myrnd
(
&
seed1
,
256
);
g
=
myrnd
(
&
seed1
,
256
);
b
=
myrnd
(
&
seed1
,
256
);
b
=
myrnd
(
&
seed1
,
256
);
...
@@ -242,11 +248,11 @@ static void gen_image(int num, int w, int h)
...
@@ -242,11 +248,11 @@ static void gen_image(int num, int w, int h)
}
}
/* then moving objects */
/* then moving objects */
for
(
i
=
0
;
i
<
NB_OBJS
;
i
++
)
{
for
(
i
=
0
;
i
<
NB_OBJS
;
i
++
)
{
VObj
*
p
=
&
objs
[
i
];
VObj
*
p
=
&
objs
[
i
];
seed1
=
i
;
seed1
=
i
;
for
(
y
=
0
;
y
<
p
->
h
;
y
++
)
{
for
(
y
=
0
;
y
<
p
->
h
;
y
++
)
{
for
(
x
=
0
;
x
<
p
->
w
;
x
++
)
{
for
(
x
=
0
;
x
<
p
->
w
;
x
++
)
{
r
=
p
->
r
;
r
=
p
->
r
;
g
=
p
->
g
;
g
=
p
->
g
;
b
=
p
->
b
;
b
=
p
->
b
;
...
@@ -281,7 +287,7 @@ int main(int argc, char **argv)
...
@@ -281,7 +287,7 @@ int main(int argc, char **argv)
width
=
w
;
width
=
w
;
height
=
h
;
height
=
h
;
for
(
i
=
0
;
i
<
DEFAULT_NB_PICT
;
i
++
)
{
for
(
i
=
0
;
i
<
DEFAULT_NB_PICT
;
i
++
)
{
snprintf
(
buf
,
sizeof
(
buf
),
"%s%02d.pgm"
,
argv
[
1
],
i
);
snprintf
(
buf
,
sizeof
(
buf
),
"%s%02d.pgm"
,
argv
[
1
],
i
);
gen_image
(
i
,
w
,
h
);
gen_image
(
i
,
w
,
h
);
pgmyuv_save
(
buf
,
w
,
h
,
rgb_tab
);
pgmyuv_save
(
buf
,
w
,
h
,
rgb_tab
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment