From: ShadowFlare Date: Wed, 5 Dec 2007 05:56:13 +0000 (+0000) Subject: Change duplicate frame detection X-Git-Url: https://sfsrealm.hopto.org/projects/?a=commitdiff_plain;h=6ac16fc3a1be03db0b4f50c3d5e6561e70ad8341;p=grpapi.git Change duplicate frame detection --- diff --git a/grpapi/grpapi.cpp b/grpapi/grpapi.cpp index 67726c4..b002e12 100644 --- a/grpapi/grpapi.cpp +++ b/grpapi/grpapi.cpp @@ -525,20 +525,18 @@ HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMa lpFrameHeaders[i].Width = x2; lpFrameHeaders[i].Height = y2; - EncodeFrameData(lpImageData, i, &GrpHeader, &lpFrameHeaders[i], &lpFrameData[i], bNoCompress); - // Search for duplicate frames for (j = 0; j < i; j++) { - if (lpFrameData[j].lpRowOffsets && lpFrameHeaders[i].Width == lpFrameHeaders[j].Width && lpFrameHeaders[i].Height == lpFrameHeaders[j].Height && lpFrameData[i].Size == lpFrameData[j].Size) { - for (y = 0; y < lpFrameHeaders[i].Height; y++) { - if (!lpFrameData[i].lpRowData[y] && !lpFrameData[j].lpRowData[y]) - continue; + if (lpFrameData[j].lpRowOffsets && lpFrameHeaders[i].Width == lpFrameHeaders[j].Width && lpFrameHeaders[i].Height == lpFrameHeaders[j].Height) { + y1 = i * wMaxWidth * wMaxHeight + lpFrameHeaders[i].Top * wMaxWidth + lpFrameHeaders[i].Left; + y2 = j * wMaxWidth * wMaxHeight + lpFrameHeaders[j].Top * wMaxWidth + lpFrameHeaders[j].Left; - if ((!lpFrameData[i].lpRowData[y] && lpFrameData[j].lpRowData[y]) || (lpFrameData[i].lpRowData[y] && !lpFrameData[j].lpRowData[y]) || lpFrameData[i].lpRowSizes[y] != lpFrameData[j].lpRowSizes[y]) + for (y = 0; y < lpFrameHeaders[i].Height; y++) { + if (memcmp(&lpImageData[y1], &lpImageData[y2], lpFrameHeaders[i].Width * sizeof(short)) != 0) break; - if (memcmp(lpFrameData[i].lpRowData[y], lpFrameData[j].lpRowData[y], lpFrameData[i].lpRowSizes[y]) != 0) - break; + y1 += wMaxWidth; + y2 += wMaxWidth; } if (y == lpFrameHeaders[i].Height) { @@ -548,17 +546,7 @@ HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMa } if (j < i) { - // Duplicate frame found, free stored frame data and change offset - for (y = 0; y < lpFrameHeaders[i].Height; y++) { - if (lpFrameData[i].lpRowData[y]) { - free(lpFrameData[i].lpRowData[y]); - } - } - - free(lpFrameData[i].lpRowOffsets); - free(lpFrameData[i].lpRowSizes); - free(lpFrameData[i].lpRowData); - + // Duplicate frame found, set offset and flag as duplicate lpFrameHeaders[i].Offset = lpFrameHeaders[j].Offset; lpFrameData[i].lpRowOffsets = 0; lpFrameData[i].lpRowSizes = 0; @@ -567,6 +555,7 @@ HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMa continue; } + EncodeFrameData(lpImageData, i, &GrpHeader, &lpFrameHeaders[i], &lpFrameData[i], bNoCompress); nLastOffset = lpFrameHeaders[i].Offset + lpFrameData[i].Size; }