PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/HDRVQM/src/HDRVQMFrame.cpp

https://gitlab.com/standards/HDRTools
C++ | 561 lines | 402 code | 67 blank | 92 comment | 159 complexity | 036d1e43996cb425b53fe8354357ae0c MD5 | raw file
  1. /* The copyright in this software is being made available under the BSD
  2. * License, included below. This software may be subject to other third party
  3. * and contributor rights, including patent rights, and no such rights are
  4. * granted under this license.
  5. *
  6. * <OWNER> = Samsung Electronics, Apple Inc.
  7. * <ORGANIZATION> = Samsung Electronics, Apple Inc.
  8. * <YEAR> = 2016
  9. *
  10. * Copyright (c) 2016, Samsung Electronics, Apple Inc.
  11. * All rights reserved.
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions are met:
  15. *
  16. * * Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. * * Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. * * Neither the name of the <ORGANIZATION> nor the names of its contributors may
  22. * be used to endorse or promote products derived from this software without
  23. * specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
  29. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  30. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  31. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  32. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  33. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  34. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  35. * THE POSSIBILITY OF SUCH DAMAGE.
  36. */
  37. /*!
  38. *************************************************************************************
  39. * \file HDRVQMFrame.cpp
  40. *
  41. * \brief
  42. * HDRVQMFrame class source files for computing VQM for a frame
  43. *
  44. * \author
  45. * - Kulbhushan Pachauri <kb.pachauri@samsung.com>
  46. * - Alexis Michael Tourapis <atourapis@apple.com>
  47. *************************************************************************************
  48. */
  49. #include <time.h>
  50. #include <string.h>
  51. #include <math.h>
  52. #include <vector>
  53. #include "HDRVQMFrame.H"
  54. //-----------------------------------------------------------------------------
  55. // constructor /de-constructor
  56. //-----------------------------------------------------------------------------
  57. HDRVQMFrame::HDRVQMFrame(ProjectParameters *inputParams)
  58. {
  59. using ::hdrtoolslib::Frame;
  60. using ::hdrtoolslib::Input;
  61. using ::hdrtoolslib::IOVideo;
  62. m_numberOfClips = 2;
  63. m_frameStore = new Frame* [m_numberOfClips];
  64. m_cropFrameStore = new Frame* [m_numberOfClips];
  65. m_windowFrameStore = new Frame* [m_numberOfClips];
  66. m_inputFrame = new Input* [m_numberOfClips];
  67. m_inputFile = new IOVideo* [m_numberOfClips];
  68. m_startFrame = new int [m_numberOfClips];
  69. m_cropOffsetLeft = new int [m_numberOfClips];
  70. m_cropOffsetTop = new int [m_numberOfClips];
  71. m_cropOffsetRight = new int [m_numberOfClips];
  72. m_cropOffsetBottom = new int [m_numberOfClips];
  73. for (int index = 0; index < m_numberOfClips; index++) {
  74. m_frameStore[index] = NULL;
  75. m_cropFrameStore[index] = NULL;
  76. m_windowFrameStore[index] = NULL;
  77. m_inputFrame[index] = NULL;
  78. m_inputFile[index] = &inputParams->m_inputFile[index];
  79. m_startFrame[index] = m_inputFile[index]->m_startFrame;
  80. m_cropOffsetLeft[index] = inputParams->m_cropOffsetLeft [index];
  81. m_cropOffsetTop[index] = inputParams->m_cropOffsetTop [index];
  82. m_cropOffsetRight[index] = inputParams->m_cropOffsetRight [index];
  83. m_cropOffsetBottom[index] = inputParams->m_cropOffsetBottom[index];
  84. }
  85. m_distortionMetric = new hdrtoolslib::DistortionMetric*[hdrtoolslib::DIST_METRICS];
  86. m_windowDistortionMetric = new hdrtoolslib::DistortionMetric*[hdrtoolslib::DIST_METRICS];
  87. m_enableWindow = false;
  88. m_windowMinPosX = 0;
  89. m_windowMaxPosX = 0;
  90. m_windowMinPosY = 0;
  91. m_windowMaxPosY = 0;
  92. m_windowWidth = 0;
  93. m_windowHeight = 0;
  94. // Copy input distortion parameters
  95. m_distortionParameters = inputParams->m_distortionParameters;
  96. for (int index = hdrtoolslib::DIST_NULL; index < hdrtoolslib::DIST_METRICS; index++) {
  97. m_distortionMetric[index] = NULL;
  98. m_windowDistortionMetric[index] = NULL;
  99. }
  100. }
  101. HDRVQMFrame::~HDRVQMFrame()
  102. {
  103. if (m_frameStore != NULL) {
  104. delete [] m_frameStore;
  105. m_frameStore = NULL;
  106. }
  107. if (m_cropFrameStore != NULL) {
  108. delete [] m_cropFrameStore;
  109. m_cropFrameStore = NULL;
  110. }
  111. if (m_windowFrameStore != NULL) {
  112. delete [] m_windowFrameStore;
  113. m_windowFrameStore = NULL;
  114. }
  115. if (m_inputFrame != NULL) {
  116. delete [] m_inputFrame;
  117. m_inputFrame = NULL;
  118. }
  119. if (m_inputFile != NULL) {
  120. delete [] m_inputFile;
  121. m_inputFile = NULL;
  122. }
  123. if (m_startFrame != NULL) {
  124. delete [] m_startFrame;
  125. m_startFrame = NULL;
  126. }
  127. // Cropping parameters
  128. if (m_cropOffsetLeft != NULL) {
  129. delete [] m_cropOffsetLeft;
  130. m_cropOffsetLeft = NULL;
  131. }
  132. if (m_cropOffsetTop != NULL) {
  133. delete [] m_cropOffsetTop;
  134. m_cropOffsetTop = NULL;
  135. }
  136. if (m_cropOffsetRight != NULL) {
  137. delete [] m_cropOffsetRight;
  138. m_cropOffsetRight = NULL;
  139. }
  140. if (m_cropOffsetBottom != NULL) {
  141. delete [] m_cropOffsetBottom;
  142. m_cropOffsetBottom = NULL;
  143. }
  144. // Distortion parameters
  145. if (m_distortionMetric != NULL) {
  146. delete [] m_distortionMetric;
  147. m_distortionMetric = NULL;
  148. }
  149. if (m_windowDistortionMetric != NULL) {
  150. delete [] m_windowDistortionMetric;
  151. m_windowDistortionMetric = NULL;
  152. }
  153. }
  154. //-----------------------------------------------------------------------------
  155. // allocate memory - create frame stores
  156. //-----------------------------------------------------------------------------
  157. void HDRVQMFrame::allocateFrameStores(hdrtoolslib::Input *inputFrame, hdrtoolslib::Frame **frameStore)
  158. {
  159. // delete frame store if previous allocated
  160. if ((*frameStore) != NULL)
  161. delete (*frameStore);
  162. // create frame memory as necessary
  163. // Input. This has the same format as the Input file.
  164. using ::hdrtoolslib::Y_COMP;
  165. (*frameStore) = new hdrtoolslib::Frame(inputFrame->m_width[Y_COMP], inputFrame->m_height[Y_COMP], inputFrame->m_isFloat, inputFrame->m_colorSpace, inputFrame->m_colorPrimaries, inputFrame->m_chromaFormat, inputFrame->m_sampleRange, inputFrame->m_bitDepthComp[Y_COMP], inputFrame->m_isInterlaced, inputFrame->m_transferFunction, inputFrame->m_systemGamma);
  166. (*frameStore)->clear();
  167. }
  168. //-----------------------------------------------------------------------------
  169. // initialize
  170. //-----------------------------------------------------------------------------
  171. void HDRVQMFrame::init (ProjectParameters *inputParams)
  172. {
  173. std::vector <int> width (m_numberOfClips);
  174. std::vector <int> height(m_numberOfClips);
  175. using ::hdrtoolslib::Y_COMP;
  176. for (int index = 0; index < m_numberOfClips; index++) {
  177. // Input frame objects initialization
  178. hdrtoolslib::IOFunctions::openFile (m_inputFile[index]);
  179. if (m_inputFile[index]->m_isConcatenated == false && strlen(m_inputFile[index]->m_fTail) == 0) {
  180. // Update number of frames to be processed
  181. inputParams->m_numberOfFrames = 1;
  182. }
  183. // create memory for reading the input filesource
  184. m_inputFrame[index] = hdrtoolslib::Input::create(m_inputFile[index], &inputParams->m_source[index], inputParams);
  185. if (m_inputFile[index]->m_videoType == hdrtoolslib::VIDEO_YUV)
  186. allocateFrameStores(m_inputFrame[index], &m_frameStore[index]);
  187. else
  188. {
  189. // Read first frame just to see if there is need to update any parameters. This is very important for OpenEXR files
  190. if (m_inputFrame[index]->readOneFrame(m_inputFile[index], 0, m_inputFile[index]->m_fileHeader, m_startFrame[index]) == true) {
  191. allocateFrameStores(m_inputFrame[index], &m_frameStore[index]);
  192. }
  193. else {
  194. fprintf(stderr, "Error reading input file. Process exiting.\n");
  195. destroy();
  196. exit(EXIT_FAILURE);
  197. }
  198. }
  199. if (m_cropOffsetLeft[index] != 0 || m_cropOffsetTop[index] != 0 || m_cropOffsetRight[index] != 0 || m_cropOffsetBottom[index] != 0) {
  200. width[index] = m_inputFrame[index]->m_width[Y_COMP] - m_cropOffsetLeft[index] + m_cropOffsetRight[index];
  201. height[index] = m_inputFrame[index]->m_height[Y_COMP] - m_cropOffsetTop[index] + m_cropOffsetBottom[index];
  202. m_cropFrameStore[index] = new hdrtoolslib::Frame(width[index], height[index], m_inputFrame[index]->m_isFloat, m_inputFrame[index]->m_colorSpace, m_inputFrame[index]->m_colorPrimaries, m_inputFrame[index]->m_chromaFormat, m_inputFrame[index]->m_sampleRange, m_inputFrame[index]->m_bitDepthComp[Y_COMP], m_inputFrame[index]->m_isInterlaced, m_inputFrame[index]->m_transferFunction, m_inputFrame[index]->m_systemGamma);
  203. m_cropFrameStore[index]->clear();
  204. }
  205. else {
  206. width[index] = m_inputFrame[index]->m_width[Y_COMP];
  207. height[index] = m_inputFrame[index]->m_height[Y_COMP];
  208. }
  209. }
  210. if (m_frameStore[0]->equalType(m_frameStore[1]) == false) {
  211. fprintf(stderr, "Error. Input sources of different type.\n");
  212. destroy();
  213. exit(EXIT_FAILURE);
  214. }
  215. for (int index = hdrtoolslib::DIST_NULL; index < hdrtoolslib::DIST_METRICS; index++) {
  216. m_enableMetric[index] = inputParams->m_enableMetric[index];
  217. if (m_enableMetric[index] == true)
  218. m_distortionMetric[index] = hdrtoolslib::DistortionMetric::create(&m_frameStore[0]->m_format, index, &m_distortionParameters, false);
  219. }
  220. m_enableWindow = inputParams->m_enableWindow;
  221. if (m_enableWindow) {
  222. m_windowMinPosX = inputParams->m_windowMinPosX;
  223. m_windowMaxPosX = inputParams->m_windowMaxPosX;
  224. m_windowMinPosY = inputParams->m_windowMinPosY;
  225. m_windowMaxPosY = inputParams->m_windowMaxPosY;
  226. m_windowWidth = hdrtoolslib::iAbs(m_windowMaxPosX - m_windowMinPosX + 1);
  227. m_windowHeight = hdrtoolslib::iAbs(m_windowMaxPosY - m_windowMinPosY + 1);
  228. m_windowFrameStore[0] = new hdrtoolslib::Frame(m_windowWidth, m_windowHeight, m_inputFrame[0]->m_isFloat, m_inputFrame[0]->m_colorSpace, m_inputFrame[0]->m_colorPrimaries, m_inputFrame[0]->m_chromaFormat, m_inputFrame[0]->m_sampleRange, m_inputFrame[0]->m_bitDepthComp[Y_COMP], m_inputFrame[0]->m_isInterlaced, m_inputFrame[0]->m_transferFunction, m_inputFrame[0]->m_systemGamma);
  229. m_windowFrameStore[0]->clear();
  230. m_windowFrameStore[1] = new hdrtoolslib::Frame(m_windowWidth, m_windowHeight, m_inputFrame[1]->m_isFloat, m_inputFrame[1]->m_colorSpace, m_inputFrame[1]->m_colorPrimaries, m_inputFrame[1]->m_chromaFormat, m_inputFrame[1]->m_sampleRange, m_inputFrame[1]->m_bitDepthComp[Y_COMP], m_inputFrame[1]->m_isInterlaced, m_inputFrame[1]->m_transferFunction, m_inputFrame[1]->m_systemGamma);
  231. m_windowFrameStore[1]->clear();
  232. for (int index = hdrtoolslib::DIST_NULL; index < hdrtoolslib::DIST_METRICS; index++) {
  233. m_enableWindowMetric[index] = inputParams->m_enableWindowMetric[index];
  234. if (m_enableWindowMetric[index] == true)
  235. m_windowDistortionMetric[index] = hdrtoolslib::DistortionMetric::create(&m_windowFrameStore[0]->m_format, index, &m_distortionParameters, true);
  236. }
  237. }
  238. }
  239. //-----------------------------------------------------------------------------
  240. // deallocate memory - destroy objects
  241. //-----------------------------------------------------------------------------
  242. void HDRVQMFrame::destroy()
  243. {
  244. for (int index = 0; index < m_numberOfClips; index++) {
  245. if (m_enableWindow) {
  246. if (m_windowFrameStore[index] != NULL) {
  247. delete m_windowFrameStore[index];
  248. m_windowFrameStore[index] = NULL;
  249. }
  250. }
  251. if (m_frameStore[index] != NULL) {
  252. delete m_frameStore[index];
  253. m_frameStore[index] = NULL;
  254. }
  255. if (m_cropFrameStore[index] != NULL) {
  256. delete m_cropFrameStore[index];
  257. m_cropFrameStore[index] = NULL;
  258. }
  259. if (m_inputFrame[index] != NULL) {
  260. delete m_inputFrame[index];
  261. m_inputFrame[index] = NULL;
  262. }
  263. hdrtoolslib::IOFunctions::closeFile(m_inputFile[index]);
  264. }
  265. for (int index = hdrtoolslib::DIST_NULL; index < hdrtoolslib::DIST_METRICS; index++) {
  266. if (m_distortionMetric[index] != NULL) {
  267. delete m_distortionMetric[index];
  268. m_distortionMetric[index] = NULL;
  269. }
  270. if (m_windowDistortionMetric[index] != NULL) {
  271. delete m_windowDistortionMetric[index];
  272. m_windowDistortionMetric[index] = NULL;
  273. }
  274. }
  275. }
  276. //-----------------------------------------------------------------------------
  277. // main filtering function
  278. //-----------------------------------------------------------------------------
  279. void HDRVQMFrame::process( ProjectParameters *inputParams ) {
  280. int frameNumber;
  281. int iCurrentFrameToProcess = 0;
  282. std::vector <hdrtoolslib::Frame *> currentFrame(m_numberOfClips);
  283. hdrtoolslib::VQMParams *paramsVQM = &inputParams->m_distortionParameters.m_VQM;
  284. int index;
  285. clock_t clk;
  286. bool errorRead = false;
  287. bool single_pass = false; // tells if single pass is done or not
  288. int mult_factor;
  289. if(paramsVQM->m_displayAdapt == false) {
  290. single_pass = true;
  291. if (paramsVQM->m_frameRate == 0.0f)
  292. mult_factor = (int) ceil(paramsVQM->m_fixationTime);
  293. else
  294. mult_factor = (int) ceil(paramsVQM->m_frameRate * paramsVQM->m_fixationTime);
  295. }
  296. else {
  297. mult_factor = 1;
  298. }
  299. for (frameNumber = 0; frameNumber < inputParams->m_numberOfFrames; frameNumber = frameNumber + mult_factor) {
  300. for(int iters = 0; (iters < mult_factor) && (frameNumber + iters < inputParams->m_numberOfFrames); iters++) {
  301. clk = clock();
  302. using ::hdrtoolslib::Y_COMP;
  303. using ::hdrtoolslib::DIST_VQM;
  304. for (index = 0; index < m_numberOfClips; index++) {
  305. // Current frame to process depends on frame rate of current sequence versus frame rate of the first sequence
  306. //so, frames for 1st image read for even iterations of this for-loop. Baaki 2nd ke liye
  307. if ( inputParams->m_source[index % 2].m_frameRate == 0.0f || inputParams->m_source[0].m_frameRate == 0.0f)
  308. iCurrentFrameToProcess = frameNumber + iters;
  309. else
  310. iCurrentFrameToProcess = int((frameNumber + iters) * inputParams->m_source[index % 2].m_frameRate / inputParams->m_source[0].m_frameRate);
  311. if (m_inputFrame[index]->readOneFrame(m_inputFile[index % 2], iCurrentFrameToProcess, m_inputFile[index % 2]->m_fileHeader, m_startFrame[index]) == true) {
  312. // If the size of the images has changed, then reallocate space appropriately
  313. if ((m_inputFrame[index]->m_width[Y_COMP] != m_frameStore[index]->m_width[Y_COMP]) || (m_inputFrame[index]->m_height[Y_COMP] != m_frameStore[index]->m_height[Y_COMP])) {
  314. allocateFrameStores(m_inputFrame[index], &m_frameStore[index]);
  315. }
  316. // Now copy input frame buffer to processing frame buffer for any subsequent processing
  317. m_frameStore[index]->m_frameNo = frameNumber + iters;
  318. m_inputFrame[index]->copyFrame(m_frameStore[index]);
  319. currentFrame[index] = m_frameStore[index];
  320. if (m_cropFrameStore[index] != NULL) {
  321. m_cropFrameStore[index]->copy(m_frameStore[index], m_cropOffsetLeft[index], m_cropOffsetTop[index], m_frameStore[index]->m_width[Y_COMP] + m_cropOffsetRight[index], m_frameStore[index]->m_height[Y_COMP] + m_cropOffsetBottom[index], 0, 0);
  322. currentFrame[index] = m_cropFrameStore[index];
  323. }
  324. if (m_enableWindow == true) {
  325. m_windowFrameStore[index]->copy(currentFrame[index], m_windowMinPosX, m_windowMinPosY, m_windowMaxPosX, m_windowMaxPosY, 0, 0);
  326. }
  327. }
  328. else {
  329. inputParams->m_numberOfFrames = frameNumber + iters;
  330. errorRead = true;
  331. break;
  332. }
  333. }
  334. if (m_enableMetric[DIST_VQM] == true) {
  335. m_distortionMetric[DIST_VQM]->computeMetric(currentFrame[0], currentFrame[1]);
  336. }
  337. if (currentFrame[0]->equalType(currentFrame[1]) == false) {
  338. fprintf(stderr, "Error. Input sources of different type.\n");
  339. errorRead = true;
  340. break;
  341. }
  342. if (errorRead == true) {
  343. break;
  344. }
  345. else {
  346. if (inputParams->m_silentMode == false) {
  347. printf("%06d ", frameNumber + iters );
  348. m_distortionMetric[DIST_VQM]->reportMetric();
  349. }
  350. }
  351. if((frameNumber + iters) == inputParams->m_numberOfFrames - 1 && !single_pass) {
  352. //alright, adapt_display done. Now scale the image and compute
  353. m_distortionMetric[DIST_VQM]->m_allFrames = true;
  354. //m_distortionMetric[DIST_VQM]->computeMetric(currentFrame[0], currentFrame[1]);
  355. //change this too. Mult_factor is for running the for-loop for 15frames to account for pooling
  356. single_pass = true;
  357. frameNumber = -1;
  358. }
  359. if (inputParams->m_silentMode == false){
  360. clk = clock() - clk;
  361. printf("%7.3f", 1.0 * clk / CLOCKS_PER_SEC);
  362. printf("\n");
  363. fflush(stdout);
  364. }
  365. else {
  366. printf("Processing Frame : %d\r", frameNumber);
  367. fflush(stdout);
  368. }
  369. }
  370. if(single_pass)
  371. {
  372. if (paramsVQM->m_frameRate == 0.0f)
  373. mult_factor = (int) ceil(paramsVQM->m_fixationTime);
  374. else
  375. mult_factor = (int) ceil(paramsVQM->m_frameRate * paramsVQM->m_fixationTime);
  376. if(frameNumber%mult_factor != 0)
  377. frameNumber = -mult_factor;
  378. }
  379. }
  380. }
  381. //-----------------------------------------------------------------------------
  382. // header output
  383. //-----------------------------------------------------------------------------
  384. void HDRVQMFrame::outputHeader(ProjectParameters *inputParams) {
  385. printf("================================================================================================================\n");
  386. for (int index = 0; index < m_numberOfClips; index++) {
  387. printf("Input%d: %s\n", index, inputParams->m_inputFile[index].m_fName);
  388. using ::hdrtoolslib::Y_COMP;
  389. printf("W x H: (%dx%d) ~ (%dx%d - %dx%d) => (%dx%d)\n", m_inputFrame[index]->m_width[Y_COMP], m_inputFrame[index]->m_height[Y_COMP],
  390. m_cropOffsetLeft[index], m_cropOffsetTop[index], m_cropOffsetRight[index], m_cropOffsetBottom[index],
  391. m_inputFrame[index]->m_width[Y_COMP] - m_cropOffsetLeft[index] + m_cropOffsetRight[index], m_inputFrame[index]->m_height[Y_COMP] - m_cropOffsetTop[index] + m_cropOffsetBottom[index]);
  392. m_inputFrame[index]->printFormat();
  393. if (index < m_numberOfClips - 1) {
  394. printf("----------------------------------------------------------------------------------------------------------------\n");
  395. }
  396. else {
  397. printf("================================================================================================================\n");
  398. }
  399. }
  400. if (m_enableWindow) {
  401. printf(" Cropped Window Statistics Enabled from rectangle position (%d,%d) and size (%dx%d)\n", hdrtoolslib::iMin(m_windowMinPosX,m_windowMaxPosX), hdrtoolslib::iMin(m_windowMinPosY,m_windowMaxPosY), m_windowWidth, m_windowHeight);
  402. printf("================================================================================================================\n");
  403. }
  404. if (inputParams->m_silentMode == false) {
  405. for (int index = hdrtoolslib::DIST_NULL; index < hdrtoolslib::DIST_METRICS; index++) {
  406. if (m_enableMetric[index] == true)
  407. m_distortionMetric[index]->printSeparator();
  408. }
  409. if (m_enableWindow) {
  410. printf("---");
  411. for (int index = hdrtoolslib::DIST_NULL; index < hdrtoolslib::DIST_METRICS; index++) {
  412. if (m_enableWindowMetric[index] == true)
  413. m_windowDistortionMetric[index]->printSeparator();
  414. }
  415. }
  416. // Separators for 'Frame# Time'
  417. printf("---------------------------------------------------------\n");
  418. printf("Frame# "); // 8
  419. for (int index = hdrtoolslib::DIST_NULL; index < hdrtoolslib::DIST_METRICS; index++) {
  420. if (m_enableMetric[index] == true)
  421. m_distortionMetric[index]->printHeader();
  422. }
  423. if (m_enableWindow) {
  424. printf(" | ");
  425. for (int index = hdrtoolslib::DIST_NULL; index < hdrtoolslib::DIST_METRICS; index++) {
  426. if (m_enableWindowMetric[index] == true)
  427. m_windowDistortionMetric[index]->printHeader();
  428. }
  429. }
  430. printf(" Time "); // 7
  431. printf("\n---------------------------------------------------------\n");
  432. }
  433. }
  434. //-----------------------------------------------------------------------------
  435. // footer output
  436. //-----------------------------------------------------------------------------
  437. void HDRVQMFrame::outputFooter(ProjectParameters *inputParams) {
  438. int j;
  439. clock_t clk = clock();
  440. FILE* f = hdrtoolslib::IOFunctions::openFile(inputParams->m_logFile, "at");
  441. if (f != NULL) {
  442. fprintf(f, "%s ", inputParams->m_inputFile[0].m_fName);
  443. fprintf(f, "%s ", inputParams->m_inputFile[1].m_fName);
  444. fprintf(f, "%d ", inputParams->m_numberOfFrames);
  445. fprintf(f, "%f \n", 1.0 * clk / inputParams->m_numberOfFrames / CLOCKS_PER_SEC);
  446. }
  447. //if (inputParams->m_silentMode == FALSE){
  448. if (1) {
  449. for (j = hdrtoolslib::DIST_NULL; j < hdrtoolslib::DIST_METRICS; j++) {
  450. if (m_enableMetric[j] == true)
  451. m_distortionMetric[j]->printSeparator();
  452. }
  453. if (m_enableWindow) {
  454. printf("---");
  455. for (int index = hdrtoolslib::DIST_NULL; index < hdrtoolslib::DIST_METRICS; index++) {
  456. if (m_enableWindowMetric[index] == true)
  457. m_windowDistortionMetric[index]->printSeparator();
  458. }
  459. }
  460. // Separators for 'Frame# Time'
  461. printf("---------------------------------------------------------\n");
  462. //printf("%06d ", inputParams->m_numberOfFrames);
  463. printf("HDR-VQM ");
  464. for (j = hdrtoolslib::DIST_NULL; j < hdrtoolslib::DIST_METRICS; j++) {
  465. if (m_enableMetric[j] == true)
  466. m_distortionMetric[j]->reportSummary();
  467. }
  468. if (m_enableWindow) {
  469. printf(" |");
  470. for (int index = hdrtoolslib::DIST_NULL; index < hdrtoolslib::DIST_METRICS; index++) {
  471. if (m_enableWindowMetric[index] == true)
  472. m_windowDistortionMetric[index]->reportSummary();
  473. }
  474. }
  475. //printf("%7.3f", clk / ((float) inputParams->m_numberOfFrames * (float) CLOCKS_PER_SEC));
  476. }
  477. // Separators for 'Frame# Time'
  478. printf("\n---------------------------------------------------------");
  479. printf("\nTotal of %d frames processed in %5.3f seconds\n",inputParams->m_numberOfFrames, 1.0 * clk / CLOCKS_PER_SEC);
  480. printf("Processing Speed: %3.2ffps\n", (float) inputParams->m_numberOfFrames * CLOCKS_PER_SEC / clk);
  481. for (j = hdrtoolslib::DIST_NULL; j < hdrtoolslib::DIST_METRICS; j++) {
  482. if (m_enableMetric[j] == true)
  483. m_distortionMetric[j]->printSeparator();
  484. }
  485. if (m_enableWindow) {
  486. printf("---");
  487. for (int index = hdrtoolslib::DIST_NULL; index < hdrtoolslib::DIST_METRICS; index++) {
  488. if (m_enableWindowMetric[index] == true)
  489. m_windowDistortionMetric[index]->printSeparator();
  490. }
  491. }
  492. printf("---------------------------------------------------------\n");
  493. hdrtoolslib::IOFunctions::closeFile(f);
  494. }