1 /*****************************************************************************
2 * Copyright (C) 2014 x265 project
4 * Authors: Steve Borho <steve@borho.org>
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.
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.
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.
20 * This program is also available under a commercial proprietary license.
21 * For more information, contact us at license @ x265.com.
22 *****************************************************************************/
41 pixel
* m_picBuf
[3]; // full allocated buffers, including margins
42 pixel
* m_picOrg
[3]; // pointers to plane starts
50 uint32_t m_hChromaShift
;
51 uint32_t m_vChromaShift
;
53 intptr_t* m_cuOffsetY
; /* these four buffers are owned by the top-level encoder */
54 intptr_t* m_cuOffsetC
;
55 intptr_t* m_buOffsetY
;
56 intptr_t* m_buOffsetC
;
58 uint32_t m_lumaMarginX
;
59 uint32_t m_lumaMarginY
;
60 uint32_t m_chromaMarginX
;
61 uint32_t m_chromaMarginY
;
65 bool create(uint32_t picWidth
, uint32_t picHeight
, uint32_t csp
);
66 bool createOffsets(const SPS
& sps
);
69 void copyFromPicture(const x265_picture
&, int padx
, int pady
);
71 intptr_t getChromaAddrOffset(uint32_t ctuAddr
, uint32_t absPartIdx
) const { return m_cuOffsetC
[ctuAddr
] + m_buOffsetC
[absPartIdx
]; }
73 /* get pointer to CTU start address */
74 pixel
* getLumaAddr(uint32_t ctuAddr
) { return m_picOrg
[0] + m_cuOffsetY
[ctuAddr
]; }
75 pixel
* getCbAddr(uint32_t ctuAddr
) { return m_picOrg
[1] + m_cuOffsetC
[ctuAddr
]; }
76 pixel
* getCrAddr(uint32_t ctuAddr
) { return m_picOrg
[2] + m_cuOffsetC
[ctuAddr
]; }
77 pixel
* getChromaAddr(uint32_t chromaId
, uint32_t ctuAddr
) { return m_picOrg
[chromaId
] + m_cuOffsetC
[ctuAddr
]; }
78 pixel
* getPlaneAddr(uint32_t plane
, uint32_t ctuAddr
) { return m_picOrg
[plane
] + (plane
? m_cuOffsetC
[ctuAddr
] : m_cuOffsetY
[ctuAddr
]); }
80 /* get pointer to CU start address */
81 pixel
* getLumaAddr(uint32_t ctuAddr
, uint32_t absPartIdx
) { return m_picOrg
[0] + m_cuOffsetY
[ctuAddr
] + m_buOffsetY
[absPartIdx
]; }
82 pixel
* getCbAddr(uint32_t ctuAddr
, uint32_t absPartIdx
) { return m_picOrg
[1] + m_cuOffsetC
[ctuAddr
] + m_buOffsetC
[absPartIdx
]; }
83 pixel
* getCrAddr(uint32_t ctuAddr
, uint32_t absPartIdx
) { return m_picOrg
[2] + m_cuOffsetC
[ctuAddr
] + m_buOffsetC
[absPartIdx
]; }
84 pixel
* getChromaAddr(uint32_t chromaId
, uint32_t ctuAddr
, uint32_t absPartIdx
) { return m_picOrg
[chromaId
] + m_cuOffsetC
[ctuAddr
] + m_buOffsetC
[absPartIdx
]; }
87 void updateChecksum(const pixel
* plane
, uint32_t& checksumVal
, uint32_t height
, uint32_t width
, intptr_t stride
, int row
, uint32_t cuHeight
);
88 void updateCRC(const pixel
* plane
, uint32_t& crcVal
, uint32_t height
, uint32_t width
, intptr_t stride
);
89 void crcFinish(uint32_t & crc
, uint8_t digest
[16]);
90 void checksumFinish(uint32_t checksum
, uint8_t digest
[16]);
91 void updateMD5Plane(MD5Context
& md5
, const pixel
* plane
, uint32_t width
, uint32_t height
, intptr_t stride
);
94 #endif // ifndef X265_PICYUV_H