9c7abee032a5018b598548129533a96904ee59e4
1 /*****************************************************************************
2 * Copyright (C) 2013 x265 project
4 * Author: 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 *****************************************************************************/
27 #include "framedata.h"
33 m_bChromaExtended
= false;
34 m_reconRowCount
.set(0);
35 m_countRefEncoders
= 0;
40 memset(&m_lowres
, 0, sizeof(m_lowres
));
43 bool Frame::create(x265_param
*param
)
45 m_fencPic
= new PicYuv
;
47 return m_fencPic
->create(param
->sourceWidth
, param
->sourceHeight
, param
->internalCsp
) &&
48 m_lowres
.create(m_fencPic
, param
->bframes
, !!param
->rc
.aqMode
);
51 bool Frame::allocEncodeData(x265_param
*param
, const SPS
& sps
)
53 m_encData
= new FrameData
;
54 m_reconPic
= new PicYuv
;
55 m_encData
->m_reconPic
= m_reconPic
;
56 bool ok
= m_encData
->create(param
, sps
) && m_reconPic
->create(param
->sourceWidth
, param
->sourceHeight
, param
->internalCsp
);
59 /* initialize right border of m_reconpicYuv as SAO may read beyond the
60 * end of the picture accessing uninitialized pixels */
61 int maxHeight
= sps
.numCuInHeight
* g_maxCUSize
;
62 memset(m_reconPic
->m_picOrg
[0], 0, m_reconPic
->m_stride
* maxHeight
);
63 memset(m_reconPic
->m_picOrg
[1], 0, m_reconPic
->m_strideC
* (maxHeight
>> m_reconPic
->m_vChromaShift
));
64 memset(m_reconPic
->m_picOrg
[2], 0, m_reconPic
->m_strideC
* (maxHeight
>> m_reconPic
->m_vChromaShift
));
69 /* prepare to re-use a FrameData instance to encode a new picture */
70 void Frame::reinit(const SPS
& sps
)
72 m_bChromaExtended
= false;
73 m_reconPic
= m_encData
->m_reconPic
;
74 m_encData
->reinit(sps
);
95 m_reconPic
->destroy();