react-native-vision-camera-spoof-detector 1.0.22 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/README.md +442 -442
  2. package/android/.gradle/9.2.0/checksums/checksums.lock +0 -0
  3. package/android/.gradle/9.2.0/fileHashes/fileHashes.bin +0 -0
  4. package/android/.gradle/9.2.0/fileHashes/fileHashes.lock +0 -0
  5. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  6. package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
  7. package/android/build/reports/problems/problems-report.html +659 -0
  8. package/android/build.gradle +12 -4
  9. package/android/src/main/cpp/CMakeLists.txt +101 -94
  10. package/android/src/main/cpp/libyuv/.clang-format +6 -6
  11. package/android/src/main/cpp/libyuv/.gn +40 -40
  12. package/android/src/main/cpp/libyuv/.vpython3 +410 -410
  13. package/android/src/main/cpp/libyuv/AUTHORS +7 -7
  14. package/android/src/main/cpp/libyuv/Android.bp +202 -202
  15. package/android/src/main/cpp/libyuv/Android.mk +106 -106
  16. package/android/src/main/cpp/libyuv/BUILD.gn +490 -490
  17. package/android/src/main/cpp/libyuv/CM_linux_packages.cmake +70 -70
  18. package/android/src/main/cpp/libyuv/CMakeLists.txt +259 -252
  19. package/android/src/main/cpp/libyuv/DEPS +935 -935
  20. package/android/src/main/cpp/libyuv/DIR_METADATA +3 -3
  21. package/android/src/main/cpp/libyuv/LICENSE +29 -29
  22. package/android/src/main/cpp/libyuv/OWNERS +11 -11
  23. package/android/src/main/cpp/libyuv/PATENTS +23 -23
  24. package/android/src/main/cpp/libyuv/PRESUBMIT.py +65 -65
  25. package/android/src/main/cpp/libyuv/README.chromium +11 -11
  26. package/android/src/main/cpp/libyuv/README.md +19 -19
  27. package/android/src/main/cpp/libyuv/build_overrides/build.gni +60 -60
  28. package/android/src/main/cpp/libyuv/build_overrides/gtest.gni +19 -19
  29. package/android/src/main/cpp/libyuv/build_overrides/partition_alloc.gni +17 -17
  30. package/android/src/main/cpp/libyuv/codereview.settings +5 -5
  31. package/android/src/main/cpp/libyuv/docs/deprecated_builds.md +409 -409
  32. package/android/src/main/cpp/libyuv/docs/environment_variables.md +64 -64
  33. package/android/src/main/cpp/libyuv/docs/feature_detection.md +108 -108
  34. package/android/src/main/cpp/libyuv/docs/filtering.md +196 -196
  35. package/android/src/main/cpp/libyuv/docs/formats.md +208 -208
  36. package/android/src/main/cpp/libyuv/docs/getting_started.md +296 -296
  37. package/android/src/main/cpp/libyuv/docs/rotation.md +107 -107
  38. package/android/src/main/cpp/libyuv/download_vs_toolchain.py +29 -29
  39. package/android/src/main/cpp/libyuv/include/libyuv/basic_types.h +68 -68
  40. package/android/src/main/cpp/libyuv/include/libyuv/compare.h +111 -111
  41. package/android/src/main/cpp/libyuv/include/libyuv/compare_row.h +112 -112
  42. package/android/src/main/cpp/libyuv/include/libyuv/convert.h +1117 -1117
  43. package/android/src/main/cpp/libyuv/include/libyuv/convert_argb.h +2335 -2335
  44. package/android/src/main/cpp/libyuv/include/libyuv/convert_from.h +203 -203
  45. package/android/src/main/cpp/libyuv/include/libyuv/convert_from_argb.h +394 -394
  46. package/android/src/main/cpp/libyuv/include/libyuv/cpu_id.h +147 -147
  47. package/android/src/main/cpp/libyuv/include/libyuv/cpu_support.h +99 -99
  48. package/android/src/main/cpp/libyuv/include/libyuv/loongson_intrinsics.h +1949 -1949
  49. package/android/src/main/cpp/libyuv/include/libyuv/mjpeg_decoder.h +195 -195
  50. package/android/src/main/cpp/libyuv/include/libyuv/planar_functions.h +1131 -1131
  51. package/android/src/main/cpp/libyuv/include/libyuv/rotate.h +296 -296
  52. package/android/src/main/cpp/libyuv/include/libyuv/rotate_argb.h +37 -37
  53. package/android/src/main/cpp/libyuv/include/libyuv/rotate_row.h +265 -265
  54. package/android/src/main/cpp/libyuv/include/libyuv/row.h +6738 -6738
  55. package/android/src/main/cpp/libyuv/include/libyuv/row_sve.h +2154 -2154
  56. package/android/src/main/cpp/libyuv/include/libyuv/scale.h +336 -336
  57. package/android/src/main/cpp/libyuv/include/libyuv/scale_argb.h +76 -76
  58. package/android/src/main/cpp/libyuv/include/libyuv/scale_rgb.h +42 -42
  59. package/android/src/main/cpp/libyuv/include/libyuv/scale_row.h +1726 -1726
  60. package/android/src/main/cpp/libyuv/include/libyuv/scale_uv.h +51 -51
  61. package/android/src/main/cpp/libyuv/include/libyuv/version.h +16 -16
  62. package/android/src/main/cpp/libyuv/include/libyuv/video_common.h +222 -222
  63. package/android/src/main/cpp/libyuv/include/libyuv.h +33 -33
  64. package/android/src/main/cpp/libyuv/infra/config/OWNERS +3 -3
  65. package/android/src/main/cpp/libyuv/infra/config/PRESUBMIT.py +17 -17
  66. package/android/src/main/cpp/libyuv/infra/config/README.md +2 -2
  67. package/android/src/main/cpp/libyuv/infra/config/codereview.settings +6 -6
  68. package/android/src/main/cpp/libyuv/infra/config/commit-queue.cfg +144 -144
  69. package/android/src/main/cpp/libyuv/infra/config/cr-buildbucket.cfg +1185 -1185
  70. package/android/src/main/cpp/libyuv/infra/config/luci-logdog.cfg +9 -9
  71. package/android/src/main/cpp/libyuv/infra/config/luci-milo.cfg +246 -246
  72. package/android/src/main/cpp/libyuv/infra/config/luci-scheduler.cfg +385 -385
  73. package/android/src/main/cpp/libyuv/infra/config/main.star +402 -402
  74. package/android/src/main/cpp/libyuv/infra/config/project.cfg +16 -16
  75. package/android/src/main/cpp/libyuv/infra/config/realms.cfg +111 -111
  76. package/android/src/main/cpp/libyuv/libyuv.gni +34 -34
  77. package/android/src/main/cpp/libyuv/libyuv.gyp +149 -149
  78. package/android/src/main/cpp/libyuv/libyuv.gypi +87 -87
  79. package/android/src/main/cpp/libyuv/linux.mk +96 -96
  80. package/android/src/main/cpp/libyuv/public.mk +13 -13
  81. package/android/src/main/cpp/libyuv/pylintrc +49 -49
  82. package/android/src/main/cpp/libyuv/riscv_script/prepare_toolchain_qemu.sh +74 -74
  83. package/android/src/main/cpp/libyuv/riscv_script/riscv-clang.cmake +56 -56
  84. package/android/src/main/cpp/libyuv/riscv_script/run_qemu.sh +15 -15
  85. package/android/src/main/cpp/libyuv/source/compare.cc +435 -435
  86. package/android/src/main/cpp/libyuv/source/compare_common.cc +74 -74
  87. package/android/src/main/cpp/libyuv/source/compare_gcc.cc +362 -362
  88. package/android/src/main/cpp/libyuv/source/compare_neon.cc +96 -96
  89. package/android/src/main/cpp/libyuv/source/compare_neon64.cc +223 -223
  90. package/android/src/main/cpp/libyuv/source/compare_win.cc +241 -241
  91. package/android/src/main/cpp/libyuv/source/convert.cc +4746 -4746
  92. package/android/src/main/cpp/libyuv/source/convert_argb.cc +9179 -9179
  93. package/android/src/main/cpp/libyuv/source/convert_from.cc +866 -866
  94. package/android/src/main/cpp/libyuv/source/convert_from_argb.cc +3671 -3671
  95. package/android/src/main/cpp/libyuv/source/convert_jpeg.cc +602 -602
  96. package/android/src/main/cpp/libyuv/source/convert_to_argb.cc +391 -391
  97. package/android/src/main/cpp/libyuv/source/convert_to_i420.cc +288 -288
  98. package/android/src/main/cpp/libyuv/source/cpu_id.cc +496 -496
  99. package/android/src/main/cpp/libyuv/source/mjpeg_decoder.cc +580 -580
  100. package/android/src/main/cpp/libyuv/source/mjpeg_validate.cc +71 -71
  101. package/android/src/main/cpp/libyuv/source/planar_functions.cc +5663 -5663
  102. package/android/src/main/cpp/libyuv/source/rotate.cc +1241 -1241
  103. package/android/src/main/cpp/libyuv/source/rotate_any.cc +76 -76
  104. package/android/src/main/cpp/libyuv/source/rotate_argb.cc +259 -259
  105. package/android/src/main/cpp/libyuv/source/rotate_common.cc +208 -208
  106. package/android/src/main/cpp/libyuv/source/rotate_gcc.cc +505 -505
  107. package/android/src/main/cpp/libyuv/source/rotate_lsx.cc +233 -233
  108. package/android/src/main/cpp/libyuv/source/rotate_neon.cc +219 -219
  109. package/android/src/main/cpp/libyuv/source/rotate_neon64.cc +273 -273
  110. package/android/src/main/cpp/libyuv/source/rotate_sme.cc +174 -174
  111. package/android/src/main/cpp/libyuv/source/rotate_win.cc +253 -253
  112. package/android/src/main/cpp/libyuv/source/row_any.cc +2519 -2519
  113. package/android/src/main/cpp/libyuv/source/row_common.cc +4461 -4461
  114. package/android/src/main/cpp/libyuv/source/row_gcc.cc +9570 -9570
  115. package/android/src/main/cpp/libyuv/source/row_lasx.cc +2343 -2343
  116. package/android/src/main/cpp/libyuv/source/row_lsx.cc +3030 -3030
  117. package/android/src/main/cpp/libyuv/source/row_neon.cc +4026 -4026
  118. package/android/src/main/cpp/libyuv/source/row_neon64.cc +5617 -5617
  119. package/android/src/main/cpp/libyuv/source/row_rvv.cc +2599 -2599
  120. package/android/src/main/cpp/libyuv/source/row_sme.cc +1183 -1183
  121. package/android/src/main/cpp/libyuv/source/row_sve.cc +1088 -1088
  122. package/android/src/main/cpp/libyuv/source/row_win.cc +6453 -6453
  123. package/android/src/main/cpp/libyuv/source/scale.cc +2710 -2710
  124. package/android/src/main/cpp/libyuv/source/scale_any.cc +991 -991
  125. package/android/src/main/cpp/libyuv/source/scale_argb.cc +1158 -1158
  126. package/android/src/main/cpp/libyuv/source/scale_common.cc +1977 -1977
  127. package/android/src/main/cpp/libyuv/source/scale_gcc.cc +2947 -2947
  128. package/android/src/main/cpp/libyuv/source/scale_lsx.cc +739 -739
  129. package/android/src/main/cpp/libyuv/source/scale_neon.cc +1449 -1449
  130. package/android/src/main/cpp/libyuv/source/scale_neon64.cc +1552 -1552
  131. package/android/src/main/cpp/libyuv/source/scale_rgb.cc +82 -82
  132. package/android/src/main/cpp/libyuv/source/scale_rvv.cc +1971 -1971
  133. package/android/src/main/cpp/libyuv/source/scale_sme.cc +555 -555
  134. package/android/src/main/cpp/libyuv/source/scale_uv.cc +1159 -1159
  135. package/android/src/main/cpp/libyuv/source/scale_win.cc +1392 -1392
  136. package/android/src/main/cpp/libyuv/source/test.sh +35 -35
  137. package/android/src/main/cpp/libyuv/source/video_common.cc +62 -62
  138. package/android/src/main/cpp/libyuv/tools_libyuv/OWNERS +4 -4
  139. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/roll_deps.py +931 -931
  140. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/roll_deps_test.py +164 -164
  141. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS +21 -21
  142. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.new +13 -13
  143. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.old +13 -13
  144. package/android/src/main/cpp/libyuv/tools_libyuv/get_landmines.py +38 -38
  145. package/android/src/main/cpp/libyuv/tools_libyuv/msan/OWNERS +3 -3
  146. package/android/src/main/cpp/libyuv/tools_libyuv/msan/blacklist.txt +9 -9
  147. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/OWNERS +3 -3
  148. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/blacklist.txt +15 -15
  149. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/vptr_blacklist.txt +25 -25
  150. package/android/src/main/cpp/libyuv/unit_test/basictypes_test.cc +43 -43
  151. package/android/src/main/cpp/libyuv/unit_test/color_test.cc +848 -848
  152. package/android/src/main/cpp/libyuv/unit_test/compare_test.cc +739 -739
  153. package/android/src/main/cpp/libyuv/unit_test/convert_argb_test.cc +2867 -2867
  154. package/android/src/main/cpp/libyuv/unit_test/convert_test.cc +2133 -2133
  155. package/android/src/main/cpp/libyuv/unit_test/cpu_test.cc +427 -427
  156. package/android/src/main/cpp/libyuv/unit_test/cpu_thread_test.cc +63 -63
  157. package/android/src/main/cpp/libyuv/unit_test/math_test.cc +160 -160
  158. package/android/src/main/cpp/libyuv/unit_test/planar_test.cc +4731 -4731
  159. package/android/src/main/cpp/libyuv/unit_test/rotate_argb_test.cc +334 -334
  160. package/android/src/main/cpp/libyuv/unit_test/rotate_test.cc +962 -962
  161. package/android/src/main/cpp/libyuv/unit_test/scale_argb_test.cc +590 -590
  162. package/android/src/main/cpp/libyuv/unit_test/scale_plane_test.cc +465 -465
  163. package/android/src/main/cpp/libyuv/unit_test/scale_rgb_test.cc +280 -280
  164. package/android/src/main/cpp/libyuv/unit_test/scale_test.cc +1135 -1135
  165. package/android/src/main/cpp/libyuv/unit_test/scale_uv_test.cc +249 -249
  166. package/android/src/main/cpp/libyuv/unit_test/testdata/arm_v7.txt +12 -12
  167. package/android/src/main/cpp/libyuv/unit_test/testdata/mips.txt +7 -7
  168. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson2k.txt +5 -5
  169. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson3.txt +10 -10
  170. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson_mmi.txt +7 -7
  171. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64.txt +3 -3
  172. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64_rvv.txt +3 -3
  173. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64_rvv_zvfh.txt +3 -3
  174. package/android/src/main/cpp/libyuv/unit_test/testdata/tegra3.txt +23 -23
  175. package/android/src/main/cpp/libyuv/unit_test/unit_test.cc +581 -581
  176. package/android/src/main/cpp/libyuv/unit_test/unit_test.h +232 -232
  177. package/android/src/main/cpp/libyuv/unit_test/video_common_test.cc +112 -112
  178. package/android/src/main/cpp/libyuv/util/Makefile +9 -9
  179. package/android/src/main/cpp/libyuv/util/color.cc +120 -120
  180. package/android/src/main/cpp/libyuv/util/compare.cc +67 -67
  181. package/android/src/main/cpp/libyuv/util/cpuid.c +211 -211
  182. package/android/src/main/cpp/libyuv/util/i444tonv12_eg.cc +27 -27
  183. package/android/src/main/cpp/libyuv/util/psnr.cc +291 -291
  184. package/android/src/main/cpp/libyuv/util/psnr.h +47 -47
  185. package/android/src/main/cpp/libyuv/util/psnr_main.cc +620 -620
  186. package/android/src/main/cpp/libyuv/util/ssim.cc +364 -364
  187. package/android/src/main/cpp/libyuv/util/ssim.h +38 -38
  188. package/android/src/main/cpp/libyuv/util/yuvconstants.c +114 -114
  189. package/android/src/main/cpp/libyuv/util/yuvconvert.cc +367 -367
  190. package/android/src/main/cpp/libyuv/winarm.mk +47 -47
  191. package/index.js +17 -1
  192. package/ios/FaceAntiSpoofFrameProcessor.swift +283 -0
  193. package/ios/FaceAntiSpoofJSI.h +12 -0
  194. package/ios/FaceAntiSpoofJSI.mm +92 -0
  195. package/ios/FaceAntiSpoofManager.swift +63 -0
  196. package/ios/FaceAntiSpoofModule.m +191 -0
  197. package/ios/FaceAntiSpoofPluginRegister.m +42 -0
  198. package/ios/models/FaceAntiSpoofing.tflite +0 -0
  199. package/ios/models/model_spec.json +16 -0
  200. package/package.json +87 -86
  201. package/.gitignore +0 -27
  202. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  203. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  204. package/android/.gradle/8.9/gc.properties +0 -0
  205. /package/android/.gradle/{8.9 → 9.2.0}/fileChanges/last-build.bin +0 -0
  206. /package/android/.gradle/{8.9/dependencies-accessors → 9.2.0}/gc.properties +0 -0
