Commit | Line | Data |
---|---|---|
72b9787e JB |
1 | /***************************************************************************** |
2 | * Copyright (C) 2013 x265 project | |
3 | * | |
4 | * Author: Steve Borho <steve@borho.org> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. | |
19 | * | |
20 | * This program is also available under a commercial proprietary license. | |
21 | * For more information, contact us at license @ x265.com. | |
22 | *****************************************************************************/ | |
23 | ||
24 | #ifndef X265_FRAMEDATA_H | |
25 | #define X265_FRAMEDATA_H | |
26 | ||
27 | #include "common.h" | |
28 | #include "slice.h" | |
29 | #include "cudata.h" | |
30 | ||
31 | namespace x265 { | |
32 | // private namespace | |
33 | ||
34 | class PicYuv; | |
35 | ||
36 | /* Per-frame data that is used during encodes and referenced while the picture | |
37 | * is available for reference. A FrameData instance is attached to a Frame as it | |
38 | * comes out of the lookahead. Frames which are not being encoded do not have a | |
39 | * FrameData instance. These instances are re-used once the encoded frame has | |
40 | * no active references. They hold the Slice instance and the 'official' CTU | |
41 | * data structures. They are maintained in a free-list pool along together with | |
42 | * a reconstructed image PicYuv in order to conserve memory. */ | |
43 | class FrameData | |
44 | { | |
45 | public: | |
46 | ||
47 | Slice* m_slice; | |
48 | SAOParam* m_saoParam; | |
49 | x265_param* m_param; | |
50 | ||
51 | FrameData* m_freeListNext; | |
b53f7c52 | 52 | PicYuv* m_reconPic; |
72b9787e JB |
53 | bool m_bHasReferences; /* used during DPB/RPS updates */ |
54 | int m_frameEncoderID; /* the ID of the FrameEncoder encoding this frame */ | |
55 | ||
56 | CUDataMemPool m_cuMemPool; | |
57 | CUData* m_picCTU; | |
58 | ||
59 | /* Rate control data used during encode and by references */ | |
60 | struct RCStatCU | |
61 | { | |
62 | uint32_t totalBits; /* total bits to encode this CTU */ | |
63 | uint32_t vbvCost; /* sum of lowres costs for 16x16 sub-blocks */ | |
64 | uint32_t intraVbvCost; /* sum of lowres intra costs for 16x16 sub-blocks */ | |
65 | uint64_t avgCost[4]; /* stores the avg cost of CU's in frame for each depth */ | |
66 | uint32_t count[4]; /* count and avgCost only used by Analysis at RD0..4 */ | |
67 | double baseQp; /* Qp of Cu set from RateControl/Vbv (only used by frame encoder) */ | |
68 | }; | |
69 | ||
70 | struct RCStatRow | |
71 | { | |
72 | uint32_t numEncodedCUs; /* ctuAddr of last encoded CTU in row */ | |
73 | uint32_t encodedBits; /* sum of 'totalBits' of encoded CTUs */ | |
74 | uint32_t satdForVbv; /* sum of lowres (estimated) costs for entire row */ | |
75 | uint32_t diagSatd; | |
76 | uint32_t diagIntraSatd; | |
77 | double diagQp; | |
78 | double diagQpScale; | |
79 | double sumQpRc; | |
80 | double sumQpAq; | |
81 | }; | |
82 | ||
83 | RCStatCU* m_cuStat; | |
84 | RCStatRow* m_rowStat; | |
85 | ||
86 | double m_avgQpRc; /* avg QP as decided by rate-control */ | |
87 | double m_avgQpAq; /* avg QP as decided by AQ in addition to rate-control */ | |
88 | double m_rateFactor; /* calculated based on the Frame QP */ | |
89 | ||
90 | FrameData(); | |
91 | ||
92 | bool create(x265_param *param, const SPS& sps); | |
93 | void reinit(const SPS& sps); | |
94 | void destroy(); | |
95 | ||
96 | CUData* getPicCTU(uint32_t ctuAddr) { return &m_picCTU[ctuAddr]; } | |
97 | }; | |
98 | } | |
99 | ||
100 | #endif // ifndef X265_FRAMEDATA_H |