Revision: 34714
http://sourceforge.net/p/opalvoip/code/34714
Author: rjongbloed
Date: 2016-03-21 19:18:02 +0000 (Mon, 21 Mar 2016)
Log Message:
-----------
More handling of odd video resolutions.
Modified Paths:
--------------
ptlib/trunk/src/ptlib/common/vconvert.cxx
Modified: ptlib/trunk/src/ptlib/common/vconvert.cxx
===================================================================
--- ptlib/trunk/src/ptlib/common/vconvert.cxx 2016-03-21 18:08:39 UTC (rev 34713)
+++ ptlib/trunk/src/ptlib/common/vconvert.cxx 2016-03-21 19:18:02 UTC (rev 34714)
@@ -943,13 +943,13 @@
unsigned planeWidth = (frameWidth+1)&~1;
unsigned planeHeight = (frameHeight+1)&~1;
- unsigned char * Yptr = yuv + ( y * planeWidth ) + x;
- unsigned char * Uptr = yuv + (planeWidth * planeHeight) + ( (y * planeWidth) >> 2) + (x >> 1);
- unsigned char * Vptr = Uptr + planeWidth * planeHeight / 4;
-
int halfRectWidth = width/2;
int halfPlaneWidth = planeWidth/2;
+ unsigned char * Yptr = yuv + y*planeWidth + x;
+ unsigned char * Uptr = yuv + (planeWidth * planeHeight) + y/2*halfPlaneWidth + x/2;
+ unsigned char * Vptr = Uptr + planeWidth * planeHeight / 4;
+
for (unsigned dy = 0; dy < height; dy += 2) {
memset(Yptr, Y, width);
Yptr += planeWidth;
@@ -1883,7 +1883,9 @@
if (bytesReturned != NULL)
*bytesReturned = m_dstFrameBytes;
- unsigned yPlaneSize = m_srcFrameWidth*m_srcFrameHeight;
+ unsigned planeWidth = (m_srcFrameWidth+1)&~1;
+ unsigned planeHeight = (m_srcFrameHeight+1)&~1;
+ unsigned yPlaneSize = planeWidth*planeHeight;
const BYTE * scanLinePtrY = srcFrameBuffer; // 1 byte Y (luminance) for each pixel
const BYTE * scanLinePtrU = scanLinePtrY+yPlaneSize; // 1 byte U for a block of 4 pixels
const BYTE * scanLinePtrV = scanLinePtrU+yPlaneSize/4; // 1 byte V for a block of 4 pixels
@@ -1917,7 +1919,7 @@
BYTE * scanLinePtrRGB = dstFrameBuffer;
int scanLineSizeRGB = (int)((rgbIncrement*m_dstFrameWidth+3)&~3);
- unsigned srcPixpos[4] = { 0, 1, m_srcFrameWidth, m_srcFrameWidth + 1 };
+ unsigned srcPixpos[4] = { 0, 1, planeWidth, planeWidth + 1 };
unsigned dstPixpos[4] = { 0, rgbIncrement, (unsigned)scanLineSizeRGB, (unsigned)scanLineSizeRGB+rgbIncrement };
if (m_verticalFlip) {
@@ -1952,8 +1954,9 @@
for (unsigned y = 0; y < m_srcFrameHeight; y += 2) {
BYTE * pixelRGB = scanLinePtrRGB;
for (unsigned x = 0; x < m_srcFrameWidth; x += 2) {
+ unsigned pixels = x < m_srcFrameWidth-1 ? 4 : 2;
YUV420PtoRGB_PIXEL_UV(scanLinePtrU, scanLinePtrV);
- for (unsigned p = 0; p < 4; p++) {
+ for (unsigned p = 0; p < pixels; p++) {
BYTE * rgbPtr = pixelRGB + dstPixpos[p];
YUV420PtoRGB_PIXEL_RGB(scanLinePtrY);
if (rgbIncrement == 4)
@@ -1965,12 +1968,12 @@
scanLinePtrV++;
}
scanLinePtrRGB += scanLineSizeRGB;
- scanLinePtrY += m_srcFrameWidth;
+ scanLinePtrY += planeWidth;
}
}
else {
- unsigned scanLineSizeY = m_srcFrameWidth*2; // Actually two scan lines
- unsigned scanLineSizeUV = m_srcFrameWidth/2;
+ unsigned scanLineSizeY = planeWidth*2; // Actually two scan lines
+ unsigned scanLineSizeUV = planeWidth/2;
PRasterDutyCycle raster(m_resizeMode, m_srcFrameWidth, m_srcFrameHeight, m_dstFrameWidth, m_dstFrameHeight, 2, 2);
do {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|