/* Calculate the pad-aligned scanline width of a surface  */
static Sint64 SDL_CalculatePitch(Uint32 format, int width)
/* Calculate the pad-aligned scanline width of a surface  */
static Sint64 SDL_CalculatePitch(Uint32 format, int width)
{
    Sint64 pitch;
    if (SDL_ISPIXELFORMAT_FOURCC(format) || SDL_BITSPERPIXEL(format) >= 8) {
        pitch = ((Sint64)width * SDL_BYTESPERPIXEL(format));
    } else {
        pitch = (((Sint64)width * SDL_BITSPERPIXEL(format)) + 7) / 8;
    }
    pitch = (pitch + 3) & ~3;
    return pitch;
}