1 /*!
2  * \copy
3  *     Copyright (c)  2013, Cisco Systems
4  *     All rights reserved.
5  *
6  *     Redistribution and use in source and binary forms, with or without
7  *     modification, are permitted provided that the following conditions
8  *     are met:
9  *
10  *        * Redistributions of source code must retain the above copyright
11  *          notice, this list of conditions and the following disclaimer.
12  *
13  *        * Redistributions in binary form must reproduce the above copyright
14  *          notice, this list of conditions and the following disclaimer in
15  *          the documentation and/or other materials provided with the
16  *          distribution.
17  *
18  *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23  *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24  *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28  *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  *     POSSIBILITY OF SUCH DAMAGE.
30  *
31  */
32 
33 //wels_svc_layer.h
34 #ifndef WELS_SVC_EXTENSION_LAYER_H__
35 #define WELS_SVC_EXTENSION_LAYER_H__
36 
37 #include "typedefs.h"
38 #include "wels_const.h"
39 #include "wels_common_basis.h"
40 #include "parameter_sets.h"
41 #include "slice.h"
42 #include "picture.h"
43 #include "svc_enc_macroblock.h"
44 
45 
46 #include "svc_enc_slice_segment.h"
47 namespace WelsEnc {
48 
49 /*
50  *  Frame level in SVC DQLayer instead.
51  *  Dependency-Quaility layer struction definition for SVC extension of H.264/AVC
52  */
53 
54 ///////////////////////////////////DQ Layer level///////////////////////////////////
55 
56 typedef struct TagDqLayer   SDqLayer;
57 typedef SDqLayer*           pDqLayer;
58 
59 typedef struct TagFeatureSearchPreparation {
60 SScreenBlockFeatureStorage*     pRefBlockFeature;//point the the ref frame storage
61 
62 uint16_t*       pFeatureOfBlock;                // Feature of every block (8x8), begin with the point
63 uint8_t         uiFeatureStrategyIndex;// index of hash strategy
64 
65 /* for FME frame-level switch */
66 bool bFMESwitchFlag;
67 uint8_t uiFMEGoodFrameCount;
68 int32_t iHighFreMbCount;
69 } SFeatureSearchPreparation; //maintain only one
70 
71 typedef struct TagSliceBufferInfo {
72 SSlice*                 pSliceBuffer;  // slice buffer for multi thread,
73 int32_t                 iMaxSliceNum;
74 int32_t                 iCodedSliceNum;
75 }SSliceBufferInfo;
76 
77 typedef struct TagLayerInfo {
78 SNalUnitHeaderExt       sNalHeaderExt;
79 SSubsetSps*             pSubsetSpsP;    // current pSubsetSps used, memory alloc in external
80 SWelsSPS*               pSpsP;          // current pSps based avc used, memory alloc in external
81 SWelsPPS*               pPpsP;          // current pPps used
82 } SLayerInfo;
83 /* Layer Representation */
84 struct TagDqLayer {
85 SLayerInfo              sLayerInfo;
86 SSliceBufferInfo        sSliceBufferInfo[MAX_THREADS_NUM];
87 SSlice**                ppSliceInLayer;
88 SSliceCtx               sSliceEncCtx;   // current slice context
89 uint8_t*                pCsData[3];     // pointer to reconstructed picture pData
90 int32_t                 iCsStride[3];   // Cs stride
91 
92 uint8_t*                pEncData[3];    // pData picture to be encoded in current layer
93 int32_t                 iEncStride[3];  // pData picture stride
94 
95 SMB*                    sMbDataP;       // pointer to mb of mbAddr equal to 0 in slice, mb_data_ptr = mb_base_ptr + (1+iMbStride).
96 int16_t                 iMbWidth;       // MB width of this picture, equal to pSps.iMbWidth
97 int16_t                 iMbHeight;      // MB height of this picture, equal to pSps.iMbHeight;
98 
99 bool                    bBaseLayerAvailableFlag;        // whether base layer is available for prediction?
100 bool                    bSatdInMdFlag; // whether SATD is calculated in ME and integer-pel MD
101 
102 uint8_t                 iLoopFilterDisableIdc;  // 0: on, 1: off, 2: on except for slice boundaries
103 int8_t                  iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0
104 int8_t                  iLoopFilterBetaOffset;  // BetaOffset:  valid range [-6, 6], default 0
105 uint8_t                 uiDisableInterLayerDeblockingFilterIdc;
106 int8_t                  iInterLayerSliceAlphaC0Offset;
107 int8_t                  iInterLayerSliceBetaOffset;
108 bool                    bDeblockingParallelFlag; //parallel_deblocking_flag
109 
110 SPicture*               pRefPic;        // reference picture pointer
111 SPicture*               pDecPic;        // reconstruction picture pointer for layer
112 SPicture*               pRefOri[MAX_REF_PIC_COUNT];
113 
114 bool                    bThreadSlcBufferFlag;
115 bool                    bSliceBsBufferFlag;
116 int32_t                 iMaxSliceNum;
117 int32_t                 NumSliceCodedOfPartition[MAX_THREADS_NUM];      // for dynamic slicing mode
118 int32_t                 LastCodedMbIdxOfPartition[MAX_THREADS_NUM];     // for dynamic slicing mode
119 int32_t                 FirstMbIdxOfPartition[MAX_THREADS_NUM];         // for dynamic slicing mode
120 int32_t                 EndMbIdxOfPartition[MAX_THREADS_NUM];           // for dynamic slicing mode
121 int32_t*                pFirstMbIdxOfSlice;
122 int32_t*                pCountMbNumInSlice;
123 
124 bool                    bNeedAdjustingSlicing;
125 
126 SFeatureSearchPreparation* pFeatureSearchPreparation;
127 
128 SDqLayer*               pRefLayer;              // pointer to referencing dq_layer of current layer to be decoded
129 };
130 
131 ///////////////////////////////////////////////////////////////////////
132 
133 // frame structure for svc
134 typedef SDqLayer SWelsSvcFrame;
135 }
136 #endif//WELS_SVC_EXTENSION_LAYER_H__
137