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
9f1280de
Commit
9f1280de
authored
Jul 29, 2012
by
Mans Rullgard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tiny_psnr: support 32-bit float samples
Signed-off-by:
Mans Rullgard
<
mans@mansr.com
>
parent
f3eb0083
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
5 deletions
+49
-5
tiny_psnr.c
tests/tiny_psnr.c
+49
-5
No files found.
tests/tiny_psnr.c
View file @
9f1280de
...
...
@@ -24,6 +24,8 @@
#include <inttypes.h>
#include <assert.h>
#include "libavutil/intfloat.h"
#define FFMIN(a, b) ((a) > (b) ? (b) : (a))
#define F 100
#define SIZE 2048
...
...
@@ -88,6 +90,23 @@ static uint64_t int_sqrt(uint64_t a)
return
ret
;
}
static
int16_t
get_s16l
(
uint8_t
*
p
)
{
union
{
uint16_t
u
;
int16_t
s
;
}
v
;
v
.
u
=
p
[
0
]
|
p
[
1
]
<<
8
;
return
v
.
s
;
}
static
float
get_f32l
(
uint8_t
*
p
)
{
union
av_intfloat32
v
;
v
.
i
=
p
[
0
]
|
p
[
1
]
<<
8
|
p
[
2
]
<<
16
|
p
[
3
]
<<
24
;
return
v
.
f
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
i
,
j
;
...
...
@@ -96,8 +115,8 @@ int main(int argc, char *argv[])
FILE
*
f
[
2
];
uint8_t
buf
[
2
][
SIZE
];
uint64_t
psnr
;
int
len
=
argc
<
4
?
1
:
atoi
(
argv
[
3
])
;
int64_t
max
=
(
1
<<
(
8
*
len
))
-
1
;
int
len
=
1
;
int64_t
max
;
int
shift
=
argc
<
5
?
0
:
atoi
(
argv
[
4
]);
int
skip_bytes
=
argc
<
6
?
0
:
atoi
(
argv
[
5
]);
int
size0
=
0
;
...
...
@@ -110,6 +129,25 @@ int main(int argc, char *argv[])
return
1
;
}
if
(
argc
>
3
)
{
if
(
!
strcmp
(
argv
[
3
],
"u8"
))
{
len
=
1
;
}
else
if
(
!
strcmp
(
argv
[
3
],
"s16"
))
{
len
=
2
;
}
else
if
(
!
strcmp
(
argv
[
3
],
"f32"
))
{
len
=
4
;
}
else
{
char
*
end
;
len
=
strtol
(
argv
[
3
],
&
end
,
0
);
if
(
*
end
||
len
>
2
)
{
fprintf
(
stderr
,
"Unsupported sample format: %s
\n
"
,
argv
[
3
]);
return
1
;
}
}
}
max
=
(
1
<<
(
8
*
len
))
-
1
;
f
[
0
]
=
fopen
(
argv
[
1
],
"rb"
);
f
[
1
]
=
fopen
(
argv
[
2
],
"rb"
);
if
(
!
f
[
0
]
||
!
f
[
1
])
{
...
...
@@ -145,13 +183,19 @@ int main(int argc, char *argv[])
int
s0
=
fread
(
buf
[
0
],
1
,
SIZE
,
f
[
0
]);
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
+=
len
)
{
int64_t
a
=
buf
[
0
][
j
];
int64_t
b
=
buf
[
1
][
j
];
int
dist
;
if
(
len
==
2
)
{
a
=
(
int16_t
)(
a
|
(
buf
[
0
][
++
j
]
<<
8
));
b
=
(
int16_t
)(
b
|
(
buf
[
1
][
j
]
<<
8
));
a
=
get_s16l
(
buf
[
0
]
+
j
);
b
=
get_s16l
(
buf
[
1
]
+
j
);
}
else
if
(
len
==
4
)
{
a
=
get_f32l
(
buf
[
0
]
+
j
)
*
(
1
<<
24
);
b
=
get_f32l
(
buf
[
1
]
+
j
)
*
(
1
<<
24
);
}
else
{
a
=
buf
[
0
][
j
];
b
=
buf
[
1
][
j
];
}
sse
+=
(
a
-
b
)
*
(
a
-
b
);
dist
=
abs
(
a
-
b
);
...
...
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