1 | |
---|
2 | |
---|
3 | /** \file TComPicSym.cpp |
---|
4 | \brief picture symbol class |
---|
5 | */ |
---|
6 | |
---|
7 | #include "TComPicSym.h" |
---|
8 | |
---|
9 | // ==================================================================================================================== |
---|
10 | // Constructor / destructor / create / destroy |
---|
11 | // ==================================================================================================================== |
---|
12 | |
---|
13 | Void TComPicSym::create ( Int iPicWidth, Int iPicHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth ) |
---|
14 | { |
---|
15 | UInt i; |
---|
16 | |
---|
17 | m_uhTotalDepth = uiMaxDepth; |
---|
18 | m_uiNumPartitions = 1<<(m_uhTotalDepth<<1); |
---|
19 | |
---|
20 | m_uiMaxCUWidth = uiMaxWidth; |
---|
21 | m_uiMaxCUHeight = uiMaxHeight; |
---|
22 | |
---|
23 | m_uiMinCUWidth = uiMaxWidth >> m_uhTotalDepth; |
---|
24 | m_uiMinCUHeight = uiMaxHeight >> m_uhTotalDepth; |
---|
25 | |
---|
26 | m_uiNumPartInWidth = m_uiMaxCUWidth / m_uiMinCUWidth; |
---|
27 | m_uiNumPartInHeight = m_uiMaxCUHeight / m_uiMinCUHeight; |
---|
28 | |
---|
29 | m_uiWidthInCU = ( iPicWidth %m_uiMaxCUWidth ) ? iPicWidth /m_uiMaxCUWidth + 1 : iPicWidth /m_uiMaxCUWidth; |
---|
30 | m_uiHeightInCU = ( iPicHeight%m_uiMaxCUHeight ) ? iPicHeight/m_uiMaxCUHeight + 1 : iPicHeight/m_uiMaxCUHeight; |
---|
31 | |
---|
32 | m_uiNumCUsInFrame = m_uiWidthInCU * m_uiHeightInCU; |
---|
33 | m_apcTComDataCU = new TComDataCU*[m_uiNumCUsInFrame]; |
---|
34 | |
---|
35 | if (m_uiNumAllocatedSlice>0) |
---|
36 | { |
---|
37 | for ( i=0; i<m_uiNumAllocatedSlice ; i++ ) |
---|
38 | { |
---|
39 | delete m_apcTComSlice[i]; |
---|
40 | } |
---|
41 | delete [] m_apcTComSlice; |
---|
42 | } |
---|
43 | m_apcTComSlice = new TComSlice*[m_uiNumCUsInFrame]; |
---|
44 | m_apcTComSlice[0] = new TComSlice; |
---|
45 | m_uiNumAllocatedSlice = 1; |
---|
46 | for ( i=0; i<m_uiNumCUsInFrame ; i++ ) |
---|
47 | { |
---|
48 | m_apcTComDataCU[i] = new TComDataCU; |
---|
49 | m_apcTComDataCU[i]->create( m_uiNumPartitions, m_uiMaxCUWidth, m_uiMaxCUHeight, false ); |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | Void TComPicSym::destroy() |
---|
54 | { |
---|
55 | Int i; |
---|
56 | |
---|
57 | if (m_uiNumAllocatedSlice>0) |
---|
58 | { |
---|
59 | for ( i=0; i<m_uiNumAllocatedSlice ; i++ ) |
---|
60 | { |
---|
61 | delete m_apcTComSlice[i]; |
---|
62 | } |
---|
63 | delete [] m_apcTComSlice; |
---|
64 | } |
---|
65 | m_apcTComSlice = NULL; |
---|
66 | |
---|
67 | for (i = 0; i < m_uiNumCUsInFrame; i++) |
---|
68 | { |
---|
69 | m_apcTComDataCU[i]->destroy(); |
---|
70 | delete m_apcTComDataCU[i]; |
---|
71 | m_apcTComDataCU[i] = NULL; |
---|
72 | } |
---|
73 | delete [] m_apcTComDataCU; |
---|
74 | m_apcTComDataCU = NULL; |
---|
75 | } |
---|
76 | |
---|
77 | Void TComPicSym::allocateNewSlice() |
---|
78 | { |
---|
79 | assert(m_uiNumCUsInFrame >= m_uiNumAllocatedSlice); |
---|
80 | m_apcTComSlice[m_uiNumAllocatedSlice ++] = new TComSlice; |
---|
81 | } |
---|
82 | |
---|
83 | Void TComPicSym::clearSliceBuffer() |
---|
84 | { |
---|
85 | UInt i; |
---|
86 | for (i = 1; i < m_uiNumAllocatedSlice; i++) |
---|
87 | { |
---|
88 | delete m_apcTComSlice[i]; |
---|
89 | } |
---|
90 | m_uiNumAllocatedSlice = 1; |
---|
91 | } |
---|