Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
0c90161f
Commit
0c90161f
authored
20 years ago
by
Michael Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
signed 16bit support
Originally committed as revision 3913 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
b2eef2f0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/tiny_psnr.c
+18
-10
18 additions, 10 deletions
tests/tiny_psnr.c
with
18 additions
and
10 deletions
tests/tiny_psnr.c
+
18
−
10
View file @
0c90161f
...
...
@@ -24,7 +24,7 @@
#define F 100
#define SIZE 2048
uint64_t
exp16_table
[
2
0
]
=
{
uint64_t
exp16_table
[
2
1
]
=
{
65537
,
65538
,
65540
,
...
...
@@ -45,6 +45,7 @@ uint64_t exp16_table[20]={
484249
,
3578144
,
195360063
,
582360139072LL
,
};
#if 1
// 16.16 fixpoint exp()
...
...
@@ -60,14 +61,15 @@ static unsigned int exp16(unsigned int a){
return
out
;
}
// 16.16 fixpoint log()
static
u
int64_t
log16
(
uint64_t
a
){
static
int64_t
log16
(
uint64_t
a
){
int
i
;
int
out
=
0
;
assert
(
a
>=
(
1
<<
16
));
if
(
a
<
1
<<
16
)
return
-
log16
((
1LL
<<
32
)
/
a
);
a
<<=
16
;
for
(
i
=
19
;
i
>=
0
;
i
--
){
for
(
i
=
20
;
i
>=
0
;
i
--
){
int64_t
b
=
exp16_table
[
i
];
if
(
a
<
(
b
<<
16
))
continue
;
out
|=
1
<<
i
;
...
...
@@ -100,8 +102,10 @@ int main(int argc,char* argv[]){
FILE
*
f
[
2
];
uint8_t
buf
[
2
][
SIZE
];
uint64_t
psnr
;
int
len
=
argc
<
4
?
1
:
2
;
int64_t
max
=
(
1
<<
(
8
*
len
))
-
1
;
if
(
argc
!=
3
){
if
(
argc
<
3
){
printf
(
"tiny_psnr <file1> <file2>
\n
"
);
return
-
1
;
}
...
...
@@ -114,16 +118,20 @@ int main(int argc,char* argv[]){
if
(
fread
(
buf
[
1
],
SIZE
,
1
,
f
[
1
])
!=
1
)
break
;
for
(
j
=
0
;
j
<
SIZE
;
i
++
,
j
++
){
const
int
a
=
buf
[
0
][
j
];
const
int
b
=
buf
[
1
][
j
];
int64_t
a
=
buf
[
0
][
j
];
int64_t
b
=
buf
[
1
][
j
];
if
(
len
==
2
){
a
=
(
int16_t
)(
a
|
(
buf
[
0
][
++
j
]
<<
8
));
b
=
(
int16_t
)(
b
|
(
buf
[
1
][
j
]
<<
8
));
}
sse
+=
(
a
-
b
)
*
(
a
-
b
);
}
}
if
(
!
i
)
i
=
1
;
dev
=
int_sqrt
((
sse
*
F
*
F
)
/
i
);
dev
=
int_sqrt
(
(
(
sse
/
i
)
*
F
*
F
)
+
(((
sse
%
i
)
*
F
*
F
)
+
i
/
2
)
/
i
);
if
(
sse
)
psnr
=
(
log16
(
256
*
256
*
255
*
255LL
*
i
/
sse
)
*
284619LL
*
F
+
(
1
<<
31
))
/
(
1LL
<<
32
);
psnr
=
(
(
2
*
log16
(
max
<<
16
)
+
log16
(
i
)
-
log16
(
sse
)
)
*
284619LL
*
F
+
(
1
<<
31
))
/
(
1LL
<<
32
);
else
psnr
=
100
*
F
-
1
;
//floating point free infinity :)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment