Commit a1f5254a authored by fbarchard@google.com's avatar fbarchard@google.com

Switch to c style casts for all source and includes.

BUG=303
TESTED=try
R=tpsiaki@google.com

Review URL: https://webrtc-codereview.appspot.com/6629004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@952 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 0ba7b239
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 951 Version: 952
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -75,9 +75,13 @@ typedef signed char int8; ...@@ -75,9 +75,13 @@ typedef signed char int8;
#endif #endif
#ifndef ALIGNP #ifndef ALIGNP
#ifdef __cplusplus
#define ALIGNP(p, t) \ #define ALIGNP(p, t) \
(reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \ (reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \
((t) - 1)) & ~((t) - 1)))) ((t) - 1)) & ~((t) - 1))))
#else
#define ALIGNP(p, t) ((uint8*)((((uintptr_t)(p) + ((t) - 1)) & ~((t) - 1))))
#endif
#endif #endif
#if !defined(LIBYUV_API) #if !defined(LIBYUV_API)
......
...@@ -22,18 +22,26 @@ extern "C" { ...@@ -22,18 +22,26 @@ extern "C" {
#define IS_ALIGNED(p, a) (!((uintptr_t)(p) & ((a) - 1))) #define IS_ALIGNED(p, a) (!((uintptr_t)(p) & ((a) - 1)))
// TODO(fbarchard): Port to C. #ifdef __cplusplus
#define align_buffer_64(var, size) \ #define align_buffer_64(var, size) \
uint8* var; \ uint8* var; \
uint8* var##_mem; \ uint8* var##_mem; \
var##_mem = reinterpret_cast<uint8*>(malloc((size) + 63)); \ var##_mem = reinterpret_cast<uint8*>(malloc((size) + 63)); \
var = reinterpret_cast<uint8*> \ var = reinterpret_cast<uint8*> \
((reinterpret_cast<intptr_t>(var##_mem) + 63) & ~63) ((reinterpret_cast<intptr_t>(var##_mem) + 63) & ~63)
#else
#define align_buffer_64(var, size) \
uint8* var; \
uint8* var##_mem; \
var##_mem = (uint8*)(malloc((size) + 63)); \
var = (uint8*) (((intptr_t)(var##_mem) + 63) & ~63)
#endif
#define free_aligned_buffer_64(var) \ #define free_aligned_buffer_64(var) \
free(var##_mem); \ free(var##_mem); \
var = 0 var = 0
#if defined(__CLR_VER) || defined(COVERAGE_ENABLED) || \ #if defined(__CLR_VER) || defined(COVERAGE_ENABLED) || \
defined(TARGET_IPHONE_SIMULATOR) defined(TARGET_IPHONE_SIMULATOR)
#define LIBYUV_DISABLE_X86 #define LIBYUV_DISABLE_X86
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 951 #define LIBYUV_VERSION 952
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
...@@ -59,18 +59,18 @@ uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed) { ...@@ -59,18 +59,18 @@ uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed) {
#endif #endif
const int kBlockSize = 1 << 15; // 32768; const int kBlockSize = 1 << 15; // 32768;
while (count >= static_cast<uint64>(kBlockSize)) { while (count >= (uint64)(kBlockSize)) {
seed = HashDjb2_SSE(src, kBlockSize, seed); seed = HashDjb2_SSE(src, kBlockSize, seed);
src += kBlockSize; src += kBlockSize;
count -= kBlockSize; count -= kBlockSize;
} }
int remainder = static_cast<int>(count) & ~15; int remainder = (int)(count) & ~15;
if (remainder) { if (remainder) {
seed = HashDjb2_SSE(src, remainder, seed); seed = HashDjb2_SSE(src, remainder, seed);
src += remainder; src += remainder;
count -= remainder; count -= remainder;
} }
remainder = static_cast<int>(count) & 15; remainder = (int)(count) & 15;
if (remainder) { if (remainder) {
seed = HashDjb2_C(src, remainder, seed); seed = HashDjb2_C(src, remainder, seed);
} }
...@@ -168,7 +168,7 @@ LIBYUV_API ...@@ -168,7 +168,7 @@ LIBYUV_API
double SumSquareErrorToPsnr(uint64 sse, uint64 count) { double SumSquareErrorToPsnr(uint64 sse, uint64 count) {
double psnr; double psnr;
if (sse > 0) { if (sse > 0) {
double mse = static_cast<double>(count) / static_cast<double>(sse); double mse = (double)(count) / (double)(sse);
psnr = 10.0 * log10(255.0 * 255.0 * mse); psnr = 10.0 * log10(255.0 * 255.0 * mse);
} else { } else {
psnr = kMaxPsnr; // Limit to prevent divide by 0 psnr = kMaxPsnr; // Limit to prevent divide by 0
......
...@@ -19,7 +19,7 @@ uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count) { ...@@ -19,7 +19,7 @@ uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count) {
uint32 sse = 0u; uint32 sse = 0u;
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
int diff = src_a[i] - src_b[i]; int diff = src_a[i] - src_b[i];
sse += static_cast<uint32>(diff * diff); sse += (uint32)(diff * diff);
} }
return sse; return sse;
} }
......
...@@ -368,7 +368,7 @@ int BGRAToARGB(const uint8* src_bgra, int src_stride_bgra, ...@@ -368,7 +368,7 @@ int BGRAToARGB(const uint8* src_bgra, int src_stride_bgra,
int width, int height) { int width, int height) {
return ARGBShuffle(src_bgra, src_stride_bgra, return ARGBShuffle(src_bgra, src_stride_bgra,
dst_argb, dst_stride_argb, dst_argb, dst_stride_argb,
reinterpret_cast<const uint8*>(&kShuffleMaskBGRAToARGB), (const uint8*)(&kShuffleMaskBGRAToARGB),
width, height); width, height);
} }
...@@ -379,7 +379,7 @@ int ABGRToARGB(const uint8* src_abgr, int src_stride_abgr, ...@@ -379,7 +379,7 @@ int ABGRToARGB(const uint8* src_abgr, int src_stride_abgr,
int width, int height) { int width, int height) {
return ARGBShuffle(src_abgr, src_stride_abgr, return ARGBShuffle(src_abgr, src_stride_abgr,
dst_argb, dst_stride_argb, dst_argb, dst_stride_argb,
reinterpret_cast<const uint8*>(&kShuffleMaskABGRToARGB), (const uint8*)(&kShuffleMaskABGRToARGB),
width, height); width, height);
} }
...@@ -390,7 +390,7 @@ int RGBAToARGB(const uint8* src_rgba, int src_stride_rgba, ...@@ -390,7 +390,7 @@ int RGBAToARGB(const uint8* src_rgba, int src_stride_rgba,
int width, int height) { int width, int height) {
return ARGBShuffle(src_rgba, src_stride_rgba, return ARGBShuffle(src_rgba, src_stride_rgba,
dst_argb, dst_stride_argb, dst_argb, dst_stride_argb,
reinterpret_cast<const uint8*>(&kShuffleMaskRGBAToARGB), (const uint8*)(&kShuffleMaskRGBAToARGB),
width, height); width, height);
} }
......
...@@ -717,7 +717,7 @@ int ARGBToRGBA(const uint8* src_argb, int src_stride_argb, ...@@ -717,7 +717,7 @@ int ARGBToRGBA(const uint8* src_argb, int src_stride_argb,
int width, int height) { int width, int height) {
return ARGBShuffle(src_argb, src_stride_argb, return ARGBShuffle(src_argb, src_stride_argb,
dst_rgba, dst_stride_rgba, dst_rgba, dst_stride_rgba,
reinterpret_cast<const uint8*>(&kShuffleMaskARGBToRGBA), (const uint8*)(&kShuffleMaskARGBToRGBA),
width, height); width, height);
} }
......
...@@ -35,7 +35,7 @@ static void JpegCopyI420(void* opaque, ...@@ -35,7 +35,7 @@ static void JpegCopyI420(void* opaque,
const uint8* const* data, const uint8* const* data,
const int* strides, const int* strides,
int rows) { int rows) {
I420Buffers* dest = static_cast<I420Buffers*>(opaque); I420Buffers* dest = (I420Buffers*)(opaque);
I420Copy(data[0], strides[0], I420Copy(data[0], strides[0],
data[1], strides[1], data[1], strides[1],
data[2], strides[2], data[2], strides[2],
...@@ -53,7 +53,7 @@ static void JpegI422ToI420(void* opaque, ...@@ -53,7 +53,7 @@ static void JpegI422ToI420(void* opaque,
const uint8* const* data, const uint8* const* data,
const int* strides, const int* strides,
int rows) { int rows) {
I420Buffers* dest = static_cast<I420Buffers*>(opaque); I420Buffers* dest = (I420Buffers*)(opaque);
I422ToI420(data[0], strides[0], I422ToI420(data[0], strides[0],
data[1], strides[1], data[1], strides[1],
data[2], strides[2], data[2], strides[2],
...@@ -71,7 +71,7 @@ static void JpegI444ToI420(void* opaque, ...@@ -71,7 +71,7 @@ static void JpegI444ToI420(void* opaque,
const uint8* const* data, const uint8* const* data,
const int* strides, const int* strides,
int rows) { int rows) {
I420Buffers* dest = static_cast<I420Buffers*>(opaque); I420Buffers* dest = (I420Buffers*)(opaque);
I444ToI420(data[0], strides[0], I444ToI420(data[0], strides[0],
data[1], strides[1], data[1], strides[1],
data[2], strides[2], data[2], strides[2],
...@@ -89,7 +89,7 @@ static void JpegI411ToI420(void* opaque, ...@@ -89,7 +89,7 @@ static void JpegI411ToI420(void* opaque,
const uint8* const* data, const uint8* const* data,
const int* strides, const int* strides,
int rows) { int rows) {
I420Buffers* dest = static_cast<I420Buffers*>(opaque); I420Buffers* dest = (I420Buffers*)(opaque);
I411ToI420(data[0], strides[0], I411ToI420(data[0], strides[0],
data[1], strides[1], data[1], strides[1],
data[2], strides[2], data[2], strides[2],
...@@ -107,7 +107,7 @@ static void JpegI400ToI420(void* opaque, ...@@ -107,7 +107,7 @@ static void JpegI400ToI420(void* opaque,
const uint8* const* data, const uint8* const* data,
const int* strides, const int* strides,
int rows) { int rows) {
I420Buffers* dest = static_cast<I420Buffers*>(opaque); I420Buffers* dest = (I420Buffers*)(opaque);
I400ToI420(data[0], strides[0], I400ToI420(data[0], strides[0],
dest->y, dest->y_stride, dest->y, dest->y_stride,
dest->u, dest->u_stride, dest->u, dest->u_stride,
...@@ -233,7 +233,7 @@ static void JpegI420ToARGB(void* opaque, ...@@ -233,7 +233,7 @@ static void JpegI420ToARGB(void* opaque,
const uint8* const* data, const uint8* const* data,
const int* strides, const int* strides,
int rows) { int rows) {
ARGBBuffers* dest = static_cast<ARGBBuffers*>(opaque); ARGBBuffers* dest = (ARGBBuffers*)(opaque);
I420ToARGB(data[0], strides[0], I420ToARGB(data[0], strides[0],
data[1], strides[1], data[1], strides[1],
data[2], strides[2], data[2], strides[2],
...@@ -247,7 +247,7 @@ static void JpegI422ToARGB(void* opaque, ...@@ -247,7 +247,7 @@ static void JpegI422ToARGB(void* opaque,
const uint8* const* data, const uint8* const* data,
const int* strides, const int* strides,
int rows) { int rows) {
ARGBBuffers* dest = static_cast<ARGBBuffers*>(opaque); ARGBBuffers* dest = (ARGBBuffers*)(opaque);
I422ToARGB(data[0], strides[0], I422ToARGB(data[0], strides[0],
data[1], strides[1], data[1], strides[1],
data[2], strides[2], data[2], strides[2],
...@@ -261,7 +261,7 @@ static void JpegI444ToARGB(void* opaque, ...@@ -261,7 +261,7 @@ static void JpegI444ToARGB(void* opaque,
const uint8* const* data, const uint8* const* data,
const int* strides, const int* strides,
int rows) { int rows) {
ARGBBuffers* dest = static_cast<ARGBBuffers*>(opaque); ARGBBuffers* dest = (ARGBBuffers*)(opaque);
I444ToARGB(data[0], strides[0], I444ToARGB(data[0], strides[0],
data[1], strides[1], data[1], strides[1],
data[2], strides[2], data[2], strides[2],
...@@ -275,7 +275,7 @@ static void JpegI411ToARGB(void* opaque, ...@@ -275,7 +275,7 @@ static void JpegI411ToARGB(void* opaque,
const uint8* const* data, const uint8* const* data,
const int* strides, const int* strides,
int rows) { int rows) {
ARGBBuffers* dest = static_cast<ARGBBuffers*>(opaque); ARGBBuffers* dest = (ARGBBuffers*)(opaque);
I411ToARGB(data[0], strides[0], I411ToARGB(data[0], strides[0],
data[1], strides[1], data[1], strides[1],
data[2], strides[2], data[2], strides[2],
...@@ -289,7 +289,7 @@ static void JpegI400ToARGB(void* opaque, ...@@ -289,7 +289,7 @@ static void JpegI400ToARGB(void* opaque,
const uint8* const* data, const uint8* const* data,
const int* strides, const int* strides,
int rows) { int rows) {
ARGBBuffers* dest = static_cast<ARGBBuffers*>(opaque); ARGBBuffers* dest = (ARGBBuffers*)(opaque);
I400ToARGB(data[0], strides[0], I400ToARGB(data[0], strides[0],
dest->argb, dest->argb_stride, dest->argb, dest->argb_stride,
dest->w, rows); dest->w, rows);
......
...@@ -22,10 +22,10 @@ extern "C" { ...@@ -22,10 +22,10 @@ extern "C" {
// generate a selector mask useful for pshufb // generate a selector mask useful for pshufb
static uint32 GenerateSelector(int select0, int select1) { static uint32 GenerateSelector(int select0, int select1) {
return static_cast<uint32>(select0) | return (uint32)(select0) |
static_cast<uint32>((select1 + 4) << 8) | (uint32)((select1 + 4) << 8) |
static_cast<uint32>((select0 + 8) << 16) | (uint32)((select0 + 8) << 16) |
static_cast<uint32>((select1 + 12) << 24); (uint32)((select1 + 12) << 24);
} }
static int MakeSelectors(const int blue_index, static int MakeSelectors(const int blue_index,
......
...@@ -81,7 +81,7 @@ bool MJpegDecoder::LoadFrame(const uint8* src, size_t src_len) { ...@@ -81,7 +81,7 @@ bool MJpegDecoder::LoadFrame(const uint8* src, size_t src_len) {
} }
buf_.data = src; buf_.data = src;
buf_.len = static_cast<int>(src_len); buf_.len = (int)(src_len);
buf_vec_.pos = 0; buf_vec_.pos = 0;
decompress_struct_->client_data = &buf_vec_; decompress_struct_->client_data = &buf_vec_;
#ifdef HAVE_SETJMP #ifdef HAVE_SETJMP
...@@ -391,7 +391,7 @@ void MJpegDecoder::init_source(j_decompress_ptr cinfo) { ...@@ -391,7 +391,7 @@ void MJpegDecoder::init_source(j_decompress_ptr cinfo) {
} }
boolean MJpegDecoder::fill_input_buffer(j_decompress_ptr cinfo) { boolean MJpegDecoder::fill_input_buffer(j_decompress_ptr cinfo) {
BufferVector* buf_vec = static_cast<BufferVector*>(cinfo->client_data); BufferVector* buf_vec = (BufferVector*)(cinfo->client_data);
if (buf_vec->pos >= buf_vec->len) { if (buf_vec->pos >= buf_vec->len) {
assert(0 && "No more data"); assert(0 && "No more data");
// ERROR: No more data // ERROR: No more data
...@@ -427,7 +427,7 @@ void MJpegDecoder::ErrorHandler(j_common_ptr cinfo) { ...@@ -427,7 +427,7 @@ void MJpegDecoder::ErrorHandler(j_common_ptr cinfo) {
// ERROR: Error in jpeglib: buf // ERROR: Error in jpeglib: buf
#endif #endif
SetJmpErrorMgr* mgr = reinterpret_cast<SetJmpErrorMgr*>(cinfo->err); SetJmpErrorMgr* mgr = (SetJmpErrorMgr*)(cinfo->err);
// This rewinds the call stack to the point of the corresponding setjmp() // This rewinds the call stack to the point of the corresponding setjmp()
// and causes it to return (for a second time) with value 1. // and causes it to return (for a second time) with value 1.
longjmp(mgr->setjmp_buffer, 1); longjmp(mgr->setjmp_buffer, 1);
...@@ -507,7 +507,7 @@ void MJpegDecoder::SetScanlinePointers(uint8** data) { ...@@ -507,7 +507,7 @@ void MJpegDecoder::SetScanlinePointers(uint8** data) {
} }
inline bool MJpegDecoder::DecodeImcuRow() { inline bool MJpegDecoder::DecodeImcuRow() {
return static_cast<unsigned int>(GetImageScanlinesPerImcuRow()) == return (unsigned int)(GetImageScanlinesPerImcuRow()) ==
jpeg_read_raw_data(decompress_struct_, jpeg_read_raw_data(decompress_struct_,
scanlines_, scanlines_,
GetImageScanlinesPerImcuRow()); GetImageScanlinesPerImcuRow());
......
...@@ -1399,7 +1399,7 @@ int RGBColorMatrix(uint8* dst_argb, int dst_stride_argb, ...@@ -1399,7 +1399,7 @@ int RGBColorMatrix(uint8* dst_argb, int dst_stride_argb,
matrix_argb[15] = 64; // 1.0 matrix_argb[15] = 64; // 1.0
uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4; uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
return ARGBColorMatrix(const_cast<const uint8*>(dst), dst_stride_argb, return ARGBColorMatrix((const uint8*)(dst), dst_stride_argb,
dst, dst_stride_argb, dst, dst_stride_argb,
&matrix_argb[0], width, height); &matrix_argb[0], width, height);
} }
......
...@@ -377,8 +377,8 @@ static void TransposeWx8_SSSE3(const uint8* src, int src_stride, ...@@ -377,8 +377,8 @@ static void TransposeWx8_SSSE3(const uint8* src, int src_stride,
: "+r"(src), // %0 : "+r"(src), // %0
"+r"(dst), // %1 "+r"(dst), // %1
"+r"(width) // %2 "+r"(width) // %2
: "r"(static_cast<intptr_t>(src_stride)), // %3 : "r"((intptr_t)(src_stride)), // %3
"r"(static_cast<intptr_t>(dst_stride)) // %4 "r"((intptr_t)(dst_stride)) // %4
: "memory", "cc" : "memory", "cc"
#if defined(__SSE2__) #if defined(__SSE2__)
, "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"
...@@ -648,8 +648,8 @@ static void TransposeWx8_FAST_SSSE3(const uint8* src, int src_stride, ...@@ -648,8 +648,8 @@ static void TransposeWx8_FAST_SSSE3(const uint8* src, int src_stride,
: "+r"(src), // %0 : "+r"(src), // %0
"+r"(dst), // %1 "+r"(dst), // %1
"+r"(width) // %2 "+r"(width) // %2
: "r"(static_cast<intptr_t>(src_stride)), // %3 : "r"((intptr_t)(src_stride)), // %3
"r"(static_cast<intptr_t>(dst_stride)) // %4 "r"((intptr_t)(dst_stride)) // %4
: "memory", "cc", : "memory", "cc",
"xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7",
"xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15"
...@@ -758,9 +758,9 @@ static void TransposeUVWx8_SSE2(const uint8* src, int src_stride, ...@@ -758,9 +758,9 @@ static void TransposeUVWx8_SSE2(const uint8* src, int src_stride,
"+r"(dst_a), // %1 "+r"(dst_a), // %1
"+r"(dst_b), // %2 "+r"(dst_b), // %2
"+r"(w) // %3 "+r"(w) // %3
: "r"(static_cast<intptr_t>(src_stride)), // %4 : "r"((intptr_t)(src_stride)), // %4
"r"(static_cast<intptr_t>(dst_stride_a)), // %5 "r"((intptr_t)(dst_stride_a)), // %5
"r"(static_cast<intptr_t>(dst_stride_b)) // %6 "r"((intptr_t)(dst_stride_b)) // %6
: "memory", "cc", : "memory", "cc",
"xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7",
"xmm8", "xmm9" "xmm8", "xmm9"
......
This diff is collapsed.
This diff is collapsed.
...@@ -2030,15 +2030,15 @@ void RGBAToUVRow_Unaligned_SSSE3(const uint8* src_argb0, int src_stride_argb, ...@@ -2030,15 +2030,15 @@ void RGBAToUVRow_Unaligned_SSSE3(const uint8* src_argb0, int src_stride_argb,
} }
#endif // HAS_ARGBTOYROW_SSSE3 #endif // HAS_ARGBTOYROW_SSSE3
#define YG 74 /* static_cast<int8>(1.164 * 64 + 0.5) */ #define YG 74 /* (int8)(1.164 * 64 + 0.5) */
#define UB 127 /* min(63,static_cast<int8>(2.018 * 64)) */ #define UB 127 /* min(63,(int8)(2.018 * 64)) */
#define UG -25 /* static_cast<int8>(-0.391 * 64 - 0.5) */ #define UG -25 /* (int8)(-0.391 * 64 - 0.5) */
#define UR 0 #define UR 0
#define VB 0 #define VB 0
#define VG -52 /* static_cast<int8>(-0.813 * 64 - 0.5) */ #define VG -52 /* (int8)(-0.813 * 64 - 0.5) */
#define VR 102 /* static_cast<int8>(1.596 * 64 + 0.5) */ #define VR 102 /* (int8)(1.596 * 64 + 0.5) */
// Bias // Bias
#define BB UB * 128 + VB * 128 #define BB UB * 128 + VB * 128
......
...@@ -434,9 +434,9 @@ static void ScalePlaneBox(int src_width, int src_height, ...@@ -434,9 +434,9 @@ static void ScalePlaneBox(int src_width, int src_height,
y = (src_height << 16); y = (src_height << 16);
} }
int boxheight = (y >> 16) - iy; int boxheight = (y >> 16) - iy;
ScaleAddRows(src, src_stride, reinterpret_cast<uint16*>(row16), ScaleAddRows(src, src_stride, (uint16*)(row16),
src_width, boxheight); src_width, boxheight);
ScaleAddCols(dst_width, boxheight, x, dx, reinterpret_cast<uint16*>(row16), ScaleAddCols(dst_width, boxheight, x, dx, (uint16*)(row16),
dst_ptr); dst_ptr);
dst_ptr += dst_stride; dst_ptr += dst_stride;
} }
......
...@@ -171,14 +171,14 @@ static void ScaleARGBBilinearDown(int src_width, int src_height, ...@@ -171,14 +171,14 @@ static void ScaleARGBBilinearDown(int src_width, int src_height,
assert(src_height > 0); assert(src_height > 0);
assert(dst_width > 0); assert(dst_width > 0);
assert(dst_height > 0); assert(dst_height > 0);
int64 xlast = x + static_cast<int64>(dst_width - 1) * dx; int64 xlast = x + (int64)(dst_width - 1) * dx;
int64 xl = (dx >= 0) ? x : xlast; int64 xl = (dx >= 0) ? x : xlast;
int64 xr = (dx >= 0) ? xlast : x; int64 xr = (dx >= 0) ? xlast : x;
xl = (xl >> 16) & ~3; // Left edge aligned. xl = (xl >> 16) & ~3; // Left edge aligned.
xr = (xr >> 16) + 1; // Right most pixel used. xr = (xr >> 16) + 1; // Right most pixel used.
int clip_src_width = (((xr - xl) + 1 + 3) & ~3) * 4; // Width aligned to 4. int clip_src_width = (((xr - xl) + 1 + 3) & ~3) * 4; // Width aligned to 4.
src_argb += xl * 4; src_argb += xl * 4;
x -= static_cast<int>(xl << 16); x -= (int)(xl << 16);
void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb, void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb,
ptrdiff_t src_stride, int dst_width, int source_y_fraction) = ptrdiff_t src_stride, int dst_width, int source_y_fraction) =
InterpolateRow_C; InterpolateRow_C;
...@@ -679,13 +679,13 @@ static void ScaleARGB(const uint8* src, int src_stride, ...@@ -679,13 +679,13 @@ static void ScaleARGB(const uint8* src, int src_stride,
ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, ScaleSlope(src_width, src_height, dst_width, dst_height, filtering,
&x, &y, &dx, &dy); &x, &y, &dx, &dy);
if (clip_x) { if (clip_x) {
int64 clipf = static_cast<int64>(clip_x) * dx; int64 clipf = (int64)(clip_x) * dx;
x += (clipf & 0xffff); x += (clipf & 0xffff);
src += (clipf >> 16) * 4; src += (clipf >> 16) * 4;
dst += clip_x * 4; dst += clip_x * 4;
} }
if (clip_y) { if (clip_y) {
int64 clipf = static_cast<int64>(clip_y) * dy; int64 clipf = (int64)(clip_y) * dy;
y += (clipf & 0xffff); y += (clipf & 0xffff);
src += (clipf >> 16) * src_stride; src += (clipf >> 16) * src_stride;
dst += clip_y * dst_stride; dst += clip_y * dst_stride;
......
...@@ -204,8 +204,8 @@ void ScaleColsUp2_C(uint8* dst_ptr, const uint8* src_ptr, ...@@ -204,8 +204,8 @@ void ScaleColsUp2_C(uint8* dst_ptr, const uint8* src_ptr,
} }
// (1-f)a + fb can be replaced with a + f(b-a) // (1-f)a + fb can be replaced with a + f(b-a)
#define BLENDER(a, b, f) static_cast<uint8>(static_cast<int>(a) + \ #define BLENDER(a, b, f) (uint8)((int)(a) + \
(static_cast<int>(f) * (static_cast<int>(b) - static_cast<int>(a)) >> 16)) ((int)(f) * ((int)(b) - (int)(a)) >> 16))
void ScaleFilterCols_C(uint8* dst_ptr, const uint8* src_ptr, void ScaleFilterCols_C(uint8* dst_ptr, const uint8* src_ptr,
int dst_width, int x, int dx) { int dst_width, int x, int dx) {
...@@ -232,7 +232,7 @@ void ScaleFilterCols_C(uint8* dst_ptr, const uint8* src_ptr, ...@@ -232,7 +232,7 @@ void ScaleFilterCols_C(uint8* dst_ptr, const uint8* src_ptr,
void ScaleFilterCols64_C(uint8* dst_ptr, const uint8* src_ptr, void ScaleFilterCols64_C(uint8* dst_ptr, const uint8* src_ptr,
int dst_width, int x32, int dx) { int dst_width, int x32, int dx) {
int64 x = static_cast<int64>(x32); int64 x = (int64)(x32);
for (int j = 0; j < dst_width - 1; j += 2) { for (int j = 0; j < dst_width - 1; j += 2) {
int64 xi = x >> 16; int64 xi = x >> 16;
int a = src_ptr[xi]; int a = src_ptr[xi];
...@@ -332,8 +332,8 @@ void ScaleAddRows_C(const uint8* src_ptr, ptrdiff_t src_stride, ...@@ -332,8 +332,8 @@ void ScaleAddRows_C(const uint8* src_ptr, ptrdiff_t src_stride,
void ScaleARGBRowDown2_C(const uint8* src_argb, void ScaleARGBRowDown2_C(const uint8* src_argb,
ptrdiff_t /* src_stride */, ptrdiff_t /* src_stride */,
uint8* dst_argb, int dst_width) { uint8* dst_argb, int dst_width) {
const uint32* src = reinterpret_cast<const uint32*>(src_argb); const uint32* src = (const uint32*)(src_argb);
uint32* dst = reinterpret_cast<uint32*>(dst_argb); uint32* dst = (uint32*)(dst_argb);
for (int x = 0; x < dst_width - 1; x += 2) { for (int x = 0; x < dst_width - 1; x += 2) {
dst[0] = src[1]; dst[0] = src[1];
...@@ -378,8 +378,8 @@ void ScaleARGBRowDown2Box_C(const uint8* src_argb, ptrdiff_t src_stride, ...@@ -378,8 +378,8 @@ void ScaleARGBRowDown2Box_C(const uint8* src_argb, ptrdiff_t src_stride,
void ScaleARGBRowDownEven_C(const uint8* src_argb, ptrdiff_t /* src_stride */, void ScaleARGBRowDownEven_C(const uint8* src_argb, ptrdiff_t /* src_stride */,
int src_stepx, int src_stepx,
uint8* dst_argb, int dst_width) { uint8* dst_argb, int dst_width) {
const uint32* src = reinterpret_cast<const uint32*>(src_argb); const uint32* src = (const uint32*)(src_argb);
uint32* dst = reinterpret_cast<uint32*>(dst_argb); uint32* dst = (uint32*)(dst_argb);
for (int x = 0; x < dst_width - 1; x += 2) { for (int x = 0; x < dst_width - 1; x += 2) {
dst[0] = src[0]; dst[0] = src[0];
...@@ -413,8 +413,8 @@ void ScaleARGBRowDownEvenBox_C(const uint8* src_argb, ...@@ -413,8 +413,8 @@ void ScaleARGBRowDownEvenBox_C(const uint8* src_argb,
// Scales a single row of pixels using point sampling. // Scales a single row of pixels using point sampling.
void ScaleARGBCols_C(uint8* dst_argb, const uint8* src_argb, void ScaleARGBCols_C(uint8* dst_argb, const uint8* src_argb,
int dst_width, int x, int dx) { int dst_width, int x, int dx) {
const uint32* src = reinterpret_cast<const uint32*>(src_argb); const uint32* src = (const uint32*)(src_argb);
uint32* dst = reinterpret_cast<uint32*>(dst_argb); uint32* dst = (uint32*)(dst_argb);
for (int j = 0; j < dst_width - 1; j += 2) { for (int j = 0; j < dst_width - 1; j += 2) {
dst[0] = src[x >> 16]; dst[0] = src[x >> 16];
x += dx; x += dx;
...@@ -429,9 +429,9 @@ void ScaleARGBCols_C(uint8* dst_argb, const uint8* src_argb, ...@@ -429,9 +429,9 @@ void ScaleARGBCols_C(uint8* dst_argb, const uint8* src_argb,
void ScaleARGBCols64_C(uint8* dst_argb, const uint8* src_argb, void ScaleARGBCols64_C(uint8* dst_argb, const uint8* src_argb,
int dst_width, int x32, int dx) { int dst_width, int x32, int dx) {
int64 x = static_cast<int64>(x32); int64 x = (int64)(x32);
const uint32* src = reinterpret_cast<const uint32*>(src_argb); const uint32* src = (const uint32*)(src_argb);
uint32* dst = reinterpret_cast<uint32*>(dst_argb); uint32* dst = (uint32*)(dst_argb);
for (int j = 0; j < dst_width - 1; j += 2) { for (int j = 0; j < dst_width - 1; j += 2) {
dst[0] = src[x >> 16]; dst[0] = src[x >> 16];
x += dx; x += dx;
...@@ -447,8 +447,8 @@ void ScaleARGBCols64_C(uint8* dst_argb, const uint8* src_argb, ...@@ -447,8 +447,8 @@ void ScaleARGBCols64_C(uint8* dst_argb, const uint8* src_argb,
// Scales a single row of pixels up by 2x using point sampling. // Scales a single row of pixels up by 2x using point sampling.
void ScaleARGBColsUp2_C(uint8* dst_argb, const uint8* src_argb, void ScaleARGBColsUp2_C(uint8* dst_argb, const uint8* src_argb,
int dst_width, int, int) { int dst_width, int, int) {
const uint32* src = reinterpret_cast<const uint32*>(src_argb); const uint32* src = (const uint32*)(src_argb);
uint32* dst = reinterpret_cast<uint32*>(dst_argb); uint32* dst = (uint32*)(dst_argb);
for (int j = 0; j < dst_width - 1; j += 2) { for (int j = 0; j < dst_width - 1; j += 2) {
dst[1] = dst[0] = src[0]; dst[1] = dst[0] = src[0];
src += 1; src += 1;
...@@ -461,7 +461,7 @@ void ScaleARGBColsUp2_C(uint8* dst_argb, const uint8* src_argb, ...@@ -461,7 +461,7 @@ void ScaleARGBColsUp2_C(uint8* dst_argb, const uint8* src_argb,
// Mimics SSSE3 blender // Mimics SSSE3 blender
#define BLENDER1(a, b, f) ((a) * (0x7f ^ f) + (b) * f) >> 7 #define BLENDER1(a, b, f) ((a) * (0x7f ^ f) + (b) * f) >> 7
#define BLENDERC(a, b, f, s) static_cast<uint32>( \ #define BLENDERC(a, b, f, s) (uint32)( \
BLENDER1(((a) >> s) & 255, ((b) >> s) & 255, f) << s) BLENDER1(((a) >> s) & 255, ((b) >> s) & 255, f) << s)
#define BLENDER(a, b, f) \ #define BLENDER(a, b, f) \
BLENDERC(a, b, f, 24) | BLENDERC(a, b, f, 16) | \ BLENDERC(a, b, f, 24) | BLENDERC(a, b, f, 16) | \
...@@ -469,8 +469,8 @@ void ScaleARGBColsUp2_C(uint8* dst_argb, const uint8* src_argb, ...@@ -469,8 +469,8 @@ void ScaleARGBColsUp2_C(uint8* dst_argb, const uint8* src_argb,
void ScaleARGBFilterCols_C(uint8* dst_argb, const uint8* src_argb, void ScaleARGBFilterCols_C(uint8* dst_argb, const uint8* src_argb,
int dst_width, int x, int dx) { int dst_width, int x, int dx) {
const uint32* src = reinterpret_cast<const uint32*>(src_argb); const uint32* src = (const uint32*)(src_argb);
uint32* dst = reinterpret_cast<uint32*>(dst_argb); uint32* dst = (uint32*)(dst_argb);
for (int j = 0; j < dst_width - 1; j += 2) { for (int j = 0; j < dst_width - 1; j += 2) {
int xi = x >> 16; int xi = x >> 16;
int xf = (x >> 9) & 0x7f; int xf = (x >> 9) & 0x7f;
...@@ -497,9 +497,9 @@ void ScaleARGBFilterCols_C(uint8* dst_argb, const uint8* src_argb, ...@@ -497,9 +497,9 @@ void ScaleARGBFilterCols_C(uint8* dst_argb, const uint8* src_argb,
void ScaleARGBFilterCols64_C(uint8* dst_argb, const uint8* src_argb, void ScaleARGBFilterCols64_C(uint8* dst_argb, const uint8* src_argb,
int dst_width, int x32, int dx) { int dst_width, int x32, int dx) {
int64 x = static_cast<int64>(x32); int64 x = (int64)(x32);
const uint32* src = reinterpret_cast<const uint32*>(src_argb); const uint32* src = (const uint32*)(src_argb);
uint32* dst = reinterpret_cast<uint32*>(dst_argb); uint32* dst = (uint32*)(dst_argb);
for (int j = 0; j < dst_width - 1; j += 2) { for (int j = 0; j < dst_width - 1; j += 2) {
int64 xi = x >> 16; int64 xi = x >> 16;
int xf = (x >> 9) & 0x7f; int xf = (x >> 9) & 0x7f;
...@@ -656,12 +656,12 @@ FilterMode ScaleFilterReduce(int src_width, int src_height, ...@@ -656,12 +656,12 @@ FilterMode ScaleFilterReduce(int src_width, int src_height,
// Divide num by div and return as 16.16 fixed point result. // Divide num by div and return as 16.16 fixed point result.
int FixedDiv_C(int num, int div) { int FixedDiv_C(int num, int div) {
return static_cast<int>((static_cast<int64>(num) << 16) / div); return (int)(((int64)(num) << 16) / div);
} }
// Divide num by div and return as 16.16 fixed point result. // Divide num by div and return as 16.16 fixed point result.
int FixedDiv1_C(int num, int div) { int FixedDiv1_C(int num, int div) {
return static_cast<int>(((static_cast<int64>(num) << 16) - 0x00010001) / return (int)((((int64)(num) << 16) - 0x00010001) /
(div - 1)); (div - 1));
} }
......
...@@ -189,7 +189,7 @@ void ScaleRowDown2Box_SSE2(const uint8* src_ptr, ptrdiff_t src_stride, ...@@ -189,7 +189,7 @@ void ScaleRowDown2Box_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
: "+r"(src_ptr), // %0 : "+r"(src_ptr), // %0
"+r"(dst_ptr), // %1 "+r"(dst_ptr), // %1
"+r"(dst_width) // %2 "+r"(dst_width) // %2
: "r"(static_cast<intptr_t>(src_stride)) // %3 : "r"((intptr_t)(src_stride)) // %3
: "memory", "cc" : "memory", "cc"
#if defined(__native_client__) && defined(__x86_64__) #if defined(__native_client__) && defined(__x86_64__)
, "r14" , "r14"
...@@ -295,7 +295,7 @@ void ScaleRowDown2Box_Unaligned_SSE2(const uint8* src_ptr, ...@@ -295,7 +295,7 @@ void ScaleRowDown2Box_Unaligned_SSE2(const uint8* src_ptr,
: "+r"(src_ptr), // %0 : "+r"(src_ptr), // %0
"+r"(dst_ptr), // %1 "+r"(dst_ptr), // %1
"+r"(dst_width) // %2 "+r"(dst_width) // %2
: "r"(static_cast<intptr_t>(src_stride)) // %3 : "r"((intptr_t)(src_stride)) // %3
: "memory", "cc" : "memory", "cc"
#if defined(__native_client__) && defined(__x86_64__) #if defined(__native_client__) && defined(__x86_64__)
, "r14" , "r14"
...@@ -387,7 +387,7 @@ void ScaleRowDown4Box_SSE2(const uint8* src_ptr, ptrdiff_t src_stride, ...@@ -387,7 +387,7 @@ void ScaleRowDown4Box_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
"+r"(dst_ptr), // %1 "+r"(dst_ptr), // %1
"+r"(dst_width), // %2 "+r"(dst_width), // %2
"+r"(stridex3) // %3 "+r"(stridex3) // %3
: "r"(static_cast<intptr_t>(src_stride)) // %4 : "r"((intptr_t)(src_stride)) // %4
: "memory", "cc" : "memory", "cc"
#if defined(__native_client__) && defined(__x86_64__) #if defined(__native_client__) && defined(__x86_64__)
, "r14" , "r14"
...@@ -496,7 +496,7 @@ void ScaleRowDown34_1_Box_SSSE3(const uint8* src_ptr, ...@@ -496,7 +496,7 @@ void ScaleRowDown34_1_Box_SSSE3(const uint8* src_ptr,
: "+r"(src_ptr), // %0 : "+r"(src_ptr), // %0
"+r"(dst_ptr), // %1 "+r"(dst_ptr), // %1
"+r"(dst_width) // %2 "+r"(dst_width) // %2
: "r"(static_cast<intptr_t>(src_stride)), // %3 : "r"((intptr_t)(src_stride)), // %3
"m"(kMadd21) // %4 "m"(kMadd21) // %4
: "memory", "cc" : "memory", "cc"
#if defined(__native_client__) && defined(__x86_64__) #if defined(__native_client__) && defined(__x86_64__)
...@@ -570,7 +570,7 @@ void ScaleRowDown34_0_Box_SSSE3(const uint8* src_ptr, ...@@ -570,7 +570,7 @@ void ScaleRowDown34_0_Box_SSSE3(const uint8* src_ptr,
: "+r"(src_ptr), // %0 : "+r"(src_ptr), // %0
"+r"(dst_ptr), // %1 "+r"(dst_ptr), // %1
"+r"(dst_width) // %2 "+r"(dst_width) // %2
: "r"(static_cast<intptr_t>(src_stride)), // %3 : "r"((intptr_t)(src_stride)), // %3
"m"(kMadd21) // %4 "m"(kMadd21) // %4
: "memory", "cc" : "memory", "cc"
#if defined(__native_client__) && defined(__x86_64__) #if defined(__native_client__) && defined(__x86_64__)
...@@ -652,7 +652,7 @@ void ScaleRowDown38_2_Box_SSSE3(const uint8* src_ptr, ...@@ -652,7 +652,7 @@ void ScaleRowDown38_2_Box_SSSE3(const uint8* src_ptr,
: "+r"(src_ptr), // %0 : "+r"(src_ptr), // %0
"+r"(dst_ptr), // %1 "+r"(dst_ptr), // %1
"+r"(dst_width) // %2 "+r"(dst_width) // %2
: "r"(static_cast<intptr_t>(src_stride)) // %3 : "r"((intptr_t)(src_stride)) // %3
: "memory", "cc" : "memory", "cc"
#if defined(__native_client__) && defined(__x86_64__) #if defined(__native_client__) && defined(__x86_64__)
, "r14" , "r14"
...@@ -720,7 +720,7 @@ void ScaleRowDown38_3_Box_SSSE3(const uint8* src_ptr, ...@@ -720,7 +720,7 @@ void ScaleRowDown38_3_Box_SSSE3(const uint8* src_ptr,
: "+r"(src_ptr), // %0 : "+r"(src_ptr), // %0
"+r"(dst_ptr), // %1 "+r"(dst_ptr), // %1
"+r"(dst_width) // %2 "+r"(dst_width) // %2
: "r"(static_cast<intptr_t>(src_stride)) // %3 : "r"((intptr_t)(src_stride)) // %3
: "memory", "cc" : "memory", "cc"
#if defined(__native_client__) && defined(__x86_64__) #if defined(__native_client__) && defined(__x86_64__)
, "r14" , "r14"
...@@ -777,7 +777,7 @@ void ScaleAddRows_SSE2(const uint8* src_ptr, ptrdiff_t src_stride, ...@@ -777,7 +777,7 @@ void ScaleAddRows_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
"+r"(tmp_src), // %3 "+r"(tmp_src), // %3
"+r"(src_width), // %4 "+r"(src_width), // %4
"+rm"(src_height) // %5 "+rm"(src_height) // %5
: "rm"(static_cast<intptr_t>(src_stride)) // %6 : "rm"((intptr_t)(src_stride)) // %6
: "memory", "cc" : "memory", "cc"
#if defined(__SSE2__) #if defined(__SSE2__)
, "xmm0", "xmm1", "xmm2", "xmm3", "xmm4" , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4"
...@@ -970,7 +970,7 @@ void ScaleARGBRowDown2Box_SSE2(const uint8* src_argb, ...@@ -970,7 +970,7 @@ void ScaleARGBRowDown2Box_SSE2(const uint8* src_argb,
: "+r"(src_argb), // %0 : "+r"(src_argb), // %0
"+r"(dst_argb), // %1 "+r"(dst_argb), // %1
"+r"(dst_width) // %2 "+r"(dst_width) // %2
: "r"(static_cast<intptr_t>(src_stride)) // %3 : "r"((intptr_t)(src_stride)) // %3
: "memory", "cc" : "memory", "cc"
#if defined(__native_client__) && defined(__x86_64__) #if defined(__native_client__) && defined(__x86_64__)
, "r14" , "r14"
...@@ -986,7 +986,7 @@ void ScaleARGBRowDown2Box_SSE2(const uint8* src_argb, ...@@ -986,7 +986,7 @@ void ScaleARGBRowDown2Box_SSE2(const uint8* src_argb,
void ScaleARGBRowDownEven_SSE2(const uint8* src_argb, ptrdiff_t src_stride, void ScaleARGBRowDownEven_SSE2(const uint8* src_argb, ptrdiff_t src_stride,
int src_stepx, int src_stepx,
uint8* dst_argb, int dst_width) { uint8* dst_argb, int dst_width) {
intptr_t src_stepx_x4 = static_cast<intptr_t>(src_stepx); intptr_t src_stepx_x4 = (intptr_t)(src_stepx);
intptr_t src_stepx_x12 = 0; intptr_t src_stepx_x12 = 0;
asm volatile ( asm volatile (
"lea " MEMLEA3(0x00,1,4) ",%1 \n" "lea " MEMLEA3(0x00,1,4) ",%1 \n"
...@@ -1027,9 +1027,9 @@ void ScaleARGBRowDownEven_SSE2(const uint8* src_argb, ptrdiff_t src_stride, ...@@ -1027,9 +1027,9 @@ void ScaleARGBRowDownEven_SSE2(const uint8* src_argb, ptrdiff_t src_stride,
void ScaleARGBRowDownEvenBox_SSE2(const uint8* src_argb, void ScaleARGBRowDownEvenBox_SSE2(const uint8* src_argb,
ptrdiff_t src_stride, int src_stepx, ptrdiff_t src_stride, int src_stepx,
uint8* dst_argb, int dst_width) { uint8* dst_argb, int dst_width) {
intptr_t src_stepx_x4 = static_cast<intptr_t>(src_stepx); intptr_t src_stepx_x4 = (intptr_t)(src_stepx);
intptr_t src_stepx_x12 = 0; intptr_t src_stepx_x12 = 0;
intptr_t row1 = static_cast<intptr_t>(src_stride); intptr_t row1 = (intptr_t)(src_stride);
asm volatile ( asm volatile (
"lea " MEMLEA3(0x00,1,4) ",%1 \n" "lea " MEMLEA3(0x00,1,4) ",%1 \n"
"lea " MEMLEA4(0x00,1,1,2) ",%4 \n" "lea " MEMLEA4(0x00,1,1,2) ",%4 \n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment