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_iPicWidth = iPicWidth; |
---|
21 | m_iPicHeight = iPicHeight; |
---|
22 | |
---|
23 | m_uiMaxCUWidth = uiMaxWidth; |
---|
24 | m_uiMaxCUHeight = uiMaxHeight; |
---|
25 | |
---|
26 | m_uiMinCUWidth = uiMaxWidth >> m_uhTotalDepth; |
---|
27 | m_uiMinCUHeight = uiMaxHeight >> m_uhTotalDepth; |
---|
28 | |
---|
29 | m_uiNumPartInWidth = m_uiMaxCUWidth / m_uiMinCUWidth; |
---|
30 | m_uiNumPartInHeight = m_uiMaxCUHeight / m_uiMinCUHeight; |
---|
31 | |
---|
32 | m_uiWidthInCU = ( iPicWidth %m_uiMaxCUWidth ) ? iPicWidth /m_uiMaxCUWidth + 1 : iPicWidth /m_uiMaxCUWidth; |
---|
33 | m_uiHeightInCU = ( iPicHeight%m_uiMaxCUHeight ) ? iPicHeight/m_uiMaxCUHeight + 1 : iPicHeight/m_uiMaxCUHeight; |
---|
34 | |
---|
35 | m_uiNumCUsInFrame = m_uiWidthInCU * m_uiHeightInCU; |
---|
36 | m_apcTComDataCU = new TComDataCU*[m_uiNumCUsInFrame]; |
---|
37 | |
---|
38 | if (m_uiNumAllocatedSlice>0) |
---|
39 | { |
---|
40 | for ( i=0; i<m_uiNumAllocatedSlice ; i++ ) |
---|
41 | { |
---|
42 | delete m_apcTComSlice[i]; |
---|
43 | } |
---|
44 | delete [] m_apcTComSlice; |
---|
45 | } |
---|
46 | m_apcTComSlice = new TComSlice*[m_uiNumCUsInFrame]; |
---|
47 | m_apcTComSlice[0] = new TComSlice; |
---|
48 | m_uiNumAllocatedSlice = 1; |
---|
49 | for ( i=0; i<m_uiNumCUsInFrame ; i++ ) |
---|
50 | { |
---|
51 | m_apcTComDataCU[i] = new TComDataCU; |
---|
52 | m_apcTComDataCU[i]->create( m_uiNumPartitions, m_uiMaxCUWidth, m_uiMaxCUHeight, false ); |
---|
53 | } |
---|
54 | } |
---|
55 | |
---|
56 | Void TComPicSym::destroy() |
---|
57 | { |
---|
58 | Int i; |
---|
59 | |
---|
60 | if (m_uiNumAllocatedSlice>0) |
---|
61 | { |
---|
62 | for ( i=0; i<m_uiNumAllocatedSlice ; i++ ) |
---|
63 | { |
---|
64 | delete m_apcTComSlice[i]; |
---|
65 | } |
---|
66 | delete [] m_apcTComSlice; |
---|
67 | } |
---|
68 | m_apcTComSlice = NULL; |
---|
69 | |
---|
70 | for (i = 0; i < m_uiNumCUsInFrame; i++) |
---|
71 | { |
---|
72 | m_apcTComDataCU[i]->destroy(); |
---|
73 | delete m_apcTComDataCU[i]; |
---|
74 | m_apcTComDataCU[i] = NULL; |
---|
75 | } |
---|
76 | delete [] m_apcTComDataCU; |
---|
77 | m_apcTComDataCU = NULL; |
---|
78 | } |
---|
79 | |
---|
80 | Void TComPicSym::allocateNewSlice() |
---|
81 | { |
---|
82 | assert(m_uiNumCUsInFrame >= m_uiNumAllocatedSlice); |
---|
83 | m_apcTComSlice[m_uiNumAllocatedSlice ++] = new TComSlice; |
---|
84 | } |
---|
85 | |
---|
86 | Void TComPicSym::clearSliceBuffer() |
---|
87 | { |
---|
88 | UInt i; |
---|
89 | for (i = 1; i < m_uiNumAllocatedSlice; i++) |
---|
90 | { |
---|
91 | delete m_apcTComSlice[i]; |
---|
92 | } |
---|
93 | m_uiNumAllocatedSlice = 1; |
---|
94 | } |
---|