Issue #2101 - Part 2: Use stdint.h types instead of uint8 and friends

Required for upcoming libyuv update
This commit is contained in:
u3shit 2023-02-24 21:28:16 +01:00 • committed by roytam1
commit 42f3296899
19 changed files with 431 additions and 451 deletions

View file

@ -12,28 +12,28 @@ namespace dom {
/* /*
* Utility function form libyuv source files. * Utility function form libyuv source files.
*/ */
static __inline int32 clamp0(int32 v) { static __inline int32_t clamp0(int32_t v) {
return ((-(v) >> 31) & (v)); return ((-(v) >> 31) & (v));
} }
static __inline int32 clamp255(int32 v) { static __inline int32_t clamp255(int32_t v) {
return (((255 - (v)) >> 31) | (v)) & 255; return (((255 - (v)) >> 31) | (v)) & 255;
} }
static __inline uint32 Clamp(int32 val) { static __inline uint32_t Clamp(int32_t val) {
int v = clamp0(val); int v = clamp0(val);
return (uint32)(clamp255(v)); return (uint32_t)(clamp255(v));
} }
#define YG 74 /* (int8)(1.164 * 64 + 0.5) */ #define YG 74 /* (int8_t)(1.164 * 64 + 0.5) */
#define UB 127 /* min(63,(int8)(2.018 * 64)) */ #define UB 127 /* min(63,(int8_t)(2.018 * 64)) */
#define UG -25 /* (int8)(-0.391 * 64 - 0.5) */ #define UG -25 /* (int8_t)(-0.391 * 64 - 0.5) */
#define UR 0 #define UR 0
#define VB 0 #define VB 0
#define VG -52 /* (int8)(-0.813 * 64 - 0.5) */ #define VG -52 /* (int8_t)(-0.813 * 64 - 0.5) */
#define VR 102 /* (int8)(1.596 * 64 + 0.5) */ #define VR 102 /* (int8_t)(1.596 * 64 + 0.5) */
// Bias // Bias
#define BB UB * 128 + VB * 128 #define BB UB * 128 + VB * 128
@ -41,28 +41,28 @@ static __inline uint32 Clamp(int32 val) {
#define BR UR * 128 + VR * 128 #define BR UR * 128 + VR * 128
static __inline void static __inline void
YuvPixel(uint8 y, uint8 u, uint8 v, uint8* b, uint8* g, uint8* r) YuvPixel(uint8_t y, uint8_t u, uint8_t v, uint8_t* b, uint8_t* g, uint8_t* r)
{ {
int32 y1 = ((int32)(y) - 16) * YG; int32_t y1 = ((int32_t)(y) - 16) * YG;
*b = Clamp((int32)((u * UB + v * VB) - (BB) + y1) >> 6); *b = Clamp((int32_t)((u * UB + v * VB) - (BB) + y1) >> 6);
*g = Clamp((int32)((u * UG + v * VG) - (BG) + y1) >> 6); *g = Clamp((int32_t)((u * UG + v * VG) - (BG) + y1) >> 6);
*r = Clamp((int32)((u * UR + v * VR) - (BR) + y1) >> 6); *r = Clamp((int32_t)((u * UR + v * VR) - (BR) + y1) >> 6);
} }
static __inline int static __inline int
RGBToY(uint8 r, uint8 g, uint8 b) RGBToY(uint8_t r, uint8_t g, uint8_t b)
{ {
return (66 * r + 129 * g + 25 * b + 0x1080) >> 8; return (66 * r + 129 * g + 25 * b + 0x1080) >> 8;
} }
static __inline int static __inline int
RGBToU(uint8 r, uint8 g, uint8 b) RGBToU(uint8_t r, uint8_t g, uint8_t b)
{ {
return (112 * b - 74 * g - 38 * r + 0x8080) >> 8; return (112 * b - 74 * g - 38 * r + 0x8080) >> 8;
} }
static __inline int static __inline int
RGBToV(uint8 r, uint8 g, uint8 b) RGBToV(uint8_t r, uint8_t g, uint8_t b)
{ {
return (112 * r - 94 * g - 18 * b + 0x8080) >> 8; return (112 * r - 94 * g - 18 * b + 0x8080) >> 8;
} }

View file

@ -391,7 +391,7 @@ nsresult VP8TrackEncoder::PrepareRawFrame(VideoChunk &aChunk)
switch (surf->GetFormat()) { switch (surf->GetFormat()) {
case SurfaceFormat::B8G8R8A8: case SurfaceFormat::B8G8R8A8:
case SurfaceFormat::B8G8R8X8: case SurfaceFormat::B8G8R8X8:
rv = libyuv::ARGBToI420(static_cast<uint8*>(map.GetData()), rv = libyuv::ARGBToI420(static_cast<uint8_t*>(map.GetData()),
map.GetStride(), map.GetStride(),
y, mFrameWidth, y, mFrameWidth,
cb, halfWidth, cb, halfWidth,
@ -399,7 +399,7 @@ nsresult VP8TrackEncoder::PrepareRawFrame(VideoChunk &aChunk)
mFrameWidth, mFrameHeight); mFrameWidth, mFrameHeight);
break; break;
case SurfaceFormat::R5G6B5_UINT16: case SurfaceFormat::R5G6B5_UINT16:
rv = libyuv::RGB565ToI420(static_cast<uint8*>(map.GetData()), rv = libyuv::RGB565ToI420(static_cast<uint8_t*>(map.GetData()),
map.GetStride(), map.GetStride(),
y, mFrameWidth, y, mFrameWidth,
cb, halfWidth, cb, halfWidth,

View file

@ -68,21 +68,21 @@ struct YUVBuferIter {
int src_stride_y; int src_stride_y;
int src_stride_u; int src_stride_u;
int src_stride_v; int src_stride_v;
const uint8* src_y; const uint8_t* src_y;
const uint8* src_u; const uint8_t* src_u;
const uint8* src_v; const uint8_t* src_v;
uint32 src_fourcc; uint32_t src_fourcc;
const struct YuvConstants* yuvconstants; const struct YuvConstants* yuvconstants;
int y_index; int y_index;
const uint8* src_row_y; const uint8_t* src_row_y;
const uint8* src_row_u; const uint8_t* src_row_u;
const uint8* src_row_v; const uint8_t* src_row_v;
void (*YUVToARGBRow)(const uint8* y_buf, void (*YUVToARGBRow)(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
const struct YuvConstants* yuvconstants, const struct YuvConstants* yuvconstants,
int width); int width);
void (*MoveTo)(YUVBuferIter& iter, int y_index); void (*MoveTo)(YUVBuferIter& iter, int y_index);
@ -202,11 +202,11 @@ static void YUVBuferIter_MoveToNextRowForI420(YUVBuferIter& iter) {
iter.y_index++; iter.y_index++;
} }
static __inline void YUVBuferIter_ConvertToARGBRow(YUVBuferIter& iter, uint8* argb_row) { static __inline void YUVBuferIter_ConvertToARGBRow(YUVBuferIter& iter, uint8_t* argb_row) {
iter.YUVToARGBRow(iter.src_row_y, iter.src_row_u, iter.src_row_v, argb_row, iter.yuvconstants, iter.src_width); iter.YUVToARGBRow(iter.src_row_y, iter.src_row_u, iter.src_row_v, argb_row, iter.yuvconstants, iter.src_width);
} }
void YUVBuferIter_Init(YUVBuferIter& iter, uint32 src_fourcc, mozilla::YUVColorSpace yuv_color_space) { void YUVBuferIter_Init(YUVBuferIter& iter, uint32_t src_fourcc, mozilla::YUVColorSpace yuv_color_space) {
iter.src_fourcc = src_fourcc; iter.src_fourcc = src_fourcc;
iter.y_index = 0; iter.y_index = 0;
iter.src_row_y = iter.src_y; iter.src_row_y = iter.src_y;
@ -243,20 +243,20 @@ static void ScaleYUVToARGBDown2(int src_width, int src_height,
int src_stride_u, int src_stride_u,
int src_stride_v, int src_stride_v,
int dst_stride_argb, int dst_stride_argb,
const uint8* src_y, const uint8_t* src_y,
const uint8* src_u, const uint8_t* src_u,
const uint8* src_v, const uint8_t* src_v,
uint8* dst_argb, uint8_t* dst_argb,
int x, int dx, int y, int dy, int x, int dx, int y, int dy,
enum FilterMode filtering, enum FilterMode filtering,
uint32 src_fourcc, uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space) { mozilla::YUVColorSpace yuv_color_space) {
int j; int j;
// Allocate 2 rows of ARGB for source conversion. // Allocate 2 rows of ARGB for source conversion.
const int kRowSize = (src_width * 4 + 15) & ~15; const int kRowSize = (src_width * 4 + 15) & ~15;
align_buffer_64(argb_cnv_row, kRowSize * 2); align_buffer_64(argb_cnv_row, kRowSize * 2);
uint8* argb_cnv_rowptr = argb_cnv_row; uint8_t* argb_cnv_rowptr = argb_cnv_row;
int argb_cnv_rowstride = kRowSize; int argb_cnv_rowstride = kRowSize;
YUVBuferIter iter; YUVBuferIter iter;
@ -270,8 +270,8 @@ static void ScaleYUVToARGBDown2(int src_width, int src_height,
iter.src_v = src_v; iter.src_v = src_v;
YUVBuferIter_Init(iter, src_fourcc, yuv_color_space); YUVBuferIter_Init(iter, src_fourcc, yuv_color_space);
void (*ScaleARGBRowDown2)(const uint8* src_argb, ptrdiff_t src_stride, void (*ScaleARGBRowDown2)(const uint8_t* src_argb, ptrdiff_t src_stride,
uint8* dst_argb, int dst_width) = uint8_t* dst_argb, int dst_width) =
filtering == kFilterNone ? ScaleARGBRowDown2_C : filtering == kFilterNone ? ScaleARGBRowDown2_C :
(filtering == kFilterLinear ? ScaleARGBRowDown2Linear_C : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_C :
ScaleARGBRowDown2Box_C); ScaleARGBRowDown2Box_C);
@ -380,24 +380,24 @@ static void ScaleYUVToARGBDownEven(int src_width, int src_height,
int src_stride_u, int src_stride_u,
int src_stride_v, int src_stride_v,
int dst_stride_argb, int dst_stride_argb,
const uint8* src_y, const uint8_t* src_y,
const uint8* src_u, const uint8_t* src_u,
const uint8* src_v, const uint8_t* src_v,
uint8* dst_argb, uint8_t* dst_argb,
int x, int dx, int y, int dy, int x, int dx, int y, int dy,
enum FilterMode filtering, enum FilterMode filtering,
uint32 src_fourcc, uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space) { mozilla::YUVColorSpace yuv_color_space) {
int j; int j;
// Allocate 2 rows of ARGB for source conversion. // Allocate 2 rows of ARGB for source conversion.
const int kRowSize = (src_width * 4 + 15) & ~15; const int kRowSize = (src_width * 4 + 15) & ~15;
align_buffer_64(argb_cnv_row, kRowSize * 2); align_buffer_64(argb_cnv_row, kRowSize * 2);
uint8* argb_cnv_rowptr = argb_cnv_row; uint8_t* argb_cnv_rowptr = argb_cnv_row;
int argb_cnv_rowstride = kRowSize; int argb_cnv_rowstride = kRowSize;
int col_step = dx >> 16; int col_step = dx >> 16;
void (*ScaleARGBRowDownEven)(const uint8* src_argb, ptrdiff_t src_stride, void (*ScaleARGBRowDownEven)(const uint8_t* src_argb, ptrdiff_t src_stride,
int src_step, uint8* dst_argb, int dst_width) = int src_step, uint8_t* dst_argb, int dst_width) =
filtering ? ScaleARGBRowDownEvenBox_C : ScaleARGBRowDownEven_C; filtering ? ScaleARGBRowDownEvenBox_C : ScaleARGBRowDownEven_C;
assert(IS_ALIGNED(src_width, 2)); assert(IS_ALIGNED(src_width, 2));
assert(IS_ALIGNED(src_height, 2)); assert(IS_ALIGNED(src_height, 2));
@ -501,24 +501,24 @@ static void ScaleYUVToARGBBilinearDown(int src_width, int src_height,
int src_stride_u, int src_stride_u,
int src_stride_v, int src_stride_v,
int dst_stride_argb, int dst_stride_argb,
const uint8* src_y, const uint8_t* src_y,
const uint8* src_u, const uint8_t* src_u,
const uint8* src_v, const uint8_t* src_v,
uint8* dst_argb, uint8_t* dst_argb,
int x, int dx, int y, int dy, int x, int dx, int y, int dy,
enum FilterMode filtering, enum FilterMode filtering,
uint32 src_fourcc, uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space) { mozilla::YUVColorSpace yuv_color_space) {
int j; int j;
void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb, void (*InterpolateRow)(uint8_t* dst_argb, const uint8_t* 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;
void (*ScaleARGBFilterCols)(uint8* dst_argb, const uint8* src_argb, void (*ScaleARGBFilterCols)(uint8_t* dst_argb, const uint8_t* src_argb,
int dst_width, int x, int dx) = int dst_width, int x, int dx) =
(src_width >= 32768) ? ScaleARGBFilterCols64_C : ScaleARGBFilterCols_C; (src_width >= 32768) ? ScaleARGBFilterCols64_C : ScaleARGBFilterCols_C;
int64 xlast = x + (int64)(dst_width - 1) * dx; int64_t xlast = x + (int64_t)(dst_width - 1) * dx;
int64 xl = (dx >= 0) ? x : xlast; int64_t xl = (dx >= 0) ? x : xlast;
int64 xr = (dx >= 0) ? xlast : x; int64_t xr = (dx >= 0) ? xlast : x;
int clip_src_width; int clip_src_width;
xl = (xl >> 16) & ~3; // Left edge aligned. xl = (xl >> 16) & ~3; // Left edge aligned.
xr = (xr >> 16) + 1; // Right most pixel used. Bilinear uses 2 pixels. xr = (xr >> 16) + 1; // Right most pixel used. Bilinear uses 2 pixels.
@ -533,7 +533,7 @@ static void ScaleYUVToARGBBilinearDown(int src_width, int src_height,
// Allocate 2 row of ARGB for source conversion. // Allocate 2 row of ARGB for source conversion.
const int kRowSize = (src_width * 4 + 15) & ~15; const int kRowSize = (src_width * 4 + 15) & ~15;
align_buffer_64(argb_cnv_row, kRowSize * 2); align_buffer_64(argb_cnv_row, kRowSize * 2);
uint8* argb_cnv_rowptr = argb_cnv_row; uint8_t* argb_cnv_rowptr = argb_cnv_row;
int argb_cnv_rowstride = kRowSize; int argb_cnv_rowstride = kRowSize;
#if defined(HAS_INTERPOLATEROW_SSSE3) #if defined(HAS_INTERPOLATEROW_SSSE3)
@ -670,19 +670,19 @@ static void ScaleYUVToARGBBilinearUp(int src_width, int src_height,
int src_stride_u, int src_stride_u,
int src_stride_v, int src_stride_v,
int dst_stride_argb, int dst_stride_argb,
const uint8* src_y, const uint8_t* src_y,
const uint8* src_u, const uint8_t* src_u,
const uint8* src_v, const uint8_t* src_v,
uint8* dst_argb, uint8_t* dst_argb,
int x, int dx, int y, int dy, int x, int dx, int y, int dy,
enum FilterMode filtering, enum FilterMode filtering,
uint32 src_fourcc, uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space) { mozilla::YUVColorSpace yuv_color_space) {
int j; int j;
void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb, void (*InterpolateRow)(uint8_t* dst_argb, const uint8_t* 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;
void (*ScaleARGBFilterCols)(uint8* dst_argb, const uint8* src_argb, void (*ScaleARGBFilterCols)(uint8_t* dst_argb, const uint8_t* src_argb,
int dst_width, int x, int dx) = int dst_width, int x, int dx) =
filtering ? ScaleARGBFilterCols_C : ScaleARGBCols_C; filtering ? ScaleARGBFilterCols_C : ScaleARGBCols_C;
const int max_y = (src_height - 1) << 16; const int max_y = (src_height - 1) << 16;
@ -781,7 +781,7 @@ static void ScaleYUVToARGBBilinearUp(int src_width, int src_height,
const int kRowSize = (dst_width * 4 + 15) & ~15; const int kRowSize = (dst_width * 4 + 15) & ~15;
align_buffer_64(row, kRowSize * 2); align_buffer_64(row, kRowSize * 2);
uint8* rowptr = row; uint8_t* rowptr = row;
int rowstride = kRowSize; int rowstride = kRowSize;
int lastyi = yi; int lastyi = yi;
@ -855,15 +855,15 @@ static void ScaleYUVToARGBSimple(int src_width, int src_height,
int src_stride_u, int src_stride_u,
int src_stride_v, int src_stride_v,
int dst_stride_argb, int dst_stride_argb,
const uint8* src_y, const uint8_t* src_y,
const uint8* src_u, const uint8_t* src_u,
const uint8* src_v, const uint8_t* src_v,
uint8* dst_argb, uint8_t* dst_argb,
int x, int dx, int y, int dy, int x, int dx, int y, int dy,
uint32 src_fourcc, uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space) { mozilla::YUVColorSpace yuv_color_space) {
int j; int j;
void (*ScaleARGBCols)(uint8* dst_argb, const uint8* src_argb, void (*ScaleARGBCols)(uint8_t* dst_argb, const uint8_t* src_argb,
int dst_width, int x, int dx) = int dst_width, int x, int dx) =
(src_width >= 32768) ? ScaleARGBCols64_C : ScaleARGBCols_C; (src_width >= 32768) ? ScaleARGBCols64_C : ScaleARGBCols_C;
@ -923,13 +923,13 @@ static void ScaleYUVToARGBSimple(int src_width, int src_height,
free_aligned_buffer_64(argb_cnv_row); free_aligned_buffer_64(argb_cnv_row);
} }
static void YUVToARGBCopy(const uint8* src_y, int src_stride_y, static void YUVToARGBCopy(const uint8_t* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u, const uint8_t* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v, const uint8_t* src_v, int src_stride_v,
int src_width, int src_height, int src_width, int src_height,
uint8* dst_argb, int dst_stride_argb, uint8_t* dst_argb, int dst_stride_argb,
int dst_width, int dst_height, int dst_width, int dst_height,
uint32 src_fourcc, uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space) mozilla::YUVColorSpace yuv_color_space)
{ {
YUVBuferIter iter; YUVBuferIter iter;
@ -950,14 +950,14 @@ static void YUVToARGBCopy(const uint8* src_y, int src_stride_y,
} }
} }
static void ScaleYUVToARGB(const uint8* src_y, int src_stride_y, static void ScaleYUVToARGB(const uint8_t* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u, const uint8_t* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v, const uint8_t* src_v, int src_stride_v,
int src_width, int src_height, int src_width, int src_height,
uint8* dst_argb, int dst_stride_argb, uint8_t* dst_argb, int dst_stride_argb,
int dst_width, int dst_height, int dst_width, int dst_height,
enum FilterMode filtering, enum FilterMode filtering,
uint32 src_fourcc, uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space) mozilla::YUVColorSpace yuv_color_space)
{ {
// Initial source x/y coordinate and step values as 16.16 fixed point. // Initial source x/y coordinate and step values as 16.16 fixed point.
@ -1081,7 +1081,7 @@ static void ScaleYUVToARGB(const uint8* src_y, int src_stride_y,
yuv_color_space); yuv_color_space);
} }
bool IsConvertSupported(uint32 src_fourcc) bool IsConvertSupported(uint32_t src_fourcc)
{ {
if (src_fourcc == FOURCC_I444 || if (src_fourcc == FOURCC_I444 ||
src_fourcc == FOURCC_I422 || src_fourcc == FOURCC_I422 ||
@ -1092,13 +1092,13 @@ bool IsConvertSupported(uint32 src_fourcc)
} }
LIBYUV_API LIBYUV_API
int YUVToARGBScale(const uint8* src_y, int src_stride_y, int YUVToARGBScale(const uint8_t* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u, const uint8_t* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v, const uint8_t* src_v, int src_stride_v,
uint32 src_fourcc, uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space, mozilla::YUVColorSpace yuv_color_space,
int src_width, int src_height, int src_width, int src_height,
uint8* dst_argb, int dst_stride_argb, uint8_t* dst_argb, int dst_stride_argb,
int dst_width, int dst_height, int dst_width, int dst_height,
enum FilterMode filtering) enum FilterMode filtering)
{ {

View file

@ -21,13 +21,13 @@ namespace libyuv {
extern "C" { extern "C" {
#endif #endif
int YUVToARGBScale(const uint8* src_y, int src_stride_y, int YUVToARGBScale(const uint8_t* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u, const uint8_t* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v, const uint8_t* src_v, int src_stride_v,
uint32 src_fourcc, uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space, mozilla::YUVColorSpace yuv_color_space,
int src_width, int src_height, int src_width, int src_height,
uint8* dst_argb, int dst_stride_argb, uint8_t* dst_argb, int dst_stride_argb,
int dst_width, int dst_height, int dst_width, int dst_height,
enum FilterMode filtering); enum FilterMode filtering);

View file

@ -71,10 +71,10 @@ typedef void (*yuv2rgb565_row_scale_nearest_func)(
extern "C" void ScaleYCbCr42xToRGB565_BilinearY_Row_NEON( extern "C" void ScaleYCbCr42xToRGB565_BilinearY_Row_NEON(
const yuv2rgb565_row_scale_bilinear_ctx *ctx, int dither); const yuv2rgb565_row_scale_bilinear_ctx *ctx, int dither);
void __attribute((noinline)) yuv42x_to_rgb565_row_neon(uint16 *dst, void __attribute((noinline)) yuv42x_to_rgb565_row_neon(uint16_t *dst,
const uint8 *y, const uint8_t *y,
const uint8 *u, const uint8_t *u,
const uint8 *v, const uint8_t *v,
int n, int n,
int oddflag); int oddflag);
@ -581,10 +581,10 @@ bool IsScaleYCbCrToRGB565Fast(int source_x0,
void yuv_to_rgb565_row_c(uint16 *dst, void yuv_to_rgb565_row_c(uint16_t *dst,
const uint8 *y, const uint8_t *y,
const uint8 *u, const uint8_t *u,
const uint8 *v, const uint8_t *v,
int x_shift, int x_shift,
int pic_x, int pic_x,
int pic_width) int pic_width)
@ -599,10 +599,10 @@ void yuv_to_rgb565_row_c(uint16 *dst,
} }
} }
void ConvertYCbCrToRGB565(const uint8* y_buf, void ConvertYCbCrToRGB565(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int pic_x, int pic_x,
int pic_y, int pic_y,
int pic_width, int pic_width,
@ -625,7 +625,7 @@ void ConvertYCbCrToRGB565(const uint8* y_buf,
int uvoffs; int uvoffs;
yoffs = y_pitch * (pic_y+i) + pic_x; yoffs = y_pitch * (pic_y+i) + pic_x;
uvoffs = uv_pitch * ((pic_y+i)>>y_shift) + (pic_x>>x_shift); uvoffs = uv_pitch * ((pic_y+i)>>y_shift) + (pic_x>>x_shift);
yuv42x_to_rgb565_row_neon((uint16*)(rgb_buf + rgb_pitch * i), yuv42x_to_rgb565_row_neon((uint16_t*)(rgb_buf + rgb_pitch * i),
y_buf + yoffs, y_buf + yoffs,
u_buf + uvoffs, u_buf + uvoffs,
v_buf + uvoffs, v_buf + uvoffs,
@ -641,7 +641,7 @@ void ConvertYCbCrToRGB565(const uint8* y_buf,
int uvoffs; int uvoffs;
yoffs = y_pitch * (pic_y+i); yoffs = y_pitch * (pic_y+i);
uvoffs = uv_pitch * ((pic_y+i)>>y_shift); uvoffs = uv_pitch * ((pic_y+i)>>y_shift);
yuv_to_rgb565_row_c((uint16*)(rgb_buf + rgb_pitch * i), yuv_to_rgb565_row_c((uint16_t*)(rgb_buf + rgb_pitch * i),
y_buf + yoffs, y_buf + yoffs,
u_buf + uvoffs, u_buf + uvoffs,
v_buf + uvoffs, v_buf + uvoffs,

View file

@ -17,10 +17,10 @@ namespace gfx {
#ifdef HAVE_YCBCR_TO_RGB565 #ifdef HAVE_YCBCR_TO_RGB565
// Convert a frame of YUV to 16 bit RGB565. // Convert a frame of YUV to 16 bit RGB565.
void ConvertYCbCrToRGB565(const uint8* yplane, void ConvertYCbCrToRGB565(const uint8_t* yplane,
const uint8* uplane, const uint8_t* uplane,
const uint8* vplane, const uint8_t* vplane,
uint8* rgbframe, uint8_t* rgbframe,
int pic_x, int pic_x,
int pic_y, int pic_y,
int pic_width, int pic_width,

View file

@ -82,10 +82,10 @@ void GBRPlanarToARGB(const uint8_t* src_y, int y_pitch,
} }
// Convert a frame of YUV to 32 bit ARGB. // Convert a frame of YUV to 32 bit ARGB.
void ConvertYCbCrToRGB32(const uint8* y_buf, void ConvertYCbCrToRGB32(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int pic_x, int pic_x,
int pic_y, int pic_y,
int pic_width, int pic_width,
@ -119,11 +119,11 @@ void ConvertYCbCrToRGB32(const uint8* y_buf,
y_pitch, uv_pitch, rgb_pitch, yuv_type); y_pitch, uv_pitch, rgb_pitch, yuv_type);
return; return;
} }
if (yuv_type == YV24) { if (yuv_type == YV24) {
const uint8* src_y = y_buf + y_pitch * pic_y + pic_x; const uint8_t* src_y = y_buf + y_pitch * pic_y + pic_x;
const uint8* src_u = u_buf + uv_pitch * pic_y + pic_x; const uint8_t* src_u = u_buf + uv_pitch * pic_y + pic_x;
const uint8* src_v = v_buf + uv_pitch * pic_y + pic_x; const uint8_t* src_v = v_buf + uv_pitch * pic_y + pic_x;
if (yuv_color_space == YUVColorSpace::IDENTITY) { if (yuv_color_space == YUVColorSpace::IDENTITY) {
// Special case for RGB image // Special case for RGB image
GBRPlanarToARGB(src_y, y_pitch, src_u, uv_pitch, src_v, uv_pitch, GBRPlanarToARGB(src_y, y_pitch, src_u, uv_pitch, src_v, uv_pitch,
@ -138,9 +138,9 @@ void ConvertYCbCrToRGB32(const uint8* y_buf,
MOZ_ASSERT(!err); MOZ_ASSERT(!err);
} }
} else if (yuv_type == YV16) { } else if (yuv_type == YV16) {
const uint8* src_y = y_buf + y_pitch * pic_y + pic_x; const uint8_t* src_y = y_buf + y_pitch * pic_y + pic_x;
const uint8* src_u = u_buf + uv_pitch * pic_y + pic_x / 2; const uint8_t* src_u = u_buf + uv_pitch * pic_y + pic_x / 2;
const uint8* src_v = v_buf + uv_pitch * pic_y + pic_x / 2; const uint8_t* src_v = v_buf + uv_pitch * pic_y + pic_x / 2;
DebugOnly<int> err = libyuv::I422ToARGB(src_y, y_pitch, DebugOnly<int> err = libyuv::I422ToARGB(src_y, y_pitch,
src_u, uv_pitch, src_u, uv_pitch,
src_v, uv_pitch, src_v, uv_pitch,
@ -149,9 +149,9 @@ void ConvertYCbCrToRGB32(const uint8* y_buf,
MOZ_ASSERT(!err); MOZ_ASSERT(!err);
} else { } else {
MOZ_ASSERT(yuv_type == YV12); MOZ_ASSERT(yuv_type == YV12);
const uint8* src_y = y_buf + y_pitch * pic_y + pic_x; const uint8_t* src_y = y_buf + y_pitch * pic_y + pic_x;
const uint8* src_u = u_buf + (uv_pitch * pic_y + pic_x) / 2; const uint8_t* src_u = u_buf + (uv_pitch * pic_y + pic_x) / 2;
const uint8* src_v = v_buf + (uv_pitch * pic_y + pic_x) / 2; const uint8_t* src_v = v_buf + (uv_pitch * pic_y + pic_x) / 2;
if (yuv_color_space == YUVColorSpace::BT709) { if (yuv_color_space == YUVColorSpace::BT709) {
DebugOnly<int> err = libyuv::H420ToARGB(src_y, y_pitch, DebugOnly<int> err = libyuv::H420ToARGB(src_y, y_pitch,
src_u, uv_pitch, src_u, uv_pitch,
@ -172,10 +172,10 @@ void ConvertYCbCrToRGB32(const uint8* y_buf,
} }
// Convert a frame of YUV to 32 bit ARGB. // Convert a frame of YUV to 32 bit ARGB.
void ConvertYCbCrToRGB32_deprecated(const uint8* y_buf, void ConvertYCbCrToRGB32_deprecated(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int pic_x, int pic_x,
int pic_y, int pic_y,
int pic_width, int pic_width,
@ -195,10 +195,10 @@ void ConvertYCbCrToRGB32_deprecated(const uint8* y_buf,
int x_width = odd_pic_x ? pic_width - 1 : pic_width; int x_width = odd_pic_x ? pic_width - 1 : pic_width;
for (int y = pic_y; y < pic_height + pic_y; ++y) { for (int y = pic_y; y < pic_height + pic_y; ++y) {
uint8* rgb_row = rgb_buf + (y - pic_y) * rgb_pitch; uint8_t* rgb_row = rgb_buf + (y - pic_y) * rgb_pitch;
const uint8* y_ptr = y_buf + y * y_pitch + pic_x; const uint8_t* y_ptr = y_buf + y * y_pitch + pic_x;
const uint8* u_ptr = u_buf + (y >> y_shift) * uv_pitch + (pic_x >> x_shift); const uint8_t* u_ptr = u_buf + (y >> y_shift) * uv_pitch + (pic_x >> x_shift);
const uint8* v_ptr = v_buf + (y >> y_shift) * uv_pitch + (pic_x >> x_shift); const uint8_t* v_ptr = v_buf + (y >> y_shift) * uv_pitch + (pic_x >> x_shift);
if (odd_pic_x) { if (odd_pic_x) {
// Handle the single odd pixel manually and use the // Handle the single odd pixel manually and use the
@ -235,11 +235,11 @@ void ConvertYCbCrToRGB32_deprecated(const uint8* y_buf,
} }
// C version does 8 at a time to mimic MMX code // C version does 8 at a time to mimic MMX code
static void FilterRows_C(uint8* ybuf, const uint8* y0_ptr, const uint8* y1_ptr, static void FilterRows_C(uint8_t* ybuf, const uint8_t* y0_ptr, const uint8_t* y1_ptr,
int source_width, int source_y_fraction) { int source_width, int source_y_fraction) {
int y1_fraction = source_y_fraction; int y1_fraction = source_y_fraction;
int y0_fraction = 256 - y1_fraction; int y0_fraction = 256 - y1_fraction;
uint8* end = ybuf + source_width; uint8_t* end = ybuf + source_width;
do { do {
ybuf[0] = (y0_ptr[0] * y0_fraction + y1_ptr[0] * y1_fraction) >> 8; ybuf[0] = (y0_ptr[0] * y0_fraction + y1_ptr[0] * y1_fraction) >> 8;
ybuf[1] = (y0_ptr[1] * y0_fraction + y1_ptr[1] * y1_fraction) >> 8; ybuf[1] = (y0_ptr[1] * y0_fraction + y1_ptr[1] * y1_fraction) >> 8;
@ -256,17 +256,17 @@ static void FilterRows_C(uint8* ybuf, const uint8* y0_ptr, const uint8* y1_ptr,
} }
#ifdef MOZILLA_MAY_SUPPORT_MMX #ifdef MOZILLA_MAY_SUPPORT_MMX
void FilterRows_MMX(uint8* ybuf, const uint8* y0_ptr, const uint8* y1_ptr, void FilterRows_MMX(uint8_t* ybuf, const uint8_t* y0_ptr, const uint8_t* y1_ptr,
int source_width, int source_y_fraction); int source_width, int source_y_fraction);
#endif #endif
#ifdef MOZILLA_MAY_SUPPORT_SSE2 #ifdef MOZILLA_MAY_SUPPORT_SSE2
void FilterRows_SSE2(uint8* ybuf, const uint8* y0_ptr, const uint8* y1_ptr, void FilterRows_SSE2(uint8_t* ybuf, const uint8_t* y0_ptr, const uint8_t* y1_ptr,
int source_width, int source_y_fraction); int source_width, int source_y_fraction);
#endif #endif
static inline void FilterRows(uint8* ybuf, const uint8* y0_ptr, static inline void FilterRows(uint8_t* ybuf, const uint8_t* y0_ptr,
const uint8* y1_ptr, int source_width, const uint8_t* y1_ptr, int source_width,
int source_y_fraction) { int source_y_fraction) {
#ifdef MOZILLA_MAY_SUPPORT_SSE2 #ifdef MOZILLA_MAY_SUPPORT_SSE2
if (mozilla::supports_sse2()) { if (mozilla::supports_sse2()) {
@ -287,10 +287,10 @@ static inline void FilterRows(uint8* ybuf, const uint8* y0_ptr,
// Scale a frame of YUV to 32 bit ARGB. // Scale a frame of YUV to 32 bit ARGB.
void ScaleYCbCrToRGB32(const uint8* y_buf, void ScaleYCbCrToRGB32(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int source_width, int source_width,
int source_height, int source_height,
int width, int width,
@ -327,7 +327,7 @@ void ScaleYCbCrToRGB32(const uint8* y_buf,
} }
if (yuv_type == YV24 && yuv_color_space == YUVColorSpace::IDENTITY) { if (yuv_type == YV24 && yuv_color_space == YUVColorSpace::IDENTITY) {
auto buffer = MakeUnique<uint8[]>(source_width * source_height * 4); auto buffer = MakeUnique<uint8_t[]>(source_width * source_height * 4);
auto buffer_pitch = source_width * 4; auto buffer_pitch = source_width * 4;
GBRPlanarToARGB(y_buf, y_pitch, u_buf, uv_pitch, v_buf, uv_pitch, GBRPlanarToARGB(y_buf, y_pitch, u_buf, uv_pitch, v_buf, uv_pitch,
buffer.get(), buffer_pitch, source_width, source_height); buffer.get(), buffer_pitch, source_width, source_height);
@ -356,10 +356,10 @@ void ScaleYCbCrToRGB32(const uint8* y_buf,
} }
// Scale a frame of YUV to 32 bit ARGB. // Scale a frame of YUV to 32 bit ARGB.
void ScaleYCbCrToRGB32_deprecated(const uint8* y_buf, void ScaleYCbCrToRGB32_deprecated(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int source_width, int source_width,
int source_height, int source_height,
int width, int width,
@ -443,39 +443,39 @@ void ScaleYCbCrToRGB32_deprecated(const uint8* y_buf,
// Need padding because FilterRows() will write 1 to 16 extra pixels // Need padding because FilterRows() will write 1 to 16 extra pixels
// after the end for SSE2 version. // after the end for SSE2 version.
uint8 yuvbuf[16 + kFilterBufferSize * 3 + 16]; uint8_t yuvbuf[16 + kFilterBufferSize * 3 + 16];
uint8* ybuf = uint8_t* ybuf =
reinterpret_cast<uint8*>(reinterpret_cast<uintptr_t>(yuvbuf + 15) & ~15); reinterpret_cast<uint8_t*>(reinterpret_cast<uintptr_t>(yuvbuf + 15) & ~15);
uint8* ubuf = ybuf + kFilterBufferSize; uint8_t* ubuf = ybuf + kFilterBufferSize;
uint8* vbuf = ubuf + kFilterBufferSize; uint8_t* vbuf = ubuf + kFilterBufferSize;
// TODO(fbarchard): Fixed point math is off by 1 on negatives. // TODO(fbarchard): Fixed point math is off by 1 on negatives.
int yscale_fixed = (source_height << kFractionBits) / height; int yscale_fixed = (source_height << kFractionBits) / height;
// TODO(fbarchard): Split this into separate function for better efficiency. // TODO(fbarchard): Split this into separate function for better efficiency.
for (int y = 0; y < height; ++y) { for (int y = 0; y < height; ++y) {
uint8* dest_pixel = rgb_buf + y * rgb_pitch; uint8_t* dest_pixel = rgb_buf + y * rgb_pitch;
int source_y_subpixel = (y * yscale_fixed); int source_y_subpixel = (y * yscale_fixed);
if (yscale_fixed >= (kFractionMax * 2)) { if (yscale_fixed >= (kFractionMax * 2)) {
source_y_subpixel += kFractionMax / 2; // For 1/2 or less, center filter. source_y_subpixel += kFractionMax / 2; // For 1/2 or less, center filter.
} }
int source_y = source_y_subpixel >> kFractionBits; int source_y = source_y_subpixel >> kFractionBits;
const uint8* y0_ptr = y_buf + source_y * y_pitch; const uint8_t* y0_ptr = y_buf + source_y * y_pitch;
const uint8* y1_ptr = y0_ptr + y_pitch; const uint8_t* y1_ptr = y0_ptr + y_pitch;
const uint8* u0_ptr = u_buf + (source_y >> y_shift) * uv_pitch; const uint8_t* u0_ptr = u_buf + (source_y >> y_shift) * uv_pitch;
const uint8* u1_ptr = u0_ptr + uv_pitch; const uint8_t* u1_ptr = u0_ptr + uv_pitch;
const uint8* v0_ptr = v_buf + (source_y >> y_shift) * uv_pitch; const uint8_t* v0_ptr = v_buf + (source_y >> y_shift) * uv_pitch;
const uint8* v1_ptr = v0_ptr + uv_pitch; const uint8_t* v1_ptr = v0_ptr + uv_pitch;
// vertical scaler uses 16.8 fixed point // vertical scaler uses 16.8 fixed point
int source_y_fraction = (source_y_subpixel & kFractionMask) >> 8; int source_y_fraction = (source_y_subpixel & kFractionMask) >> 8;
int source_uv_fraction = int source_uv_fraction =
((source_y_subpixel >> y_shift) & kFractionMask) >> 8; ((source_y_subpixel >> y_shift) & kFractionMask) >> 8;
const uint8* y_ptr = y0_ptr; const uint8_t* y_ptr = y0_ptr;
const uint8* u_ptr = u0_ptr; const uint8_t* u_ptr = u0_ptr;
const uint8* v_ptr = v0_ptr; const uint8_t* v_ptr = v0_ptr;
// Apply vertical filtering if necessary. // Apply vertical filtering if necessary.
// TODO(fbarchard): Remove memcpy when not necessary. // TODO(fbarchard): Remove memcpy when not necessary.
if (filter & mozilla::gfx::FILTER_BILINEAR_V) { if (filter & mozilla::gfx::FILTER_BILINEAR_V) {

View file

@ -45,10 +45,10 @@ YUVType TypeFromSize(int ywidth, int yheight, int cbcrwidth, int cbcrheight);
// Convert a frame of YUV to 32 bit ARGB. // Convert a frame of YUV to 32 bit ARGB.
// Pass in YV16/YV12 depending on source format // Pass in YV16/YV12 depending on source format
void ConvertYCbCrToRGB32(const uint8* yplane, void ConvertYCbCrToRGB32(const uint8_t* yplane,
const uint8* uplane, const uint8_t* uplane,
const uint8* vplane, const uint8_t* vplane,
uint8* rgbframe, uint8_t* rgbframe,
int pic_x, int pic_x,
int pic_y, int pic_y,
int pic_width, int pic_width,
@ -59,10 +59,10 @@ void ConvertYCbCrToRGB32(const uint8* yplane,
YUVType yuv_type, YUVType yuv_type,
YUVColorSpace yuv_color_space); YUVColorSpace yuv_color_space);
void ConvertYCbCrToRGB32_deprecated(const uint8* yplane, void ConvertYCbCrToRGB32_deprecated(const uint8_t* yplane,
const uint8* uplane, const uint8_t* uplane,
const uint8* vplane, const uint8_t* vplane,
uint8* rgbframe, uint8_t* rgbframe,
int pic_x, int pic_x,
int pic_y, int pic_y,
int pic_width, int pic_width,
@ -74,10 +74,10 @@ void ConvertYCbCrToRGB32_deprecated(const uint8* yplane,
// Scale a frame of YUV to 32 bit ARGB. // Scale a frame of YUV to 32 bit ARGB.
// Supports rotation and mirroring. // Supports rotation and mirroring.
void ScaleYCbCrToRGB32(const uint8* yplane, void ScaleYCbCrToRGB32(const uint8_t* yplane,
const uint8* uplane, const uint8_t* uplane,
const uint8* vplane, const uint8_t* vplane,
uint8* rgbframe, uint8_t* rgbframe,
int source_width, int source_width,
int source_height, int source_height,
int width, int width,
@ -89,10 +89,10 @@ void ScaleYCbCrToRGB32(const uint8* yplane,
YUVColorSpace yuv_color_space, YUVColorSpace yuv_color_space,
ScaleFilter filter); ScaleFilter filter);
void ScaleYCbCrToRGB32_deprecated(const uint8* yplane, void ScaleYCbCrToRGB32_deprecated(const uint8_t* yplane,
const uint8* uplane, const uint8_t* uplane,
const uint8* vplane, const uint8_t* vplane,
uint8* rgbframe, uint8_t* rgbframe,
int source_width, int source_width,
int source_height, int source_height,
int width, int width,

View file

@ -21,20 +21,20 @@ void __attribute((noinline))
# else # else
void __attribute((noinline,optimize("-fomit-frame-pointer"))) void __attribute((noinline,optimize("-fomit-frame-pointer")))
# endif # endif
yuv42x_to_rgb565_row_neon(uint16 *dst, yuv42x_to_rgb565_row_neon(uint16_t *dst,
const uint8 *y, const uint8_t *y,
const uint8 *u, const uint8_t *u,
const uint8 *v, const uint8_t *v,
int n, int n,
int oddflag) int oddflag)
{ {
static __attribute__((aligned(16))) uint16 acc_r[8] = { static __attribute__((aligned(16))) uint16_t acc_r[8] = {
22840, 22840, 22840, 22840, 22840, 22840, 22840, 22840, 22840, 22840, 22840, 22840, 22840, 22840, 22840, 22840,
}; };
static __attribute__((aligned(16))) uint16 acc_g[8] = { static __attribute__((aligned(16))) uint16_t acc_g[8] = {
17312, 17312, 17312, 17312, 17312, 17312, 17312, 17312, 17312, 17312, 17312, 17312, 17312, 17312, 17312, 17312,
}; };
static __attribute__((aligned(16))) uint16 acc_b[8] = { static __attribute__((aligned(16))) uint16_t acc_b[8] = {
28832, 28832, 28832, 28832, 28832, 28832, 28832, 28832, 28832, 28832, 28832, 28832, 28832, 28832, 28832, 28832,
}; };
/* /*

View file

@ -10,7 +10,7 @@ namespace gfx {
// FilterRows combines two rows of the image using linear interpolation. // FilterRows combines two rows of the image using linear interpolation.
// MMX version does 8 pixels at a time. // MMX version does 8 pixels at a time.
void FilterRows_MMX(uint8* ybuf, const uint8* y0_ptr, const uint8* y1_ptr, void FilterRows_MMX(uint8_t* ybuf, const uint8_t* y0_ptr, const uint8_t* y1_ptr,
int source_width, int source_y_fraction) { int source_width, int source_y_fraction) {
__m64 zero = _mm_setzero_si64(); __m64 zero = _mm_setzero_si64();
__m64 y1_fraction = _mm_set1_pi16(source_y_fraction); __m64 y1_fraction = _mm_set1_pi16(source_y_fraction);

View file

@ -10,7 +10,7 @@ namespace gfx {
// FilterRows combines two rows of the image using linear interpolation. // FilterRows combines two rows of the image using linear interpolation.
// SSE2 version does 16 pixels at a time. // SSE2 version does 16 pixels at a time.
void FilterRows_SSE2(uint8* ybuf, const uint8* y0_ptr, const uint8* y1_ptr, void FilterRows_SSE2(uint8_t* ybuf, const uint8_t* y0_ptr, const uint8_t* y1_ptr,
int source_width, int source_y_fraction) { int source_width, int source_y_fraction) {
__m128i zero = _mm_setzero_si128(); __m128i zero = _mm_setzero_si128();
__m128i y1_fraction = _mm_set1_epi16(source_y_fraction); __m128i y1_fraction = _mm_set1_epi16(source_y_fraction);

View file

@ -15,33 +15,27 @@
extern "C" { extern "C" {
// Can only do 1x. // Can only do 1x.
// This is the second fastest of the scalers. // This is the second fastest of the scalers.
void FastConvertYUVToRGB32Row(const uint8* y_buf, void FastConvertYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width); int width);
void FastConvertYUVToRGB32Row_C(const uint8* y_buf, void FastConvertYUVToRGB32Row_C(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
unsigned int x_shift); unsigned int x_shift);
void FastConvertYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
int width);
// Can do 1x, half size or any scale down by an integer amount. // Can do 1x, half size or any scale down by an integer amount.
// Step can be negative (mirroring, rotate 180). // Step can be negative (mirroring, rotate 180).
// This is the third fastest of the scalers. // This is the third fastest of the scalers.
// Only defined on Windows x86-32. // Only defined on Windows x86-32.
void ConvertYUVToRGB32Row_SSE(const uint8* y_buf, void ConvertYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int step); int step);
@ -49,10 +43,10 @@ void ConvertYUVToRGB32Row_SSE(const uint8* y_buf,
// This allows rotation by 90 or 270, by stepping by stride. // This allows rotation by 90 or 270, by stepping by stride.
// This is the forth fastest of the scalers. // This is the forth fastest of the scalers.
// Only defined on Windows x86-32. // Only defined on Windows x86-32.
void RotateConvertYUVToRGB32Row_SSE(const uint8* y_buf, void RotateConvertYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int ystep, int ystep,
int uvstep); int uvstep);
@ -60,33 +54,26 @@ void RotateConvertYUVToRGB32Row_SSE(const uint8* y_buf,
// Doubler does 4 pixels at a time. Each pixel is replicated. // Doubler does 4 pixels at a time. Each pixel is replicated.
// This is the fastest of the scalers. // This is the fastest of the scalers.
// Only defined on Windows x86-32. // Only defined on Windows x86-32.
void DoubleYUVToRGB32Row_SSE(const uint8* y_buf, void DoubleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width); int width);
// Handles arbitrary scaling up or down. // Handles arbitrary scaling up or down.
// Mirroring is supported, but not 90 or 270 degree rotation. // Mirroring is supported, but not 90 or 270 degree rotation.
// Chroma is under sampled every 2 pixels for performance. // Chroma is under sampled every 2 pixels for performance.
void ScaleYUVToRGB32Row(const uint8* y_buf, void ScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx); int source_dx);
void ScaleYUVToRGB32Row(const uint8* y_buf, void ScaleYUVToRGB32Row_C(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width,
int source_dx);
void ScaleYUVToRGB32Row_C(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
int width, int width,
int source_dx); int source_dx);
@ -94,24 +81,17 @@ void ScaleYUVToRGB32Row_C(const uint8* y_buf,
// Mirroring is supported, but not 90 or 270 degree rotation. // Mirroring is supported, but not 90 or 270 degree rotation.
// Chroma is under sampled every 2 pixels for performance. // Chroma is under sampled every 2 pixels for performance.
// This is the slowest of the scalers. // This is the slowest of the scalers.
void LinearScaleYUVToRGB32Row(const uint8* y_buf, void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx); int source_dx);
void LinearScaleYUVToRGB32Row(const uint8* y_buf, void LinearScaleYUVToRGB32Row_C(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width,
int source_dx);
void LinearScaleYUVToRGB32Row_C(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
int width, int width,
int source_dx); int source_dx);
@ -121,7 +101,7 @@ void LinearScaleYUVToRGB32Row_C(const uint8* y_buf,
#else #else
#define SIMD_ALIGNED(var) var __attribute__((aligned(16))) #define SIMD_ALIGNED(var) var __attribute__((aligned(16)))
#endif #endif
extern SIMD_ALIGNED(const int16 kCoefficientsRgbY[768][4]); extern SIMD_ALIGNED(const int16_t kCoefficientsRgbY[768][4]);
// x64 uses MMX2 (SSE) so emms is not required. // x64 uses MMX2 (SSE) so emms is not required.
// Warning C4799: function has no EMMS instruction. // Warning C4799: function has no EMMS instruction.

View file

@ -13,10 +13,10 @@ extern "C" {
#define paddsw(x, y) (((x) + (y)) < -32768 ? -32768 : \ #define paddsw(x, y) (((x) + (y)) < -32768 ? -32768 : \
(((x) + (y)) > 32767 ? 32767 : ((x) + (y)))) (((x) + (y)) > 32767 ? 32767 : ((x) + (y))))
static inline void YuvPixel(uint8 y, static inline void YuvPixel(uint8_t y,
uint8 u, uint8_t u,
uint8 v, uint8_t v,
uint8* rgb_buf) { uint8_t* rgb_buf) {
int b = kCoefficientsRgbY[256+u][0]; int b = kCoefficientsRgbY[256+u][0];
int g = kCoefficientsRgbY[256+u][1]; int g = kCoefficientsRgbY[256+u][1];
@ -38,25 +38,25 @@ static inline void YuvPixel(uint8 y,
r >>= 6; r >>= 6;
a >>= 6; a >>= 6;
*reinterpret_cast<uint32*>(rgb_buf) = (packuswb(b)) | *reinterpret_cast<uint32_t*>(rgb_buf) = (packuswb(b)) |
(packuswb(g) << 8) | (packuswb(g) << 8) |
(packuswb(r) << 16) | (packuswb(r) << 16) |
(packuswb(a) << 24); (packuswb(a) << 24);
} }
void FastConvertYUVToRGB32Row_C(const uint8* y_buf, void FastConvertYUVToRGB32Row_C(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
unsigned int x_shift) { unsigned int x_shift) {
for (int x = 0; x < width; x += 2) { for (int x = 0; x < width; x += 2) {
uint8 u = u_buf[x >> x_shift]; uint8_t u = u_buf[x >> x_shift];
uint8 v = v_buf[x >> x_shift]; uint8_t v = v_buf[x >> x_shift];
uint8 y0 = y_buf[x]; uint8_t y0 = y_buf[x];
YuvPixel(y0, u, v, rgb_buf); YuvPixel(y0, u, v, rgb_buf);
if ((x + 1) < width) { if ((x + 1) < width) {
uint8 y1 = y_buf[x + 1]; uint8_t y1 = y_buf[x + 1];
if (x_shift == 0) { if (x_shift == 0) {
u = u_buf[x + 1]; u = u_buf[x + 1];
v = v_buf[x + 1]; v = v_buf[x + 1];
@ -71,10 +71,10 @@ void FastConvertYUVToRGB32Row_C(const uint8* y_buf,
// A shift by 17 is used to further subsample the chrominence channels. // A shift by 17 is used to further subsample the chrominence channels.
// & 0xffff isolates the fixed point fraction. >> 2 to get the upper 2 bits, // & 0xffff isolates the fixed point fraction. >> 2 to get the upper 2 bits,
// for 1/65536 pixel accurate interpolation. // for 1/65536 pixel accurate interpolation.
void ScaleYUVToRGB32Row_C(const uint8* y_buf, void ScaleYUVToRGB32Row_C(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
int x = 0; int x = 0;
@ -93,10 +93,10 @@ void ScaleYUVToRGB32Row_C(const uint8* y_buf,
} }
} }
void LinearScaleYUVToRGB32Row_C(const uint8* y_buf, void LinearScaleYUVToRGB32Row_C(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
int x = 0; int x = 0;

View file

@ -5,27 +5,27 @@
#include "yuv_row.h" #include "yuv_row.h"
extern "C" { extern "C" {
void FastConvertYUVToRGB32Row(const uint8* y_buf, void FastConvertYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width) { int width) {
FastConvertYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, 1); FastConvertYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, 1);
} }
void ScaleYUVToRGB32Row(const uint8* y_buf, void ScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
ScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx); ScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);
} }
void LinearScaleYUVToRGB32Row(const uint8* y_buf, void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
LinearScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx); LinearScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);

View file

@ -14,11 +14,11 @@ extern "C" {
// We don't need CPUID guards here, since x86-64 implies SSE2. // We don't need CPUID guards here, since x86-64 implies SSE2.
// AMD64 ABI uses register paremters. // AMD64 ABI uses register paremters.
void FastConvertYUVToRGB32Row(const uint8* y_buf, // rdi void FastConvertYUVToRGB32Row(const uint8_t* y_buf, // rdi
const uint8* u_buf, // rsi const uint8_t* u_buf, // rsi
const uint8* v_buf, // rdx const uint8_t* v_buf, // rdx
uint8* rgb_buf, // rcx uint8_t* rgb_buf, // rcx
int width) { // r8 int width) { // r8
asm( asm(
"jmp 1f\n" "jmp 1f\n"
"0:" "0:"
@ -72,12 +72,12 @@ void FastConvertYUVToRGB32Row(const uint8* y_buf, // rdi
); );
} }
void ScaleYUVToRGB32Row(const uint8* y_buf, // rdi void ScaleYUVToRGB32Row(const uint8_t* y_buf, // rdi
const uint8* u_buf, // rsi const uint8_t* u_buf, // rsi
const uint8* v_buf, // rdx const uint8_t* v_buf, // rdx
uint8* rgb_buf, // rcx uint8_t* rgb_buf, // rcx
int width, // r8 int width, // r8
int source_dx) { // r9 int source_dx) { // r9
asm( asm(
"xor %%r11,%%r11\n" "xor %%r11,%%r11\n"
"sub $0x2,%4\n" "sub $0x2,%4\n"
@ -141,10 +141,10 @@ void ScaleYUVToRGB32Row(const uint8* y_buf, // rdi
); );
} }
void LinearScaleYUVToRGB32Row(const uint8* y_buf, void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
asm( asm(
@ -262,10 +262,10 @@ void LinearScaleYUVToRGB32Row(const uint8* y_buf,
// PIC version is slower because less registers are available, so // PIC version is slower because less registers are available, so
// non-PIC is used on platforms where it is possible. // non-PIC is used on platforms where it is possible.
void FastConvertYUVToRGB32Row_SSE(const uint8* y_buf, void FastConvertYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width); int width);
asm( asm(
".text\n" ".text\n"
@ -324,10 +324,10 @@ void FastConvertYUVToRGB32Row_SSE(const uint8* y_buf,
#endif #endif
); );
void FastConvertYUVToRGB32Row(const uint8* y_buf, void FastConvertYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width) int width)
{ {
if (mozilla::supports_sse()) { if (mozilla::supports_sse()) {
@ -339,10 +339,10 @@ void FastConvertYUVToRGB32Row(const uint8* y_buf,
} }
void ScaleYUVToRGB32Row_SSE(const uint8* y_buf, void ScaleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx); int source_dx);
asm( asm(
@ -417,10 +417,10 @@ void ScaleYUVToRGB32Row_SSE(const uint8* y_buf,
#endif #endif
); );
void ScaleYUVToRGB32Row(const uint8* y_buf, void ScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) int source_dx)
{ {
@ -434,10 +434,10 @@ void ScaleYUVToRGB32Row(const uint8* y_buf,
width, source_dx); width, source_dx);
} }
void LinearScaleYUVToRGB32Row_SSE(const uint8* y_buf, void LinearScaleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx); int source_dx);
asm( asm(
@ -549,10 +549,10 @@ void LinearScaleYUVToRGB32Row_SSE(const uint8* y_buf,
#endif #endif
); );
void LinearScaleYUVToRGB32Row(const uint8* y_buf, void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) int source_dx)
{ {
@ -568,12 +568,12 @@ void LinearScaleYUVToRGB32Row(const uint8* y_buf,
#elif defined(MOZILLA_MAY_SUPPORT_SSE) && defined(ARCH_CPU_X86_32) && defined(__PIC__) #elif defined(MOZILLA_MAY_SUPPORT_SSE) && defined(ARCH_CPU_X86_32) && defined(__PIC__)
void PICConvertYUVToRGB32Row_SSE(const uint8* y_buf, void PICConvertYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
const int16 *kCoefficientsRgbY); const int16_t *kCoefficientsRgbY);
asm( asm(
".text\n" ".text\n"
@ -635,10 +635,10 @@ void PICConvertYUVToRGB32Row_SSE(const uint8* y_buf,
#endif #endif
); );
void FastConvertYUVToRGB32Row(const uint8* y_buf, void FastConvertYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width) int width)
{ {
if (mozilla::supports_sse()) { if (mozilla::supports_sse()) {
@ -650,13 +650,13 @@ void FastConvertYUVToRGB32Row(const uint8* y_buf,
FastConvertYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, 1); FastConvertYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, 1);
} }
void PICScaleYUVToRGB32Row_SSE(const uint8* y_buf, void PICScaleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx, int source_dx,
const int16 *kCoefficientsRgbY); const int16_t *kCoefficientsRgbY);
asm( asm(
".text\n" ".text\n"
@ -732,10 +732,10 @@ void PICScaleYUVToRGB32Row_SSE(const uint8* y_buf,
#endif #endif
); );
void ScaleYUVToRGB32Row(const uint8* y_buf, void ScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) int source_dx)
{ {
@ -748,13 +748,13 @@ void ScaleYUVToRGB32Row(const uint8* y_buf,
ScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx); ScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);
} }
void PICLinearScaleYUVToRGB32Row_SSE(const uint8* y_buf, void PICLinearScaleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx, int source_dx,
const int16 *kCoefficientsRgbY); const int16_t *kCoefficientsRgbY);
asm( asm(
".text\n" ".text\n"
@ -871,10 +871,10 @@ void PICLinearScaleYUVToRGB32Row_SSE(const uint8* y_buf,
); );
void LinearScaleYUVToRGB32Row(const uint8* y_buf, void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) int source_dx)
{ {
@ -887,27 +887,27 @@ void LinearScaleYUVToRGB32Row(const uint8* y_buf,
LinearScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx); LinearScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);
} }
#else #else
void FastConvertYUVToRGB32Row(const uint8* y_buf, void FastConvertYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width) { int width) {
FastConvertYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, 1); FastConvertYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, 1);
} }
void ScaleYUVToRGB32Row(const uint8* y_buf, void ScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
ScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx); ScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);
} }
void LinearScaleYUVToRGB32Row(const uint8* y_buf, void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
LinearScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx); LinearScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);

View file

@ -7,27 +7,27 @@
extern "C" { extern "C" {
#define RGBY(i) { \ #define RGBY(i) { \
static_cast<int16>(1.164 * 64 * (i - 16) + 0.5), \ static_cast<int16_t>(1.164 * 64 * (i - 16) + 0.5), \
static_cast<int16>(1.164 * 64 * (i - 16) + 0.5), \ static_cast<int16_t>(1.164 * 64 * (i - 16) + 0.5), \
static_cast<int16>(1.164 * 64 * (i - 16) + 0.5), \ static_cast<int16_t>(1.164 * 64 * (i - 16) + 0.5), \
0 \ 0 \
} }
#define RGBU(i) { \ #define RGBU(i) { \
static_cast<int16>(2.018 * 64 * (i - 128) + 0.5), \ static_cast<int16_t>(2.018 * 64 * (i - 128) + 0.5), \
static_cast<int16>(-0.391 * 64 * (i - 128) + 0.5), \ static_cast<int16_t>(-0.391 * 64 * (i - 128) + 0.5), \
0, \ 0, \
static_cast<int16>(256 * 64 - 1) \ static_cast<int16_t>(256 * 64 - 1) \
} }
#define RGBV(i) { \ #define RGBV(i) { \
0, \ 0, \
static_cast<int16>(-0.813 * 64 * (i - 128) + 0.5), \ static_cast<int16_t>(-0.813 * 64 * (i - 128) + 0.5), \
static_cast<int16>(1.596 * 64 * (i - 128) + 0.5), \ static_cast<int16_t>(1.596 * 64 * (i - 128) + 0.5), \
0 \ 0 \
} }
SIMD_ALIGNED(const int16 kCoefficientsRgbY[256 * 3][4]) = { SIMD_ALIGNED(const int16_t kCoefficientsRgbY[256 * 3][4]) = {
RGBY(0x00), RGBY(0x01), RGBY(0x02), RGBY(0x03), RGBY(0x00), RGBY(0x01), RGBY(0x02), RGBY(0x03),
RGBY(0x04), RGBY(0x05), RGBY(0x06), RGBY(0x07), RGBY(0x04), RGBY(0x05), RGBY(0x06), RGBY(0x07),
RGBY(0x08), RGBY(0x09), RGBY(0x0A), RGBY(0x0B), RGBY(0x08), RGBY(0x09), RGBY(0x0A), RGBY(0x0B),

View file

@ -12,10 +12,10 @@ extern "C" {
#if defined(MOZILLA_MAY_SUPPORT_SSE) && defined(_M_IX86) #if defined(MOZILLA_MAY_SUPPORT_SSE) && defined(_M_IX86)
__declspec(naked) __declspec(naked)
void FastConvertYUVToRGB32Row_SSE(const uint8* y_buf, void FastConvertYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width) { int width) {
__asm { __asm {
pushad pushad
@ -70,10 +70,10 @@ void FastConvertYUVToRGB32Row_SSE(const uint8* y_buf,
} }
__declspec(naked) __declspec(naked)
void ConvertYUVToRGB32Row_SSE(const uint8* y_buf, void ConvertYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int step) { int step) {
__asm { __asm {
@ -131,10 +131,10 @@ void ConvertYUVToRGB32Row_SSE(const uint8* y_buf,
} }
__declspec(naked) __declspec(naked)
void RotateConvertYUVToRGB32Row_SSE(const uint8* y_buf, void RotateConvertYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int ystep, int ystep,
int uvstep) { int uvstep) {
@ -194,10 +194,10 @@ void RotateConvertYUVToRGB32Row_SSE(const uint8* y_buf,
} }
__declspec(naked) __declspec(naked)
void DoubleYUVToRGB32Row_SSE(const uint8* y_buf, void DoubleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width) { int width) {
__asm { __asm {
pushad pushad
@ -266,10 +266,10 @@ void DoubleYUVToRGB32Row_SSE(const uint8* y_buf,
// For performance the chroma is under-sampled, reducing cost of a 3x // For performance the chroma is under-sampled, reducing cost of a 3x
// 1080p scale from 8.4 ms to 5.4 ms. // 1080p scale from 8.4 ms to 5.4 ms.
__declspec(naked) __declspec(naked)
void ScaleYUVToRGB32Row_SSE(const uint8* y_buf, void ScaleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
__asm { __asm {
@ -339,10 +339,10 @@ void ScaleYUVToRGB32Row_SSE(const uint8* y_buf,
} }
__declspec(naked) __declspec(naked)
void LinearScaleYUVToRGB32Row_SSE(const uint8* y_buf, void LinearScaleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
__asm { __asm {
@ -446,10 +446,10 @@ lscalelastpixel:
} }
#endif // if defined(MOZILLA_MAY_SUPPORT_SSE) && defined(_M_IX86) #endif // if defined(MOZILLA_MAY_SUPPORT_SSE) && defined(_M_IX86)
void FastConvertYUVToRGB32Row(const uint8* y_buf, void FastConvertYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width) { int width) {
#if defined(MOZILLA_MAY_SUPPORT_SSE) && defined(_M_IX86) #if defined(MOZILLA_MAY_SUPPORT_SSE) && defined(_M_IX86)
if (mozilla::supports_sse()) { if (mozilla::supports_sse()) {
@ -461,10 +461,10 @@ void FastConvertYUVToRGB32Row(const uint8* y_buf,
FastConvertYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, 1); FastConvertYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, 1);
} }
void ScaleYUVToRGB32Row(const uint8* y_buf, void ScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
@ -478,10 +478,10 @@ void ScaleYUVToRGB32Row(const uint8* y_buf,
ScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx); ScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);
} }
void LinearScaleYUVToRGB32Row(const uint8* y_buf, void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
#if defined(MOZILLA_MAY_SUPPORT_SSE) && defined(_M_IX86) #if defined(MOZILLA_MAY_SUPPORT_SSE) && defined(_M_IX86)

View file

@ -8,15 +8,15 @@ extern "C" {
// x64 compiler doesn't support MMX and inline assembler. Use SSE2 intrinsics. // x64 compiler doesn't support MMX and inline assembler. Use SSE2 intrinsics.
#define kCoefficientsRgbU (reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 2048) #define kCoefficientsRgbU (reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 2048)
#define kCoefficientsRgbV (reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 4096) #define kCoefficientsRgbV (reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 4096)
#include <emmintrin.h> #include <emmintrin.h>
static void FastConvertYUVToRGB32Row_SSE2(const uint8* y_buf, static void FastConvertYUVToRGB32Row_SSE2(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width) { int width) {
__m128i xmm0, xmmY1, xmmY2; __m128i xmm0, xmmY1, xmmY2;
__m128 xmmY; __m128 xmmY;
@ -25,10 +25,10 @@ static void FastConvertYUVToRGB32Row_SSE2(const uint8* y_buf,
xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * *u_buf++)), xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * *u_buf++)),
_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * *v_buf++))); _mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * *v_buf++)));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * *y_buf++)); xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * *y_buf++));
xmmY1 = _mm_adds_epi16(xmmY1, xmm0); xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * *y_buf++)); xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * *y_buf++));
xmmY2 = _mm_adds_epi16(xmmY2, xmm0); xmmY2 = _mm_adds_epi16(xmmY2, xmm0);
xmmY = _mm_shuffle_ps(_mm_castsi128_ps(xmmY1), _mm_castsi128_ps(xmmY2), xmmY = _mm_shuffle_ps(_mm_castsi128_ps(xmmY1), _mm_castsi128_ps(xmmY2),
@ -44,23 +44,23 @@ static void FastConvertYUVToRGB32Row_SSE2(const uint8* y_buf,
if (width) { if (width) {
xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * *u_buf)), xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * *u_buf)),
_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * *v_buf))); _mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * *v_buf)));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * *y_buf)); xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * *y_buf));
xmmY1 = _mm_adds_epi16(xmmY1, xmm0); xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
xmmY1 = _mm_srai_epi16(xmmY1, 6); xmmY1 = _mm_srai_epi16(xmmY1, 6);
xmmY1 = _mm_packus_epi16(xmmY1, xmmY1); xmmY1 = _mm_packus_epi16(xmmY1, xmmY1);
*reinterpret_cast<uint32*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1); *reinterpret_cast<uint32_t*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1);
} }
} }
static void ScaleYUVToRGB32Row_SSE2(const uint8* y_buf, static void ScaleYUVToRGB32Row_SSE2(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
__m128i xmm0, xmmY1, xmmY2; __m128i xmm0, xmmY1, xmmY2;
__m128 xmmY; __m128 xmmY;
uint8 u, v, y; uint8_t u, v, y;
int x = 0; int x = 0;
while (width >= 2) { while (width >= 2) {
@ -71,13 +71,13 @@ static void ScaleYUVToRGB32Row_SSE2(const uint8* y_buf,
xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)), xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)),
_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v))); _mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v)));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y)); xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * y));
xmmY1 = _mm_adds_epi16(xmmY1, xmm0); xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
y = y_buf[x >> 16]; y = y_buf[x >> 16];
x += source_dx; x += source_dx;
xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y)); xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * y));
xmmY2 = _mm_adds_epi16(xmmY2, xmm0); xmmY2 = _mm_adds_epi16(xmmY2, xmm0);
xmmY = _mm_shuffle_ps(_mm_castsi128_ps(xmmY1), _mm_castsi128_ps(xmmY2), xmmY = _mm_shuffle_ps(_mm_castsi128_ps(xmmY1), _mm_castsi128_ps(xmmY2),
@ -97,24 +97,24 @@ static void ScaleYUVToRGB32Row_SSE2(const uint8* y_buf,
xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)), xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)),
_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v))); _mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v)));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y)); xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * y));
xmmY1 = _mm_adds_epi16(xmmY1, xmm0); xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
xmmY1 = _mm_srai_epi16(xmmY1, 6); xmmY1 = _mm_srai_epi16(xmmY1, 6);
xmmY1 = _mm_packus_epi16(xmmY1, xmmY1); xmmY1 = _mm_packus_epi16(xmmY1, xmmY1);
*reinterpret_cast<uint32*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1); *reinterpret_cast<uint32_t*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1);
} }
} }
static void LinearScaleYUVToRGB32Row_SSE2(const uint8* y_buf, static void LinearScaleYUVToRGB32Row_SSE2(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
__m128i xmm0, xmmY1, xmmY2; __m128i xmm0, xmmY1, xmmY2;
__m128 xmmY; __m128 xmmY;
uint8 u0, u1, v0, v1, y0, y1; uint8_t u0, u1, v0, v1, y0, y1;
uint32 uv_frac, y_frac, u, v, y; uint32_t uv_frac, y_frac, u, v, y;
int x = 0; int x = 0;
if (source_dx >= 0x20000) { if (source_dx >= 0x20000) {
@ -137,7 +137,7 @@ static void LinearScaleYUVToRGB32Row_SSE2(const uint8* y_buf,
xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)), xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)),
_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v))); _mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v)));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y)); xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * y));
xmmY1 = _mm_adds_epi16(xmmY1, xmm0); xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
y0 = y_buf[x >> 16]; y0 = y_buf[x >> 16];
@ -146,7 +146,7 @@ static void LinearScaleYUVToRGB32Row_SSE2(const uint8* y_buf,
y = (y_frac * y1 + (y_frac ^ 0xffff) * y0) >> 16; y = (y_frac * y1 + (y_frac ^ 0xffff) * y0) >> 16;
x += source_dx; x += source_dx;
xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y)); xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * y));
xmmY2 = _mm_adds_epi16(xmmY2, xmm0); xmmY2 = _mm_adds_epi16(xmmY2, xmm0);
xmmY = _mm_shuffle_ps(_mm_castsi128_ps(xmmY1), _mm_castsi128_ps(xmmY2), xmmY = _mm_shuffle_ps(_mm_castsi128_ps(xmmY1), _mm_castsi128_ps(xmmY2),
@ -166,36 +166,36 @@ static void LinearScaleYUVToRGB32Row_SSE2(const uint8* y_buf,
xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)), xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)),
_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v))); _mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v)));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y)); xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * y));
xmmY1 = _mm_adds_epi16(xmmY1, xmm0); xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
xmmY1 = _mm_srai_epi16(xmmY1, 6); xmmY1 = _mm_srai_epi16(xmmY1, 6);
xmmY1 = _mm_packus_epi16(xmmY1, xmmY1); xmmY1 = _mm_packus_epi16(xmmY1, xmmY1);
*reinterpret_cast<uint32*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1); *reinterpret_cast<uint32_t*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1);
} }
} }
void FastConvertYUVToRGB32Row(const uint8* y_buf, void FastConvertYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width) { int width) {
FastConvertYUVToRGB32Row_SSE2(y_buf, u_buf, v_buf, rgb_buf, width); FastConvertYUVToRGB32Row_SSE2(y_buf, u_buf, v_buf, rgb_buf, width);
} }
void ScaleYUVToRGB32Row(const uint8* y_buf, void ScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
ScaleYUVToRGB32Row_SSE2(y_buf, u_buf, v_buf, rgb_buf, width, source_dx); ScaleYUVToRGB32Row_SSE2(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);
} }
void LinearScaleYUVToRGB32Row(const uint8* y_buf, void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8* u_buf, const uint8_t* u_buf,
const uint8* v_buf, const uint8_t* v_buf,
uint8* rgb_buf, uint8_t* rgb_buf,
int width, int width,
int source_dx) { int source_dx) {
LinearScaleYUVToRGB32Row_SSE2(y_buf, u_buf, v_buf, rgb_buf, width, LinearScaleYUVToRGB32Row_SSE2(y_buf, u_buf, v_buf, rgb_buf, width,

View file

@ -400,11 +400,11 @@ protected:
int half_height = (size.height + 1) >> 1; int half_height = (size.height + 1) >> 1;
int c_size = half_width * half_height; int c_size = half_width * half_height;
int buffer_size = YSIZE(size.width, size.height) + 2 * c_size; int buffer_size = YSIZE(size.width, size.height) + 2 * c_size;
auto yuv_scoped = MakeUniqueFallible<uint8[]>(buffer_size); auto yuv_scoped = MakeUniqueFallible<uint8_t[]>(buffer_size);
if (!yuv_scoped) { if (!yuv_scoped) {
return; return;
} }
uint8* yuv = yuv_scoped.get(); uint8_t* yuv = yuv_scoped.get();
DataSourceSurface::ScopedMap map(data, DataSourceSurface::READ); DataSourceSurface::ScopedMap map(data, DataSourceSurface::READ);
if (!map.IsMapped()) { if (!map.IsMapped()) {
@ -420,7 +420,7 @@ protected:
switch (surf->GetFormat()) { switch (surf->GetFormat()) {
case SurfaceFormat::B8G8R8A8: case SurfaceFormat::B8G8R8A8:
case SurfaceFormat::B8G8R8X8: case SurfaceFormat::B8G8R8X8:
rv = libyuv::ARGBToI420(static_cast<uint8*>(map.GetData()), rv = libyuv::ARGBToI420(static_cast<uint8_t*>(map.GetData()),
map.GetStride(), map.GetStride(),
yuv, size.width, yuv, size.width,
yuv + cb_offset, half_width, yuv + cb_offset, half_width,
@ -428,7 +428,7 @@ protected:
size.width, size.height); size.width, size.height);
break; break;
case SurfaceFormat::R5G6B5_UINT16: case SurfaceFormat::R5G6B5_UINT16:
rv = libyuv::RGB565ToI420(static_cast<uint8*>(map.GetData()), rv = libyuv::RGB565ToI420(static_cast<uint8_t*>(map.GetData()),
map.GetStride(), map.GetStride(),
yuv, size.width, yuv, size.width,
yuv + cb_offset, half_width, yuv + cb_offset, half_width,