/src/x265/source/common/picyuv.h
Line | Count | Source (jump to first uncovered line) |
1 | | /***************************************************************************** |
2 | | * Copyright (C) 2013-2020 MulticoreWare, Inc |
3 | | * |
4 | | * Authors: 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_PICYUV_H |
25 | | #define X265_PICYUV_H |
26 | | |
27 | | #include "common.h" |
28 | | #include "md5.h" |
29 | | #include "x265.h" |
30 | | struct x265_picyuv {}; |
31 | | |
32 | | namespace X265_NS { |
33 | | // private namespace |
34 | | |
35 | | class ShortYuv; |
36 | | struct SPS; |
37 | | |
38 | | class PicYuv : public x265_picyuv |
39 | | { |
40 | | public: |
41 | | |
42 | | pixel* m_picBuf[3]; // full allocated buffers, including margins |
43 | | pixel* m_picOrg[3]; // pointers to plane starts |
44 | | |
45 | | uint32_t m_picWidth; |
46 | | uint32_t m_picHeight; |
47 | | intptr_t m_stride; |
48 | | intptr_t m_strideC; |
49 | | |
50 | | uint32_t m_picCsp; |
51 | | uint32_t m_hChromaShift; |
52 | | uint32_t m_vChromaShift; |
53 | | |
54 | | intptr_t* m_cuOffsetY; /* these four buffers are owned by the top-level encoder */ |
55 | | intptr_t* m_cuOffsetC; |
56 | | intptr_t* m_buOffsetY; |
57 | | intptr_t* m_buOffsetC; |
58 | | |
59 | | uint32_t m_lumaMarginX; |
60 | | uint32_t m_lumaMarginY; |
61 | | uint32_t m_chromaMarginX; |
62 | | uint32_t m_chromaMarginY; |
63 | | |
64 | | pixel m_maxLumaLevel; |
65 | | pixel m_minLumaLevel; |
66 | | double m_avgLumaLevel; |
67 | | |
68 | | pixel m_maxChromaULevel; |
69 | | pixel m_minChromaULevel; |
70 | | double m_avgChromaULevel; |
71 | | |
72 | | pixel m_maxChromaVLevel; |
73 | | pixel m_minChromaVLevel; |
74 | | double m_avgChromaVLevel; |
75 | | double m_vmafScore; |
76 | | x265_param *m_param; |
77 | | |
78 | | PicYuv(); |
79 | | |
80 | | bool create(x265_param* param, bool picAlloc = true, pixel *pixelbuf = NULL); |
81 | | bool createOffsets(const SPS& sps); |
82 | | void destroy(); |
83 | | int getLumaBufLen(uint32_t picWidth, uint32_t picHeight, uint32_t picCsp); |
84 | | |
85 | | void copyFromPicture(const x265_picture&, const x265_param& param, int padx, int pady); |
86 | | |
87 | 0 | intptr_t getChromaAddrOffset(uint32_t ctuAddr, uint32_t absPartIdx) const { return m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; } |
88 | | |
89 | | /* get pointer to CTU start address */ |
90 | 0 | pixel* getLumaAddr(uint32_t ctuAddr) { return m_picOrg[0] + m_cuOffsetY[ctuAddr]; } |
91 | 0 | pixel* getCbAddr(uint32_t ctuAddr) { return m_picOrg[1] + m_cuOffsetC[ctuAddr]; } |
92 | 0 | pixel* getCrAddr(uint32_t ctuAddr) { return m_picOrg[2] + m_cuOffsetC[ctuAddr]; } |
93 | 0 | pixel* getChromaAddr(uint32_t chromaId, uint32_t ctuAddr) { return m_picOrg[chromaId] + m_cuOffsetC[ctuAddr]; } |
94 | 0 | pixel* getPlaneAddr(uint32_t plane, uint32_t ctuAddr) { return m_picOrg[plane] + (plane ? m_cuOffsetC[ctuAddr] : m_cuOffsetY[ctuAddr]); } |
95 | 0 | const pixel* getLumaAddr(uint32_t ctuAddr) const { return m_picOrg[0] + m_cuOffsetY[ctuAddr]; } |
96 | 0 | const pixel* getCbAddr(uint32_t ctuAddr) const { return m_picOrg[1] + m_cuOffsetC[ctuAddr]; } |
97 | 0 | const pixel* getCrAddr(uint32_t ctuAddr) const { return m_picOrg[2] + m_cuOffsetC[ctuAddr]; } |
98 | 0 | const pixel* getChromaAddr(uint32_t chromaId, uint32_t ctuAddr) const { return m_picOrg[chromaId] + m_cuOffsetC[ctuAddr]; } |
99 | 0 | const pixel* getPlaneAddr(uint32_t plane, uint32_t ctuAddr) const { return m_picOrg[plane] + (plane ? m_cuOffsetC[ctuAddr] : m_cuOffsetY[ctuAddr]); } |
100 | | |
101 | | /* get pointer to CU start address */ |
102 | 0 | pixel* getLumaAddr(uint32_t ctuAddr, uint32_t absPartIdx) { return m_picOrg[0] + m_cuOffsetY[ctuAddr] + m_buOffsetY[absPartIdx]; } |
103 | 0 | pixel* getCbAddr(uint32_t ctuAddr, uint32_t absPartIdx) { return m_picOrg[1] + m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; } |
104 | 0 | pixel* getCrAddr(uint32_t ctuAddr, uint32_t absPartIdx) { return m_picOrg[2] + m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; } |
105 | 0 | pixel* getChromaAddr(uint32_t chromaId, uint32_t ctuAddr, uint32_t absPartIdx) { return m_picOrg[chromaId] + m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; } |
106 | 0 | const pixel* getLumaAddr(uint32_t ctuAddr, uint32_t absPartIdx) const { return m_picOrg[0] + m_cuOffsetY[ctuAddr] + m_buOffsetY[absPartIdx]; } |
107 | 0 | const pixel* getCbAddr(uint32_t ctuAddr, uint32_t absPartIdx) const { return m_picOrg[1] + m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; } |
108 | 0 | const pixel* getCrAddr(uint32_t ctuAddr, uint32_t absPartIdx) const { return m_picOrg[2] + m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; } |
109 | 0 | const pixel* getChromaAddr(uint32_t chromaId, uint32_t ctuAddr, uint32_t absPartIdx) const { return m_picOrg[chromaId] + m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; } |
110 | | }; |
111 | | |
112 | | void updateChecksum(const pixel* plane, uint32_t& checksumVal, uint32_t height, uint32_t width, intptr_t stride, int row, uint32_t cuHeight); |
113 | | void updateCRC(const pixel* plane, uint32_t& crcVal, uint32_t height, uint32_t width, intptr_t stride); |
114 | | void crcFinish(uint32_t & crc, uint8_t digest[16]); |
115 | | void checksumFinish(uint32_t checksum, uint8_t digest[16]); |
116 | | void updateMD5Plane(MD5Context& md5, const pixel* plane, uint32_t width, uint32_t height, intptr_t stride); |
117 | | } |
118 | | |
119 | | #endif // ifndef X265_PICYUV_H |