[x265] [PATCH 2 of 2] Removing older code which initializes RPS
shazeb at multicorewareinc.com
shazeb at multicorewareinc.com
Fri Aug 23 13:29:01 CEST 2013
# HG changeset patch
# User Shazeb N Khan
# Date 1377257272 -19800
# Fri Aug 23 16:57:52 2013 +0530
# Node ID 6fd3e04ac3f77be4b3d1aef33f891ddd619baf42
# Parent c0c20cd66cc7d435332c8d1651fc3799cbf7392f
Removing older code which initializes RPS
diff -r c0c20cd66cc7 -r 6fd3e04ac3f7 source/encoder/dpb.cpp
--- a/source/encoder/dpb.cpp Fri Aug 23 16:57:04 2013 +0530
+++ b/source/encoder/dpb.cpp Fri Aug 23 16:57:52 2013 +0530
@@ -528,17 +528,13 @@
int offsets[] = { 1, 2, 3, 4, 4, 3, 4, 4 };
double factors[] = { 0, 0.442, 0.3536, 0.3536, 0.68 };
int pocs[] = { 8, 4, 2, 1, 3, 6, 5, 7 };
- int rps[] = { 0, 4, 2, 1, -2, -3, 1, -2 };
for (int i = 0; i < 8; i++)
{
m_gopList[i].m_POC = pocs[i];
m_gopList[i].m_QPFactor = factors[offsets[i]];
m_gopList[i].m_QPOffset = offsets[i];
- m_gopList[i].m_deltaRPS = rps[i];
- m_gopList[i].m_sliceType = 'B';
+ m_gopList[i].m_sliceType = ((i==3)||(i==0))? 'P': 'B';
m_gopList[i].m_numRefPicsActive = i ? 2 : 4;
- m_gopList[i].m_numRefPics = i == 1 ? 3 : 4;
- m_gopList[i].m_interRPSPrediction = i ? 1 : 0;
m_gopList[i].m_numRefIdc = i == 2 ? 4 : 5;
}
@@ -546,22 +542,6 @@
m_gopList[id].VAR[0] = a; m_gopList[id].VAR[1] = b; m_gopList[id].VAR[2] = c; m_gopList[id].VAR[3] = d;
#define SET5(id, VAR, a, b, c, d, e) \
m_gopList[id].VAR[0] = a; m_gopList[id].VAR[1] = b; m_gopList[id].VAR[2] = c; m_gopList[id].VAR[3] = d; m_gopList[id].VAR[4] = e;
-
- SET4(0, m_referencePics, -8, -10, -12, -16);
- SET4(1, m_referencePics, -4, -6, 4, 0);
- SET4(2, m_referencePics, -2, -4, 2, 6);
- SET4(3, m_referencePics, -1, 1, 3, 7);
- SET4(4, m_referencePics, -1, -3, 1, 5);
- SET4(5, m_referencePics, -2, -4, -6, 2);
- SET4(6, m_referencePics, -1, -5, 1, 3);
- SET4(7, m_referencePics, -1, -3, -7, 1);
- SET5(1, m_refIdc, 1, 1, 0, 0, 1);
- SET5(2, m_refIdc, 1, 1, 1, 1, 0);
- SET5(3, m_refIdc, 1, 0, 1, 1, 1);
- SET5(4, m_refIdc, 1, 1, 1, 1, 0);
- SET5(5, m_refIdc, 1, 1, 1, 1, 0);
- SET5(6, m_refIdc, 1, 0, 1, 1, 1);
- SET5(7, m_refIdc, 1, 1, 1, 1, 0);
m_gopSize = 8;
_param->bframes = 8; // this fixed GOP structure can use refs 8 frames away
}
@@ -630,229 +610,6 @@
_param->lookaheadDepth = m_gopSize;
}
- bool verifiedGOP = false;
- bool errorGOP = false;
- int checkGOP = 1;
- int numRefs = 1;
-
- int refList[MAX_NUM_REF_PICS + 1];
- refList[0] = 0;
- bool isOK[MAX_GOP];
- for (Int i = 0; i < MAX_GOP; i++)
- {
- isOK[i] = false;
- }
-
- int numOK = 0;
- if (_param->bOpenGOP == false)
- CONFIRM(_param->keyframeMax % m_gopSize != 0, "Intra period must be a multiple of GOPSize");
-
- m_extraRPSs = 0;
- // start looping through frames in coding order until we can verify that the GOP structure is correct.
- while (!verifiedGOP && !errorGOP)
- {
- Int curGOP = (checkGOP - 1) % m_gopSize;
- Int curPOC = ((checkGOP - 1) / m_gopSize) * m_gopSize + m_gopList[curGOP].m_POC;
- if (m_gopList[curGOP].m_POC < 0)
- {
- printf("\nError: found fewer Reference Picture Sets than GOPSize\n");
- errorGOP = true;
- }
- else
- {
- //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP.
- Bool beforeI = false;
- for (Int i = 0; i < m_gopList[curGOP].m_numRefPics; i++)
- {
- Int absPOC = curPOC + m_gopList[curGOP].m_referencePics[i];
- if (absPOC < 0)
- {
- beforeI = true;
- }
- else
- {
- Bool found = false;
- for (Int j = 0; j < numRefs; j++)
- {
- if (refList[j] == absPOC)
- {
- found = true;
- for (Int k = 0; k < m_gopSize; k++)
- {
- if (absPOC % m_gopSize == m_gopList[k].m_POC % m_gopSize)
- {
- m_gopList[k].m_refPic = true;
- m_gopList[curGOP].m_usedByCurrPic[i] = 1;
- }
- }
- }
- }
-
- if (!found)
- {
- printf("\nError: ref pic %d is not available for GOP frame %d\n", m_gopList[curGOP].m_referencePics[i], curGOP + 1);
- errorGOP = true;
- }
- }
- }
-
- if (!beforeI && !errorGOP)
- {
- //all ref frames were present
- if (!isOK[curGOP])
- {
- numOK++;
- isOK[curGOP] = true;
- if (numOK == m_gopSize)
- {
- verifiedGOP = true;
- }
- }
- }
- else
- {
- //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0)
- m_gopList[m_gopSize + m_extraRPSs] = m_gopList[curGOP];
- Int newRefs = 0;
- for (Int i = 0; i < m_gopList[curGOP].m_numRefPics; i++)
- {
- Int absPOC = curPOC + m_gopList[curGOP].m_referencePics[i];
- if (absPOC >= 0)
- {
- m_gopList[m_gopSize + m_extraRPSs].m_referencePics[newRefs] = m_gopList[curGOP].m_referencePics[i];
- m_gopList[m_gopSize + m_extraRPSs].m_usedByCurrPic[newRefs] = m_gopList[curGOP].m_usedByCurrPic[i];
- newRefs++;
- }
- }
-
- Int numPrefRefs = m_gopList[curGOP].m_numRefPicsActive;
-
- for (Int offset = -1; offset > -checkGOP; offset--)
- {
- //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0.
- Int offGOP = (checkGOP - 1 + offset) % m_gopSize;
- Int offPOC = ((checkGOP - 1 + offset) / m_gopSize) * m_gopSize + m_gopList[offGOP].m_POC;
- if (offPOC >= 0)
- {
- Bool newRef = false;
- for (Int i = 0; i < numRefs; i++)
- {
- if (refList[i] == offPOC)
- {
- newRef = true;
- }
- }
-
- for (Int i = 0; i < newRefs; i++)
- {
- if (m_gopList[m_gopSize + m_extraRPSs].m_referencePics[i] == offPOC - curPOC)
- {
- newRef = false;
- }
- }
-
- if (newRef)
- {
- Int insertPoint = newRefs;
- //this picture can be added, find appropriate place in list and insert it.
- m_gopList[offGOP].m_refPic = true;
- for (Int j = 0; j < newRefs; j++)
- {
- if (m_gopList[m_gopSize + m_extraRPSs].m_referencePics[j] < offPOC - curPOC || m_gopList[m_gopSize + m_extraRPSs].m_referencePics[j] > 0)
- {
- insertPoint = j;
- break;
- }
- }
-
- Int prev = offPOC - curPOC;
- Int prevUsed = 1;
- for (Int j = insertPoint; j < newRefs + 1; j++)
- {
- Int newPrev = m_gopList[m_gopSize + m_extraRPSs].m_referencePics[j];
- Int newUsed = m_gopList[m_gopSize + m_extraRPSs].m_usedByCurrPic[j];
- m_gopList[m_gopSize + m_extraRPSs].m_referencePics[j] = prev;
- m_gopList[m_gopSize + m_extraRPSs].m_usedByCurrPic[j] = prevUsed;
- prevUsed = newUsed;
- prev = newPrev;
- }
-
- newRefs++;
- }
- }
- if (newRefs >= numPrefRefs)
- {
- break;
- }
- }
-
- m_gopList[m_gopSize + m_extraRPSs].m_numRefPics = newRefs;
- m_gopList[m_gopSize + m_extraRPSs].m_POC = curPOC;
- if (m_extraRPSs == 0)
- {
- m_gopList[m_gopSize + m_extraRPSs].m_interRPSPrediction = 0;
- m_gopList[m_gopSize + m_extraRPSs].m_numRefIdc = 0;
- }
- else
- {
- Int rIdx = m_gopSize + m_extraRPSs - 1;
- Int refPOC = m_gopList[rIdx].m_POC;
- Int refPics = m_gopList[rIdx].m_numRefPics;
- Int newIdc = 0;
- for (Int i = 0; i <= refPics; i++)
- {
- Int deltaPOC = ((i != refPics) ? m_gopList[rIdx].m_referencePics[i] : 0); // check if the reference abs POC is >= 0
- Int absPOCref = refPOC + deltaPOC;
- Int refIdc = 0;
- for (Int j = 0; j < m_gopList[m_gopSize + m_extraRPSs].m_numRefPics; j++)
- {
- if ((absPOCref - curPOC) == m_gopList[m_gopSize + m_extraRPSs].m_referencePics[j])
- {
- if (m_gopList[m_gopSize + m_extraRPSs].m_usedByCurrPic[j])
- {
- refIdc = 1;
- }
- else
- {
- refIdc = 2;
- }
- }
- }
-
- m_gopList[m_gopSize + m_extraRPSs].m_refIdc[newIdc] = refIdc;
- newIdc++;
- }
-
- m_gopList[m_gopSize + m_extraRPSs].m_interRPSPrediction = 1;
- m_gopList[m_gopSize + m_extraRPSs].m_numRefIdc = newIdc;
- m_gopList[m_gopSize + m_extraRPSs].m_deltaRPS = refPOC - m_gopList[m_gopSize + m_extraRPSs].m_POC;
- }
- curGOP = m_gopSize + m_extraRPSs;
- m_extraRPSs++;
- }
- numRefs = 0;
- for (Int i = 0; i < m_gopList[curGOP].m_numRefPics; i++)
- {
- Int absPOC = curPOC + m_gopList[curGOP].m_referencePics[i];
- if (absPOC >= 0)
- {
- refList[numRefs] = absPOC;
- numRefs++;
- }
- }
-
- refList[numRefs] = curPOC;
- numRefs++;
- }
- checkGOP++;
- }
-
- CONFIRM(errorGOP, "Invalid GOP structure given");
- for (Int i = 0; i < m_gopSize; i++)
- {
- CONFIRM(m_gopList[i].m_sliceType != 'B' && m_gopList[i].m_sliceType != 'P', "Slice type must be equal to B or P");
- }
-
for (Int i = 0; i < MAX_TLAYER; i++)
{
m_numReorderPics[i] = 0;
diff -r c0c20cd66cc7 -r 6fd3e04ac3f7 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp Fri Aug 23 16:57:04 2013 +0530
+++ b/source/encoder/frameencoder.cpp Fri Aug 23 16:57:52 2013 +0530
@@ -109,7 +109,6 @@
m_pps.setSPS(&m_sps);
top->xInitPPS(&m_pps);
- top->xInitRPS(&m_sps);
m_sps.setNumLongTermRefPicSPS(0);
if (m_cfg->getPictureTimingSEIEnabled() || m_cfg->getDecodingUnitInfoSEIEnabled())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265-2.patch
Type: text/x-patch
Size: 12530 bytes
Desc: not available
URL: <https://mailman.videolan.org/private/x265-devel/attachments/20130823/ddc3f0ca/attachment-0001.bin>
More information about the x265-devel
mailing list