Ticket #1145: patch_1145.txt

File patch_1145.txt, 6.6 KB (added by karlsharman, 7 years ago)
Line 
1Index: source/App/TAppEncoder/TAppEncCfg.cpp
2===================================================================
3--- source/App/TAppEncoder/TAppEncCfg.cpp       (revision 2966)
4+++ source/App/TAppEncoder/TAppEncCfg.cpp       (working copy)
5@@ -1422,16 +1422,9 @@
6   printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
7   if (m_isField)
8   {
9-    printf("Frame/Field          : Field based coding\n");
10-    printf("Field index          : %u - %d (%d fields)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
11-    if (m_isTopFieldFirst)
12-    {
13-      printf("Field Order            : Top field first\n");
14-    }
15-    else
16-    {
17-      printf("Field Order            : Bottom field first\n");
18-    }
19+    printf("Frame/Field                  : Field based coding\n");
20+    printf("Field index                  : %u - %d (%d fields)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
21+    printf("Field Order                  : %s field first\n", m_isTopFieldFirst?"Top":"Bottom");
22   }
23   else
24   {
25Index: source/App/TAppEncoder/TAppEncTop.cpp
26===================================================================
27--- source/App/TAppEncoder/TAppEncTop.cpp       (revision 2966)
28+++ source/App/TAppEncoder/TAppEncTop.cpp       (working copy)
29@@ -480,7 +480,7 @@
30   assert( m_iGOPSize > 0 );
31   
32   // org. buffer
33-  if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize )
34+  if ( m_cListPicYuvRec.size() >= (UInt)m_iGOPSize ) // buffer will be 1 element longer when using field coding, to maintain first field whilst processing second.
35   {
36     rpcPicYuvRec = m_cListPicYuvRec.popFront();
37 
38Index: source/Lib/TLibEncoder/TEncGOP.cpp
39===================================================================
40--- source/Lib/TLibEncoder/TEncGOP.cpp  (revision 2966)
41+++ source/Lib/TLibEncoder/TEncGOP.cpp  (working copy)
42@@ -160,7 +160,7 @@
43   seiFramePacking->m_spatialFlippingFlag = 0;
44   seiFramePacking->m_frame0FlippedFlag = 0;
45   seiFramePacking->m_fieldViewsFlag = (seiFramePacking->m_arrangementType == 2);
46-  seiFramePacking->m_currentFrameIsFrame0Flag = ((seiFramePacking->m_arrangementType == 5) && m_iNumPicCoded&1);
47+  seiFramePacking->m_currentFrameIsFrame0Flag = ((seiFramePacking->m_arrangementType == 5) && (m_iNumPicCoded&1));
48   seiFramePacking->m_frame0SelfContainedFlag = 0;
49   seiFramePacking->m_frame1SelfContainedFlag = 0;
50   seiFramePacking->m_frame0GridPositionX = 0;
51@@ -420,7 +420,7 @@
52     }
53     else
54     {
55-      pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - isField;
56+      pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - ((isField && m_iGopSize>1) ? 1:0);
57       iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC;
58     }
59     
60@@ -1888,7 +1888,7 @@
61   if( accumBitsDU != NULL) delete accumBitsDU;
62   if( accumNalsDU != NULL) delete accumNalsDU;
63   
64-  assert ( (m_iNumPicCoded == iNumPicRcvd) || (isField && iPOCLast == 1) );
65+  assert ( (m_iNumPicCoded == iNumPicRcvd) );
66 }
67 
68 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded, bool isField)
69@@ -2032,29 +2032,16 @@
70   //  Rec. output
71   TComList<TComPicYuv*>::iterator iterPicYuvRec = rcListPicYuvRecOut.end();
72   
73-  if (isField)
74+  if (isField && pocCurr > 2 && m_iGopSize!=1)
75   {
76-    for ( i = 0; i < ( (pocCurr == 0 ) || (pocCurr == 1 ) ? (iNumPicRcvd - iTimeOffset + 1) : (iNumPicRcvd - iTimeOffset + 2) ); i++ )
77-    {
78-      iterPicYuvRec--;
79-    }
80+    iTimeOffset--;
81   }
82-  else
83+
84+  for ( i = 0; i < (iNumPicRcvd - iTimeOffset + 1); i++ )
85   {
86-    for ( i = 0; i < (iNumPicRcvd - iTimeOffset + 1); i++ )
87-    {
88-      iterPicYuvRec--;
89-    }
90-   
91+    iterPicYuvRec--;
92   }
93   
94-  if (isField)
95-  {
96-    if(pocCurr == 1)
97-    {
98-      iterPicYuvRec++;
99-    }
100-  }
101   rpcPicYuvRecOut = *(iterPicYuvRec);
102   
103   //  Current pic.
104@@ -2318,8 +2305,8 @@
105   {
106     for (Int x = 0; x < width; x++)
107     {
108-      dst[x] = isTff ? (UChar) top[x] : (UChar) bottom[x];
109-      dst[stride+x] = isTff ? (UChar) bottom[x] : (UChar) top[x];
110+      dst[x] = isTff ? top[x] : bottom[x];
111+      dst[stride+x] = isTff ? bottom[x] : top[x];
112     }
113     top += stride;
114     bottom += stride;
115Index: source/Lib/TLibEncoder/TEncTop.cpp
116===================================================================
117--- source/Lib/TLibEncoder/TEncTop.cpp  (revision 2966)
118+++ source/Lib/TLibEncoder/TEncTop.cpp  (working copy)
119@@ -410,6 +410,8 @@
120 
121 Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, bool isTff)
122 {
123+  iNumEncoded = 0;
124+
125   /* -- TOP FIELD -- */
126   
127   if (pcPicYuvOrg)
128@@ -446,7 +448,7 @@
129     {
130       m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) );
131     }
132-   
133+
134     /* -- Defield -- */
135     
136     bool isTop = isTff;
137@@ -457,11 +459,16 @@
138     
139   }
140   
141-  if (m_iPOCLast == 0) // compress field 0
142+  if ( m_iNumPicRcvd && ( (m_iPOCLast/2)==0 || m_iNumPicRcvd==m_iGOPSize ) )
143   {
144+    // compress GOP
145     m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff);
146+
147+    iNumEncoded += m_iNumPicRcvd;
148+    m_uiNumAllPicCoded += m_iNumPicRcvd;
149+    m_iNumPicRcvd = 0;
150   }
151
152+
153   /* -- BOTTOM FIELD -- */
154   
155   if (pcPicYuvOrg)
156@@ -475,7 +482,7 @@
157     pcBottomField->setReconMark (false);
158     
159     TComPicYuv* rpcPicYuvRec = new TComPicYuv;
160-    if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize )
161+    if ( rcListPicYuvRecOut.size() >= (UInt)m_iGOPSize+1 ) // need to maintain field 0 in list of RecOuts while processing field 1. Hence +1 on m_iGOPSize.
162     {
163       rpcPicYuvRec = rcListPicYuvRecOut.popFront();
164     }
165@@ -509,7 +516,7 @@
166     {
167       m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) );
168     }
169-   
170+
171     /* -- Defield -- */
172     
173     bool isTop = !isTff;
174@@ -520,18 +527,15 @@
175     
176   }
177   
178-  if ( ( !(m_iNumPicRcvd) || (!flush && m_iPOCLast != 1 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize)) )
179+  if ( m_iNumPicRcvd && (flush || (m_iPOCLast/2)==0 || m_iNumPicRcvd==m_iGOPSize ) )
180   {
181-    iNumEncoded = 0;
182-    return;
183+    // compress GOP
184+    m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff);
185+
186+    iNumEncoded += m_iNumPicRcvd;
187+    m_uiNumAllPicCoded += m_iNumPicRcvd;
188+    m_iNumPicRcvd = 0;
189   }
190
191-  // compress GOP
192-  m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff);
193
194-  iNumEncoded = m_iNumPicRcvd;
195-  m_iNumPicRcvd = 0;
196-  m_uiNumAllPicCoded += iNumEncoded;
197 }
198 
199 // ====================================================================================================================