• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*!
2  * \copy
3  *     Copyright (c)  2008-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  *  ref_list_mgr_svc.h
33  *
34  *  Abstract
35  *      Interface for managing reference picture in svc encoder side
36  *
37  *  History
38  *      09/01/2008 Created
39  *      08/07/2009 Ported
40  *
41  *****************************************************************************/
42 #if !defined(REFERENCE_PICTURE_LIST_MANAGEMENT_SVC_H__)
43 #define REFERENCE_PICTURE_LIST_MANAGEMENT_SVC_H__
44 
45 #include "typedefs.h"
46 #include "encoder_context.h"
47 #include "codec_app_def.h"
48 
49 namespace WelsEnc {
50 
51 typedef enum {
52 LTR_DIRECT_MARK = 0,
53 LTR_DELAY_MARK = 1
54 } LTR_MARKING_PROCESS_MODE;
55 
56 typedef enum {
57 FRAME_NUM_EQUAL    = 0x01,
58 FRAME_NUM_BIGGER   = 0x02,
59 FRAME_NUM_SMALLER  = 0x04,
60 FRAME_NUM_OVER_MAX = 0x08
61 } COMPARE_FRAME_NUM;
62 
63 /*
64 *   reset LTR marking , recovery ,feedback state to default
65 */
66 void ResetLtrState (SLTRState* pLtr);
67 /*
68  *  reset reference picture list
69  */
70 void WelsResetRefList (sWelsEncCtx* pCtx);
71 
72 /*
73  *  update reference picture list
74  */
75 bool WelsUpdateRefList (sWelsEncCtx* pCtx);
76 /*
77  *  build reference picture list
78  */
79 bool WelsBuildRefList (sWelsEncCtx* pCtx, const int32_t kiPOC, int32_t iBestLtrRefIdx);
80 
81 /*
82  *  update syntax for reference base related
83  */
84 void WelsUpdateRefSyntax (sWelsEncCtx* pCtx, const int32_t kiPOC, const int32_t kiFrameType);
85 
86 
87 /*
88 * check current mark iFrameNum used in LTR list or not
89 */
90 bool CheckCurMarkFrameNumUsed (sWelsEncCtx* pCtx);
91 /*
92 *   decide whether current frame include long term reference mark and update long term reference mark syntax
93 */
94 void WelsMarkPic (sWelsEncCtx* pCtx);
95 
96 #ifdef LONG_TERM_REF_DUMP
97 void DumpRef (sWelsEncCtx* ctx);
98 #endif
99 
100 class IWelsReferenceStrategy {
101  public:
IWelsReferenceStrategy()102   IWelsReferenceStrategy() {};
~IWelsReferenceStrategy()103   virtual ~IWelsReferenceStrategy() { };
104 
105   static IWelsReferenceStrategy* CreateReferenceStrategy (sWelsEncCtx* pCtx, const EUsageType keUsageType,
106       const bool kbLtrEnabled);
107   virtual bool BuildRefList (const int32_t iPOC, int32_t iBestLtrRefIdx) = 0;
108   virtual void MarkPic() = 0;
109   virtual bool UpdateRefList() = 0;
110   virtual void EndofUpdateRefList() = 0;
111   virtual void AfterBuildRefList() = 0;
112 
113  protected:
114   virtual void Init (sWelsEncCtx* pCtx) = 0;
115 };
116 
117 class  CWelsReference_TemporalLayer : public IWelsReferenceStrategy {
118  public:
119   virtual bool BuildRefList (const int32_t iPOC, int32_t iBestLtrRefIdx);
120   virtual void MarkPic();
121   virtual bool UpdateRefList();
122   virtual void EndofUpdateRefList();
123   virtual void AfterBuildRefList();
124 
125   void Init (sWelsEncCtx* pCtx);
126  protected:
127   sWelsEncCtx* m_pEncoderCtx;
128 
129 };
130 
131 class  CWelsReference_Screen : public CWelsReference_TemporalLayer {
132  public:
133   virtual bool BuildRefList (const int32_t iPOC, int32_t iBestLtrRefIdx);
134   virtual void MarkPic();
135   virtual bool UpdateRefList();
136   virtual void EndofUpdateRefList();
137   virtual void AfterBuildRefList();
138 };
139 
140 class  CWelsReference_LosslessWithLtr : public CWelsReference_Screen {
141  public:
142   virtual bool BuildRefList (const int32_t iPOC, int32_t iBestLtrRefIdx);
143   virtual void MarkPic();
144   virtual bool UpdateRefList();
145   virtual void EndofUpdateRefList();
146 };
147 }
148 #endif//REFERENCE_PICTURE_LIST_MANAGEMENT_SVC_H__
149