1 /******************************************************************************\
2 Copyright (c) 2017, Intel Corporation
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 
7 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 
9 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10 
11 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12 
13 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 
15 This sample was distributed or derived from the Intel's Media Samples package.
16 The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
17 or https://software.intel.com/en-us/media-client-solutions-support.
18 \**********************************************************************************/
19 
20 #ifndef __FEI_PREDICTORS_REPACKING_H__
21 #define __FEI_PREDICTORS_REPACKING_H__
22 
23 #include "sample_hevc_fei_defs.h"
24 #include "mfxfeihevc.h"
25 
26 class PredictorsRepaking
27 {
28 public:
29     PredictorsRepaking();
~PredictorsRepaking()30     ~PredictorsRepaking() {}
31 
32     mfxStatus Init(const mfxVideoParam& videoParams, mfxU16 preencDSfactor, const mfxU16 numMvPredictors[2]);
33     mfxStatus RepackPredictors(const HevcTask& task, mfxExtFeiHevcEncMVPredictors& mvp, mfxU16 nMvPredictors[2]);
34 
35     enum
36     {
37         PERFORMANCE = 0,
38         QUALITY     = 1
39     };
40 
SetPerfomanceRepackingMode()41     inline void SetPerfomanceRepackingMode() { m_repakingMode = PERFORMANCE; }
SetQualityRepackingMode()42     inline void SetQualityRepackingMode() { m_repakingMode = QUALITY; }
43 
44 private:
45     const mfxU8  m_max_fei_enc_mvp_num;// maximum number of predictors for encoder
46     //variables
47     mfxU8  m_repakingMode;         // repaking type: PERFORMANCE or QUALITY
48     mfxU16 m_width;                // input surface width
49     mfxU16 m_height;               // input surface height
50     mfxU8  m_downsample_power2;    // power of 2 for down-sampling: 0..3
51     mfxU16 m_widthCU_ds;           // width in CU (16x16) of ds surface
52     mfxU16 m_heightCU_ds;          // height in CU (16x16) of ds surface
53     mfxU16 m_widthCU_enc;          // width in CU (16x16) for encoder
54     mfxU16 m_heightCU_enc;         // height in CU (16x16) for encoder
55     mfxU16 m_maxNumMvPredictorsL0;
56     mfxU16 m_maxNumMvPredictorsL1;
57 
58     //functions
59     mfxStatus RepackPredictorsPerformance(const HevcTask& task, mfxExtFeiHevcEncMVPredictors& mvp, mfxU16 nMvPredictors[2]);
60     mfxStatus RepackPredictorsQuality(const HevcTask& task, mfxExtFeiHevcEncMVPredictors& mvp, mfxU16 nMvPredictors[2]);
61     mfxU8 ConvertDSratioPower2(mfxU8 DSfactor);
62 
63     DISALLOW_COPY_AND_ASSIGN(PredictorsRepaking);
64 };
65 
66 #endif // #define __FEI_PREDICTORS_REPACKING_H__
67