diff --git a/avs_core/core/bitblt.cpp b/avs_core/core/bitblt.cpp index 2efbc9a23..279b8a002 100644 --- a/avs_core/core/bitblt.cpp +++ b/avs_core/core/bitblt.cpp @@ -256,40 +256,29 @@ static void asm_BitBlt_ISSE(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src #endif //X86_32 -void BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) { - - // "row_size" is the number of data bytes in a row. - // "pitch" is the distance in bytes between two rows. - // Therefore, by definition, "pitch" is at least as great as "row_size". - assert(dst_pitch >= row_size); - assert(src_pitch >= row_size); - +void BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) +{ if ( (!height) || (!row_size) ) return; - if ( ((src_pitch == dst_pitch) && (dst_pitch == row_size)) || (height == 1) ) - { // we can copy the whole buffer in one go - #ifdef X86_32 - if (GetCPUFlags() & CPUF_INTEGER_SSE) - memcpy_amd(dstp, srcp, src_pitch*height); // SSE - else -#endif - memcpy(dstp, srcp, src_pitch*height); // fallback - } - else - { // we must convert between the different pitch values - -#ifdef X86_32 - if (GetCPUFlags() & CPUF_INTEGER_SSE) + if (GetCPUFlags() & CPUF_INTEGER_SSE) + { + if (height == 1 || (src_pitch == dst_pitch && dst_pitch == row_size)) { + memcpy_amd(dstp, srcp, row_size*height); + } else { asm_BitBlt_ISSE(dstp,dst_pitch,srcp,src_pitch,row_size,height); - else + } + return; + } #endif - { - for (int y=height; y>0; --y) { - memcpy(dstp, srcp, row_size); - dstp += dst_pitch; - srcp += src_pitch; - } + + if (height == 1 || (dst_pitch == src_pitch && src_pitch == row_size)) { + memcpy(dstp, srcp, row_size*height); + } else { + for (int y = height; y > 0; --y) { + memcpy(dstp, srcp, row_size); + dstp += dst_pitch; + srcp += src_pitch; } } } \ No newline at end of file