LCOV - code coverage report
Current view: top level - eq - roiTracker.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 0 1 0.0 %
Date: 2017-12-16 05:07:20 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /* Copyright (c) 2009-2017, Maxim Makhinya
       2             :  *                          Stefan Eilemann <eile@eyescale.ch>
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or modify it under
       5             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       6             :  * by the Free Software Foundation.
       7             :  *
       8             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       9             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      10             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      11             :  * details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      15             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      16             :  */
      17             : 
      18             : #ifndef EQ_ROI_TRACKER_H
      19             : #define EQ_ROI_TRACKER_H
      20             : 
      21             : #include <eq/fabric/pixelViewport.h> // member
      22             : #include <eq/types.h>
      23             : 
      24             : #include <co/types.h>
      25             : 
      26             : #include <string>
      27             : #include <unordered_map>
      28             : #include <vector>
      29             : 
      30             : namespace eq
      31             : {
      32             : /** Tracks requested areas for ROI. Used to disable ROI when ROI fails. */
      33             : class ROITracker
      34             : {
      35             : public:
      36             :     ROITracker();
      37             :     virtual ~ROITracker();
      38             : 
      39             :     /**
      40             :      * Has to be called once before any ROI calculation. Tells wether ROIFinder
      41             :      * should be executed for a particular region or not.  If true is returned,
      42             :      * then updateDelay must be called once before any next useROIFinder
      43             :      * call. If false is returned, then updateDelay shouldn't be called.
      44             :      *
      45             :      * This function uses _prvFrame areas data to match with current pvp. If
      46             :      * good intersection with one of previous areas is found, it will use
      47             :      * information from that area form previous frame to decide wether it should
      48             :      * skip ROIFinder execution or not. If good intersection is not found area
      49             :      * cosidered new, and function returns true.
      50             :      *
      51             :      * @param  pvp      same viewport that will be specifyed for FOIFinder
      52             :      * @param  stage    current assembling stage
      53             :      * @param  frameID  should be different for different frames
      54             :      * @param  ticket   should be stored by caller and given to updateDelay
      55             :      *
      56             :      * @return true if ROIFinder should be called for given region.
      57             :      */
      58             :     bool useROIFinder(const PixelViewport& pvp, const uint32_t stage,
      59             :                       const uint128_t& frameID, uint8_t*& ticket);
      60             : 
      61             :     /**
      62             :      * Has to be called once after every positive result from useROIFinder.
      63             :      * Shouldn't be called otherwise
      64             :      *
      65             :      * It checks how much space ROIFinder was able to discard and if it is not
      66             :      * enough it will disable usage of ROIFinder for several next frames. If
      67             :      * ROIFinder was able to cut-off enought it will reset failure statistics
      68             :      * for that region.
      69             :      *
      70             :      * @param  pvps    result from ROIFinder
      71             :      * @param  ticket  value from useROIFinder
      72             :      */
      73             :     void updateDelay(const PixelViewports& pvps, const uint8_t* ticket);
      74             : 
      75             : private:
      76             :     ROITracker(const ROITracker&) = delete;
      77             :     ROITracker& operator=(const ROITracker&) = delete;
      78             : 
      79             :     /** Area of readback */
      80             :     struct Area
      81             :     {
      82             :         Area(const PixelViewport& pvp_, uint32_t lastSkip_ = 0,
      83             :              uint32_t skip_ = 0);
      84             : 
      85             :         PixelViewport pvp;
      86             :         uint32_t lastSkip; //!< Previousely skiped number of frames
      87             :         uint32_t skip;     //!< Number of frames to skip ROIFinder
      88             :     };
      89             :     /** Set of readback areas per compositiong stage */
      90           0 :     struct Stage
      91             :     {
      92             :         std::vector<Area> areas;
      93             :     };
      94             :     /** Areas for different compositiong stages for current frame.
      95             :         This data if filled during useROIFinder calls, it uses
      96             :         useROIFinder parameters and _prvFrame data as refference */
      97             :     std::unordered_map<uint32_t, Stage>* _curFrame;
      98             : 
      99             :     /** Areas for different compositiong stages for previous frame. */
     100             :     std::unordered_map<uint32_t, Stage>* _prvFrame;
     101             : 
     102             :     uint8_t* _ticket;  //!< returned on getDelay, should match on updateDelay
     103             :     bool _needsUpdate; //!< true after getDelay, false after updateDelay
     104             :     uint128_t _lastFrameID; //!< used to determine new frames
     105             :     uint32_t _lastStage;    //!< used in updateDelay to find last added area
     106             : 
     107             :     bool _returnPositive(uint8_t*& ticket);
     108             : };
     109             : }
     110             : 
     111             : #endif // EQ_ROI_TRACKER_H

Generated by: LCOV version 1.11