{
uint8_t *output = NULL;
- if ( input != NULL && ( iwidth != owidth || iheight != oheight ) )
+ if ( input != NULL && ( iwidth != owidth || iheight != oheight ) && ( owidth > 6 && oheight > 6 ) )
{
iwidth = iwidth - ( iwidth % 2 );
owidth = owidth - ( owidth % 2 );
int istride = iwidth * 2;
int ostride = owidth * 2;
- iwidth = iwidth - ( iwidth % 4 );
- owidth = owidth - ( owidth % 4 );
+ iwidth = iwidth - ( iwidth % 2 );
+ owidth = owidth - ( owidth % 2 );
//iheight = iheight - ( iheight % 2 );
//oheight = oheight - ( oheight % 2 );
-
+
// Optimisation point
- if ( iwidth == owidth && iheight == oheight )
+ if ( output == NULL || input == NULL || ( owidth <= 6 || oheight <= 6 || iwidth <= 6 || oheight <= 6 ) )
+ {
+ return;
+ }
+ else if ( iwidth == owidth && iheight == oheight )
+ {
memcpy( output, input, iheight * istride );
+ return;
+ }
// Coordinates (0,0 is middle of output)
int y;
uint8_t *out_ptr = out_line;
// Calculate a middle and possibly invalid pointer in the input
- uint8_t *in_middle = input + istride * ( iheight / 2 ) + ( iwidth / 2 ) * 2;
+ uint8_t *in_middle = input + istride * ( iheight / 2 ) + iwidth;
int in_line = - in_y_range * istride - in_x_range * 2;
int elements;
}
int active_width = 2 * iwidth;
- int inactive_width = out_x_range - in_x_range;
+ int left_inactive_width = out_x_range - in_x_range;
+ int right_inactive_width = left_inactive_width;
uint8_t *p = NULL;
uint8_t *end = NULL;
+ if ( in_line % 4 )
+ {
+ active_width -= 2;
+ in_middle += 2;
+ right_inactive_width += 2;
+ }
+
// Loop for the entirety of our output height.
while ( iheight -- )
{
out_ptr = out_line;
// Fill the outer part with black
- elements = inactive_width;
+ elements = left_inactive_width;
while ( elements -- )
{
*out_ptr ++ = 16;
}
// Fill the outer part with black
- elements = inactive_width;
+ elements = right_inactive_width;
while ( elements -- )
{
*out_ptr ++ = 16;