source: 3DVCSoftware/branches/0.1-poznan-univ/source/Lib/TLibEncoder/TEncSeqStructure.h @ 28

Last change on this file since 28 was 2, checked in by hhi, 13 years ago

inital import

  • Property svn:eol-style set to native
File size: 7.4 KB
Line 
1
2
3#if !defined(AFX_TEncSeqStructure_H__268768B8_4D1D_484A_904E_586985833BAC__INCLUDED_)
4#define AFX_TEncSeqStructure_H__268768B8_4D1D_484A_904E_586985833BAC__INCLUDED_
5
6#include <cctype>
7#include "../TLibCommon/CommonDef.h"
8#include <vector>
9
10//SB
11#include <map>
12
13
14class FrameDescriptor
15{
16public:
17  ErrVal initFrameDescriptor( const std::string&  rcString, UInt &ruiIncrement, std::map<UInt, UInt>& cColDirTracker);
18
19  const std::vector<int>& getAllowedRelativeRefPocs( RefPicList eRefPicList, UInt uiViewIdx ) const {
20    assert( eRefPicList == REF_PIC_LIST_0 || eRefPicList == REF_PIC_LIST_1 );
21    assert( m_aaiAllowedRelativeRefPocsL0.size() == m_aaiAllowedRelativeRefPocsL1.size() );
22    if( m_aaiAllowedRelativeRefPocsL0.size() <= uiViewIdx )
23    {
24      return eRefPicList == REF_PIC_LIST_0 ? m_aaiAllowedRelativeRefPocsL0.back() : m_aaiAllowedRelativeRefPocsL1.back();
25    }
26    return eRefPicList == REF_PIC_LIST_0 ? m_aaiAllowedRelativeRefPocsL0[uiViewIdx]: m_aaiAllowedRelativeRefPocsL1[uiViewIdx];
27  }
28
29  const std::vector<int>& getAllowedReferenceViewIdx( RefPicList eRefPicList, UInt uiViewIdx  ) const {
30    assert( eRefPicList == REF_PIC_LIST_0 || eRefPicList == REF_PIC_LIST_1 );
31    assert( m_aaiAllowedReferenceViewIdxL0.size() == m_aaiAllowedReferenceViewIdxL1.size() );
32    if( m_aaiAllowedReferenceViewIdxL0.size() <= uiViewIdx )
33    {
34      return eRefPicList == REF_PIC_LIST_0 ? m_aaiAllowedReferenceViewIdxL0.back() : m_aaiAllowedReferenceViewIdxL1.back();
35    }
36    return eRefPicList == REF_PIC_LIST_0 ? m_aaiAllowedReferenceViewIdxL0[uiViewIdx]: m_aaiAllowedReferenceViewIdxL1[uiViewIdx];
37  }
38
39  UInt getTEncSeqStructureLayer(UInt uiViewIdx)  const {
40    if (m_auiLayer.size() <= uiViewIdx)
41    {
42      return m_auiLayer.back();
43    }
44    return m_auiLayer[uiViewIdx];
45  }
46
47  bool getStoreForRef(UInt uiViewIdx)            const {
48    if (m_abStoreForRef.size() <= uiViewIdx)
49    {
50      return m_abStoreForRef.back();
51    }
52    return m_abStoreForRef[uiViewIdx];
53  }
54  bool isIdr(UInt uiViewIdx)                     const {
55    if (m_abIsIDR.size() <= uiViewIdx)
56    {
57      return m_abIsIDR.back();
58    }
59    return m_abIsIDR[uiViewIdx];
60  }
61  SliceType getSliceType(UInt uiViewIdx)        const {
62    if (m_aeSliceType.size() <= uiViewIdx)
63    {
64      return m_aeSliceType.back();
65    }
66    return m_aeSliceType[uiViewIdx];
67  }
68
69  UInt getColDir()  const { return m_uiColDir ; }
70
71  void addLayerOffset( Int iLayerOffset ) {
72     for(Int i = 0; i<m_auiLayer.size(); i++)
73     {
74       m_auiLayer[i] += iLayerOffset ;
75     }
76  }
77
78private:
79  std::vector<bool> m_abStoreForRef;
80  std::vector<bool> m_abIsIDR;
81  std::vector<UInt> m_auiLayer;
82  std::vector<SliceType>  m_aeSliceType;
83  std::vector< std::vector<int> > m_aaiAllowedRelativeRefPocsL0;
84  std::vector< std::vector<int> > m_aaiAllowedRelativeRefPocsL1;
85  std::vector< std::vector<int> > m_aaiAllowedReferenceViewIdxL0;
86  std::vector< std::vector<int> > m_aaiAllowedReferenceViewIdxL1;
87  UInt m_uiColDir ;
88
89};
90class TEncSeqStructure
91{
92private:
93  class SequencePart
94  {
95    DISABLE_DEFAULT_CPYCTOR_AND_ASOP( SequencePart );
96  protected:
97    SequencePart() : m_uiNumberOfRepetitions( 0 ) {}
98
99  public:
100    virtual ~SequencePart() {}
101
102    virtual bool isLeafNode() const = 0;
103    virtual SequencePart* getChildNode( UInt64 ui ) const { TOT( 1 ); return NULL; }
104    virtual const FrameDescriptor* getFrameDescriptor( UInt64 ui ) const { TOT( 1 ); return NULL; }
105
106    UInt64 getSize() const { TOT( isInfinitelyLong() ); return UInt64( m_uiNumberOfRepetitions ) * xGetSize(); }
107    UInt64 getIncrement( UInt64 ui ) const { return ui - UInt64( xGetIdx( ui ) ) + UInt64( xGetIncrement( ui ) ); }
108//    bool isInfinitelyLong() const { return m_uiNumberOfRepetitions == TypeLimits<UInt>::m_iMax; }
109    bool isInfinitelyLong() const { return m_uiNumberOfRepetitions == MAX_UINT; }
110
111    virtual UInt64 findIncrement( UInt64 uiIncrement, bool &rbSuccess ) const { TOT( 1 ); return 0; }
112
113  protected:
114    UInt xGetIdx( UInt64 ui ) const { return UInt( ui % xGetSize() ); }
115    void xSetNumRep( UInt ui )
116    {
117      TOT( m_uiNumberOfRepetitions );
118      TOF( ui );
119      m_uiNumberOfRepetitions = ui;
120    }
121
122  private:
123    virtual UInt   xGetIncrement( UInt64 ui ) const { TOT( 1 ); return 0; }
124    virtual UInt64 xGetSize() const = 0;
125
126    UInt m_uiNumberOfRepetitions; //GT: *n5{...}
127  };
128
129
130  class FrameSequencePart : public SequencePart //GT: Sequence of Frames without repetitions
131  {
132  public:
133    FrameSequencePart( const std::string& rcString );
134    virtual ~FrameSequencePart() {}
135
136    UInt64 xGetSize() const { return UInt64( m_acFrameDescriptors.size() ); }
137    bool isLeafNode() const { return true; }
138    const FrameDescriptor* getFrameDescriptor( UInt64 ui ) const { return &m_acFrameDescriptors[xGetIdx( ui )]; }
139    UInt xGetIncrement( UInt64 ui ) const { return m_auiIncrements[xGetIdx( ui )]; }
140    virtual UInt64 findIncrement( UInt64 uiIncrement, bool &rbSuccess ) const;
141
142  private:
143    ErrVal xCheck();
144
145    std::vector<FrameDescriptor> m_acFrameDescriptors; //GT: one descriptor for each frame B3L2(-4,+3)
146    std::vector<UInt> m_auiIncrements;                 //GT: same size as frame descriptor, stores increments  P7L1(-8)B3L2(-4,+3)b0L4(-2,+2,+6) -> 1 3 0
147
148    std::map<UInt,UInt> m_cColDirTracker ;
149  };
150
151
152  class GeneralSequencePart : public SequencePart  //GT: Sequence of FrameSequences
153  {
154  public:
155    GeneralSequencePart( const std::string& rcString );
156    virtual ~GeneralSequencePart() {}
157
158    UInt64 xGetSize() const { return UInt64( m_apcSequenceParts.size() ); }
159    bool isLeafNode() const { return false; }
160    SequencePart* getChildNode( UInt64 ui ) const { return m_apcSequenceParts[xGetIdx( ui )]; }
161
162  private:
163    AutoDeletePtrVector<SequencePart> m_apcSequenceParts;
164  };
165
166public:
167  TEncSeqStructure();
168  virtual ~TEncSeqStructure();
169
170  ErrVal init( const std::string& rcString );
171  UInt getMaxAbsPocDiff( const UInt uiNumberOfFrames );
172  UInt getDecodedPictureBufferSize( const UInt uiNumberOfFrames );
173  class Iterator
174  {
175  private:
176    class SequencePartWithPos
177    {
178    public:
179      const SequencePart *m_pcSeqPart;
180      UInt64 m_uiCurrPos;
181    };
182
183  public:
184    Iterator() : m_cBasePoc( 0 ) {}
185    virtual ~Iterator() {}
186
187    Iterator( const TEncSeqStructure &r, PicOrderCnt cLayerChangeStartPoc, int iLayerOffset );
188
189    FrameDescriptor getFrameDescriptor() const
190    {
191      if( m_iLayerOffset != 0 && getPoc() >= m_cLayerChangeStartPoc )
192      {
193        FrameDescriptor cModified = *xGetCurr().m_pcSeqPart->getFrameDescriptor( xGetCurr().m_uiCurrPos );
194        cModified.addLayerOffset ( m_iLayerOffset );
195        return cModified;
196      }
197      return *xGetCurr().m_pcSeqPart->getFrameDescriptor( xGetCurr().m_uiCurrPos );
198    }
199
200    PicOrderCnt getPoc() const { return m_cBasePoc + xGetCurr().m_pcSeqPart->getIncrement( xGetCurr().m_uiCurrPos ); }
201
202    Iterator& operator++();
203    Iterator& traverseByPocDiff( Int64 iPocDiff );
204    Iterator getIterByPocDiff( Int64 iPocDiff ) const;
205
206  private:
207    SequencePartWithPos&       xGetCurr()       { return m_acSeqPartPath.back(); }
208    const SequencePartWithPos& xGetCurr() const { return m_acSeqPartPath.back(); }
209
210    void xGoToPreviousFrameSequencePart();
211    void xGoToNextFrameSequencePart();
212
213    void xGoToLeaf( bool bGoToRightmostLeaf );
214
215    std::vector<SequencePartWithPos> m_acSeqPartPath;
216    PicOrderCnt m_cBasePoc;
217    PicOrderCnt m_cLayerChangeStartPoc;
218    int m_iLayerOffset;
219  };
220
221private:
222  SequencePart *m_pcSequencePart;
223};
224
225
226
227
228#endif // !defined(AFX_TEncSeqStructure_H__268768B8_4D1D_484A_904E_586985833BAC__INCLUDED_)
Note: See TracBrowser for help on using the repository browser.