@@ -1,620 +1,620 @@
1
- /*
2
- * Copyright 2013 The LibYuv Project Authors. All rights reserved.
3
- *
4
- * Use of this source code is governed by a BSD-style license
5
- * that can be found in the LICENSE file in the root of the source
6
- * tree. An additional intellectual property rights grant can be found
7
- * in the file PATENTS. All contributing project authors may
8
- * be found in the AUTHORS file in the root of the source tree.
9
- */
10
-
11
- // Get PSNR or SSIM for video sequence. Assuming RAW 4:2:0 Y:Cb:Cr format
12
- // To build: g++ -O3 -o psnr psnr.cc ssim.cc psnr_main.cc
13
- // or VisualC: cl /Ox psnr.cc ssim.cc psnr_main.cc
14
- //
15
- // To enable OpenMP and SSE2
16
- // gcc: g++ -msse2 -O3 -fopenmp -o psnr psnr.cc ssim.cc psnr_main.cc
17
- // vc: cl /arch:SSE2 /Ox /openmp psnr.cc ssim.cc psnr_main.cc
18
- //
19
- // Usage: psnr org_seq rec_seq -s width height [-skip skip_org skip_rec]
20
-
21
- #ifndef _CRT_SECURE_NO_WARNINGS
22
- #define _CRT_SECURE_NO_WARNINGS
23
- #endif
24
-
25
- #include <stddef.h>
26
- #include <stdio.h>
27
- #include <stdlib.h>
28
- #include <string.h>
29
- #ifdef _OPENMP
30
- #include <omp.h>
31
- #endif
32
-
33
- #include "./psnr.h"
34
- #include "./ssim.h"
35
- #ifdef HAVE_JPEG
36
- #include "libyuv/compare.h"
37
- #include "libyuv/convert.h"
38
- #endif
39
-
40
- struct metric {
41
- double y, u, v, all;
42
- double min_y, min_u, min_v, min_all;
43
- double global_y, global_u, global_v, global_all;
44
- int min_frame;
45
- };
46
-
47
- // options
48
- bool verbose = false;
49
- bool quiet = false;
50
- bool show_name = false;
51
- bool do_swap_uv = false;
52
- bool do_psnr = false;
53
- bool do_ssim = false;
54
- bool do_mse = false;
55
- bool do_lssim = false;
56
- int image_width = 0, image_height = 0;
57
- int fileindex_org = 0; // argv argument contains the source file name.
58
- int fileindex_rec = 0; // argv argument contains the destination file name.
59
- int num_rec = 0;
60
- int num_skip_org = 0;
61
- int num_skip_rec = 0;
62
- int num_frames = 0;
63
- #ifdef _OPENMP
64
- int num_threads = 0;
65
- #endif
66
-
67
- // Parse PYUV format. ie name.1920x800_24Hz_P420.yuv
68
- static bool ExtractResolutionFromFilename(const char* name,
69
- int* width_ptr,
70
- int* height_ptr) {
71
- // Isolate the .width_height. section of the filename by searching for a
72
- // dot or underscore followed by a digit.
73
- for (int i = 0; name[i]; ++i) {
74
- if ((name[i] == '.' || name[i] == '_') && name[i + 1] >= '0' &&
75
- name[i + 1] <= '9') {
76
- int n = sscanf(name + i + 1, "%dx%d", width_ptr, height_ptr); // NOLINT
77
- if (2 == n) {
78
- return true;
79
- }
80
- }
81
- }
82
-
83
- #ifdef HAVE_JPEG
84
- // Try parsing file as a jpeg.
85
- FILE* const file_org = fopen(name, "rb");
86
- if (file_org == NULL) {
87
- fprintf(stderr, "Cannot open %s\n", name);
88
- return false;
89
- }
90
- fseek(file_org, 0, SEEK_END);
91
- size_t total_size = ftell(file_org);
92
- fseek(file_org, 0, SEEK_SET);
93
- uint8_t* const ch_org = new uint8_t[total_size];
94
- memset(ch_org, 0, total_size);
95
- size_t bytes_org = fread(ch_org, sizeof(uint8_t), total_size, file_org);
96
- fclose(file_org);
97
- if (bytes_org == total_size) {
98
- if (0 == libyuv::MJPGSize(ch_org, total_size, width_ptr, height_ptr)) {
99
- delete[] ch_org;
100
- return true;
101
- }
102
- }
103
- delete[] ch_org;
104
- #endif // HAVE_JPEG
105
- return false;
106
- }
107
-
108
- // MSE = Mean Square Error
109
- static double GetMSE(double sse, double size) {
110
- return sse / size;
111
- }
112
-
113
- static void PrintHelp(const char* program) {
114
- printf("%s [-options] org_seq rec_seq [rec_seq2.. etc]\n", program);
115
- #ifdef HAVE_JPEG
116
- printf("jpeg or raw YUV 420 supported.\n");
117
- #endif
118
- printf("options:\n");
119
- printf(
120
- " -s <width> <height> .... specify YUV size, mandatory if none of the "
121
- "sequences have the\n");
122
- printf(
123
- " resolution embedded in their filename (ie. "
124
- "name.1920x800_24Hz_P420.yuv)\n");
125
- printf(" -psnr .................. compute PSNR (default)\n");
126
- printf(" -ssim .................. compute SSIM\n");
127
- printf(" -mse ................... compute MSE\n");
128
- printf(" -swap .................. Swap U and V plane\n");
129
- printf(" -skip <org> <rec> ...... Number of frame to skip of org and rec\n");
130
- printf(" -frames <num> .......... Number of frames to compare\n");
131
- #ifdef _OPENMP
132
- printf(" -t <num> ............... Number of threads\n");
133
- #endif
134
- printf(" -n ..................... Show file name\n");
135
- printf(" -v ..................... verbose++\n");
136
- printf(" -q ..................... quiet\n");
137
- printf(" -h ..................... this help\n");
138
- exit(0);
139
- }
140
-
141
- static void ParseOptions(int argc, const char* argv[]) {
142
- if (argc <= 1) {
143
- PrintHelp(argv[0]);
144
- }
145
- for (int c = 1; c < argc; ++c) {
146
- if (!strcmp(argv[c], "-v")) {
147
- verbose = true;
148
- } else if (!strcmp(argv[c], "-q")) {
149
- quiet = true;
150
- } else if (!strcmp(argv[c], "-n")) {
151
- show_name = true;
152
- } else if (!strcmp(argv[c], "-psnr")) {
153
- do_psnr = true;
154
- } else if (!strcmp(argv[c], "-mse")) {
155
- do_mse = true;
156
- } else if (!strcmp(argv[c], "-ssim")) {
157
- do_ssim = true;
158
- } else if (!strcmp(argv[c], "-lssim")) {
159
- do_ssim = true;
160
- do_lssim = true;
161
- } else if (!strcmp(argv[c], "-swap")) {
162
- do_swap_uv = true;
163
- } else if (!strcmp(argv[c], "-h") || !strcmp(argv[c], "-help")) {
164
- PrintHelp(argv[0]);
165
- } else if (!strcmp(argv[c], "-s") && c + 2 < argc) {
166
- image_width = atoi(argv[++c]); // NOLINT
167
- image_height = atoi(argv[++c]); // NOLINT
168
- } else if (!strcmp(argv[c], "-skip") && c + 2 < argc) {
169
- num_skip_org = atoi(argv[++c]); // NOLINT
170
- num_skip_rec = atoi(argv[++c]); // NOLINT
171
- } else if (!strcmp(argv[c], "-frames") && c + 1 < argc) {
172
- num_frames = atoi(argv[++c]); // NOLINT
173
- #ifdef _OPENMP
174
- } else if (!strcmp(argv[c], "-t") && c + 1 < argc) {
175
- num_threads = atoi(argv[++c]); // NOLINT
176
- #endif
177
- } else if (argv[c][0] == '-') {
178
- fprintf(stderr, "Unknown option. %s\n", argv[c]);
179
- } else if (fileindex_org == 0) {
180
- fileindex_org = c;
181
- } else if (fileindex_rec == 0) {
182
- fileindex_rec = c;
183
- num_rec = 1;
184
- } else {
185
- ++num_rec;
186
- }
187
- }
188
- if (fileindex_org == 0 || fileindex_rec == 0) {
189
- fprintf(stderr, "Missing filenames\n");
190
- PrintHelp(argv[0]);
191
- }
192
- if (num_skip_org < 0 || num_skip_rec < 0) {
193
- fprintf(stderr, "Skipped frames incorrect\n");
194
- PrintHelp(argv[0]);
195
- }
196
- if (num_frames < 0) {
197
- fprintf(stderr, "Number of frames incorrect\n");
198
- PrintHelp(argv[0]);
199
- }
200
- if (image_width == 0 || image_height == 0) {
201
- int org_width, org_height;
202
- int rec_width, rec_height;
203
- bool org_res_avail = ExtractResolutionFromFilename(argv[fileindex_org],
204
- &org_width, &org_height);
205
- bool rec_res_avail = ExtractResolutionFromFilename(argv[fileindex_rec],
206
- &rec_width, &rec_height);
207
- if (org_res_avail) {
208
- if (rec_res_avail) {
209
- if ((org_width == rec_width) && (org_height == rec_height)) {
210
- image_width = org_width;
211
- image_height = org_height;
212
- } else {
213
- fprintf(stderr, "Sequences have different resolutions.\n");
214
- PrintHelp(argv[0]);
215
- }
216
- } else {
217
- image_width = org_width;
218
- image_height = org_height;
219
- }
220
- } else if (rec_res_avail) {
221
- image_width = rec_width;
222
- image_height = rec_height;
223
- } else {
224
- fprintf(stderr, "Missing dimensions.\n");
225
- PrintHelp(argv[0]);
226
- }
227
- }
228
- }
229
-
230
- static bool UpdateMetrics(uint8_t* ch_org,
231
- uint8_t* ch_rec,
232
- const int y_size,
233
- const int uv_size,
234
- const size_t total_size,
235
- int number_of_frames,
236
- metric* cur_distortion_psnr,
237
- metric* distorted_frame,
238
- bool compute_psnr) {
239
- const int uv_offset = (do_swap_uv ? uv_size : 0);
240
- const uint8_t* const u_org = ch_org + y_size + uv_offset;
241
- const uint8_t* const u_rec = ch_rec + y_size;
242
- const uint8_t* const v_org = ch_org + y_size + (uv_size - uv_offset);
243
- const uint8_t* const v_rec = ch_rec + y_size + uv_size;
244
- if (compute_psnr) {
245
- #ifdef HAVE_JPEG
246
- double y_err = static_cast<double>(
247
- libyuv::ComputeSumSquareError(ch_org, ch_rec, y_size));
248
- double u_err = static_cast<double>(
249
- libyuv::ComputeSumSquareError(u_org, u_rec, uv_size));
250
- double v_err = static_cast<double>(
251
- libyuv::ComputeSumSquareError(v_org, v_rec, uv_size));
252
- #else
253
- double y_err = ComputeSumSquareError(ch_org, ch_rec, y_size);
254
- double u_err = ComputeSumSquareError(u_org, u_rec, uv_size);
255
- double v_err = ComputeSumSquareError(v_org, v_rec, uv_size);
256
- #endif
257
- const double total_err = y_err + u_err + v_err;
258
- cur_distortion_psnr->global_y += y_err;
259
- cur_distortion_psnr->global_u += u_err;
260
- cur_distortion_psnr->global_v += v_err;
261
- cur_distortion_psnr->global_all += total_err;
262
- distorted_frame->y = ComputePSNR(y_err, static_cast<double>(y_size));
263
- distorted_frame->u = ComputePSNR(u_err, static_cast<double>(uv_size));
264
- distorted_frame->v = ComputePSNR(v_err, static_cast<double>(uv_size));
265
- distorted_frame->all =
266
- ComputePSNR(total_err, static_cast<double>(total_size));
267
- } else {
268
- distorted_frame->y = CalcSSIM(ch_org, ch_rec, image_width, image_height);
269
- distorted_frame->u =
270
- CalcSSIM(u_org, u_rec, (image_width + 1) / 2, (image_height + 1) / 2);
271
- distorted_frame->v =
272
- CalcSSIM(v_org, v_rec, (image_width + 1) / 2, (image_height + 1) / 2);
273
- distorted_frame->all =
274
- (distorted_frame->y + distorted_frame->u + distorted_frame->v) /
275
- total_size;
276
- distorted_frame->y /= y_size;
277
- distorted_frame->u /= uv_size;
278
- distorted_frame->v /= uv_size;
279
-
280
- if (do_lssim) {
281
- distorted_frame->all = CalcLSSIM(distorted_frame->all);
282
- distorted_frame->y = CalcLSSIM(distorted_frame->y);
283
- distorted_frame->u = CalcLSSIM(distorted_frame->u);
284
- distorted_frame->v = CalcLSSIM(distorted_frame->v);
285
- }
286
- }
287
-
288
- cur_distortion_psnr->y += distorted_frame->y;
289
- cur_distortion_psnr->u += distorted_frame->u;
290
- cur_distortion_psnr->v += distorted_frame->v;
291
- cur_distortion_psnr->all += distorted_frame->all;
292
-
293
- bool ismin = false;
294
- if (distorted_frame->y < cur_distortion_psnr->min_y) {
295
- cur_distortion_psnr->min_y = distorted_frame->y;
296
- }
297
- if (distorted_frame->u < cur_distortion_psnr->min_u) {
298
- cur_distortion_psnr->min_u = distorted_frame->u;
299
- }
300
- if (distorted_frame->v < cur_distortion_psnr->min_v) {
301
- cur_distortion_psnr->min_v = distorted_frame->v;
302
- }
303
- if (distorted_frame->all < cur_distortion_psnr->min_all) {
304
- cur_distortion_psnr->min_all = distorted_frame->all;
305
- cur_distortion_psnr->min_frame = number_of_frames;
306
- ismin = true;
307
- }
308
- return ismin;
309
- }
310
-
311
- int main(int argc, const char* argv[]) {
312
- ParseOptions(argc, argv);
313
- if (!do_psnr && !do_ssim) {
314
- do_psnr = true;
315
- }
316
-
317
- #ifdef _OPENMP
318
- if (num_threads) {
319
- omp_set_num_threads(num_threads);
320
- }
321
- if (verbose) {
322
- printf("OpenMP %d procs\n", omp_get_num_procs());
323
- }
324
- #endif
325
- // Open original file (first file argument)
326
- FILE* const file_org = fopen(argv[fileindex_org], "rb");
327
- if (file_org == NULL) {
328
- fprintf(stderr, "Cannot open %s\n", argv[fileindex_org]);
329
- exit(1);
330
- }
331
-
332
- // Open all files to compare to
333
- FILE** file_rec = new FILE*[num_rec];
334
- memset(file_rec, 0, num_rec * sizeof(FILE*)); // NOLINT
335
- for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) {
336
- file_rec[cur_rec] = fopen(argv[fileindex_rec + cur_rec], "rb");
337
- if (file_rec[cur_rec] == NULL) {
338
- fprintf(stderr, "Cannot open %s\n", argv[fileindex_rec + cur_rec]);
339
- fclose(file_org);
340
- for (int i = 0; i < cur_rec; ++i) {
341
- fclose(file_rec[i]);
342
- }
343
- delete[] file_rec;
344
- exit(1);
345
- }
346
- }
347
-
348
- const int y_size = image_width * image_height;
349
- const int uv_size = ((image_width + 1) / 2) * ((image_height + 1) / 2);
350
- const size_t total_size = y_size + 2 * uv_size; // NOLINT
351
- #if defined(_MSC_VER)
352
- _fseeki64(
353
- file_org,
354
- static_cast<__int64>(num_skip_org) * static_cast<__int64>(total_size),
355
- SEEK_SET);
356
- #else
357
- fseek(file_org, num_skip_org * total_size, SEEK_SET);
358
- #endif
359
- for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) {
360
- #if defined(_MSC_VER)
361
- _fseeki64(
362
- file_rec[cur_rec],
363
- static_cast<__int64>(num_skip_rec) * static_cast<__int64>(total_size),
364
- SEEK_SET);
365
- #else
366
- fseek(file_rec[cur_rec], num_skip_rec * total_size, SEEK_SET);
367
- #endif
368
- }
369
-
370
- uint8_t* const ch_org = new uint8_t[total_size];
371
- uint8_t* const ch_rec = new uint8_t[total_size];
372
- if (ch_org == NULL || ch_rec == NULL) {
373
- fprintf(stderr, "No memory available\n");
374
- fclose(file_org);
375
- for (int i = 0; i < num_rec; ++i) {
376
- fclose(file_rec[i]);
377
- }
378
- delete[] ch_org;
379
- delete[] ch_rec;
380
- delete[] file_rec;
381
- exit(1);
382
- }
383
-
384
- metric* const distortion_psnr = new metric[num_rec];
385
- metric* const distortion_ssim = new metric[num_rec];
386
- for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) {
387
- metric* cur_distortion_psnr = &distortion_psnr[cur_rec];
388
- cur_distortion_psnr->y = 0.0;
389
- cur_distortion_psnr->u = 0.0;
390
- cur_distortion_psnr->v = 0.0;
391
- cur_distortion_psnr->all = 0.0;
392
- cur_distortion_psnr->min_y = kMaxPSNR;
393
- cur_distortion_psnr->min_u = kMaxPSNR;
394
- cur_distortion_psnr->min_v = kMaxPSNR;
395
- cur_distortion_psnr->min_all = kMaxPSNR;
396
- cur_distortion_psnr->min_frame = 0;
397
- cur_distortion_psnr->global_y = 0.0;
398
- cur_distortion_psnr->global_u = 0.0;
399
- cur_distortion_psnr->global_v = 0.0;
400
- cur_distortion_psnr->global_all = 0.0;
401
- distortion_ssim[cur_rec] = cur_distortion_psnr[cur_rec];
402
- }
403
-
404
- if (verbose) {
405
- printf("Size: %dx%d\n", image_width, image_height);
406
- }
407
-
408
- if (!quiet) {
409
- printf("Frame");
410
- if (do_psnr) {
411
- printf("\t PSNR-Y \t PSNR-U \t PSNR-V \t PSNR-All \t Frame");
412
- }
413
- if (do_ssim) {
414
- printf("\t SSIM-Y\t SSIM-U\t SSIM-V\t SSIM-All\t Frame");
415
- }
416
- if (show_name) {
417
- printf("\tName\n");
418
- } else {
419
- printf("\n");
420
- }
421
- }
422
-
423
- int number_of_frames;
424
- for (number_of_frames = 0;; ++number_of_frames) {
425
- if (num_frames && number_of_frames >= num_frames) {
426
- break;
427
- }
428
-
429
- size_t bytes_org = fread(ch_org, sizeof(uint8_t), total_size, file_org);
430
- if (bytes_org < total_size) {
431
- #ifdef HAVE_JPEG
432
- // Try parsing file as a jpeg.
433
- uint8_t* const ch_jpeg = new uint8_t[bytes_org];
434
- memcpy(ch_jpeg, ch_org, bytes_org);
435
- memset(ch_org, 0, total_size);
436
-
437
- if (0 != libyuv::MJPGToI420(ch_jpeg, bytes_org, ch_org, image_width,
438
- ch_org + y_size, (image_width + 1) / 2,
439
- ch_org + y_size + uv_size,
440
- (image_width + 1) / 2, image_width,
441
- image_height, image_width, image_height)) {
442
- delete[] ch_jpeg;
443
- break;
444
- }
445
- delete[] ch_jpeg;
446
- #else
447
- break;
448
- #endif // HAVE_JPEG
449
- }
450
-
451
- for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) {
452
- size_t bytes_rec =
453
- fread(ch_rec, sizeof(uint8_t), total_size, file_rec[cur_rec]);
454
- if (bytes_rec < total_size) {
455
- #ifdef HAVE_JPEG
456
- // Try parsing file as a jpeg.
457
- uint8_t* const ch_jpeg = new uint8_t[bytes_rec];
458
- memcpy(ch_jpeg, ch_rec, bytes_rec);
459
- memset(ch_rec, 0, total_size);
460
-
461
- if (0 != libyuv::MJPGToI420(ch_jpeg, bytes_rec, ch_rec, image_width,
462
- ch_rec + y_size, (image_width + 1) / 2,
463
- ch_rec + y_size + uv_size,
464
- (image_width + 1) / 2, image_width,
465
- image_height, image_width, image_height)) {
466
- delete[] ch_jpeg;
467
- break;
468
- }
469
- delete[] ch_jpeg;
470
- #else
471
- break;
472
- #endif // HAVE_JPEG
473
- }
474
-
475
- if (verbose) {
476
- printf("%5d", number_of_frames);
477
- }
478
- if (do_psnr) {
479
- metric distorted_frame = {};
480
- metric* cur_distortion_psnr = &distortion_psnr[cur_rec];
481
- bool ismin = UpdateMetrics(ch_org, ch_rec, y_size, uv_size, total_size,
482
- number_of_frames, cur_distortion_psnr,
483
- &distorted_frame, true);
484
- if (verbose) {
485
- printf("\t%10.6f", distorted_frame.y);
486
- printf("\t%10.6f", distorted_frame.u);
487
- printf("\t%10.6f", distorted_frame.v);
488
- printf("\t%10.6f", distorted_frame.all);
489
- printf("\t%5s", ismin ? "min" : "");
490
- }
491
- }
492
- if (do_ssim) {
493
- metric distorted_frame = {};
494
- metric* cur_distortion_ssim = &distortion_ssim[cur_rec];
495
- bool ismin = UpdateMetrics(ch_org, ch_rec, y_size, uv_size, total_size,
496
- number_of_frames, cur_distortion_ssim,
497
- &distorted_frame, false);
498
- if (verbose) {
499
- printf("\t%10.6f", distorted_frame.y);
500
- printf("\t%10.6f", distorted_frame.u);
501
- printf("\t%10.6f", distorted_frame.v);
502
- printf("\t%10.6f", distorted_frame.all);
503
- printf("\t%5s", ismin ? "min" : "");
504
- }
505
- }
506
- if (verbose) {
507
- if (show_name) {
508
- printf("\t%s", argv[fileindex_rec + cur_rec]);
509
- }
510
- printf("\n");
511
- }
512
- }
513
- }
514
-
515
- // Final PSNR computation.
516
- for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) {
517
- metric* cur_distortion_psnr = &distortion_psnr[cur_rec];
518
- metric* cur_distortion_ssim = &distortion_ssim[cur_rec];
519
- if (number_of_frames > 0) {
520
- const double norm = 1. / static_cast<double>(number_of_frames);
521
- cur_distortion_psnr->y *= norm;
522
- cur_distortion_psnr->u *= norm;
523
- cur_distortion_psnr->v *= norm;
524
- cur_distortion_psnr->all *= norm;
525
- cur_distortion_ssim->y *= norm;
526
- cur_distortion_ssim->u *= norm;
527
- cur_distortion_ssim->v *= norm;
528
- cur_distortion_ssim->all *= norm;
529
- }
530
-
531
- if (do_psnr) {
532
- const double global_psnr_y =
533
- ComputePSNR(cur_distortion_psnr->global_y,
534
- static_cast<double>(y_size) * number_of_frames);
535
- const double global_psnr_u =
536
- ComputePSNR(cur_distortion_psnr->global_u,
537
- static_cast<double>(uv_size) * number_of_frames);
538
- const double global_psnr_v =
539
- ComputePSNR(cur_distortion_psnr->global_v,
540
- static_cast<double>(uv_size) * number_of_frames);
541
- const double global_psnr_all =
542
- ComputePSNR(cur_distortion_psnr->global_all,
543
- static_cast<double>(total_size) * number_of_frames);
544
- printf("Global:\t%10.6f\t%10.6f\t%10.6f\t%10.6f\t%5d", global_psnr_y,
545
- global_psnr_u, global_psnr_v, global_psnr_all, number_of_frames);
546
- if (show_name) {
547
- printf("\t%s", argv[fileindex_rec + cur_rec]);
548
- }
549
- printf("\n");
550
- }
551
-
552
- if (!quiet) {
553
- printf("Avg:");
554
- if (do_psnr) {
555
- printf("\t%10.6f\t%10.6f\t%10.6f\t%10.6f\t%5d", cur_distortion_psnr->y,
556
- cur_distortion_psnr->u, cur_distortion_psnr->v,
557
- cur_distortion_psnr->all, number_of_frames);
558
- }
559
- if (do_ssim) {
560
- printf("\t%10.6f\t%10.6f\t%10.6f\t%10.6f\t%5d", cur_distortion_ssim->y,
561
- cur_distortion_ssim->u, cur_distortion_ssim->v,
562
- cur_distortion_ssim->all, number_of_frames);
563
- }
564
- if (show_name) {
565
- printf("\t%s", argv[fileindex_rec + cur_rec]);
566
- }
567
- printf("\n");
568
- }
569
- if (!quiet) {
570
- printf("Min:");
571
- if (do_psnr) {
572
- printf("\t%10.6f\t%10.6f\t%10.6f\t%10.6f\t%5d",
573
- cur_distortion_psnr->min_y, cur_distortion_psnr->min_u,
574
- cur_distortion_psnr->min_v, cur_distortion_psnr->min_all,
575
- cur_distortion_psnr->min_frame);
576
- }
577
- if (do_ssim) {
578
- printf("\t%10.6f\t%10.6f\t%10.6f\t%10.6f\t%5d",
579
- cur_distortion_ssim->min_y, cur_distortion_ssim->min_u,
580
- cur_distortion_ssim->min_v, cur_distortion_ssim->min_all,
581
- cur_distortion_ssim->min_frame);
582
- }
583
- if (show_name) {
584
- printf("\t%s", argv[fileindex_rec + cur_rec]);
585
- }
586
- printf("\n");
587
- }
588
-
589
- if (do_mse) {
590
- double global_mse_y =
591
- GetMSE(cur_distortion_psnr->global_y,
592
- static_cast<double>(y_size) * number_of_frames);
593
- double global_mse_u =
594
- GetMSE(cur_distortion_psnr->global_u,
595
- static_cast<double>(uv_size) * number_of_frames);
596
- double global_mse_v =
597
- GetMSE(cur_distortion_psnr->global_v,
598
- static_cast<double>(uv_size) * number_of_frames);
599
- double global_mse_all =
600
- GetMSE(cur_distortion_psnr->global_all,
601
- static_cast<double>(total_size) * number_of_frames);
602
- printf("MSE:\t%10.6f\t%10.6f\t%10.6f\t%10.6f\t%5d", global_mse_y,
603
- global_mse_u, global_mse_v, global_mse_all, number_of_frames);
604
- if (show_name) {
605
- printf("\t%s", argv[fileindex_rec + cur_rec]);
606
- }
607
- printf("\n");
608
- }
609
- }
610
- fclose(file_org);
611
- for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) {
612
- fclose(file_rec[cur_rec]);
613
- }
614
- delete[] distortion_psnr;
615
- delete[] distortion_ssim;
616
- delete[] ch_org;
617
- delete[] ch_rec;
618
- delete[] file_rec;
619
- return 0;
620
- }
1
+ /*
2
+ * Copyright 2013 The LibYuv Project Authors. All rights reserved.
3
+ *
4
+ * Use of this source code is governed by a BSD-style license
5
+ * that can be found in the LICENSE file in the root of the source
6
+ * tree. An additional intellectual property rights grant can be found
7
+ * in the file PATENTS. All contributing project authors may
8
+ * be found in the AUTHORS file in the root of the source tree.
9
+ */
10
+
11
+ // Get PSNR or SSIM for video sequence. Assuming RAW 4:2:0 Y:Cb:Cr format
12
+ // To build: g++ -O3 -o psnr psnr.cc ssim.cc psnr_main.cc
13
+ // or VisualC: cl /Ox psnr.cc ssim.cc psnr_main.cc
14
+ //
15
+ // To enable OpenMP and SSE2
16
+ // gcc: g++ -msse2 -O3 -fopenmp -o psnr psnr.cc ssim.cc psnr_main.cc
17
+ // vc: cl /arch:SSE2 /Ox /openmp psnr.cc ssim.cc psnr_main.cc
18
+ //
19
+ // Usage: psnr org_seq rec_seq -s width height [-skip skip_org skip_rec]
20
+
21
+ #ifndef _CRT_SECURE_NO_WARNINGS
22
+ #define _CRT_SECURE_NO_WARNINGS
23
+ #endif
24
+
25
+ #include <stddef.h>
26
+ #include <stdio.h>
27
+ #include <stdlib.h>
28
+ #include <string.h>
29
+ #ifdef _OPENMP
30
+ #include <omp.h>
31
+ #endif
32
+
33
+ #include "./psnr.h"
34
+ #include "./ssim.h"
35
+ #ifdef HAVE_JPEG
36
+ #include "libyuv/compare.h"
37
+ #include "libyuv/convert.h"
38
+ #endif
39
+
40
+ struct metric {
41
+ double y, u, v, all;
42
+ double min_y, min_u, min_v, min_all;
43
+ double global_y, global_u, global_v, global_all;
44
+ int min_frame;
45
+ };
46
+
47
+ // options
48
+ bool verbose = false;
49
+ bool quiet = false;
50
+ bool show_name = false;
51
+ bool do_swap_uv = false;
52
+ bool do_psnr = false;
53
+ bool do_ssim = false;
54
+ bool do_mse = false;
55
+ bool do_lssim = false;
56
+ int image_width = 0, image_height = 0;
57
+ int fileindex_org = 0; // argv argument contains the source file name.
58
+ int fileindex_rec = 0; // argv argument contains the destination file name.
59
+ int num_rec = 0;
60
+ int num_skip_org = 0;
61
+ int num_skip_rec = 0;
62
+ int num_frames = 0;
63
+ #ifdef _OPENMP
64
+ int num_threads = 0;
65
+ #endif
66
+
67
+ // Parse PYUV format. ie name.1920x800_24Hz_P420.yuv
68
+ static bool ExtractResolutionFromFilename(const char* name,
69
+ int* width_ptr,
70
+ int* height_ptr) {
71
+ // Isolate the .width_height. section of the filename by searching for a
72
+ // dot or underscore followed by a digit.
73
+ for (int i = 0; name[i]; ++i) {
74
+ if ((name[i] == '.' || name[i] == '_') && name[i + 1] >= '0' &&
75
+ name[i + 1] <= '9') {
76
+ int n = sscanf(name + i + 1, "%dx%d", width_ptr, height_ptr); // NOLINT
77
+ if (2 == n) {
78
+ return true;
79
+ }
80
+ }
81
+ }
82
+
83
+ #ifdef HAVE_JPEG
84
+ // Try parsing file as a jpeg.
85
+ FILE* const file_org = fopen(name, "rb");
86
+ if (file_org == NULL) {
87
+ fprintf(stderr, "Cannot open %s\n", name);
88
+ return false;
89
+ }
90
+ fseek(file_org, 0, SEEK_END);
91
+ size_t total_size = ftell(file_org);
92
+ fseek(file_org, 0, SEEK_SET);
93
+ uint8_t* const ch_org = new uint8_t[total_size];
94
+ memset(ch_org, 0, total_size);
95
+ size_t bytes_org = fread(ch_org, sizeof(uint8_t), total_size, file_org);
96
+ fclose(file_org);
97
+ if (bytes_org == total_size) {
98
+ if (0 == libyuv::MJPGSize(ch_org, total_size, width_ptr, height_ptr)) {
99
+ delete[] ch_org;
100
+ return true;
101
+ }
102
+ }
103
+ delete[] ch_org;
104
+ #endif // HAVE_JPEG
105
+ return false;
106
+ }
107
+
108
+ // MSE = Mean Square Error
109
+ static double GetMSE(double sse, double size) {
110
+ return sse / size;
111
+ }
112
+
113
+ static void PrintHelp(const char* program) {
114
+ printf("%s [-options] org_seq rec_seq [rec_seq2.. etc]\n", program);
115
+ #ifdef HAVE_JPEG
116
+ printf("jpeg or raw YUV 420 supported.\n");
117
+ #endif
118
+ printf("options:\n");
119
+ printf(
120
+ " -s <width> <height> .... specify YUV size, mandatory if none of the "
121
+ "sequences have the\n");
122
+ printf(
123
+ " resolution embedded in their filename (ie. "
124
+ "name.1920x800_24Hz_P420.yuv)\n");
125
+ printf(" -psnr .................. compute PSNR (default)\n");
126
+ printf(" -ssim .................. compute SSIM\n");
127
+ printf(" -mse ................... compute MSE\n");
128
+ printf(" -swap .................. Swap U and V plane\n");
129
+ printf(" -skip <org> <rec> ...... Number of frame to skip of org and rec\n");
130
+ printf(" -frames <num> .......... Number of frames to compare\n");
131
+ #ifdef _OPENMP
132
+ printf(" -t <num> ............... Number of threads\n");
133
+ #endif
134
+ printf(" -n ..................... Show file name\n");
135
+ printf(" -v ..................... verbose++\n");
136
+ printf(" -q ..................... quiet\n");
137
+ printf(" -h ..................... this help\n");
138
+ exit(0);
139
+ }
140
+
141
+ static void ParseOptions(int argc, const char* argv[]) {
142
+ if (argc <= 1) {
143
+ PrintHelp(argv[0]);
144
+ }
145
+ for (int c = 1; c < argc; ++c) {
146
+ if (!strcmp(argv[c], "-v")) {
147
+ verbose = true;
148
+ } else if (!strcmp(argv[c], "-q")) {
149
+ quiet = true;
150
+ } else if (!strcmp(argv[c], "-n")) {
151
+ show_name = true;
152
+ } else if (!strcmp(argv[c], "-psnr")) {
153
+ do_psnr = true;
154
+ } else if (!strcmp(argv[c], "-mse")) {
155
+ do_mse = true;
156
+ } else if (!strcmp(argv[c], "-ssim")) {
157
+ do_ssim = true;
158
+ } else if (!strcmp(argv[c], "-lssim")) {
159
+ do_ssim = true;
160
+ do_lssim = true;
161
+ } else if (!strcmp(argv[c], "-swap")) {
162
+ do_swap_uv = true;
163
+ } else if (!strcmp(argv[c], "-h") || !strcmp(argv[c], "-help")) {
164
+ PrintHelp(argv[0]);
165
+ } else if (!strcmp(argv[c], "-s") && c + 2 < argc) {
166
+ image_width = atoi(argv[++c]); // NOLINT
167
+ image_height = atoi(argv[++c]); // NOLINT
168
+ } else if (!strcmp(argv[c], "-skip") && c + 2 < argc) {
169
+ num_skip_org = atoi(argv[++c]); // NOLINT
170
+ num_skip_rec = atoi(argv[++c]); // NOLINT
171
+ } else if (!strcmp(argv[c], "-frames") && c + 1 < argc) {
172
+ num_frames = atoi(argv[++c]); // NOLINT
173
+ #ifdef _OPENMP
174
+ } else if (!strcmp(argv[c], "-t") && c + 1 < argc) {
175
+ num_threads = atoi(argv[++c]); // NOLINT
176
+ #endif
177
+ } else if (argv[c][0] == '-') {
178
+ fprintf(stderr, "Unknown option. %s\n", argv[c]);
179
+ } else if (fileindex_org == 0) {
180
+ fileindex_org = c;
181
+ } else if (fileindex_rec == 0) {
182
+ fileindex_rec = c;
183
+ num_rec = 1;
184
+ } else {
185
+ ++num_rec;
186
+ }
187
+ }
188
+ if (fileindex_org == 0 || fileindex_rec == 0) {
189
+ fprintf(stderr, "Missing filenames\n");
190
+ PrintHelp(argv[0]);
191
+ }
192
+ if (num_skip_org < 0 || num_skip_rec < 0) {
193
+ fprintf(stderr, "Skipped frames incorrect\n");
194
+ PrintHelp(argv[0]);
195
+ }
196
+ if (num_frames < 0) {
197
+ fprintf(stderr, "Number of frames incorrect\n");
198
+ PrintHelp(argv[0]);
199
+ }
200
+ if (image_width == 0 || image_height == 0) {
201
+ int org_width, org_height;
202
+ int rec_width, rec_height;
203
+ bool org_res_avail = ExtractResolutionFromFilename(argv[fileindex_org],
204
+ &org_width, &org_height);
205
+ bool rec_res_avail = ExtractResolutionFromFilename(argv[fileindex_rec],
206
+ &rec_width, &rec_height);
207
+ if (org_res_avail) {
208
+ if (rec_res_avail) {
209
+ if ((org_width == rec_width) && (org_height == rec_height)) {
210
+ image_width = org_width;
211
+ image_height = org_height;
212
+ } else {
213
+ fprintf(stderr, "Sequences have different resolutions.\n");
214
+ PrintHelp(argv[0]);
215
+ }
216
+ } else {
217
+ image_width = org_width;
218
+ image_height = org_height;
219
+ }
220
+ } else if (rec_res_avail) {
221
+ image_width = rec_width;
222
+ image_height = rec_height;
223
+ } else {
224
+ fprintf(stderr, "Missing dimensions.\n");
225
+ PrintHelp(argv[0]);
226
+ }
227
+ }
228
+ }
229
+
230
+ static bool UpdateMetrics(uint8_t* ch_org,
231
+ uint8_t* ch_rec,
232
+ const int y_size,
233
+ const int uv_size,
234
+ const size_t total_size,
235
+ int number_of_frames,
236
+ metric* cur_distortion_psnr,
237
+ metric* distorted_frame,
238
+ bool compute_psnr) {
239
+ const int uv_offset = (do_swap_uv ? uv_size : 0);
240
+ const uint8_t* const u_org = ch_org + y_size + uv_offset;
241
+ const uint8_t* const u_rec = ch_rec + y_size;
242
+ const uint8_t* const v_org = ch_org + y_size + (uv_size - uv_offset);
243
+ const uint8_t* const v_rec = ch_rec + y_size + uv_size;
244
+ if (compute_psnr) {
245
+ #ifdef HAVE_JPEG
246
+ double y_err = static_cast<double>(
247
+ libyuv::ComputeSumSquareError(ch_org, ch_rec, y_size));
248
+ double u_err = static_cast<double>(
249
+ libyuv::ComputeSumSquareError(u_org, u_rec, uv_size));
250
+ double v_err = static_cast<double>(
251
+ libyuv::ComputeSumSquareError(v_org, v_rec, uv_size));
252
+ #else
253
+ double y_err = ComputeSumSquareError(ch_org, ch_rec, y_size);
254
+ double u_err = ComputeSumSquareError(u_org, u_rec, uv_size);
255
+ double v_err = ComputeSumSquareError(v_org, v_rec, uv_size);
256
+ #endif
257
+ const double total_err = y_err + u_err + v_err;
258
+ cur_distortion_psnr->global_y += y_err;
259
+ cur_distortion_psnr->global_u += u_err;
260
+ cur_distortion_psnr->global_v += v_err;
261
+ cur_distortion_psnr->global_all += total_err;
262
+ distorted_frame->y = ComputePSNR(y_err, static_cast<double>(y_size));
263
+ distorted_frame->u = ComputePSNR(u_err, static_cast<double>(uv_size));
264
+ distorted_frame->v = ComputePSNR(v_err, static_cast<double>(uv_size));
265
+ distorted_frame->all =
266
+ ComputePSNR(total_err, static_cast<double>(total_size));
267
+ } else {
268
+ distorted_frame->y = CalcSSIM(ch_org, ch_rec, image_width, image_height);
269
+ distorted_frame->u =
270
+ CalcSSIM(u_org, u_rec, (image_width + 1) / 2, (image_height + 1) / 2);
271
+ distorted_frame->v =
272
+ CalcSSIM(v_org, v_rec, (image_width + 1) / 2, (image_height + 1) / 2);
273
+ distorted_frame->all =
274
+ (distorted_frame->y + distorted_frame->u + distorted_frame->v) /
275
+ total_size;
276
+ distorted_frame->y /= y_size;
277
+ distorted_frame->u /= uv_size;
278
+ distorted_frame->v /= uv_size;
279
+
280
+ if (do_lssim) {
281
+ distorted_frame->all = CalcLSSIM(distorted_frame->all);
282
+ distorted_frame->y = CalcLSSIM(distorted_frame->y);
283
+ distorted_frame->u = CalcLSSIM(distorted_frame->u);
284
+ distorted_frame->v = CalcLSSIM(distorted_frame->v);
285
+ }
286
+ }
287
+
288
+ cur_distortion_psnr->y += distorted_frame->y;
289
+ cur_distortion_psnr->u += distorted_frame->u;
290
+ cur_distortion_psnr->v += distorted_frame->v;
291
+ cur_distortion_psnr->all += distorted_frame->all;
292
+
293
+ bool ismin = false;
294
+ if (distorted_frame->y < cur_distortion_psnr->min_y) {
295
+ cur_distortion_psnr->min_y = distorted_frame->y;
296
+ }
297
+ if (distorted_frame->u < cur_distortion_psnr->min_u) {
298
+ cur_distortion_psnr->min_u = distorted_frame->u;
299
+ }
300
+ if (distorted_frame->v < cur_distortion_psnr->min_v) {
301
+ cur_distortion_psnr->min_v = distorted_frame->v;
302
+ }
303
+ if (distorted_frame->all < cur_distortion_psnr->min_all) {
304
+ cur_distortion_psnr->min_all = distorted_frame->all;
305
+ cur_distortion_psnr->min_frame = number_of_frames;
306
+ ismin = true;
307
+ }
308
+ return ismin;
309
+ }
310
+
311
+ int main(int argc, const char* argv[]) {
312
+ ParseOptions(argc, argv);
313
+ if (!do_psnr && !do_ssim) {
314
+ do_psnr = true;
315
+ }
316
+
317
+ #ifdef _OPENMP
318
+ if (num_threads) {
319
+ omp_set_num_threads(num_threads);
320
+ }
321
+ if (verbose) {
322
+ printf("OpenMP %d procs\n", omp_get_num_procs());
323
+ }
324
+ #endif
325
+ // Open original file (first file argument)
326
+ FILE* const file_org = fopen(argv[fileindex_org], "rb");
327
+ if (file_org == NULL) {
328
+ fprintf(stderr, "Cannot open %s\n", argv[fileindex_org]);
329
+ exit(1);
330
+ }
331
+
332
+ // Open all files to compare to
333
+ FILE** file_rec = new FILE*[num_rec];
334
+ memset(file_rec, 0, num_rec * sizeof(FILE*)); // NOLINT
335
+ for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) {
336
+ file_rec[cur_rec] = fopen(argv[fileindex_rec + cur_rec], "rb");
337
+ if (file_rec[cur_rec] == NULL) {
338
+ fprintf(stderr, "Cannot open %s\n", argv[fileindex_rec + cur_rec]);
339
+ fclose(file_org);
340
+ for (int i = 0; i < cur_rec; ++i) {
341
+ fclose(file_rec[i]);
342
+ }
343
+ delete[] file_rec;
344
+ exit(1);
345
+ }
346
+ }
347
+
348
+ const int y_size = image_width * image_height;
349
+ const int uv_size = ((image_width + 1) / 2) * ((image_height + 1) / 2);
350
+ const size_t total_size = y_size + 2 * uv_size; // NOLINT
351
+ #if defined(_MSC_VER)
352
+ _fseeki64(
353
+ file_org,
354
+ static_cast<__int64>(num_skip_org) * static_cast<__int64>(total_size),
355
+ SEEK_SET);
356
+ #else
357
+ fseek(file_org, num_skip_org * total_size, SEEK_SET);
358
+ #endif
359
+ for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) {
360
+ #if defined(_MSC_VER)
361
+ _fseeki64(
362
+ file_rec[cur_rec],
363
+ static_cast<__int64>(num_skip_rec) * static_cast<__int64>(total_size),
364
+ SEEK_SET);
365
+ #else
366
+ fseek(file_rec[cur_rec], num_skip_rec * total_size, SEEK_SET);
367
+ #endif
368
+ }
369
+
370
+ uint8_t* const ch_org = new uint8_t[total_size];
371
+ uint8_t* const ch_rec = new uint8_t[total_size];
372
+ if (ch_org == NULL || ch_rec == NULL) {
373
+ fprintf(stderr, "No memory available\n");
374
+ fclose(file_org);
375
+ for (int i = 0; i < num_rec; ++i) {
376
+ fclose(file_rec[i]);
377
+ }
378
+ delete[] ch_org;
379
+ delete[] ch_rec;
380
+ delete[] file_rec;
381
+ exit(1);
382
+ }
383
+
384
+ metric* const distortion_psnr = new metric[num_rec];
385
+ metric* const distortion_ssim = new metric[num_rec];
386
+ for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) {
387
+ metric* cur_distortion_psnr = &distortion_psnr[cur_rec];
388
+ cur_distortion_psnr->y = 0.0;
389
+ cur_distortion_psnr->u = 0.0;
390
+ cur_distortion_psnr->v = 0.0;
391
+ cur_distortion_psnr->all = 0.0;
392
+ cur_distortion_psnr->min_y = kMaxPSNR;
393
+ cur_distortion_psnr->min_u = kMaxPSNR;
394
+ cur_distortion_psnr->min_v = kMaxPSNR;
395
+ cur_distortion_psnr->min_all = kMaxPSNR;
396
+ cur_distortion_psnr->min_frame = 0;
397
+ cur_distortion_psnr->global_y = 0.0;
398
+ cur_distortion_psnr->global_u = 0.0;
399
+ cur_distortion_psnr->global_v = 0.0;
400
+ cur_distortion_psnr->global_all = 0.0;
401
+ distortion_ssim[cur_rec] = cur_distortion_psnr[cur_rec];
402
+ }
403
+
404
+ if (verbose) {
405
+ printf("Size: %dx%d\n", image_width, image_height);
406
+ }
407
+
408
+ if (!quiet) {
409
+ printf("Frame");
410
+ if (do_psnr) {
411
+ printf("\t PSNR-Y \t PSNR-U \t PSNR-V \t PSNR-All \t Frame");
412
+ }
413
+ if (do_ssim) {
414
+ printf("\t SSIM-Y\t SSIM-U\t SSIM-V\t SSIM-All\t Frame");
415
+ }
416
+ if (show_name) {
417
+ printf("\tName\n");
418
+ } else {
419
+ printf("\n");
420
+ }
421
+ }
422
+
423
+ int number_of_frames;
424
+ for (number_of_frames = 0;; ++number_of_frames) {
425
+ if (num_frames && number_of_frames >= num_frames) {
426
+ break;
427
+ }
428
+
429
+ size_t bytes_org = fread(ch_org, sizeof(uint8_t), total_size, file_org);
430
+ if (bytes_org < total_size) {
431
+ #ifdef HAVE_JPEG
432
+ // Try parsing file as a jpeg.
433
+ uint8_t* const ch_jpeg = new uint8_t[bytes_org];
434
+ memcpy(ch_jpeg, ch_org, bytes_org);
435
+ memset(ch_org, 0, total_size);
436
+
437
+ if (0 != libyuv::MJPGToI420(ch_jpeg, bytes_org, ch_org, image_width,
438
+ ch_org + y_size, (image_width + 1) / 2,
439
+ ch_org + y_size + uv_size,
440
+ (image_width + 1) / 2, image_width,
441
+ image_height, image_width, image_height)) {
442
+ delete[] ch_jpeg;
443
+ break;
444
+ }
445
+ delete[] ch_jpeg;
446
+ #else
447
+ break;
448
+ #endif // HAVE_JPEG
449
+ }
450
+
451
+ for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) {
452
+ size_t bytes_rec =
453
+ fread(ch_rec, sizeof(uint8_t), total_size, file_rec[cur_rec]);
454
+ if (bytes_rec < total_size) {
455
+ #ifdef HAVE_JPEG
456
+ // Try parsing file as a jpeg.
457
+ uint8_t* const ch_jpeg = new uint8_t[bytes_rec];
458
+ memcpy(ch_jpeg, ch_rec, bytes_rec);
459
+ memset(ch_rec, 0, total_size);
460
+
461
+ if (0 != libyuv::MJPGToI420(ch_jpeg, bytes_rec, ch_rec, image_width,
462
+ ch_rec + y_size, (image_width + 1) / 2,
463
+ ch_rec + y_size + uv_size,
464
+ (image_width + 1) / 2, image_width,
465
+ image_height, image_width, image_height)) {
466
+ delete[] ch_jpeg;
467
+ break;
468
+ }
469
+ delete[] ch_jpeg;
470
+ #else
471
+ break;
472
+ #endif // HAVE_JPEG
473
+ }
474
+
475
+ if (verbose) {
476
+ printf("%5d", number_of_frames);
477
+ }
478
+ if (do_psnr) {
479
+ metric distorted_frame = {};
480
+ metric* cur_distortion_psnr = &distortion_psnr[cur_rec];
481
+ bool ismin = UpdateMetrics(ch_org, ch_rec, y_size, uv_size, total_size,
482
+ number_of_frames, cur_distortion_psnr,
483
+ &distorted_frame, true);
484
+ if (verbose) {
485
+ printf("\t%10.6f", distorted_frame.y);
486
+ printf("\t%10.6f", distorted_frame.u);
487
+ printf("\t%10.6f", distorted_frame.v);
488
+ printf("\t%10.6f", distorted_frame.all);
489
+ printf("\t%5s", ismin ? "min" : "");
490
+ }
491
+ }
492
+ if (do_ssim) {
493
+ metric distorted_frame = {};
494
+ metric* cur_distortion_ssim = &distortion_ssim[cur_rec];
495
+ bool ismin = UpdateMetrics(ch_org, ch_rec, y_size, uv_size, total_size,
496
+ number_of_frames, cur_distortion_ssim,
497
+ &distorted_frame, false);
498
+ if (verbose) {
499
+ printf("\t%10.6f", distorted_frame.y);
500
+ printf("\t%10.6f", distorted_frame.u);
501
+ printf("\t%10.6f", distorted_frame.v);
502
+ printf("\t%10.6f", distorted_frame.all);
503
+ printf("\t%5s", ismin ? "min" : "");
504
+ }
505
+ }
506
+ if (verbose) {
507
+ if (show_name) {
508
+ printf("\t%s", argv[fileindex_rec + cur_rec]);
509
+ }
510
+ printf("\n");
511
+ }
512
+ }
513
+ }
514
+
515
+ // Final PSNR computation.
516
+ for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) {
517
+ metric* cur_distortion_psnr = &distortion_psnr[cur_rec];
518
+ metric* cur_distortion_ssim = &distortion_ssim[cur_rec];
519
+ if (number_of_frames > 0) {
520
+ const double norm = 1. / static_cast<double>(number_of_frames);
521
+ cur_distortion_psnr->y *= norm;
522
+ cur_distortion_psnr->u *= norm;
523
+ cur_distortion_psnr->v *= norm;
524
+ cur_distortion_psnr->all *= norm;
525
+ cur_distortion_ssim->y *= norm;
526
+ cur_distortion_ssim->u *= norm;
527
+ cur_distortion_ssim->v *= norm;
528
+ cur_distortion_ssim->all *= norm;
529
+ }
530
+
531
+ if (do_psnr) {
532
+ const double global_psnr_y =
533
+ ComputePSNR(cur_distortion_psnr->global_y,
534
+ static_cast<double>(y_size) * number_of_frames);
535
+ const double global_psnr_u =
536
+ ComputePSNR(cur_distortion_psnr->global_u,
537
+ static_cast<double>(uv_size) * number_of_frames);
538
+ const double global_psnr_v =
539
+ ComputePSNR(cur_distortion_psnr->global_v,
540
+ static_cast<double>(uv_size) * number_of_frames);
541
+ const double global_psnr_all =
542
+ ComputePSNR(cur_distortion_psnr->global_all,
543
+ static_cast<double>(total_size) * number_of_frames);
544
+ printf("Global:\t%10.6f\t%10.6f\t%10.6f\t%10.6f\t%5d", global_psnr_y,
545
+ global_psnr_u, global_psnr_v, global_psnr_all, number_of_frames);
546
+ if (show_name) {
547
+ printf("\t%s", argv[fileindex_rec + cur_rec]);
548
+ }
549
+ printf("\n");
550
+ }
551
+
552
+ if (!quiet) {
553
+ printf("Avg:");
554
+ if (do_psnr) {
555
+ printf("\t%10.6f\t%10.6f\t%10.6f\t%10.6f\t%5d", cur_distortion_psnr->y,
556
+ cur_distortion_psnr->u, cur_distortion_psnr->v,
557
+ cur_distortion_psnr->all, number_of_frames);
558
+ }
559
+ if (do_ssim) {
560
+ printf("\t%10.6f\t%10.6f\t%10.6f\t%10.6f\t%5d", cur_distortion_ssim->y,
561
+ cur_distortion_ssim->u, cur_distortion_ssim->v,
562
+ cur_distortion_ssim->all, number_of_frames);
563
+ }
564
+ if (show_name) {
565
+ printf("\t%s", argv[fileindex_rec + cur_rec]);
566
+ }
567
+ printf("\n");
568
+ }
569
+ if (!quiet) {
570
+ printf("Min:");
571
+ if (do_psnr) {
572
+ printf("\t%10.6f\t%10.6f\t%10.6f\t%10.6f\t%5d",
573
+ cur_distortion_psnr->min_y, cur_distortion_psnr->min_u,
574
+ cur_distortion_psnr->min_v, cur_distortion_psnr->min_all,
575
+ cur_distortion_psnr->min_frame);
576
+ }
577
+ if (do_ssim) {
578
+ printf("\t%10.6f\t%10.6f\t%10.6f\t%10.6f\t%5d",
579
+ cur_distortion_ssim->min_y, cur_distortion_ssim->min_u,
580
+ cur_distortion_ssim->min_v, cur_distortion_ssim->min_all,
581
+ cur_distortion_ssim->min_frame);
582
+ }
583
+ if (show_name) {
584
+ printf("\t%s", argv[fileindex_rec + cur_rec]);
585
+ }
586
+ printf("\n");
587
+ }
588
+
589
+ if (do_mse) {
590
+ double global_mse_y =
591
+ GetMSE(cur_distortion_psnr->global_y,
592
+ static_cast<double>(y_size) * number_of_frames);
593
+ double global_mse_u =
594
+ GetMSE(cur_distortion_psnr->global_u,
595
+ static_cast<double>(uv_size) * number_of_frames);
596
+ double global_mse_v =
597
+ GetMSE(cur_distortion_psnr->global_v,
598
+ static_cast<double>(uv_size) * number_of_frames);
599
+ double global_mse_all =
600
+ GetMSE(cur_distortion_psnr->global_all,
601
+ static_cast<double>(total_size) * number_of_frames);
602
+ printf("MSE:\t%10.6f\t%10.6f\t%10.6f\t%10.6f\t%5d", global_mse_y,
603
+ global_mse_u, global_mse_v, global_mse_all, number_of_frames);
604
+ if (show_name) {
605
+ printf("\t%s", argv[fileindex_rec + cur_rec]);
606
+ }
607
+ printf("\n");
608
+ }
609
+ }
610
+ fclose(file_org);
611
+ for (int cur_rec = 0; cur_rec < num_rec; ++cur_rec) {
612
+ fclose(file_rec[cur_rec]);
613
+ }
614
+ delete[] distortion_psnr;
615
+ delete[] distortion_ssim;
616
+ delete[] ch_org;
617
+ delete[] ch_rec;
618
+ delete[] file_rec;
619
+ return 0;
620
+ }