Scale4x

All the inane chatter goes in here. If you're curious about whether we will support a game, post HERE not in General Discussion :)

Moderator: ScummVM Team

Post Reply
Lostech
Posts: 157
Joined: Fri May 04, 2007 8:42 am
Contact:

Scale4x

Post by Lostech »

Yes, I know, there had been many discussions for and against a 4x scaler here (too much to read them all, honestly), so therefore I´m posting in the junkyard. :lol:

First of all I´m not a big C coder, I normally use Delphi and for a project I ported the scale2x scaler to Delphi. By doing this I read the explanation of the scale2x algorithm and found a 4x scaler algorithm which is simply scale2x applied two times.
Now I thought by myself this could be also possible with ScummVM and started to look into the sources and it had been a big surprise for me that it seems that there is already a scale4x implementation available
for e.g. in scalebit.cpp:

Code: Select all

/**
 * Apply the Scale effect on a bitmap.
 * This function is simply a common interface for ::scale2x(), ::scale3x() and ::scale4x().
 * \param scale Scale factor. 2, 3 or 4.
 * \param void_dst Pointer at the first pixel of the destination bitmap.
 * \param dst_slice Size in bytes of a destination bitmap row.
 * \param void_src Pointer at the first pixel of the source bitmap.
 * \param src_slice Size in bytes of a source bitmap row.
 * \param pixel Bytes per pixel of the source and destination bitmap.
 * \param width Horizontal size in pixels of the source bitmap.
 * \param height Vertical size in pixels of the source bitmap.
 */
void scale(unsigned scale, void* void_dst, unsigned dst_slice, const void* void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height)
{
	switch (scale) {
	case 2 :
		scale2x(void_dst, dst_slice, void_src, src_slice, pixel, width, height);
		break;
	case 3 :
		scale3x(void_dst, dst_slice, void_src, src_slice, pixel, width, height);
		break;
	case 4 :
		scale4x(void_dst, dst_slice, void_src, src_slice, pixel, width, height);
		break;
	}
}

Code: Select all

/**
 * Apply the Scale4x effect on a bitmap.
 * The destination bitmap is filled with the scaled version of the source bitmap.
 * The source bitmap isn't modified.
 * The destination bitmap must be manually allocated before calling the function,
 * note that the resulting size is exactly 4x4 times the size of the source bitmap.
 * \note This function operates like ::scale4x_buf() but the intermediate buffer is
 * automatically allocated in the stack.
 * \param void_dst Pointer at the first pixel of the destination bitmap.
 * \param dst_slice Size in bytes of a destination bitmap row.
 * \param void_src Pointer at the first pixel of the source bitmap.
 * \param src_slice Size in bytes of a source bitmap row.
 * \param pixel Bytes per pixel of the source and destination bitmap.
 * \param width Horizontal size in pixels of the source bitmap.
 * \param height Vertical size in pixels of the source bitmap.
 */
static void scale4x(void* void_dst, unsigned dst_slice, const void* void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height)
{
	unsigned mid_slice;
	void* mid;

	mid_slice = 2 * pixel * width; /* required space for 1 row buffer */

	mid_slice = (mid_slice + 0x7) & ~0x7; /* align to 8 bytes */

#if defined(HAVE_ALLOCA)
	mid = alloca(6 * mid_slice); /* allocate space for 6 row buffers */

	assert(mid != 0); /* alloca should never fails */
#else
	mid = malloc(6 * mid_slice); /* allocate space for 6 row buffers */

	if (!mid)
		return;
#endif

	scale4x_buf(void_dst, dst_slice, mid, mid_slice, void_src, src_slice, pixel, width, height);

#if !defined(HAVE_ALLOCA)
	free(mid);
#endif
}
There are also some more scale4x functions which I will not quote here now because I think its clear what I´m talking about.

So my question is if there are official plans to implement a advmame4x scaler since it seems to be prepared in the sources or are there known problems why it is not used?
fingolfin
Retired
Posts: 1452
Joined: Wed Sep 21, 2005 4:12 pm

Post by fingolfin »

In general, we do not add new scalers. See the various patches for scalers on our patch tracker:
Lostech
Posts: 157
Joined: Fri May 04, 2007 8:42 am
Contact:

Post by Lostech »

Yes, I read something about this in an old forum topic. But the difference is that this advmame4x scaler is more or less already available in the original source code without adding any external patches.
So therefore my question why it isn´t used. Is it not working in the existing state or might there be some well known problems or is it just "philosophy" to stay on the existing scaler base?
Post Reply