Commit 7a15b258 authored by Reimar Döffinger's avatar Reimar Döffinger

Take advantage of available input padding to optimize mszh_decomp

Originally committed as revision 19059 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent a5d2745d
......@@ -73,7 +73,7 @@ typedef struct LclDecContext {
/**
* \param srcptr compressed source buffer, must be padded with at least 4 extra bytes
* \param srcptr compressed source buffer, must be padded with at least 5 extra bytes
* \param destptr must be padded sufficiently for av_memcpy_backptr
*/
static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize)
......@@ -81,16 +81,11 @@ static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsign
unsigned char *destptr_bak = destptr;
unsigned char *destptr_end = destptr + destsize;
const unsigned char *srcptr_end = srcptr + srclen;
unsigned char mask = 0;
unsigned char maskbit = 0;
unsigned char mask = *srcptr++;
unsigned char maskbit = 0x80;
unsigned int ofs, cnt;
while (srcptr < srcptr_end && destptr < destptr_end) {
if (maskbit == 0) {
mask = *srcptr++;
maskbit = 0x80;
continue;
}
if (!(mask & maskbit)) {
memcpy(destptr, srcptr, 4);
destptr += 4;
......@@ -105,6 +100,10 @@ static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsign
destptr += cnt;
}
maskbit >>= 1;
if (!maskbit) {
mask = *srcptr++;
maskbit = 0x80;
}
}
return destptr - destptr_bak;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment