mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-06 16:56:55 +08:00
tidy applied with all cppcoreguidelines and google
TBR=braveyao@chromium.org Bug: libyuv:750 Test: builds and runs and passes more tidy tests Change-Id: I1400a915ee5734c38d19dab9cf1f210ca43d17fc Reviewed-on: https://chromium-review.googlesource.com/905810 Reviewed-by: Frank Barchard <fbarchard@chromium.org>
This commit is contained in:
parent
e1f6c1c0b5
commit
b792e0dbc1
@ -263,8 +263,9 @@ double SumSquareErrorToPsnr(uint64_t sse, uint64_t count) {
|
|||||||
psnr = kMaxPsnr; // Limit to prevent divide by 0
|
psnr = kMaxPsnr; // Limit to prevent divide by 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if (psnr > kMaxPsnr)
|
if (psnr > kMaxPsnr) {
|
||||||
psnr = kMaxPsnr;
|
psnr = kMaxPsnr;
|
||||||
|
}
|
||||||
|
|
||||||
return psnr;
|
return psnr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -504,9 +504,10 @@ TEST_F(LibYUVCompareTest, BenchmarkPsnr_Opt) {
|
|||||||
MaskCpuFlags(benchmark_cpu_info_);
|
MaskCpuFlags(benchmark_cpu_info_);
|
||||||
|
|
||||||
double opt_time = get_time();
|
double opt_time = get_time();
|
||||||
for (int i = 0; i < benchmark_iterations_; ++i)
|
for (int i = 0; i < benchmark_iterations_; ++i) {
|
||||||
CalcFramePsnr(src_a, benchmark_width_, src_b, benchmark_width_,
|
CalcFramePsnr(src_a, benchmark_width_, src_b, benchmark_width_,
|
||||||
benchmark_width_, benchmark_height_);
|
benchmark_width_, benchmark_height_);
|
||||||
|
}
|
||||||
|
|
||||||
opt_time = (get_time() - opt_time) / benchmark_iterations_;
|
opt_time = (get_time() - opt_time) / benchmark_iterations_;
|
||||||
printf("BenchmarkPsnr_Opt - %8.2f us opt\n", opt_time * 1e6);
|
printf("BenchmarkPsnr_Opt - %8.2f us opt\n", opt_time * 1e6);
|
||||||
@ -528,9 +529,10 @@ TEST_F(LibYUVCompareTest, BenchmarkPsnr_Unaligned) {
|
|||||||
MaskCpuFlags(benchmark_cpu_info_);
|
MaskCpuFlags(benchmark_cpu_info_);
|
||||||
|
|
||||||
double opt_time = get_time();
|
double opt_time = get_time();
|
||||||
for (int i = 0; i < benchmark_iterations_; ++i)
|
for (int i = 0; i < benchmark_iterations_; ++i) {
|
||||||
CalcFramePsnr(src_a + 1, benchmark_width_, src_b, benchmark_width_,
|
CalcFramePsnr(src_a + 1, benchmark_width_, src_b, benchmark_width_,
|
||||||
benchmark_width_, benchmark_height_);
|
benchmark_width_, benchmark_height_);
|
||||||
|
}
|
||||||
|
|
||||||
opt_time = (get_time() - opt_time) / benchmark_iterations_;
|
opt_time = (get_time() - opt_time) / benchmark_iterations_;
|
||||||
printf("BenchmarkPsnr_Opt - %8.2f us opt\n", opt_time * 1e6);
|
printf("BenchmarkPsnr_Opt - %8.2f us opt\n", opt_time * 1e6);
|
||||||
@ -629,9 +631,10 @@ TEST_F(LibYUVCompareTest, DISABLED_BenchmarkSsim_Opt) {
|
|||||||
MaskCpuFlags(benchmark_cpu_info_);
|
MaskCpuFlags(benchmark_cpu_info_);
|
||||||
|
|
||||||
double opt_time = get_time();
|
double opt_time = get_time();
|
||||||
for (int i = 0; i < benchmark_iterations_; ++i)
|
for (int i = 0; i < benchmark_iterations_; ++i) {
|
||||||
CalcFrameSsim(src_a, benchmark_width_, src_b, benchmark_width_,
|
CalcFrameSsim(src_a, benchmark_width_, src_b, benchmark_width_,
|
||||||
benchmark_width_, benchmark_height_);
|
benchmark_width_, benchmark_height_);
|
||||||
|
}
|
||||||
|
|
||||||
opt_time = (get_time() - opt_time) / benchmark_iterations_;
|
opt_time = (get_time() - opt_time) / benchmark_iterations_;
|
||||||
printf("BenchmarkSsim_Opt - %8.2f us opt\n", opt_time * 1e6);
|
printf("BenchmarkSsim_Opt - %8.2f us opt\n", opt_time * 1e6);
|
||||||
|
|||||||
@ -2191,12 +2191,15 @@ TEST_F(LibYUVConvertTest, TestH420ToARGB) {
|
|||||||
int count_g = 0;
|
int count_g = 0;
|
||||||
int count_r = 0;
|
int count_r = 0;
|
||||||
for (int i = 0; i < kSize; ++i) {
|
for (int i = 0; i < kSize; ++i) {
|
||||||
if (histogram_b[i])
|
if (histogram_b[i]) {
|
||||||
++count_b;
|
++count_b;
|
||||||
if (histogram_g[i])
|
}
|
||||||
|
if (histogram_g[i]) {
|
||||||
++count_g;
|
++count_g;
|
||||||
if (histogram_r[i])
|
}
|
||||||
|
if (histogram_r[i]) {
|
||||||
++count_r;
|
++count_r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("uniques: B %d, G, %d, R %d\n", count_b, count_g, count_r);
|
printf("uniques: B %d, G, %d, R %d\n", count_b, count_g, count_r);
|
||||||
|
|
||||||
@ -2249,12 +2252,15 @@ TEST_F(LibYUVConvertTest, TestH010ToARGB) {
|
|||||||
int count_g = 0;
|
int count_g = 0;
|
||||||
int count_r = 0;
|
int count_r = 0;
|
||||||
for (int i = 0; i < kSize; ++i) {
|
for (int i = 0; i < kSize; ++i) {
|
||||||
if (histogram_b[i])
|
if (histogram_b[i]) {
|
||||||
++count_b;
|
++count_b;
|
||||||
if (histogram_g[i])
|
}
|
||||||
|
if (histogram_g[i]) {
|
||||||
++count_g;
|
++count_g;
|
||||||
if (histogram_r[i])
|
}
|
||||||
|
if (histogram_r[i]) {
|
||||||
++count_r;
|
++count_r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("uniques: B %d, G, %d, R %d\n", count_b, count_g, count_r);
|
printf("uniques: B %d, G, %d, R %d\n", count_b, count_g, count_r);
|
||||||
|
|
||||||
@ -2309,12 +2315,15 @@ TEST_F(LibYUVConvertTest, TestH010ToAR30) {
|
|||||||
int count_g = 0;
|
int count_g = 0;
|
||||||
int count_r = 0;
|
int count_r = 0;
|
||||||
for (int i = 0; i < kSize; ++i) {
|
for (int i = 0; i < kSize; ++i) {
|
||||||
if (histogram_b[i])
|
if (histogram_b[i]) {
|
||||||
++count_b;
|
++count_b;
|
||||||
if (histogram_g[i])
|
}
|
||||||
|
if (histogram_g[i]) {
|
||||||
++count_g;
|
++count_g;
|
||||||
if (histogram_r[i])
|
}
|
||||||
|
if (histogram_r[i]) {
|
||||||
++count_r;
|
++count_r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("uniques: B %d, G, %d, R %d\n", count_b, count_g, count_r);
|
printf("uniques: B %d, G, %d, R %d\n", count_b, count_g, count_r);
|
||||||
|
|
||||||
@ -2368,12 +2377,15 @@ TEST_F(LibYUVConvertTest, TestH420ToAR30) {
|
|||||||
int count_g = 0;
|
int count_g = 0;
|
||||||
int count_r = 0;
|
int count_r = 0;
|
||||||
for (int i = 0; i < kHistSize; ++i) {
|
for (int i = 0; i < kHistSize; ++i) {
|
||||||
if (histogram_b[i])
|
if (histogram_b[i]) {
|
||||||
++count_b;
|
++count_b;
|
||||||
if (histogram_g[i])
|
}
|
||||||
|
if (histogram_g[i]) {
|
||||||
++count_g;
|
++count_g;
|
||||||
if (histogram_r[i])
|
}
|
||||||
|
if (histogram_r[i]) {
|
||||||
++count_r;
|
++count_r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("uniques: B %d, G, %d, R %d\n", count_b, count_g, count_r);
|
printf("uniques: B %d, G, %d, R %d\n", count_b, count_g, count_r);
|
||||||
|
|
||||||
|
|||||||
@ -1390,8 +1390,9 @@ TEST_F(LibYUVPlanarTest, TestCopyPlane) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < y_plane_size; ++i) {
|
for (i = 0; i < y_plane_size; ++i) {
|
||||||
if (dst_c[i] != dst_opt[i])
|
if (dst_c[i] != dst_opt[i]) {
|
||||||
++err;
|
++err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free_aligned_buffer_page_end(orig_y);
|
free_aligned_buffer_page_end(orig_y);
|
||||||
|
|||||||
@ -129,7 +129,6 @@ class LibYUVColorTest : public ::testing::Test {
|
|||||||
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
|
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
|
||||||
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
|
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
|
||||||
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
|
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
|
||||||
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
|
|
||||||
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
|
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
|
||||||
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
|
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
|
||||||
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
|
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
|
||||||
@ -142,7 +141,6 @@ class LibYUVConvertTest : public ::testing::Test {
|
|||||||
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
|
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
|
||||||
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
|
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
|
||||||
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
|
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
|
||||||
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
|
|
||||||
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
|
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
|
||||||
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
|
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
|
||||||
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
|
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
|
||||||
@ -155,7 +153,6 @@ class LibYUVScaleTest : public ::testing::Test {
|
|||||||
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
|
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
|
||||||
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
|
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
|
||||||
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
|
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
|
||||||
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
|
|
||||||
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
|
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
|
||||||
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
|
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
|
||||||
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
|
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
|
||||||
@ -168,7 +165,6 @@ class LibYUVRotateTest : public ::testing::Test {
|
|||||||
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
|
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
|
||||||
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
|
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
|
||||||
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
|
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
|
||||||
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
|
|
||||||
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
|
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
|
||||||
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
|
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
|
||||||
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
|
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
|
||||||
@ -181,7 +177,6 @@ class LibYUVPlanarTest : public ::testing::Test {
|
|||||||
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
|
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
|
||||||
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
|
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
|
||||||
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
|
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
|
||||||
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
|
|
||||||
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
|
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
|
||||||
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
|
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
|
||||||
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
|
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
|
||||||
@ -194,7 +189,6 @@ class LibYUVBaseTest : public ::testing::Test {
|
|||||||
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
|
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
|
||||||
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
|
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
|
||||||
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
|
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
|
||||||
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
|
|
||||||
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
|
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
|
||||||
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
|
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
|
||||||
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
|
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
|
||||||
@ -207,7 +201,6 @@ class LibYUVCompareTest : public ::testing::Test {
|
|||||||
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
|
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
|
||||||
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
|
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
|
||||||
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
|
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
|
||||||
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
|
|
||||||
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
|
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
|
||||||
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
|
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
|
||||||
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
|
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
|
||||||
|
|||||||
@ -39,12 +39,14 @@ int main(int argc, char** argv) {
|
|||||||
int amt2 = 0;
|
int amt2 = 0;
|
||||||
do {
|
do {
|
||||||
amt1 = static_cast<int>(fread(buf1, 1, kBlockSize, fin1));
|
amt1 = static_cast<int>(fread(buf1, 1, kBlockSize, fin1));
|
||||||
if (amt1 > 0)
|
if (amt1 > 0) {
|
||||||
hash1 = libyuv::HashDjb2(buf1, amt1, hash1);
|
hash1 = libyuv::HashDjb2(buf1, amt1, hash1);
|
||||||
|
}
|
||||||
if (fin2) {
|
if (fin2) {
|
||||||
amt2 = static_cast<int>(fread(buf2, 1, kBlockSize, fin2));
|
amt2 = static_cast<int>(fread(buf2, 1, kBlockSize, fin2));
|
||||||
if (amt2 > 0)
|
if (amt2 > 0) {
|
||||||
hash2 = libyuv::HashDjb2(buf2, amt2, hash2);
|
hash2 = libyuv::HashDjb2(buf2, amt2, hash2);
|
||||||
|
}
|
||||||
int amt_min = (amt1 < amt2) ? amt1 : amt2;
|
int amt_min = (amt1 < amt2) ? amt1 : amt2;
|
||||||
size_min += amt_min;
|
size_min += amt_min;
|
||||||
sum_square_err += libyuv::ComputeSumSquareError(buf1, buf2, amt_min);
|
sum_square_err += libyuv::ComputeSumSquareError(buf1, buf2, amt_min);
|
||||||
|
|||||||
@ -280,8 +280,9 @@ double ComputeSumSquareError(const uint8_t* src_a,
|
|||||||
// Returns 128.0 (kMaxPSNR) if sse is 0 (perfect match).
|
// Returns 128.0 (kMaxPSNR) if sse is 0 (perfect match).
|
||||||
double ComputePSNR(double sse, double size) {
|
double ComputePSNR(double sse, double size) {
|
||||||
const double kMINSSE = 255.0 * 255.0 * size / pow(10.0, kMaxPSNR / 10.0);
|
const double kMINSSE = 255.0 * 255.0 * size / pow(10.0, kMaxPSNR / 10.0);
|
||||||
if (sse <= kMINSSE)
|
if (sse <= kMINSSE) {
|
||||||
sse = kMINSSE; // Produces max PSNR of 128
|
sse = kMINSSE; // Produces max PSNR of 128
|
||||||
|
}
|
||||||
return 10.0 * log10(255.0 * 255.0 * size / sse);
|
return 10.0 * log10(255.0 * 255.0 * size / sse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -109,10 +109,12 @@ bool ExtractResolutionFromFilename(const char* name,
|
|||||||
// This can be useful when comparing codecs that are inconsistant about Y
|
// This can be useful when comparing codecs that are inconsistant about Y
|
||||||
uint8_t ScaleY(uint8_t y) {
|
uint8_t ScaleY(uint8_t y) {
|
||||||
int ny = (y - 16) * 256 / 224;
|
int ny = (y - 16) * 256 / 224;
|
||||||
if (ny < 0)
|
if (ny < 0) {
|
||||||
ny = 0;
|
ny = 0;
|
||||||
if (ny > 255)
|
}
|
||||||
|
if (ny > 255) {
|
||||||
ny = 255;
|
ny = 255;
|
||||||
|
}
|
||||||
return static_cast<uint8_t>(ny);
|
return static_cast<uint8_t>(ny);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,8 +152,9 @@ void PrintHelp(const char* program) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ParseOptions(int argc, const char* argv[]) {
|
void ParseOptions(int argc, const char* argv[]) {
|
||||||
if (argc <= 1)
|
if (argc <= 1) {
|
||||||
PrintHelp(argv[0]);
|
PrintHelp(argv[0]);
|
||||||
|
}
|
||||||
for (int c = 1; c < argc; ++c) {
|
for (int c = 1; c < argc; ++c) {
|
||||||
if (!strcmp(argv[c], "-v")) {
|
if (!strcmp(argv[c], "-v")) {
|
||||||
verbose = true;
|
verbose = true;
|
||||||
@ -301,12 +304,15 @@ bool UpdateMetrics(uint8_t* ch_org,
|
|||||||
cur_distortion_psnr->all += distorted_frame->all;
|
cur_distortion_psnr->all += distorted_frame->all;
|
||||||
|
|
||||||
bool ismin = false;
|
bool ismin = false;
|
||||||
if (distorted_frame->y < cur_distortion_psnr->min_y)
|
if (distorted_frame->y < cur_distortion_psnr->min_y) {
|
||||||
cur_distortion_psnr->min_y = distorted_frame->y;
|
cur_distortion_psnr->min_y = distorted_frame->y;
|
||||||
if (distorted_frame->u < cur_distortion_psnr->min_u)
|
}
|
||||||
|
if (distorted_frame->u < cur_distortion_psnr->min_u) {
|
||||||
cur_distortion_psnr->min_u = distorted_frame->u;
|
cur_distortion_psnr->min_u = distorted_frame->u;
|
||||||
if (distorted_frame->v < cur_distortion_psnr->min_v)
|
}
|
||||||
|
if (distorted_frame->v < cur_distortion_psnr->min_v) {
|
||||||
cur_distortion_psnr->min_v = distorted_frame->v;
|
cur_distortion_psnr->min_v = distorted_frame->v;
|
||||||
|
}
|
||||||
if (distorted_frame->all < cur_distortion_psnr->min_all) {
|
if (distorted_frame->all < cur_distortion_psnr->min_all) {
|
||||||
cur_distortion_psnr->min_all = distorted_frame->all;
|
cur_distortion_psnr->min_all = distorted_frame->all;
|
||||||
cur_distortion_psnr->min_frame = number_of_frames;
|
cur_distortion_psnr->min_frame = number_of_frames;
|
||||||
@ -429,8 +435,9 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
int number_of_frames;
|
int number_of_frames;
|
||||||
for (number_of_frames = 0;; ++number_of_frames) {
|
for (number_of_frames = 0;; ++number_of_frames) {
|
||||||
if (num_frames && number_of_frames >= num_frames)
|
if (num_frames && number_of_frames >= num_frames) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
size_t bytes_org = fread(ch_org, sizeof(uint8_t), total_size, file_org);
|
size_t bytes_org = fread(ch_org, sizeof(uint8_t), total_size, file_org);
|
||||||
if (bytes_org < total_size) {
|
if (bytes_org < total_size) {
|
||||||
@ -482,7 +489,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
printf("%5d", number_of_frames);
|
printf("%5d", number_of_frames);
|
||||||
}
|
}
|
||||||
if (do_psnr) {
|
if (do_psnr) {
|
||||||
metric distorted_frame;
|
metric distorted_frame = {};
|
||||||
metric* cur_distortion_psnr = &distortion_psnr[cur_rec];
|
metric* cur_distortion_psnr = &distortion_psnr[cur_rec];
|
||||||
bool ismin = UpdateMetrics(ch_org, ch_rec, y_size, uv_size, total_size,
|
bool ismin = UpdateMetrics(ch_org, ch_rec, y_size, uv_size, total_size,
|
||||||
number_of_frames, cur_distortion_psnr,
|
number_of_frames, cur_distortion_psnr,
|
||||||
@ -496,7 +503,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (do_ssim) {
|
if (do_ssim) {
|
||||||
metric distorted_frame;
|
metric distorted_frame = {};
|
||||||
metric* cur_distortion_ssim = &distortion_ssim[cur_rec];
|
metric* cur_distortion_ssim = &distortion_ssim[cur_rec];
|
||||||
bool ismin = UpdateMetrics(ch_org, ch_rec, y_size, uv_size, total_size,
|
bool ismin = UpdateMetrics(ch_org, ch_rec, y_size, uv_size, total_size,
|
||||||
number_of_frames, cur_distortion_ssim,
|
number_of_frames, cur_distortion_ssim,
|
||||||
|
|||||||
@ -88,10 +88,12 @@ static double FinalizeSSIM(double iw,
|
|||||||
double sxx = xxm * iw - iwx * iwx;
|
double sxx = xxm * iw - iwx * iwx;
|
||||||
double syy = yym * iw - iwy * iwy;
|
double syy = yym * iw - iwy * iwy;
|
||||||
// small errors are possible, due to rounding. Clamp to zero.
|
// small errors are possible, due to rounding. Clamp to zero.
|
||||||
if (sxx < 0.)
|
if (sxx < 0.) {
|
||||||
sxx = 0.;
|
sxx = 0.;
|
||||||
if (syy < 0.)
|
}
|
||||||
|
if (syy < 0.) {
|
||||||
syy = 0.;
|
syy = 0.;
|
||||||
|
}
|
||||||
const double sxsy = sqrt(sxx * syy);
|
const double sxsy = sqrt(sxx * syy);
|
||||||
const double sxy = xym * iw - iwx * iwy;
|
const double sxy = xym * iw - iwx * iwy;
|
||||||
static const double C11 = (0.01 * 0.01) * (255 * 255);
|
static const double C11 = (0.01 * 0.01) * (255 * 255);
|
||||||
@ -122,8 +124,9 @@ double GetSSIM(const uint8_t* org,
|
|||||||
rec += (yo - KERNEL) * stride;
|
rec += (yo - KERNEL) * stride;
|
||||||
rec += (xo - KERNEL);
|
rec += (xo - KERNEL);
|
||||||
for (int y_ = 0; y_ < KERNEL_SIZE; ++y_, org += stride, rec += stride) {
|
for (int y_ = 0; y_ < KERNEL_SIZE; ++y_, org += stride, rec += stride) {
|
||||||
if (((yo - KERNEL + y_) < 0) || ((yo - KERNEL + y_) >= H))
|
if (((yo - KERNEL + y_) < 0) || ((yo - KERNEL + y_) >= H)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
const int Wy = K[y_];
|
const int Wy = K[y_];
|
||||||
for (int x_ = 0; x_ < KERNEL_SIZE; ++x_) {
|
for (int x_ = 0; x_ < KERNEL_SIZE; ++x_) {
|
||||||
const int Wxy = Wy * K[x_];
|
const int Wxy = Wy * K[x_];
|
||||||
|
|||||||
@ -79,8 +79,9 @@ void PrintHelp(const char* program) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ParseOptions(int argc, const char* argv[]) {
|
void ParseOptions(int argc, const char* argv[]) {
|
||||||
if (argc <= 1)
|
if (argc <= 1) {
|
||||||
PrintHelp(argv[0]);
|
PrintHelp(argv[0]);
|
||||||
|
}
|
||||||
for (int c = 1; c < argc; ++c) {
|
for (int c = 1; c < argc; ++c) {
|
||||||
if (!strcmp(argv[c], "-v")) {
|
if (!strcmp(argv[c], "-v")) {
|
||||||
verbose = true;
|
verbose = true;
|
||||||
@ -265,14 +266,16 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
int number_of_frames;
|
int number_of_frames;
|
||||||
for (number_of_frames = 0;; ++number_of_frames) {
|
for (number_of_frames = 0;; ++number_of_frames) {
|
||||||
if (num_frames && number_of_frames >= num_frames)
|
if (num_frames && number_of_frames >= num_frames) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Load original YUV or ARGB frame.
|
// Load original YUV or ARGB frame.
|
||||||
size_t bytes_org =
|
size_t bytes_org =
|
||||||
fread(ch_org, sizeof(uint8_t), static_cast<size_t>(org_size), file_org);
|
fread(ch_org, sizeof(uint8_t), static_cast<size_t>(org_size), file_org);
|
||||||
if (bytes_org < static_cast<size_t>(org_size))
|
if (bytes_org < static_cast<size_t>(org_size)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(fbarchard): Attenuate doesnt need to know dimensions.
|
// TODO(fbarchard): Attenuate doesnt need to know dimensions.
|
||||||
// ARGB attenuate frame
|
// ARGB attenuate frame
|
||||||
@ -331,14 +334,16 @@ int main(int argc, const char* argv[]) {
|
|||||||
size_t bytes_rec =
|
size_t bytes_rec =
|
||||||
fwrite(ch_rec, sizeof(uint8_t), static_cast<size_t>(total_size),
|
fwrite(ch_rec, sizeof(uint8_t), static_cast<size_t>(total_size),
|
||||||
file_rec[cur_rec]);
|
file_rec[cur_rec]);
|
||||||
if (bytes_rec < static_cast<size_t>(total_size))
|
if (bytes_rec < static_cast<size_t>(total_size)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
size_t bytes_rec =
|
size_t bytes_rec =
|
||||||
fwrite(ch_dst, sizeof(uint8_t), static_cast<size_t>(dst_size),
|
fwrite(ch_dst, sizeof(uint8_t), static_cast<size_t>(dst_size),
|
||||||
file_rec[cur_rec]);
|
file_rec[cur_rec]);
|
||||||
if (bytes_rec < static_cast<size_t>(dst_size))
|
if (bytes_rec < static_cast<size_t>(dst_size)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf("%5d", number_of_frames);
|
printf("%5d", number_of_frames);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user