[xiph-commits] r16926 - trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder

cristianadam at svn.xiph.org cristianadam at svn.xiph.org
Sat Feb 20 16:01:02 PST 2010


Author: cristianadam
Date: 2010-02-20 16:01:02 -0800 (Sat, 20 Feb 2010)
New Revision: 16926

Modified:
   trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp
Log:
Better handling of video sizes not divisible by two.

Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp	2010-02-20 02:38:34 UTC (rev 16925)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp	2010-02-21 00:01:02 UTC (rev 16926)
@@ -703,6 +703,8 @@
     unsigned char * ptrv = inYUVBuffer->v + (m_yOffset / 2) * inYUVBuffer->uv_stride;
 	unsigned char * ptro = locBuffer;
 
+    unsigned long stride = (m_bmiWidth * 2 + 3) & ~3;
+
 	for (unsigned long i = 0; i < m_pictureHeight; ++i) 
 	{
 		unsigned char* ptro2 = ptro;
@@ -745,7 +747,7 @@
 			ptru += inYUVBuffer->uv_stride;
 			ptrv += inYUVBuffer->uv_stride;
 		}
-		ptro += m_bmiWidth * 2;
+		ptro += stride;
 	}
 }
 
@@ -920,6 +922,8 @@
     unsigned char * ptrv = inYUVBuffer->v + (m_yOffset / 2) * inYUVBuffer->uv_stride;
     unsigned char * ptro = locBuffer;
 
+    unsigned long stride = (m_bmiWidth * 2 + 3) & ~3;
+
     for (unsigned long i = 0; i < m_pictureHeight; ++i) 
     {
         unsigned char* ptro2 = ptro;
@@ -937,7 +941,7 @@
             ptru += inYUVBuffer->uv_stride;
             ptrv += inYUVBuffer->uv_stride;
         }
-        ptro += m_bmiWidth * 2;
+        ptro += stride;
     }
 }
 
@@ -1045,8 +1049,9 @@
 			m_xOffset = m_theoraFormatInfo->xOffset;
 			m_yOffset = m_theoraFormatInfo->outerFrameHeight - m_theoraFormatInfo->pictureHeight - m_theoraFormatInfo->yOffset;
 
-			m_pictureWidth = m_theoraFormatInfo->pictureWidth;
-			m_pictureHeight = m_theoraFormatInfo->pictureHeight;
+            // Round up to multiple of two, to remove artefacts when the picture dimensions are not divisible by two
+			m_pictureWidth = (m_theoraFormatInfo->pictureWidth >> 1) << 1;
+			m_pictureHeight = (m_theoraFormatInfo->pictureHeight >> 1) << 1;
 
 			//How many UNITS does one frame take.
 			m_frameDuration = (UNITS * m_theoraFormatInfo->frameRateDenominator) / (m_theoraFormatInfo->frameRateNumerator);



More information about the commits mailing list