Fixed some more C 'old-style-cast' code.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3208 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2015-09-15 12:39:07 +00:00
parent ffc9ac65a7
commit 75893a6a3e
3 changed files with 74 additions and 92 deletions

View File

@ -111,7 +111,7 @@ void atari_ntsc_blit_single( atari_ntsc_t const* ntsc,
{
atari_ntsc_in_t const* line_in = atari_in;
ATARI_NTSC_BEGIN_ROW( ntsc, TO_SINGLE(atari_ntsc_black), TO_SINGLE(line_in[0]) );
atari_ntsc_out_t* restrict line_out = (atari_ntsc_out_t*) rgb_out;
atari_ntsc_out_t* restrict line_out = static_cast<atari_ntsc_out_t*>(rgb_out);
int n;
++line_in;
@ -146,7 +146,7 @@ void atari_ntsc_blit_single( atari_ntsc_t const* ntsc,
ATARI_NTSC_RGB_OUT_8888( 6, line_out[6] );
atari_in += in_row_width;
rgb_out = (char*) rgb_out + out_pitch;
rgb_out = static_cast<char*>(rgb_out) + out_pitch;
}
}
@ -165,7 +165,7 @@ void atari_ntsc_blit_double( atari_ntsc_t const* ntsc,
ATARI_NTSC_BEGIN_ROW( ntsc,
TO_DOUBLE(atari_ntsc_black, atari_ntsc_black),
TO_DOUBLE(line_in1[0], line_in2[0]) );
atari_ntsc_out_t* restrict line_out = (atari_ntsc_out_t*) rgb_out;
atari_ntsc_out_t* restrict line_out = static_cast<atari_ntsc_out_t*>(rgb_out);
int n;
++line_in1;
++line_in2;
@ -207,6 +207,6 @@ void atari_ntsc_blit_double( atari_ntsc_t const* ntsc,
atari_in1 += in_row_width;
atari_in2 += in_row_width;
rgb_out = (char*) rgb_out + out_pitch;
rgb_out = static_cast<char*>(rgb_out) + out_pitch;
}
}

View File

@ -97,14 +97,14 @@ static void init_filters( init_t* impl, atari_ntsc_setup_t const* setup )
/* generate luma (y) filter using sinc kernel */
{
/* sinc with rolloff (dsf) */
float const rolloff = 1 + (float) setup->sharpness * (float) 0.032;
float const rolloff = 1 + float(setup->sharpness) * 0.032;
float const maxh = 32;
float const pow_a_n = (float) pow( rolloff, maxh );
float const pow_a_n = float(pow( rolloff, maxh ));
float sum;
int i;
/* quadratic mapping to reduce negative (blurring) range */
float to_angle = (float) setup->resolution + 1;
to_angle = PI / maxh * (float) LUMA_CUTOFF * (to_angle * to_angle + 1);
float to_angle = float(setup->resolution) + 1;
to_angle = PI / maxh * float(LUMA_CUTOFF) * (to_angle * to_angle + 1);
kernels [kernel_size * 3 / 2] = maxh; /* default center value */
for ( i = 0; i < kernel_half * 2 + 1; i++ )
@ -112,15 +112,15 @@ static void init_filters( init_t* impl, atari_ntsc_setup_t const* setup )
int x = i - kernel_half;
float angle = x * to_angle;
/* instability occurs at center point with rolloff very close to 1.0 */
if ( x || pow_a_n > (float) 1.056 || pow_a_n < (float) 0.981 )
if ( x || pow_a_n > 1.056 || pow_a_n < 0.981 )
{
float rolloff_cos_a = rolloff * (float) cos( angle );
float rolloff_cos_a = rolloff * float(cos( angle ));
float num = 1 - rolloff_cos_a -
pow_a_n * (float) cos( maxh * angle ) +
pow_a_n * rolloff * (float) cos( (maxh - 1) * angle );
pow_a_n * float(cos( maxh * angle )) +
pow_a_n * rolloff * float(cos( (maxh - 1) * angle ));
float den = 1 - rolloff_cos_a - rolloff_cos_a + rolloff * rolloff;
float dsf = num / den;
kernels [kernel_size * 3 / 2 - kernel_half + i] = dsf - (float) 0.5;
kernels [kernel_size * 3 / 2 - kernel_half + i] = dsf - 0.5;
}
}
@ -129,7 +129,7 @@ static void init_filters( init_t* impl, atari_ntsc_setup_t const* setup )
for ( i = 0; i < kernel_half * 2 + 1; i++ )
{
float x = PI * 2 / (kernel_half * 2) * i;
float blackman = 0.42f - 0.5f * (float) cos( x ) + 0.08f * (float) cos( x * 2 );
float blackman = 0.42f - 0.5f * float(cos( x )) + 0.08f * float(cos( x * 2 ));
sum += (kernels [kernel_size * 3 / 2 - kernel_half + i] *= blackman);
}
@ -145,7 +145,7 @@ static void init_filters( init_t* impl, atari_ntsc_setup_t const* setup )
/* generate chroma (iq) filter using gaussian kernel */
{
float const cutoff_factor = -0.03125f;
float cutoff = (float) setup->bleed;
float cutoff = float(setup->bleed);
int i;
if ( cutoff < 0 )
@ -159,7 +159,7 @@ static void init_filters( init_t* impl, atari_ntsc_setup_t const* setup )
cutoff = cutoff_factor - 0.65f * cutoff_factor * cutoff;
for ( i = -kernel_half; i <= kernel_half; i++ )
kernels [kernel_size / 2 + i] = (float) exp( i * i * cutoff );
kernels [kernel_size / 2 + i] = float(exp( i * i * cutoff ));
/* normalize even and odd phases separately */
for ( i = 0; i < 2; i++ )
@ -215,15 +215,15 @@ static float const default_decoder [6] =
static void init( init_t* impl, atari_ntsc_setup_t const* setup )
{
impl->brightness = (float) setup->brightness * (0.5f * rgb_unit) + rgb_offset;
impl->contrast = (float) setup->contrast * (0.5f * rgb_unit) + rgb_unit;
impl->brightness = float(setup->brightness) * (0.5f * rgb_unit) + rgb_offset;
impl->contrast = float(setup->contrast) * (0.5f * rgb_unit) + rgb_unit;
impl->artifacts = (float) setup->artifacts;
impl->artifacts = float(setup->artifacts);
if ( impl->artifacts > 0 )
impl->artifacts *= artifacts_max - artifacts_mid;
impl->artifacts = impl->artifacts * artifacts_mid + artifacts_mid;
impl->fringing = (float) setup->fringing;
impl->fringing = float(setup->fringing);
if ( impl->fringing > 0 )
impl->fringing *= fringing_max - fringing_mid;
impl->fringing = impl->fringing * fringing_mid + fringing_mid;
@ -234,18 +234,18 @@ static void init( init_t* impl, atari_ntsc_setup_t const* setup )
if ( gamma_size > 1 )
{
float const to_float = 1.0f / (gamma_size - (gamma_size > 1));
float const gamma = 1.1333f - (float) setup->gamma * 0.5f;
float const gamma = 1.1333f - float(setup->gamma) * 0.5f;
/* match common PC's 2.2 gamma to TV's 2.65 gamma */
int i;
for ( i = 0; i < gamma_size; i++ )
impl->to_float [i] =
(float) pow( i * to_float, gamma ) * impl->contrast + impl->brightness;
float(pow( i * to_float, gamma )) * impl->contrast + impl->brightness;
}
/* setup decoder matricies */
{
float hue = (float) setup->hue * PI + PI / 180 * ext_decoder_hue;
float sat = (float) setup->saturation + 1;
float hue = float(setup->hue) * PI + PI / 180 * ext_decoder_hue;
float sat = float(setup->saturation) + 1;
float const* decoder = setup->decoder_matrix;
if ( !decoder )
{
@ -255,8 +255,8 @@ static void init( init_t* impl, atari_ntsc_setup_t const* setup )
}
{
float s = (float) sin( hue ) * sat;
float c = (float) cos( hue ) * sat;
float s = float(sin( hue )) * sat;
float c = float(cos( hue )) * sat;
float* out = impl->to_rgb;
int n;
@ -290,9 +290,9 @@ static void init( init_t* impl, atari_ntsc_setup_t const* setup )
((r) * 0.211456f - (g) * 0.522591f + (b) * 0.311135f)\
)
#define YIQ_TO_RGB( y, i, q, to_rgb, type, r, g ) (\
r = (type) (y + to_rgb [0] * i + to_rgb [1] * q),\
g = (type) (y + to_rgb [2] * i + to_rgb [3] * q),\
(type) (y + to_rgb [4] * i + to_rgb [5] * q)\
r = type(y + to_rgb [0] * i + to_rgb [1] * q),\
g = type(y + to_rgb [2] * i + to_rgb [3] * q),\
type(y + to_rgb [4] * i + to_rgb [5] * q)\
)
#ifndef PACK_RGB

View File

@ -82,8 +82,6 @@ static void MD5Final(uInt8[16], MD5_CTX*);
static void MD5Transform(uInt32 [4], const uInt8 [64]);
static void Encode(uInt8*, uInt32*, uInt32);
static void Decode(uInt32*, const uInt8*, uInt32);
static void MD5_memcpy(POINTER, POINTER, uInt32);
static void MD5_memset(POINTER, int, uInt32);
static uInt8 PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -103,22 +101,22 @@ static uInt8 PADDING[64] = {
// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
// Rotation is separate from addition to prevent recomputation.
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (uInt32)(ac); \
(a) += F ((b), (c), (d)) + (x) + uInt32(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (uInt32)(ac); \
(a) += G ((b), (c), (d)) + (x) + uInt32(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (uInt32)(ac); \
(a) += H ((b), (c), (d)) + (x) + uInt32(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (uInt32)(ac); \
(a) += I ((b), (c), (d)) + (x) + uInt32(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
@ -143,19 +141,20 @@ static void MD5Update(MD5_CTX* context, const uInt8* input,
uInt32 i, index, partLen;
/* Compute number of bytes mod 64 */
index = (uInt32)((context->count[0] >> 3) & 0x3F);
index = uInt32((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((uInt32)inputLen << 3))
< ((uInt32)inputLen << 3))
if ((context->count[0] += (uInt32(inputLen) << 3))
< (uInt32(inputLen) << 3))
context->count[1]++;
context->count[1] += ((uInt32)inputLen >> 29);
context->count[1] += (uInt32(inputLen) >> 29);
partLen = 64 - index;
/* Transform as many times as possible. */
if (inputLen >= partLen) {
MD5_memcpy ((POINTER)&context->buffer[index], (POINTER)input, partLen);
memcpy (const_cast<POINTER>(&context->buffer[index]),
const_cast<POINTER>(input), partLen);
MD5Transform (context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
@ -167,7 +166,8 @@ static void MD5Update(MD5_CTX* context, const uInt8* input,
i = 0;
/* Buffer remaining input */
MD5_memcpy((POINTER)&context->buffer[index], (POINTER)&input[i], inputLen-i);
memcpy(const_cast<POINTER>(&context->buffer[index]),
const_cast<POINTER>(&input[i]), inputLen-i);
}
// MD5 finalization. Ends an MD5 message-digest operation, writing the
@ -181,7 +181,7 @@ static void MD5Final(uInt8 digest[16], MD5_CTX* context)
Encode (bits, context->count, 8);
/* Pad out to 56 mod 64. */
index = (uInt32)((context->count[0] >> 3) & 0x3f);
index = uInt32((context->count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
MD5Update (context, PADDING, padLen);
@ -191,7 +191,7 @@ static void MD5Final(uInt8 digest[16], MD5_CTX* context)
Encode (digest, context->state, 16);
/* Zeroize sensitive information. */
MD5_memset ((POINTER)context, 0, sizeof (*context));
memset (reinterpret_cast<POINTER>(context), 0, sizeof(*context));
}
// MD5 basic transformation. Transforms state based on block.
@ -279,7 +279,7 @@ static void MD5Transform(uInt32 state[4], const uInt8 block[64])
state[3] += d;
/* Zeroize sensitive information. */
MD5_memset ((POINTER)x, 0, sizeof (x));
memset (reinterpret_cast<POINTER>(x), 0, sizeof(x));
}
// Encodes input (uInt32) into output (uInt8). Assumes len is
@ -289,10 +289,10 @@ static void Encode(uInt8* output, uInt32* input, uInt32 len)
uInt32 i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (uInt8)(input[i] & 0xff);
output[j+1] = (uInt8)((input[i] >> 8) & 0xff);
output[j+2] = (uInt8)((input[i] >> 16) & 0xff);
output[j+3] = (uInt8)((input[i] >> 24) & 0xff);
output[j] = uInt8(input[i] & 0xff);
output[j+1] = uInt8((input[i] >> 8) & 0xff);
output[j+2] = uInt8((input[i] >> 16) & 0xff);
output[j+3] = uInt8((input[i] >> 24) & 0xff);
}
}
@ -303,26 +303,8 @@ static void Decode(uInt32* output, const uInt8* input, uInt32 len)
uInt32 i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((uInt32)input[j]) | (((uInt32)input[j+1]) << 8) |
(((uInt32)input[j+2]) << 16) | (((uInt32)input[j+3]) << 24);
}
// Note: Replace "for loop" with standard memcpy if possible.
static void MD5_memcpy(POINTER output, POINTER input, uInt32 len)
{
uInt32 i;
for (i = 0; i < len; i++)
output[i] = input[i];
}
// Note: Replace "for loop" with standard memset if possible.
static void MD5_memset(POINTER output, int value, uInt32 len)
{
uInt32 i;
for (i = 0; i < len; i++)
((char *)output)[i] = (char)value;
output[i] = (uInt32(input[j])) | ((uInt32(input[j+1])) << 8) |
((uInt32(input[j+2])) << 16) | ((uInt32(input[j+3])) << 24);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -