mirror of https://github.com/FreeRDP/FreeRDP
Improve codec error logging
This commit is contained in:
parent
968d4d8f8a
commit
21cfb23e0b
|
@ -111,6 +111,8 @@ static INLINE INT32 planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
|
|||
UINT32 x, y;
|
||||
BYTE controlByte;
|
||||
|
||||
WINPR_ASSERT(pSrcData);
|
||||
|
||||
for (y = 0; y < nHeight; y++)
|
||||
{
|
||||
for (x = 0; x < nWidth;)
|
||||
|
@ -119,7 +121,11 @@ static INLINE INT32 planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
|
|||
int nRunLength;
|
||||
|
||||
if (used >= SrcSize)
|
||||
{
|
||||
WLog_ERR(TAG, "planar plane used %" PRIu32 " exceeds SrcSize %" PRIu32, used,
|
||||
SrcSize);
|
||||
return -1;
|
||||
}
|
||||
|
||||
controlByte = pSrcData[used++];
|
||||
nRunLength = PLANAR_CONTROL_BYTE_RUN_LENGTH(controlByte);
|
||||
|
@ -141,15 +147,25 @@ static INLINE INT32 planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
|
|||
x += nRunLength;
|
||||
|
||||
if (x > nWidth)
|
||||
{
|
||||
WLog_ERR(TAG, "planar plane x %" PRIu32 " exceeds width %" PRIu32, x, nWidth);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (used > SrcSize)
|
||||
{
|
||||
WLog_ERR(TAG, "planar plane used %" PRIu32 " exceeds SrcSize %" PRIu32, used,
|
||||
INT32_MAX);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (used > INT32_MAX)
|
||||
{
|
||||
WLog_ERR(TAG, "planar plane used %" PRIu32 " exceeds SrcSize %" PRIu32, used, SrcSize);
|
||||
return -1;
|
||||
}
|
||||
return (INT32)used;
|
||||
}
|
||||
|
||||
|
@ -166,8 +182,8 @@ static INLINE INT32 planar_decompress_plane_rle_only(const BYTE* pSrcData, UINT3
|
|||
BYTE* previousScanline;
|
||||
const BYTE* srcp = pSrcData;
|
||||
|
||||
if ((nHeight > INT32_MAX) || (nWidth > INT32_MAX))
|
||||
return -1;
|
||||
WINPR_ASSERT(nHeight <= INT32_MAX);
|
||||
WINPR_ASSERT(nWidth <= INT32_MAX);
|
||||
|
||||
previousScanline = NULL;
|
||||
|
||||
|
@ -289,8 +305,9 @@ static INLINE INT32 planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 Src
|
|||
BYTE* previousScanline;
|
||||
const BYTE* srcp = pSrcData;
|
||||
|
||||
if ((nHeight > INT32_MAX) || (nWidth > INT32_MAX) || (nDstStep > INT32_MAX))
|
||||
return -1;
|
||||
WINPR_ASSERT(nHeight <= INT32_MAX);
|
||||
WINPR_ASSERT(nWidth <= INT32_MAX);
|
||||
WINPR_ASSERT(nDstStep <= INT32_MAX);
|
||||
|
||||
previousScanline = NULL;
|
||||
|
||||
|
@ -416,8 +433,9 @@ static INLINE INT32 planar_set_plane(BYTE bValue, BYTE* pDstData, INT32 nDstStep
|
|||
INT32 x, y;
|
||||
INT32 beg, end, inc;
|
||||
|
||||
if ((nHeight > INT32_MAX) || (nWidth > INT32_MAX) || (nDstStep > INT32_MAX))
|
||||
return -1;
|
||||
WINPR_ASSERT(nHeight <= INT32_MAX);
|
||||
WINPR_ASSERT(nWidth <= INT32_MAX);
|
||||
WINPR_ASSERT(nDstStep <= INT32_MAX);
|
||||
|
||||
if (vFlip)
|
||||
{
|
||||
|
@ -451,8 +469,10 @@ static INLINE BOOL writeLine(BYTE** ppRgba, UINT32 DstFormat, UINT32 width, cons
|
|||
{
|
||||
UINT32 x;
|
||||
|
||||
if (!ppRgba || !ppR || !ppG || !ppB)
|
||||
return FALSE;
|
||||
WINPR_ASSERT(ppRgba);
|
||||
WINPR_ASSERT(ppR);
|
||||
WINPR_ASSERT(ppG);
|
||||
WINPR_ASSERT(ppB);
|
||||
|
||||
switch (DstFormat)
|
||||
{
|
||||
|
@ -534,17 +554,33 @@ static INLINE BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4], BYTE* p
|
|||
}
|
||||
|
||||
if (nYDst + nHeight > totalHeight)
|
||||
{
|
||||
WLog_ERR(TAG,
|
||||
"planar plane destination Y %" PRIu32 " + height %" PRIu32
|
||||
" exceeds totalHeight %" PRIu32,
|
||||
nYDst, nHeight, totalHeight);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((nXDst + nWidth) * bpp > nDstStep)
|
||||
{
|
||||
WLog_ERR(TAG,
|
||||
"planar plane destination (X %" PRIu32 " + width %" PRIu32 ") * bpp %" PRIu32
|
||||
" exceeds stride %" PRIu32,
|
||||
nXDst, nWidth, bpp, nDstStep);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (y = beg; y != end; y += inc)
|
||||
{
|
||||
BYTE* pRGB;
|
||||
|
||||
if (y > (INT64)nHeight)
|
||||
{
|
||||
WLog_ERR(TAG, "planar plane destination Y %" PRId32 " exceeds height %" PRIu32, y,
|
||||
nHeight);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * bpp)];
|
||||
|
||||
|
@ -563,14 +599,22 @@ static BOOL planar_subsample_expand(const BYTE* plane, size_t planeLength, UINT3
|
|||
UINT32 y;
|
||||
WINPR_UNUSED(planeLength);
|
||||
|
||||
if (!plane || !deltaPlane)
|
||||
return FALSE;
|
||||
WINPR_ASSERT(plane);
|
||||
WINPR_ASSERT(deltaPlane);
|
||||
|
||||
if (nWidth > nPlaneWidth * 2)
|
||||
{
|
||||
WLog_ERR(TAG, "planar subsample width %" PRIu32 " > PlaneWidth %" PRIu32 " * 2", nWidth,
|
||||
nPlaneWidth);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (nHeight > nPlaneHeight * 2)
|
||||
{
|
||||
WLog_ERR(TAG, "planar subsample height %" PRIu32 " > PlaneHeight %" PRIu32 " * 2", nHeight,
|
||||
nPlaneHeight);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (y = 0; y < nHeight; y++)
|
||||
{
|
||||
|
@ -688,7 +732,11 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar, const BYTE* pSrcData, UINT
|
|||
if (alpha)
|
||||
{
|
||||
if ((SrcSize - (srcp - pSrcData)) < (planeSize + base))
|
||||
{
|
||||
WLog_ERR(TAG, "Alpha plane size mismatch %" PRIu32 " < %" PRIu32,
|
||||
SrcSize - (srcp - pSrcData), (planeSize + base));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
planes[3] = srcp; /* AlphaPlane */
|
||||
planes[0] = planes[3] + rawSizes[3]; /* LumaOrRedPlane */
|
||||
|
@ -696,19 +744,31 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar, const BYTE* pSrcData, UINT
|
|||
planes[2] = planes[1] + rawSizes[1]; /* GreenChromaOrBluePlane */
|
||||
|
||||
if ((planes[2] + rawSizes[2]) > &pSrcData[SrcSize])
|
||||
{
|
||||
WLog_ERR(TAG, "plane size mismatch %p + %" PRIu32 " > %p", planes[2], rawSizes[2],
|
||||
&pSrcData[SrcSize]);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((SrcSize - (srcp - pSrcData)) < base)
|
||||
{
|
||||
WLog_ERR(TAG, "plane size mismatch %" PRIu32 " < %" PRIu32,
|
||||
SrcSize - (srcp - pSrcData), base);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
planes[0] = srcp; /* LumaOrRedPlane */
|
||||
planes[1] = planes[0] + rawSizes[0]; /* OrangeChromaOrGreenPlane */
|
||||
planes[2] = planes[1] + rawSizes[1]; /* GreenChromaOrBluePlane */
|
||||
|
||||
if ((planes[2] + rawSizes[2]) > &pSrcData[SrcSize])
|
||||
{
|
||||
WLog_ERR(TAG, "plane size mismatch %p + %" PRIu32 " > %p", planes[2], rawSizes[2],
|
||||
&pSrcData[SrcSize]);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* RLE */
|
||||
|
@ -827,7 +887,10 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar, const BYTE* pSrcData, UINT
|
|||
{
|
||||
if (!freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, w, h, pTempData,
|
||||
TempFormat, nTempStep, nXDst, nYDst, NULL, FREERDP_FLIP_NONE))
|
||||
{
|
||||
WLog_ERR(TAG, "planar image copy failed");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* YCoCg */
|
||||
|
@ -844,7 +907,9 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar, const BYTE* pSrcData, UINT
|
|||
TempFormat = PIXEL_FORMAT_BGRX32;
|
||||
|
||||
if (!pTempData)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (rle) /* RLE encoded data. Decode and handle it like raw data. */
|
||||
{
|
||||
|
@ -931,9 +996,14 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar, const BYTE* pSrcData, UINT
|
|||
srcp++; /* pad */
|
||||
}
|
||||
|
||||
if (prims->YCoCgToRGB_8u_AC4R(pTempData, nTempStep, dst, DstFormat, nDstStep, w, h, cll,
|
||||
useAlpha) != PRIMITIVES_SUCCESS)
|
||||
WINPR_ASSERT(prims->YCoCgToRGB_8u_AC4R);
|
||||
int rc = prims->YCoCgToRGB_8u_AC4R(pTempData, nTempStep, dst, DstFormat, nDstStep, w, h,
|
||||
cll, useAlpha);
|
||||
if (rc != PRIMITIVES_SUCCESS)
|
||||
{
|
||||
WLog_ERR(TAG, "YCoCgToRGB_8u_AC4R failed with %d", rc);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
WINPR_UNUSED(srcp);
|
||||
|
|
|
@ -1793,7 +1793,6 @@ static INLINE int progressive_process_tiles(PROGRESSIVE_CONTEXT* progressive, wS
|
|||
return -1;
|
||||
}
|
||||
|
||||
WINPR_ASSERT(region->tiles || (region->numTiles == 0));
|
||||
for (index = 0; index < region->numTiles; index++)
|
||||
{
|
||||
RFX_PROGRESSIVE_TILE* tile = region->tiles[index];
|
||||
|
|
Loading…
Reference in New Issue