1 /*****************************************************************************
2 * x265: ShortYUV class for short sized YUV-style frames
3 *****************************************************************************
4 * Copyright (C) 2013 x265 project
6 * Authors: Deepthi Nandakumar <deepthi@multicorewareinc.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
22 * This program is also available under a commercial proprietary license.
23 * For more information, contact us at license @ x265.com
24 *****************************************************************************/
26 #ifndef X265_SHORTYUV_H
27 #define X265_SHORTYUV_H
36 /* A ShortYuv instance holds int16_ts for a square CU (64x64 down to 8x8) for all three planes,
37 * these are typically used to hold residual or coefficients */
53 bool create(uint32_t size
, int csp
);
57 int16_t* getLumaAddr(uint32_t absPartIdx
) { return m_buf
[0] + getAddrOffset(absPartIdx
, m_size
); }
58 int16_t* getCbAddr(uint32_t absPartIdx
) { return m_buf
[1] + getChromaAddrOffset(absPartIdx
); }
59 int16_t* getCrAddr(uint32_t absPartIdx
) { return m_buf
[2] + getChromaAddrOffset(absPartIdx
); }
60 int16_t* getChromaAddr(uint32_t chromaId
, uint32_t partUnitIdx
) { return m_buf
[chromaId
] + getChromaAddrOffset(partUnitIdx
); }
62 const int16_t* getLumaAddr(uint32_t absPartIdx
) const { return m_buf
[0] + getAddrOffset(absPartIdx
, m_size
); }
63 const int16_t* getCbAddr(uint32_t absPartIdx
) const { return m_buf
[1] + getChromaAddrOffset(absPartIdx
); }
64 const int16_t* getCrAddr(uint32_t absPartIdx
) const { return m_buf
[2] + getChromaAddrOffset(absPartIdx
); }
65 const int16_t* getChromaAddr(uint32_t chromaId
, uint32_t partUnitIdx
) const { return m_buf
[chromaId
] + getChromaAddrOffset(partUnitIdx
); }
67 void subtract(const Yuv
& srcYuv0
, const Yuv
& srcYuv1
, uint32_t log2Size
);
69 void copyPartToPartLuma(ShortYuv
& dstYuv
, uint32_t absPartIdx
, uint32_t log2Size
) const;
70 void copyPartToPartChroma(ShortYuv
& dstYuv
, uint32_t absPartIdx
, uint32_t log2SizeL
) const;
72 void copyPartToPartLuma(Yuv
& dstYuv
, uint32_t absPartIdx
, uint32_t log2Size
) const;
73 void copyPartToPartChroma(Yuv
& dstYuv
, uint32_t absPartIdx
, uint32_t log2SizeL
) const;
75 int getChromaAddrOffset(uint32_t idx
) const
77 int blkX
= g_zscanToPelX
[idx
] >> m_hChromaShift
;
78 int blkY
= g_zscanToPelY
[idx
] >> m_vChromaShift
;
80 return blkX
+ blkY
* m_csize
;
83 static int getAddrOffset(uint32_t idx
, uint32_t width
)
85 int blkX
= g_zscanToPelX
[idx
];
86 int blkY
= g_zscanToPelY
[idx
];
88 return blkX
+ blkY
* width
;
93 #endif // ifndef X265_SHORTYUV_H