<div dir="ltr"><div><div>Hello,<br><br></div>We spent a bunch of effort last year to remove STL dependencies, since they cause serious trouble between different compilers (even between different
compiler versions). This is especially since a lot of users will use x265 as a static library. <br><br></div>Thanks,<br>Deepthi<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 9, 2014 at 3:00 PM, Satoshi Nakagawa <span dir="ltr"><<a href="mailto:nakagawa424@oki.com" target="_blank">nakagawa424@oki.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Satoshi Nakagawa <<a href="mailto:nakagawa424@oki.com">nakagawa424@oki.com</a>><br>
# Date 1404898046 -32400<br>
# Wed Jul 09 18:27:26 2014 +0900<br>
# Node ID a3f4317f4acd89b7ef9bb8616068f9e4ff24328c<br>
# Parent 644773b8532929a30f910fd269f521e44621f2f7<br>
use std::swap() for readability<br>
<br>
diff -r 644773b85329 -r a3f4317f4acd source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp<br>
--- a/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp Wed Jul 09 13:55:42 2014 +0530<br>
+++ b/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp Wed Jul 09 18:27:26 2014 +0900<br>
@@ -535,12 +535,10 @@<br>
int isChroma = (yCbCr != 0) ? 1 : 0;<br>
int shift;<br>
int cuHeightTmp;<br>
- pixel* tmpLSwap;<br>
pixel* tmpL;<br>
pixel* tmpU;<br>
pixel* clipTbl = NULL;<br>
int32_t *offsetBo = NULL;<br>
- int32_t *tmp_swap;<br>
<br>
picWidthTmp = (isChroma == 0) ? m_picWidth : m_picWidth >> m_hChromaShift;<br>
picHeightTmp = (isChroma == 0) ? m_picHeight : m_picHeight >> m_vChromaShift;<br>
@@ -707,9 +705,7 @@<br>
<br>
m_upBufft[startX] = signDown2;<br>
<br>
- tmp_swap = m_upBuff1;<br>
- m_upBuff1 = m_upBufft;<br>
- m_upBufft = tmp_swap;<br>
+ std::swap(m_upBuff1, m_upBufft);<br>
<br>
rec += stride;<br>
}<br>
@@ -775,9 +771,7 @@<br>
<br>
// if (iSaoType!=SAO_BO_0 || iSaoType!=SAO_BO_1)<br>
{<br>
- tmpLSwap = m_tmpL1;<br>
- m_tmpL1 = m_tmpL2;<br>
- m_tmpL2 = tmpLSwap;<br>
+ std::swap(m_tmpL1, m_tmpL2);<br>
}<br>
}<br>
<br>
@@ -864,7 +858,6 @@<br>
int frameWidthInCU = m_pic->getFrameWidthInCU();<br>
int frameHeightInCU = m_pic->getFrameHeightInCU();<br>
int stride;<br>
- pixel *tmpUSwap;<br>
int sChroma = (yCbCr == 0) ? 0 : 1;<br>
bool mergeLeftFlag;<br>
int saoBitIncrease = (yCbCr == 0) ? m_saoBitIncreaseY : m_saoBitIncreaseC;<br>
@@ -976,9 +969,7 @@<br>
}<br>
}<br>
<br>
- tmpUSwap = m_tmpU1[yCbCr];<br>
- m_tmpU1[yCbCr] = m_tmpU2[yCbCr];<br>
- m_tmpU2[yCbCr] = tmpUSwap;<br>
+ std::swap(m_tmpU1[yCbCr], m_tmpU2[yCbCr]);<br>
}<br>
}<br>
<br>
@@ -1018,7 +1009,6 @@<br>
int addr;<br>
int frameWidthInCU = m_pic->getFrameWidthInCU();<br>
int stride;<br>
- pixel *tmpUSwap;<br>
int sChroma = (yCbCr == 0) ? 0 : 1;<br>
bool mergeLeftFlag;<br>
int saoBitIncrease = (yCbCr == 0) ? m_saoBitIncreaseY : m_saoBitIncreaseC;<br>
@@ -1122,9 +1112,7 @@<br>
}<br>
}<br>
<br>
- tmpUSwap = m_tmpU1[yCbCr];<br>
- m_tmpU1[yCbCr] = m_tmpU2[yCbCr];<br>
- m_tmpU2[yCbCr] = tmpUSwap;<br>
+ std::swap(m_tmpU1[yCbCr], m_tmpU2[yCbCr]);<br>
}<br>
}<br>
<br>
diff -r 644773b85329 -r a3f4317f4acd source/Lib/TLibEncoder/TEncCu.cpp<br>
--- a/source/Lib/TLibEncoder/TEncCu.cpp Wed Jul 09 13:55:42 2014 +0530<br>
+++ b/source/Lib/TLibEncoder/TEncCu.cpp Wed Jul 09 18:27:26 2014 +0900<br>
@@ -1258,22 +1258,11 @@<br>
uint64_t bestCost = m_rdCost->psyRdEnabled() ? outBestCU->m_totalPsyCost : outBestCU->m_totalRDCost;<br>
if (tempCost < bestCost)<br>
{<br>
- TComDataCU* tmp = outTempCU;<br>
- outTempCU = outBestCU;<br>
- outBestCU = tmp;<br>
-<br>
- // Change Prediction data<br>
- TComYuv* yuv = NULL;<br>
- yuv = outBestPredYuv;<br>
- outBestPredYuv = m_tmpPredYuv[depth];<br>
- m_tmpPredYuv[depth] = yuv;<br>
-<br>
- yuv = rpcYuvReconBest;<br>
- rpcYuvReconBest = m_tmpRecoYuv[depth];<br>
- m_tmpRecoYuv[depth] = yuv;<br>
-<br>
+ std::swap(outBestCU, outTempCU);<br>
+ std::swap(outBestPredYuv, m_tmpPredYuv[depth]);<br>
+ std::swap(rpcYuvReconBest, m_tmpRecoYuv[depth]);<br>
m_rdSbacCoders[depth][CI_TEMP_BEST]->store(m_rdSbacCoders[depth][CI_NEXT_BEST]);<br>
- }<br>
+ }<br>
outTempCU->setQPSubParts(origQP, 0, depth);<br>
outTempCU->setSkipFlagSubParts(false, 0, depth);<br>
if (!bestIsSkip)<br>
@@ -1446,21 +1435,14 @@<br>
<br>
if (tempCost < bestCost)<br>
{<br>
- TComYuv* yuv;<br>
// Change Information data<br>
- TComDataCU* cu = outBestCU;<br>
- outBestCU = outTempCU;<br>
- outTempCU = cu;<br>
+ std::swap(outBestCU, outTempCU);<br>
<br>
// Change Prediction data<br>
- yuv = m_bestPredYuv[depth];<br>
- m_bestPredYuv[depth] = m_tmpPredYuv[depth];<br>
- m_tmpPredYuv[depth] = yuv;<br>
+ std::swap(m_bestPredYuv[depth], m_tmpPredYuv[depth]);<br>
<br>
// Change Reconstruction data<br>
- yuv = m_bestRecoYuv[depth];<br>
- m_bestRecoYuv[depth] = m_tmpRecoYuv[depth];<br>
- m_tmpRecoYuv[depth] = yuv;<br>
+ std::swap(m_bestRecoYuv[depth], m_tmpRecoYuv[depth]);<br>
<br>
m_rdSbacCoders[depth][CI_TEMP_BEST]->store(m_rdSbacCoders[depth][CI_NEXT_BEST]);<br>
}<br>
diff -r 644773b85329 -r a3f4317f4acd source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp<br>
--- a/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp Wed Jul 09 13:55:42 2014 +0530<br>
+++ b/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp Wed Jul 09 18:27:26 2014 +0900<br>
@@ -566,7 +566,6 @@<br>
int iEndX;<br>
int iEndY;<br>
pixel* pTableBo = (yCbCr == 0) ? m_lumaTableBo : m_chromaTableBo;<br>
- int32_t *tmp_swap;<br>
<br>
int iIsChroma = (yCbCr != 0) ? 1 : 0;<br>
int numSkipLine = iIsChroma ? 4 - (2 * m_vChromaShift) : 4;<br>
@@ -756,9 +755,7 @@<br>
}<br>
<br>
m_upBufft[iStartX] = iSignDown2;<br>
- tmp_swap = m_upBuff1;<br>
- m_upBuff1 = m_upBufft;<br>
- m_upBufft = tmp_swap;<br>
+ std::swap(m_upBuff1, m_upBufft);<br>
<br>
pRec += stride;<br>
fenc += stride;<br>
@@ -844,7 +841,6 @@<br>
uint32_t lPelX, tPelY;<br>
TComDataCU *pTmpCu;<br>
pixel* pTableBo;<br>
- int32_t *tmp_swap;<br>
<br>
// NOTE: Row<br>
{<br>
@@ -1054,9 +1050,7 @@<br>
}<br>
<br>
m_upBufft[firstX] = signDown2;<br>
- tmp_swap = m_upBuff1;<br>
- m_upBuff1 = m_upBufft;<br>
- m_upBufft = tmp_swap;<br>
+ std::swap(m_upBuff1, m_upBufft);<br>
<br>
pRec += stride;<br>
fenc += stride;<br>
diff -r 644773b85329 -r a3f4317f4acd source/encoder/compress.cpp<br>
--- a/source/encoder/compress.cpp Wed Jul 09 13:55:42 2014 +0530<br>
+++ b/source/encoder/compress.cpp Wed Jul 09 18:27:26 2014 +0900<br>
@@ -280,13 +280,9 @@<br>
if (outTempCU->m_totalRDCost < outBestCU->m_totalRDCost)<br>
{<br>
bestMergeCand = mergeCand;<br>
- TComDataCU* tmp = outTempCU;<br>
- outTempCU = outBestCU;<br>
- outBestCU = tmp;<br>
+ std::swap(outBestCU, outTempCU);<br>
// Change Prediction data<br>
- TComYuv* yuv = bestPredYuv;<br>
- bestPredYuv = m_tmpPredYuv[depth];<br>
- m_tmpPredYuv[depth] = yuv;<br>
+ std::swap(bestPredYuv, m_tmpPredYuv[depth]);<br>
}<br>
}<br>
}<br>
@@ -308,7 +304,6 @@<br>
outTempCU->m_totalRDCost = m_rdCost->calcRdSADCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);<br>
outTempCU->m_sa8dCost = outTempCU->m_totalRDCost;<br>
outBestCU->m_sa8dCost = outTempCU->m_sa8dCost;<br>
- TComYuv* yuv;<br>
if (m_param->rdLevel >= 1)<br>
{<br>
//calculate the motion compensation for chroma for the best mode selected<br>
@@ -327,9 +322,7 @@<br>
//No-residue mode<br>
m_search->encodeResAndCalcRdInterCU(outBestCU, m_origYuv[depth], bestPredYuv, m_tmpResiYuv[depth], m_bestResiYuv[depth], m_tmpRecoYuv[depth], true, true);<br>
<br>
- yuv = yuvReconBest;<br>
- yuvReconBest = m_tmpRecoYuv[depth];<br>
- m_tmpRecoYuv[depth] = yuv;<br>
+ std::swap(yuvReconBest, m_tmpRecoYuv[depth]);<br>
}<br>
<br>
//Encode with residue<br>
@@ -339,13 +332,8 @@<br>
uint64_t bestCost = m_rdCost->psyRdEnabled() ? outBestCU->m_totalPsyCost : outBestCU->m_totalRDCost;<br>
if (tempCost < bestCost) //Choose best from no-residue mode and residue mode<br>
{<br>
- TComDataCU* tmp = outTempCU;<br>
- outTempCU = outBestCU;<br>
- outBestCU = tmp;<br>
-<br>
- yuv = yuvReconBest;<br>
- yuvReconBest = m_tmpRecoYuv[depth];<br>
- m_tmpRecoYuv[depth] = yuv;<br>
+ std::swap(outBestCU, outTempCU);<br>
+ std::swap(yuvReconBest, m_tmpRecoYuv[depth]);<br>
}<br>
}<br>
}<br>
@@ -391,7 +379,6 @@<br>
m_origYuv[depth]->copyToPicYuv(pic->getPicYuvRec(), cu->getAddr(), 0);<br>
}<br>
// We need to split, so don't try these modes.<br>
- TComYuv* tempYuv = NULL;<br>
#if TOPSKIP<br>
if (bInsidePicture && !bInsidePictureParent)<br>
{<br>
@@ -462,9 +449,7 @@<br>
xComputeCostInter(m_interCU_2Nx2N[depth], m_modePredYuv[0][depth], SIZE_2Nx2N);<br>
/* Choose best mode; initialise outBestCU to 2Nx2N */<br>
outBestCU = m_interCU_2Nx2N[depth];<br>
- tempYuv = m_modePredYuv[0][depth];<br>
- m_modePredYuv[0][depth] = m_bestPredYuv[depth];<br>
- m_bestPredYuv[depth] = tempYuv;<br>
+ std::swap(m_bestPredYuv[depth], m_modePredYuv[0][depth]);<br>
}<br>
<br>
/* Compute Rect costs */<br>
@@ -475,18 +460,12 @@<br>
if (m_interCU_Nx2N[depth]->m_totalRDCost < outBestCU->m_totalRDCost)<br>
{<br>
outBestCU = m_interCU_Nx2N[depth];<br>
-<br>
- tempYuv = m_modePredYuv[1][depth];<br>
- m_modePredYuv[1][depth] = m_bestPredYuv[depth];<br>
- m_bestPredYuv[depth] = tempYuv;<br>
+ std::swap(m_bestPredYuv[depth], m_modePredYuv[1][depth]);<br>
}<br>
if (m_interCU_2NxN[depth]->m_totalRDCost < outBestCU->m_totalRDCost)<br>
{<br>
outBestCU = m_interCU_2NxN[depth];<br>
-<br>
- tempYuv = m_modePredYuv[2][depth];<br>
- m_modePredYuv[2][depth] = m_bestPredYuv[depth];<br>
- m_bestPredYuv[depth] = tempYuv;<br>
+ std::swap(m_bestPredYuv[depth], m_modePredYuv[2][depth]);<br>
}<br>
}<br>
<br>
@@ -506,13 +485,8 @@<br>
if (bestMergeCost < bestCost)<br>
{<br>
outBestCU = m_bestMergeCU[depth];<br>
- tempYuv = m_modePredYuv[3][depth];<br>
- m_modePredYuv[3][depth] = m_bestPredYuv[depth];<br>
- m_bestPredYuv[depth] = tempYuv;<br>
-<br>
- tempYuv = m_bestRecoYuv[depth];<br>
- m_bestRecoYuv[depth] = m_bestMergeRecoYuv[depth];<br>
- m_bestMergeRecoYuv[depth] = tempYuv;<br>
+ std::swap(m_bestPredYuv[depth], m_modePredYuv[3][depth]);<br>
+ std::swap(m_bestRecoYuv[depth], m_bestMergeRecoYuv[depth]);<br>
}<br>
}<br>
<br>
@@ -547,13 +521,8 @@<br>
if (intraInInterCost < bestCost)<br>
{<br>
outBestCU = m_intraInInterCU[depth];<br>
- tempYuv = m_modePredYuv[5][depth];<br>
- m_modePredYuv[5][depth] = m_bestPredYuv[depth];<br>
- m_bestPredYuv[depth] = tempYuv;<br>
-<br>
- TComYuv* tmpPic = m_bestRecoYuv[depth];<br>
- m_bestRecoYuv[depth] = m_tmpRecoYuv[depth];<br>
- m_tmpRecoYuv[depth] = tmpPic;<br>
+ std::swap(m_bestPredYuv[depth], m_modePredYuv[5][depth]);<br>
+ std::swap(m_bestRecoYuv[depth], m_tmpRecoYuv[depth]);<br>
}<br>
}<br>
}<br>
@@ -562,13 +531,8 @@<br>
if (m_bestMergeCU[depth]->m_sa8dCost < outBestCU->m_totalRDCost)<br>
{<br>
outBestCU = m_bestMergeCU[depth];<br>
- tempYuv = m_modePredYuv[3][depth];<br>
- m_modePredYuv[3][depth] = m_bestPredYuv[depth];<br>
- m_bestPredYuv[depth] = tempYuv;<br>
-<br>
- tempYuv = m_bestRecoYuv[depth];<br>
- m_bestRecoYuv[depth] = m_bestMergeRecoYuv[depth];<br>
- m_bestMergeRecoYuv[depth] = tempYuv;<br>
+ std::swap(m_bestPredYuv[depth], m_modePredYuv[3][depth]);<br>
+ std::swap(m_bestRecoYuv[depth], m_bestMergeRecoYuv[depth]);<br>
}<br>
else if (outBestCU->getPredictionMode(0) == MODE_INTER)<br>
{<br>
@@ -591,13 +555,8 @@<br>
if (m_bestMergeCU[depth]->m_sa8dCost < outBestCU->m_totalRDCost)<br>
{<br>
outBestCU = m_bestMergeCU[depth];<br>
- tempYuv = m_modePredYuv[3][depth];<br>
- m_modePredYuv[3][depth] = m_bestPredYuv[depth];<br>
- m_bestPredYuv[depth] = tempYuv;<br>
-<br>
- tempYuv = m_bestRecoYuv[depth];<br>
- m_bestRecoYuv[depth] = m_bestMergeRecoYuv[depth];<br>
- m_bestMergeRecoYuv[depth] = tempYuv;<br>
+ std::swap(m_bestPredYuv[depth], m_modePredYuv[3][depth]);<br>
+ std::swap(m_bestRecoYuv[depth], m_bestMergeRecoYuv[depth]);<br>
}<br>
else if (outBestCU->getPredictionMode(0) == MODE_INTER)<br>
{<br>
@@ -630,13 +589,8 @@<br>
else<br>
{<br>
outBestCU = m_bestMergeCU[depth];<br>
- tempYuv = m_modePredYuv[3][depth];<br>
- m_modePredYuv[3][depth] = m_bestPredYuv[depth];<br>
- m_bestPredYuv[depth] = tempYuv;<br>
-<br>
- tempYuv = m_bestRecoYuv[depth];<br>
- m_bestRecoYuv[depth] = m_bestMergeRecoYuv[depth];<br>
- m_bestMergeRecoYuv[depth] = tempYuv;<br>
+ std::swap(m_bestPredYuv[depth], m_modePredYuv[3][depth]);<br>
+ std::swap(m_bestRecoYuv[depth], m_bestMergeRecoYuv[depth]);<br>
}<br>
<br>
if (m_param->rdLevel > 0) // checkDQP can be done only after residual encoding is done<br>
@@ -856,23 +810,15 @@<br>
if (tempCost < bestCost)<br>
{<br>
outBestCU = outTempCU;<br>
- tempYuv = m_tmpRecoYuv[depth];<br>
- m_tmpRecoYuv[depth] = m_bestRecoYuv[depth];<br>
- m_bestRecoYuv[depth] = tempYuv;<br>
- tempYuv = m_tmpPredYuv[depth];<br>
- m_tmpPredYuv[depth] = m_bestPredYuv[depth];<br>
- m_bestPredYuv[depth] = tempYuv;<br>
+ std::swap(m_bestRecoYuv[depth], m_tmpRecoYuv[depth]);<br>
+ std::swap(m_bestPredYuv[depth], m_tmpPredYuv[depth]);<br>
}<br>
}<br>
else<br>
{<br>
outBestCU = outTempCU;<br>
- tempYuv = m_tmpRecoYuv[depth];<br>
- m_tmpRecoYuv[depth] = m_bestRecoYuv[depth];<br>
- m_bestRecoYuv[depth] = tempYuv;<br>
- tempYuv = m_tmpPredYuv[depth];<br>
- m_tmpPredYuv[depth] = m_bestPredYuv[depth];<br>
- m_bestPredYuv[depth] = tempYuv;<br>
+ std::swap(m_bestRecoYuv[depth], m_tmpRecoYuv[depth]);<br>
+ std::swap(m_bestPredYuv[depth], m_tmpPredYuv[depth]);<br>
}<br>
}<br>
<br>
diff -r 644773b85329 -r a3f4317f4acd source/encoder/framefilter.cpp<br>
--- a/source/encoder/framefilter.cpp Wed Jul 09 13:55:42 2014 +0530<br>
+++ b/source/encoder/framefilter.cpp Wed Jul 09 18:27:26 2014 +0900<br>
@@ -480,9 +480,7 @@<br>
{<br>
for (; z <= y; z++)<br>
{<br>
- void* swap = sum0;<br>
- sum0 = sum1;<br>
- sum1 = (int(*)[4])swap;<br>
+ std::swap(sum0, sum1);<br>
for (int x = 0; x < width; x += 2)<br>
{<br>
primitives.ssim_4x4x2_core(&pix1[(4 * x + (z * stride1))], stride1, &pix2[(4 * x + (z * stride2))], stride2, &sum0[x]);<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br></div>