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
cbb71834
Commit
cbb71834
authored
Apr 06, 2012
by
Reimar Döffinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tiny_psnr: allow searching for optimal shift value.
Signed-off-by:
Reimar Döffinger
<
Reimar.Doeffinger@gmx.de
>
parent
50361e51
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
17 deletions
+39
-17
tiny_psnr.c
tests/tiny_psnr.c
+39
-17
No files found.
tests/tiny_psnr.c
View file @
cbb71834
...
...
@@ -103,34 +103,20 @@ static uint64_t int_sqrt(uint64_t a)
return
ret
;
}
int
main
(
int
argc
,
char
*
argv
[]
)
static
int
run_psnr
(
FILE
*
f
[
2
],
int
len
,
int
shift
,
int
skip_bytes
)
{
int
i
,
j
;
uint64_t
sse
=
0
;
uint64_t
dev
;
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
shift
=
argc
<
5
?
0
:
atoi
(
argv
[
4
]);
int
skip_bytes
=
argc
<
6
?
0
:
atoi
(
argv
[
5
]);
int
size0
=
0
;
int
size1
=
0
;
int
maxdist
=
0
;
if
(
argc
<
3
)
{
printf
(
"tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]
\n
"
);
printf
(
"WAV headers are skipped automatically.
\n
"
);
return
1
;
}
f
[
0
]
=
fopen
(
argv
[
1
],
"rb"
);
f
[
1
]
=
fopen
(
argv
[
2
],
"rb"
);
if
(
!
f
[
0
]
||
!
f
[
1
])
{
fprintf
(
stderr
,
"Could not open input files.
\n
"
);
return
1
;
}
rewind
(
f
[
0
]);
rewind
(
f
[
1
]);
for
(
i
=
0
;
i
<
2
;
i
++
)
{
uint8_t
*
p
=
buf
[
i
];
...
...
@@ -193,5 +179,41 @@ int main(int argc, char *argv[])
(
int
)(
dev
/
F
),
(
int
)(
dev
%
F
),
(
int
)(
psnr
/
F
),
(
int
)(
psnr
%
F
),
maxdist
,
size0
,
size1
);
return
psnr
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
FILE
*
f
[
2
];
int
len
=
argc
<
4
?
1
:
atoi
(
argv
[
3
]);
int
shift_first
=
argc
<
5
?
0
:
atoi
(
argv
[
4
]);
int
skip_bytes
=
argc
<
6
?
0
:
atoi
(
argv
[
5
]);
int
shift_last
=
shift_first
+
(
argc
<
7
?
0
:
atoi
(
argv
[
6
]));
int
shift
;
int
max_psnr
=
-
1
;
int
max_psnr_shift
=
0
;
if
(
argc
<
3
)
{
printf
(
"tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes> [<shift search range>]]]]
\n
"
);
printf
(
"WAV headers are skipped automatically.
\n
"
);
return
1
;
}
f
[
0
]
=
fopen
(
argv
[
1
],
"rb"
);
f
[
1
]
=
fopen
(
argv
[
2
],
"rb"
);
if
(
!
f
[
0
]
||
!
f
[
1
])
{
fprintf
(
stderr
,
"Could not open input files.
\n
"
);
return
1
;
}
for
(
shift
=
shift_first
;
shift
<=
shift_last
;
shift
++
)
{
int
psnr
=
run_psnr
(
f
,
len
,
shift
,
skip_bytes
);
if
(
psnr
>
max_psnr
||
(
shift
<
0
&&
psnr
==
max_psnr
))
{
max_psnr
=
psnr
;
max_psnr_shift
=
shift
;
}
}
if
(
shift_last
>
shift_first
)
printf
(
"Best PSNR is %3d.%02d for shift %i
\n
"
,
(
int
)(
max_psnr
/
F
),
(
int
)(
max_psnr
%
F
),
max_psnr_shift
);
return
0
;
}
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