early-access version 2864

This commit is contained in:
pineappleEA
2022-07-27 20:06:50 +02:00
parent 569d5e0f66
commit c1feb74617
2062 changed files with 73334 additions and 70676 deletions

View File

@@ -25,6 +25,5 @@ OBJS-$(CONFIG_SHARED) += log2_tab.o
SLIBOBJS-$(HAVE_GNU_WINDRES) += swscaleres.o
TESTPROGS = colorspace \
floatimg_cmp \
pixdesc_query \
swscale \

View File

@@ -42,14 +42,15 @@ static int ifmt##_to_##ofmt##_neon_wrapper(SwsContext *c, const uint8_t *src[],
uint8_t *dst[], int dstStride[]) { \
const int16_t yuv2rgb_table[] = { YUV_TO_RGB_TABLE }; \
\
return ff_##ifmt##_to_##ofmt##_neon(c->srcW, srcSliceH, \
dst[0] + srcSliceY * dstStride[0], dstStride[0], \
src[0], srcStride[0], \
src[1], srcStride[1], \
src[2], srcStride[2], \
yuv2rgb_table, \
c->yuv2rgb_y_offset >> 6, \
c->yuv2rgb_y_coeff); \
ff_##ifmt##_to_##ofmt##_neon(c->srcW, srcSliceH, \
dst[0] + srcSliceY * dstStride[0], dstStride[0], \
src[0], srcStride[0], \
src[1], srcStride[1], \
src[2], srcStride[2], \
yuv2rgb_table, \
c->yuv2rgb_y_offset >> 6, \
c->yuv2rgb_y_coeff); \
return 0; \
} \
#define DECLARE_FF_YUVX_TO_ALL_RGBX_FUNCS(yuvx) \
@@ -75,12 +76,14 @@ static int ifmt##_to_##ofmt##_neon_wrapper(SwsContext *c, const uint8_t *src[],
uint8_t *dst[], int dstStride[]) { \
const int16_t yuv2rgb_table[] = { YUV_TO_RGB_TABLE }; \
\
return ff_##ifmt##_to_##ofmt##_neon(c->srcW, srcSliceH, \
dst[0] + srcSliceY * dstStride[0], dstStride[0], \
src[0], srcStride[0], src[1], srcStride[1], \
yuv2rgb_table, \
c->yuv2rgb_y_offset >> 6, \
c->yuv2rgb_y_coeff); \
ff_##ifmt##_to_##ofmt##_neon(c->srcW, srcSliceH, \
dst[0] + srcSliceY * dstStride[0], dstStride[0], \
src[0], srcStride[0], src[1], srcStride[1], \
yuv2rgb_table, \
c->yuv2rgb_y_offset >> 6, \
c->yuv2rgb_y_coeff); \
\
return 0; \
} \
#define DECLARE_FF_NVX_TO_ALL_RGBX_FUNCS(nvx) \

View File

@@ -142,7 +142,6 @@
.macro declare_func ifmt ofmt
function ff_\ifmt\()_to_\ofmt\()_neon, export=1
load_args_\ifmt
mov w9, w1
1:
mov w8, w0 // w8 = width
2:
@@ -194,7 +193,6 @@ function ff_\ifmt\()_to_\ofmt\()_neon, export=1
increment_\ifmt
subs w1, w1, #1 // height -= 1
b.gt 1b
mov w0, w9
ret
endfunc
.endm

View File

@@ -118,72 +118,6 @@
B(1, 1) = (T(0, 1) + T(2, 1)) >> (1 + BAYER_SHIFT);
#endif
#if defined(BAYER_BGGR) || defined(BAYER_RGGB)
#define BAYER_TO_RGB48_COPY \
R(0, 0) = \
R(0, 1) = \
R(1, 1) = \
R(1, 0) = S(1, 1); \
\
G(0, 1) = S(0, 1); \
G(0, 0) = \
G(1, 1) = (T(0, 1) + T(1, 0)) >> 1; \
G(1, 0) = S(1, 0); \
\
B(1, 1) = \
B(0, 0) = \
B(0, 1) = \
B(1, 0) = S(0, 0);
#define BAYER_TO_RGB48_INTERPOLATE \
R(0, 0) = (T(-1, -1) + T(-1, 1) + T(1, -1) + T(1, 1)) >> 2; \
G(0, 0) = (T(-1, 0) + T( 0, -1) + T(0, 1) + T(1, 0)) >> 2; \
B(0, 0) = S(0, 0); \
\
R(0, 1) = (T(-1, 1) + T(1, 1)) >> 1; \
G(0, 1) = S(0, 1); \
B(0, 1) = (T(0, 0) + T(0, 2)) >> 1; \
\
R(1, 0) = (T(1, -1) + T(1, 1)) >> 1; \
G(1, 0) = S(1, 0); \
B(1, 0) = (T(0, 0) + T(2, 0)) >> 1; \
\
R(1, 1) = S(1, 1); \
G(1, 1) = (T(0, 1) + T(1, 0) + T(1, 2) + T(2, 1)) >> 2; \
B(1, 1) = (T(0, 0) + T(0, 2) + T(2, 0) + T(2, 2)) >> 2;
#else
#define BAYER_TO_RGB48_COPY \
R(0, 0) = \
R(0, 1) = \
R(1, 1) = \
R(1, 0) = S(1, 0); \
\
G(0, 0) = S(0, 0); \
G(1, 1) = S(1, 1); \
G(0, 1) = \
G(1, 0) = (T(0, 0) + T(1, 1)) >> 1; \
\
B(1, 1) = \
B(0, 0) = \
B(0, 1) = \
B(1, 0) = S(0, 1);
#define BAYER_TO_RGB48_INTERPOLATE \
R(0, 0) = (T(-1, 0) + T(1, 0)) >> 1; \
G(0, 0) = S(0, 0); \
B(0, 0) = (T(0, -1) + T(0, 1)) >> 1; \
\
R(0, 1) = (T(-1, 0) + T(-1, 2) + T(1, 0) + T(1, 2)) >> 2; \
G(0, 1) = (T(-1, 1) + T(0, 0) + T(0, 2) + T(1, 1)) >> 2; \
B(0, 1) = S(0, 1); \
\
R(1, 0) = S(1, 0); \
G(1, 0) = (T(0, 0) + T(1, -1) + T(1, 1) + T(2, 0)) >> 2; \
B(1, 0) = (T(0, -1) + T(0, 1) + T(2, -1) + T(2, 1)) >> 2; \
\
R(1, 1) = (T(1, 0) + T(1, 2)) >> 1; \
G(1, 1) = S(1, 1); \
B(1, 1) = (T(0, 1) + T(2, 1)) >> 1;
#endif
/**
* invoke ff_rgb24toyv12 for 2x2 pixels
*/
@@ -219,40 +153,6 @@ static void BAYER_RENAME(rgb24_interpolate)(const uint8_t *src, int src_stride,
}
}
static void BAYER_RENAME(rgb48_copy)(const uint8_t *src, int src_stride, uint8_t *ddst, int dst_stride, int width)
{
uint16_t *dst = (uint16_t *)ddst;
int i;
dst_stride /= 2;
for (i = 0 ; i < width; i+= 2) {
BAYER_TO_RGB48_COPY
src += 2 * BAYER_SIZEOF;
dst += 6;
}
}
static void BAYER_RENAME(rgb48_interpolate)(const uint8_t *src, int src_stride, uint8_t *ddst, int dst_stride, int width)
{
uint16_t *dst = (uint16_t *)ddst;
int i;
dst_stride /= 2;
BAYER_TO_RGB48_COPY
src += 2 * BAYER_SIZEOF;
dst += 6;
for (i = 2 ; i < width - 2; i+= 2) {
BAYER_TO_RGB48_INTERPOLATE
src += 2 * BAYER_SIZEOF;
dst += 6;
}
if (width > 2) {
BAYER_TO_RGB48_COPY
}
}
static void BAYER_RENAME(yv12_copy)(const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, int32_t *rgb2yuv)
{
uint8_t dst[12];
@@ -303,8 +203,6 @@ static void BAYER_RENAME(yv12_interpolate)(const uint8_t *src, int src_stride, u
#undef B
#undef BAYER_TO_RGB24_COPY
#undef BAYER_TO_RGB24_INTERPOLATE
#undef BAYER_TO_RGB48_COPY
#undef BAYER_TO_RGB48_INTERPOLATE
#undef BAYER_RENAME

View File

@@ -245,11 +245,9 @@ rgb48funcs(bgr, BE, AV_PIX_FMT_BGR48BE)
origin == AV_PIX_FMT_BGRA || \
origin == AV_PIX_FMT_ARGB || \
origin == AV_PIX_FMT_ABGR) \
? AV_RN32A(&src[(i) * 4]) \
: ((origin == AV_PIX_FMT_X2RGB10LE) \
? AV_RL32(&src[(i) * 4]) \
: (isBE(origin) ? AV_RB16(&src[(i) * 2]) \
: AV_RL16(&src[(i) * 2]))))
? AV_RN32A(&src[(i) * 4]) \
: (isBE(origin) ? AV_RB16(&src[(i) * 2]) \
: AV_RL16(&src[(i) * 2])))
static av_always_inline void rgb16_32ToY_c_template(int16_t *dst,
const uint8_t *src,
@@ -393,7 +391,6 @@ rgb16_32_wrapper(AV_PIX_FMT_BGR444BE, bgr12be, 0, 0, 0, 0, 0x000F, 0x00F0,
rgb16_32_wrapper(AV_PIX_FMT_RGB565BE, rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
rgb16_32_wrapper(AV_PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
rgb16_32_wrapper(AV_PIX_FMT_RGB444BE, rgb12be, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
rgb16_32_wrapper(AV_PIX_FMT_X2RGB10LE, rgb30le, 16, 6, 0, 0, 0x3FF00000, 0xFFC00, 0x3FF, 0, 0, 4, RGB2YUV_SHIFT + 6)
static void gbr24pToUV_half_c(uint8_t *_dstU, uint8_t *_dstV,
const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc,
@@ -924,7 +921,7 @@ static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_sr
int b = rdpx(src[1] + i);
int r = rdpx(src[2] + i);
dst[i] = (ry*r + gy*g + by*b + (16 << (RGB2YUV_SHIFT + bpc - 8)) + (1 << (RGB2YUV_SHIFT + shift - 15))) >> (RGB2YUV_SHIFT + shift - 14);
dst[i] = ((ry*r + gy*g + by*b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14));
}
}
@@ -957,8 +954,8 @@ static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV,
int b = rdpx(src[1] + i);
int r = rdpx(src[2] + i);
dstU[i] = (ru*r + gu*g + bu*b + (128 << (RGB2YUV_SHIFT + bpc - 8)) + (1 << (RGB2YUV_SHIFT + shift - 15))) >> (RGB2YUV_SHIFT + shift - 14);
dstV[i] = (rv*r + gv*g + bv*b + (128 << (RGB2YUV_SHIFT + bpc - 8)) + (1 << (RGB2YUV_SHIFT + shift - 15))) >> (RGB2YUV_SHIFT + shift - 14);
dstU[i] = (ru*r + gu*g + bu*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
dstV[i] = (rv*r + gv*g + bv*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
}
}
#undef rdpx
@@ -984,14 +981,15 @@ static av_always_inline void planar_rgbf32_to_uv(uint8_t *_dstU, uint8_t *_dstV,
uint16_t *dstV = (uint16_t *)_dstV;
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
int bpc = 16;
int shift = 14;
for (i = 0; i < width; i++) {
int g = av_clip_uint16(lrintf(65535.0f * rdpx(src[0] + i)));
int b = av_clip_uint16(lrintf(65535.0f * rdpx(src[1] + i)));
int r = av_clip_uint16(lrintf(65535.0f * rdpx(src[2] + i)));
dstU[i] = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
dstV[i] = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
dstU[i] = (ru*r + gu*g + bu*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
dstV[i] = (rv*r + gv*g + bv*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
}
}
@@ -1002,13 +1000,14 @@ static av_always_inline void planar_rgbf32_to_y(uint8_t *_dst, const uint8_t *_s
uint16_t *dst = (uint16_t *)_dst;
int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
int bpc = 16;
int shift = 14;
for (i = 0; i < width; i++) {
int g = av_clip_uint16(lrintf(65535.0f * rdpx(src[0] + i)));
int b = av_clip_uint16(lrintf(65535.0f * rdpx(src[1] + i)));
int r = av_clip_uint16(lrintf(65535.0f * rdpx(src[2] + i)));
dst[i] = (ry*r + gy*g + by*b + (0x2001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
dst[i] = ((ry*r + gy*g + by*b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14));
}
}
@@ -1342,9 +1341,6 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
case AV_PIX_FMT_RGB444BE:
c->chrToYV12 = rgb12beToUV_half_c;
break;
case AV_PIX_FMT_X2RGB10LE:
c->chrToYV12 = rgb30leToUV_half_c;
break;
}
} else {
switch (srcFormat) {
@@ -1426,9 +1422,6 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
case AV_PIX_FMT_RGB444BE:
c->chrToYV12 = rgb12beToUV_c;
break;
case AV_PIX_FMT_X2RGB10LE:
c->chrToYV12 = rgb30leToUV_c;
break;
}
}
@@ -1708,9 +1701,6 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
case AV_PIX_FMT_Y210LE:
c->lumToYV12 = y210le_Y_c;
break;
case AV_PIX_FMT_X2RGB10LE:
c->lumToYV12 =rgb30leToY_c;
break;
}
if (c->needAlpha) {
if (is16BPS(srcFormat) || isNBPS(srcFormat)) {

View File

@@ -30,7 +30,6 @@
#include "libavutil/cpu.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem_internal.h"
#include "libavutil/pixdesc.h"
#include "config.h"
#include "rgb2rgb.h"
@@ -181,8 +180,7 @@ yuv2planeX_16_c_template(const int16_t *filter, int filterSize,
}
}
static void yuv2p016cX_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither,
const int16_t *chrFilter, int chrFilterSize,
static void yuv2p016cX_c(SwsContext *c, const int16_t *chrFilter, int chrFilterSize,
const int16_t **chrUSrc, const int16_t **chrVSrc,
uint8_t *dest8, int chrDstW)
{
@@ -190,7 +188,7 @@ static void yuv2p016cX_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither,
const int32_t **uSrc = (const int32_t **)chrUSrc;
const int32_t **vSrc = (const int32_t **)chrVSrc;
int shift = 15;
int big_endian = dstFormat == AV_PIX_FMT_P016BE;
int big_endian = c->dstFormat == AV_PIX_FMT_P016BE;
int i, j;
for (i = 0; i < chrDstW; i++) {
@@ -404,11 +402,12 @@ static void yuv2plane1_8_c(const int16_t *src, uint8_t *dest, int dstW,
}
}
static void yuv2nv12cX_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither,
const int16_t *chrFilter, int chrFilterSize,
const int16_t **chrUSrc, const int16_t **chrVSrc,
uint8_t *dest, int chrDstW)
static void yuv2nv12cX_c(SwsContext *c, const int16_t *chrFilter, int chrFilterSize,
const int16_t **chrUSrc, const int16_t **chrVSrc,
uint8_t *dest, int chrDstW)
{
enum AVPixelFormat dstFormat = c->dstFormat;
const uint8_t *chrDither = c->chrDither8;
int i;
if (dstFormat == AV_PIX_FMT_NV12 ||
@@ -478,14 +477,13 @@ static void yuv2p010lX_c(const int16_t *filter, int filterSize,
}
}
static void yuv2p010cX_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither,
const int16_t *chrFilter, int chrFilterSize,
static void yuv2p010cX_c(SwsContext *c, const int16_t *chrFilter, int chrFilterSize,
const int16_t **chrUSrc, const int16_t **chrVSrc,
uint8_t *dest8, int chrDstW)
{
uint16_t *dest = (uint16_t*)dest8;
int shift = 17;
int big_endian = dstFormat == AV_PIX_FMT_P010BE;
int big_endian = c->dstFormat == AV_PIX_FMT_P010BE;
int i, j;
for (i = 0; i < chrDstW; i++) {
@@ -1604,13 +1602,6 @@ yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2,
dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
} else if (target == AV_PIX_FMT_X2RGB10) {
uint32_t *dest = (uint32_t *) _dest;
const uint32_t *r = (const uint32_t *) _r;
const uint32_t *g = (const uint32_t *) _g;
const uint32_t *b = (const uint32_t *) _b;
dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1];
dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2];
} else /* 8/4 bits */ {
uint8_t *dest = (uint8_t *) _dest;
const uint8_t *r = (const uint8_t *) _r;
@@ -1848,7 +1839,6 @@ YUV2RGBWRAPPER(yuv2rgb,, 12, AV_PIX_FMT_RGB444, 0)
YUV2RGBWRAPPER(yuv2rgb,, 8, AV_PIX_FMT_RGB8, 0)
YUV2RGBWRAPPER(yuv2rgb,, 4, AV_PIX_FMT_RGB4, 0)
YUV2RGBWRAPPER(yuv2rgb,, 4b, AV_PIX_FMT_RGB4_BYTE, 0)
YUV2RGBWRAPPER(yuv2, rgb, x2rgb10, AV_PIX_FMT_X2RGB10, 0)
static av_always_inline void yuv2rgb_write_full(SwsContext *c,
uint8_t *dest, int i, int Y, int A, int U, int V,
@@ -2984,12 +2974,6 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
*yuv2packed2 = yuv2rgb4b_2_c;
*yuv2packedX = yuv2rgb4b_X_c;
break;
case AV_PIX_FMT_X2RGB10LE:
case AV_PIX_FMT_X2RGB10BE:
*yuv2packed1 = yuv2x2rgb10_1_c;
*yuv2packed2 = yuv2x2rgb10_2_c;
*yuv2packedX = yuv2x2rgb10_X_c;
break;
}
}
switch (dstFormat) {

View File

@@ -21,8 +21,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/mem_internal.h"
static void FUNC(yuv2planeX_8_16)(const int16_t *filter, int filterSize,
const int16_t **src, uint8_t *dest,
const uint8_t *dither, int offset, int x)

View File

@@ -28,7 +28,6 @@
#include "libswscale/swscale_internal.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/mem_internal.h"
#include "yuv2rgb_altivec.h"
#include "libavutil/ppc/util_altivec.h"

View File

@@ -96,7 +96,6 @@
#include "libswscale/swscale_internal.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/mem_internal.h"
#include "libavutil/pixdesc.h"
#include "yuv2rgb_altivec.h"
@@ -284,16 +283,6 @@ static inline void cvtyuvtoRGB(SwsContext *c, vector signed short Y,
* ------------------------------------------------------------------------------
*/
#if !HAVE_VSX
static inline vector unsigned char vec_xl(signed long long offset, const ubyte *addr)
{
const vector unsigned char *v_addr = (const vector unsigned char *) (addr + offset);
vector unsigned char align_perm = vec_lvsl(offset, addr);
return (vector unsigned char) vec_perm(v_addr[0], v_addr[1], align_perm);
}
#endif /* !HAVE_VSX */
#define DEFCSP420_CVT(name, out_pixels) \
static int altivec_ ## name(SwsContext *c, const unsigned char **in, \
int *instrides, int srcSliceY, int srcSliceH, \
@@ -435,13 +424,13 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in, \
}
#define out_abgr(a, b, c, ptr) \
vec_mstrgb32(__typeof__(a), ((__typeof__(a)) vec_splat((__typeof__(a)){ 255 }, 0)), c, b, a, ptr)
vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255 }), c, b, a, ptr)
#define out_bgra(a, b, c, ptr) \
vec_mstrgb32(__typeof__(a), c, b, a, ((__typeof__(a)) vec_splat((__typeof__(a)){ 255 }, 0)), ptr)
vec_mstrgb32(__typeof__(a), c, b, a, ((__typeof__(a)) { 255 }), ptr)
#define out_rgba(a, b, c, ptr) \
vec_mstrgb32(__typeof__(a), a, b, c, ((__typeof__(a)) vec_splat((__typeof__(a)){ 255 }, 0)), ptr)
vec_mstrgb32(__typeof__(a), a, b, c, ((__typeof__(a)) { 255 }), ptr)
#define out_argb(a, b, c, ptr) \
vec_mstrgb32(__typeof__(a), ((__typeof__(a)) vec_splat((__typeof__(a)){ 255 }, 0)), a, b, c, ptr)
vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255 }), a, b, c, ptr)
#define out_rgb24(a, b, c, ptr) vec_mstrgb24(a, b, c, ptr)
#define out_bgr24(a, b, c, ptr) vec_mstbgr24(a, b, c, ptr)

View File

@@ -342,6 +342,7 @@ static inline void shuffle_bytes_0321_c(const uint8_t *src, uint8_t *dst,
}
}
#if !HAVE_BIGENDIAN
#define DEFINE_SHUFFLE_BYTES(name, a, b, c, d) \
static void shuffle_bytes_##name (const uint8_t *src, \
uint8_t *dst, int src_size) \
@@ -359,6 +360,7 @@ static void shuffle_bytes_##name (const uint8_t *src, \
DEFINE_SHUFFLE_BYTES(1230_c, 1, 2, 3, 0)
DEFINE_SHUFFLE_BYTES(3012_c, 3, 0, 1, 2)
DEFINE_SHUFFLE_BYTES(3210_c, 3, 2, 1, 0)
#endif
static inline void rgb24tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
{
@@ -967,10 +969,10 @@ static av_cold void rgb2rgb_init_c(void)
#else
shuffle_bytes_0321 = shuffle_bytes_0321_c;
shuffle_bytes_2103 = shuffle_bytes_2103_c;
#endif
shuffle_bytes_1230 = shuffle_bytes_1230_c;
shuffle_bytes_3012 = shuffle_bytes_3012_c;
shuffle_bytes_3210 = shuffle_bytes_3210_c;
#endif
rgb32tobgr16 = rgb32tobgr16_c;
rgb32tobgr15 = rgb32tobgr15_c;
yv12toyuy2 = yv12toyuy2_c;

View File

@@ -158,10 +158,14 @@ int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], int stride[4], int src
chrY + chrH,
lumY + lumH};
uint8_t *const src_[4] = {src[0] + (relative ? 0 : start[0]) * stride[0],
src[1] + (relative ? 0 : start[1]) * stride[1],
src[2] + (relative ? 0 : start[2]) * stride[2],
src[3] + (relative ? 0 : start[3]) * stride[3]};
s->width = srcW;
for (i = 0; i < 4 && src[i] != NULL; ++i) {
uint8_t *const src_i = src[i] + (relative ? 0 : start[i]) * stride[i];
for (i = 0; i < 4; ++i) {
int j;
int first = s->plane[i].sliceY;
int n = s->plane[i].available_lines;
@@ -171,13 +175,13 @@ int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], int stride[4], int src
if (start[i] >= first && n >= tot_lines) {
s->plane[i].sliceH = FFMAX(tot_lines, s->plane[i].sliceH);
for (j = 0; j < lines; j+= 1)
s->plane[i].line[start[i] - first + j] = src_i + j * stride[i];
s->plane[i].line[start[i] - first + j] = src_[i] + j * stride[i];
} else {
s->plane[i].sliceY = start[i];
lines = lines > n ? n : lines;
s->plane[i].sliceH = lines;
for (j = 0; j < lines; j+= 1)
s->plane[i].line[j] = src_i + j * stride[i];
s->plane[i].line[j] = src_[i] + j * stride[i];
}
}

View File

@@ -30,7 +30,6 @@
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem_internal.h"
#include "libavutil/pixdesc.h"
#include "config.h"
#include "rgb2rgb.h"

View File

@@ -29,7 +29,6 @@
#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/log.h"
#include "libavutil/mem_internal.h"
#include "libavutil/pixfmt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/ppc/util_altivec.h"
@@ -120,8 +119,7 @@ typedef void (*yuv2planarX_fn)(const int16_t *filter, int filterSize,
* Write one line of horizontally scaled chroma to interleaved output
* with multi-point vertical scaling between input pixels.
*
* @param dstFormat destination pixel format
* @param chrDither ordered dither array of type uint8_t and size 8
* @param c SWS scaling context
* @param chrFilter vertical chroma scaling coefficients, 12 bits [0,4096]
* @param chrUSrc scaled chroma (U) source data, 15 bits for 8-10-bit
* output, 19 bits for 16-bit output (in int32_t)
@@ -132,8 +130,7 @@ typedef void (*yuv2planarX_fn)(const int16_t *filter, int filterSize,
* output, this is in uint16_t
* @param dstW width of chroma planes
*/
typedef void (*yuv2interleavedX_fn)(enum AVPixelFormat dstFormat,
const uint8_t *chrDither,
typedef void (*yuv2interleavedX_fn)(struct SwsContext *c,
const int16_t *chrFilter,
int chrFilterSize,
const int16_t **chrUSrc,
@@ -765,13 +762,6 @@ static av_always_inline int isBayer(enum AVPixelFormat pix_fmt)
return !!(desc->flags & AV_PIX_FMT_FLAG_BAYER);
}
static av_always_inline int isBayer16BPS(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
av_assert0(desc);
return desc->comp[1].depth == 8;
}
static av_always_inline int isAnyRGB(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);

View File

@@ -30,7 +30,6 @@
#include "libavutil/cpu.h"
#include "libavutil/avutil.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem_internal.h"
#include "libavutil/bswap.h"
#include "libavutil/pixdesc.h"
#include "libavutil/avassert.h"
@@ -1327,55 +1326,6 @@ static int bayer_to_rgb24_wrapper(SwsContext *c, const uint8_t* src[], int srcSt
return srcSliceH;
}
static int bayer_to_rgb48_wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
uint8_t *dstPtr= dst[0] + srcSliceY * dstStride[0];
const uint8_t *srcPtr= src[0];
int i;
void (*copy) (const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
switch(c->srcFormat) {
#define CASE(pixfmt, prefix) \
case pixfmt: copy = bayer_##prefix##_to_rgb48_copy; \
interpolate = bayer_##prefix##_to_rgb48_interpolate; \
break;
CASE(AV_PIX_FMT_BAYER_BGGR8, bggr8)
CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)
CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)
CASE(AV_PIX_FMT_BAYER_RGGB8, rggb8)
CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)
CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)
CASE(AV_PIX_FMT_BAYER_GBRG8, gbrg8)
CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)
CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)
CASE(AV_PIX_FMT_BAYER_GRBG8, grbg8)
CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)
CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)
#undef CASE
default: return 0;
}
av_assert0(srcSliceH > 1);
copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->srcW);
srcPtr += 2 * srcStride[0];
dstPtr += 2 * dstStride[0];
for (i = 2; i < srcSliceH - 2; i += 2) {
interpolate(srcPtr, srcStride[0], dstPtr, dstStride[0], c->srcW);
srcPtr += 2 * srcStride[0];
dstPtr += 2 * dstStride[0];
}
if (i + 1 == srcSliceH) {
copy(srcPtr, -srcStride[0], dstPtr, -dstStride[0], c->srcW);
} else if (i < srcSliceH)
copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->srcW);
return srcSliceH;
}
static int bayer_to_yv12_wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
@@ -1806,7 +1756,7 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
int plane, i, j;
for (plane = 0; plane < 4 && dst[plane] != NULL; plane++) {
for (plane = 0; plane < 4; plane++) {
int length = (plane == 0 || plane == 3) ? c->srcW : AV_CEIL_RSHIFT(c->srcW, c->chrDstHSubSample);
int y = (plane == 0 || plane == 3) ? srcSliceY: AV_CEIL_RSHIFT(srcSliceY, c->chrDstVSubSample);
int height = (plane == 0 || plane == 3) ? srcSliceH: AV_CEIL_RSHIFT(srcSliceH, c->chrDstVSubSample);
@@ -1814,6 +1764,8 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
uint8_t *dstPtr = dst[plane] + dstStride[plane] * y;
int shiftonly = plane == 1 || plane == 2 || (!c->srcRange && plane == 0);
if (!dst[plane])
continue;
// ignore palette for GRAY8
if (plane == 1 && !dst[2]) continue;
if (!src[plane] || (plane == 1 && !src[2])) {
@@ -2095,8 +2047,6 @@ void ff_get_unscaled_swscale(SwsContext *c)
if (isBayer(srcFormat)) {
if (dstFormat == AV_PIX_FMT_RGB24)
c->swscale = bayer_to_rgb24_wrapper;
else if (dstFormat == AV_PIX_FMT_RGB48)
c->swscale = bayer_to_rgb48_wrapper;
else if (dstFormat == AV_PIX_FMT_YUV420P)
c->swscale = bayer_to_yv12_wrapper;
else if (!isBayer(dstFormat)) {

View File

@@ -1,4 +1,3 @@
/colorspace
/floatimg_cmp
/pixdesc_query
/swscale

View File

@@ -248,7 +248,7 @@ end:
if (dstStride[i])
av_free(dst[i]);
return !!res;
return res;
}
static void selfTest(const uint8_t * const ref[4], int refStride[4],
@@ -422,11 +422,7 @@ bad_option:
for (y = 0; y < H; y++)
for (x = 0; x < W * 4; x++)
rgb_data[ x + y * 4 * W] = av_lfg_get(&rand);
res = sws_scale(sws, rgb_src, rgb_stride, 0, H / 12, (uint8_t * const *) src, stride);
if (res < 0 || res != H) {
res = -1;
goto error;
}
sws_scale(sws, rgb_src, rgb_stride, 0, H / 12, (uint8_t * const *) src, stride);
sws_freeContext(sws);
av_free(rgb_data);

View File

@@ -271,7 +271,6 @@ static const FormatEntry format_entries[] = {
[AV_PIX_FMT_NV24] = { 1, 1 },
[AV_PIX_FMT_NV42] = { 1, 1 },
[AV_PIX_FMT_Y210LE] = { 1, 0 },
[AV_PIX_FMT_X2RGB10LE] = { 1, 1 },
};
int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
@@ -353,14 +352,13 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
emms_c(); // FIXME should not be required but IS (even for non-MMX versions)
// NOTE: the +3 is for the MMX(+1) / SSE(+3) scaler which reads over the end
if (!FF_ALLOC_TYPED_ARRAY(*filterPos, dstW + 3))
goto nomem;
FF_ALLOC_ARRAY_OR_GOTO(NULL, *filterPos, (dstW + 3), sizeof(**filterPos), fail);
if (FFABS(xInc - 0x10000) < 10 && srcPos == dstPos) { // unscaled
int i;
filterSize = 1;
if (!FF_ALLOCZ_TYPED_ARRAY(filter, dstW * filterSize))
goto nomem;
FF_ALLOCZ_ARRAY_OR_GOTO(NULL, filter,
dstW, sizeof(*filter) * filterSize, fail);
for (i = 0; i < dstW; i++) {
filter[i * filterSize] = fone;
@@ -370,8 +368,8 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
int i;
int64_t xDstInSrc;
filterSize = 1;
if (!FF_ALLOC_TYPED_ARRAY(filter, dstW * filterSize))
goto nomem;
FF_ALLOC_ARRAY_OR_GOTO(NULL, filter,
dstW, sizeof(*filter) * filterSize, fail);
xDstInSrc = ((dstPos*(int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7);
for (i = 0; i < dstW; i++) {
@@ -386,8 +384,8 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
int i;
int64_t xDstInSrc;
filterSize = 2;
if (!FF_ALLOC_TYPED_ARRAY(filter, dstW * filterSize))
goto nomem;
FF_ALLOC_ARRAY_OR_GOTO(NULL, filter,
dstW, sizeof(*filter) * filterSize, fail);
xDstInSrc = ((dstPos*(int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7);
for (i = 0; i < dstW; i++) {
@@ -427,8 +425,9 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
filterSize = FFMIN(filterSize, srcW - 2);
filterSize = FFMAX(filterSize, 1);
if (!FF_ALLOC_TYPED_ARRAY(filter, dstW * filterSize))
goto nomem;
FF_ALLOC_ARRAY_OR_GOTO(NULL, filter,
dstW, sizeof(*filter) * filterSize, fail);
xDstInSrc = ((dstPos*(int64_t)xInc)>>7) - ((srcPos*0x10000LL)>>7);
for (i = 0; i < dstW; i++) {
int xx = (xDstInSrc - (filterSize - 2) * (1LL<<16)) / (1 << 17);
@@ -526,8 +525,8 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
if (dstFilter)
filter2Size += dstFilter->length - 1;
av_assert0(filter2Size > 0);
if (!FF_ALLOCZ_TYPED_ARRAY(filter2, dstW * filter2Size))
goto nomem;
FF_ALLOCZ_ARRAY_OR_GOTO(NULL, filter2, dstW, filter2Size * sizeof(*filter2), fail);
for (i = 0; i < dstW; i++) {
int j, k;
@@ -612,7 +611,7 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
av_assert0(filterSize > 0);
filter = av_malloc_array(dstW, filterSize * sizeof(*filter));
if (!filter)
goto nomem;
goto fail;
if (filterSize >= MAX_FILTER_SIZE * 16 /
((flags & SWS_ACCURATE_RND) ? APCK_SIZE : 16)) {
ret = RETCODE_USE_CASCADE;
@@ -685,8 +684,8 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
// Note the +1 is for the MMX scaler which reads over the end
/* align at 16 for AltiVec (needed by hScale_altivec_real) */
if (!FF_ALLOCZ_TYPED_ARRAY(*outFilter, *outFilterSize * (dstW + 3)))
goto nomem;
FF_ALLOCZ_ARRAY_OR_GOTO(NULL, *outFilter,
(dstW + 3), *outFilterSize * sizeof(int16_t), fail);
/* normalize & store in outFilter */
for (i = 0; i < dstW; i++) {
@@ -722,13 +721,10 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
}
ret = 0;
goto done;
nomem:
ret = AVERROR(ENOMEM);
fail:
if(ret < 0)
av_log(NULL, ret == RETCODE_USE_CASCADE ? AV_LOG_DEBUG : AV_LOG_ERROR, "sws: initFilter failed\n");
done:
av_free(filter);
av_free(filter2);
return ret;
@@ -864,11 +860,6 @@ static void fill_xyztables(struct SwsContext *c)
}
}
static int range_override_needed(enum AVPixelFormat format)
{
return !isYUV(format) && !isGray(format);
}
int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
int srcRange, const int table[4], int dstRange,
int brightness, int contrast, int saturation)
@@ -881,9 +872,9 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
desc_dst = av_pix_fmt_desc_get(c->dstFormat);
desc_src = av_pix_fmt_desc_get(c->srcFormat);
if(range_override_needed(c->dstFormat))
if(!isYUV(c->dstFormat) && !isGray(c->dstFormat))
dstRange = 0;
if(range_override_needed(c->srcFormat))
if(!isYUV(c->srcFormat) && !isGray(c->srcFormat))
srcRange = 0;
if (c->srcRange != srcRange ||
@@ -1013,8 +1004,8 @@ int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table,
*inv_table = c->srcColorspaceTable;
*table = c->dstColorspaceTable;
*srcRange = range_override_needed(c->srcFormat) ? 1 : c->srcRange;
*dstRange = range_override_needed(c->dstFormat) ? 1 : c->dstRange;
*srcRange = c->srcRange;
*dstRange = c->dstRange;
*brightness = c->brightness;
*contrast = c->contrast;
*saturation = c->saturation;
@@ -1426,8 +1417,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
c->chrDstW = AV_CEIL_RSHIFT(dstW, c->chrDstHSubSample);
c->chrDstH = AV_CEIL_RSHIFT(dstH, c->chrDstVSubSample);
if (!FF_ALLOCZ_TYPED_ARRAY(c->formatConvBuffer, FFALIGN(srcW * 2 + 78, 16) * 2))
goto nomem;
FF_ALLOCZ_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW*2+78, 16) * 2, fail);
c->srcBpc = desc_src->comp[0].depth;
if (c->srcBpc < 8)
@@ -1496,7 +1486,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
srcW, srcH, tmpFmt,
flags, NULL, NULL, c->param);
if (!c->cascaded_context[0]) {
return AVERROR(ENOMEM);
return -1;
}
c->cascaded_context[1] = sws_getContext(srcW, srcH, tmpFmt,
@@ -1504,7 +1494,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
flags, srcFilter, dstFilter, c->param);
if (!c->cascaded_context[1])
return AVERROR(ENOMEM);
return -1;
c2 = c->cascaded_context[1];
c2->is_internal_gamma = 1;
@@ -1517,10 +1507,10 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
// to properly create the gamma convert FilterDescriptor
// we have to re-initialize it
ff_free_filters(c2);
if ((ret = ff_init_filters(c2)) < 0) {
if (ff_init_filters(c2) < 0) {
sws_freeContext(c2);
c->cascaded_context[1] = NULL;
return ret;
return -1;
}
c->cascaded_context[2] = NULL;
@@ -1534,16 +1524,15 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
dstW, dstH, dstFormat,
flags, NULL, NULL, c->param);
if (!c->cascaded_context[2])
return AVERROR(ENOMEM);
return -1;
}
return 0;
}
if (isBayer(srcFormat)) {
if (!unscaled ||
(dstFormat != AV_PIX_FMT_RGB24 && dstFormat != AV_PIX_FMT_YUV420P &&
dstFormat != AV_PIX_FMT_RGB48)) {
enum AVPixelFormat tmpFormat = isBayer16BPS(srcFormat) ? AV_PIX_FMT_RGB48 : AV_PIX_FMT_RGB24;
(dstFormat != AV_PIX_FMT_RGB24 && dstFormat != AV_PIX_FMT_YUV420P)) {
enum AVPixelFormat tmpFormat = AV_PIX_FMT_RGB24;
ret = av_image_alloc(c->cascaded_tmp, c->cascaded_tmpStride,
srcW, srcH, tmpFormat, 64);
@@ -1554,13 +1543,13 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
srcW, srcH, tmpFormat,
flags, srcFilter, NULL, c->param);
if (!c->cascaded_context[0])
return AVERROR(ENOMEM);
return -1;
c->cascaded_context[1] = sws_getContext(srcW, srcH, tmpFormat,
dstW, dstH, dstFormat,
flags, NULL, dstFilter, c->param);
if (!c->cascaded_context[1])
return AVERROR(ENOMEM);
return -1;
return 0;
}
}
@@ -1581,42 +1570,41 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
if (CONFIG_SWSCALE_ALPHA && isALPHA(srcFormat) && !isALPHA(dstFormat)) {
enum AVPixelFormat tmpFormat = alphaless_fmt(srcFormat);
if (tmpFormat != AV_PIX_FMT_NONE && c->alphablend != SWS_ALPHA_BLEND_NONE) {
if (!unscaled ||
dstFormat != tmpFormat ||
usesHFilter || usesVFilter ||
c->srcRange != c->dstRange
) {
c->cascaded_mainindex = 1;
ret = av_image_alloc(c->cascaded_tmp, c->cascaded_tmpStride,
srcW, srcH, tmpFormat, 64);
if (ret < 0)
return ret;
if (tmpFormat != AV_PIX_FMT_NONE && c->alphablend != SWS_ALPHA_BLEND_NONE)
if (!unscaled ||
dstFormat != tmpFormat ||
usesHFilter || usesVFilter ||
c->srcRange != c->dstRange
) {
c->cascaded_mainindex = 1;
ret = av_image_alloc(c->cascaded_tmp, c->cascaded_tmpStride,
srcW, srcH, tmpFormat, 64);
if (ret < 0)
return ret;
c->cascaded_context[0] = sws_alloc_set_opts(srcW, srcH, srcFormat,
srcW, srcH, tmpFormat,
flags, c->param);
if (!c->cascaded_context[0])
return AVERROR(EINVAL);
c->cascaded_context[0]->alphablend = c->alphablend;
ret = sws_init_context(c->cascaded_context[0], NULL , NULL);
if (ret < 0)
return ret;
c->cascaded_context[0] = sws_alloc_set_opts(srcW, srcH, srcFormat,
srcW, srcH, tmpFormat,
flags, c->param);
if (!c->cascaded_context[0])
return -1;
c->cascaded_context[0]->alphablend = c->alphablend;
ret = sws_init_context(c->cascaded_context[0], NULL , NULL);
if (ret < 0)
return ret;
c->cascaded_context[1] = sws_alloc_set_opts(srcW, srcH, tmpFormat,
dstW, dstH, dstFormat,
flags, c->param);
if (!c->cascaded_context[1])
return AVERROR(EINVAL);
c->cascaded_context[1] = sws_alloc_set_opts(srcW, srcH, tmpFormat,
dstW, dstH, dstFormat,
flags, c->param);
if (!c->cascaded_context[1])
return -1;
c->cascaded_context[1]->srcRange = c->srcRange;
c->cascaded_context[1]->dstRange = c->dstRange;
ret = sws_init_context(c->cascaded_context[1], srcFilter , dstFilter);
if (ret < 0)
return ret;
c->cascaded_context[1]->srcRange = c->srcRange;
c->cascaded_context[1]->dstRange = c->dstRange;
ret = sws_init_context(c->cascaded_context[1], srcFilter , dstFilter);
if (ret < 0)
return ret;
return 0;
}
return 0;
}
}
@@ -1669,11 +1657,10 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
return AVERROR(ENOMEM);
}
if (!FF_ALLOCZ_TYPED_ARRAY(c->hLumFilter, dstW / 8 + 8) ||
!FF_ALLOCZ_TYPED_ARRAY(c->hChrFilter, c->chrDstW / 4 + 8) ||
!FF_ALLOCZ_TYPED_ARRAY(c->hLumFilterPos, dstW / 2 / 8 + 8) ||
!FF_ALLOCZ_TYPED_ARRAY(c->hChrFilterPos, c->chrDstW / 2 / 4 + 8))
goto nomem;
FF_ALLOCZ_OR_GOTO(c, c->hLumFilter, (dstW / 8 + 8) * sizeof(int16_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->hChrFilter, (c->chrDstW / 4 + 8) * sizeof(int16_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->hLumFilterPos, (dstW / 2 / 8 + 8) * sizeof(int32_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->hChrFilterPos, (c->chrDstW / 2 / 4 + 8) * sizeof(int32_t), fail);
ff_init_hscaler_mmxext( dstW, c->lumXInc, c->lumMmxextFilterCode,
c->hLumFilter, (uint32_t*)c->hLumFilterPos, 8);
@@ -1684,7 +1671,6 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
if ( mprotect(c->lumMmxextFilterCode, c->lumMmxextFilterCodeSize, PROT_EXEC | PROT_READ) == -1
|| mprotect(c->chrMmxextFilterCode, c->chrMmxextFilterCodeSize, PROT_EXEC | PROT_READ) == -1) {
av_log(c, AV_LOG_ERROR, "mprotect failed, cannot use fast bilinear scaler\n");
ret = AVERROR(EINVAL);
goto fail;
}
#endif
@@ -1742,9 +1728,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
goto fail;
#if HAVE_ALTIVEC
if (!FF_ALLOC_TYPED_ARRAY(c->vYCoeffsBank, c->vLumFilterSize * c->dstH) ||
!FF_ALLOC_TYPED_ARRAY(c->vCCoeffsBank, c->vChrFilterSize * c->chrDstH))
goto nomem;
FF_ALLOC_OR_GOTO(c, c->vYCoeffsBank, sizeof(vector signed short) * c->vLumFilterSize * c->dstH, fail);
FF_ALLOC_OR_GOTO(c, c->vCCoeffsBank, sizeof(vector signed short) * c->vChrFilterSize * c->chrDstH, fail);
for (i = 0; i < c->vLumFilterSize * c->dstH; i++) {
int j;
@@ -1763,8 +1748,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
}
for (i = 0; i < 4; i++)
if (!FF_ALLOCZ_TYPED_ARRAY(c->dither_error[i], c->dstW + 2))
goto nomem;
FF_ALLOCZ_OR_GOTO(c, c->dither_error[i], (c->dstW+2) * sizeof(int), fail);
c->needAlpha = (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat)) ? 1 : 0;
@@ -1854,8 +1838,6 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
c->swscale = ff_getSwsFunc(c);
return ff_init_filters(c);
nomem:
ret = AVERROR(ENOMEM);
fail: // FIXME replace things by appropriate error codes
if (ret == RETCODE_USE_CASCADE) {
int tmpW = sqrt(srcW * (int64_t)dstW);
@@ -1877,16 +1859,16 @@ fail: // FIXME replace things by appropriate error codes
tmpW, tmpH, tmpFormat,
flags, srcFilter, NULL, c->param);
if (!c->cascaded_context[0])
return AVERROR(ENOMEM);
return -1;
c->cascaded_context[1] = sws_getContext(tmpW, tmpH, tmpFormat,
dstW, dstH, dstFormat,
flags, NULL, dstFilter, c->param);
if (!c->cascaded_context[1])
return AVERROR(ENOMEM);
return -1;
return 0;
}
return ret;
return -1;
}
SwsContext *sws_alloc_set_opts(int srcW, int srcH, enum AVPixelFormat srcFormat,

View File

@@ -27,7 +27,7 @@
#include "libavutil/version.h"
#define LIBSWSCALE_VERSION_MAJOR 5
#define LIBSWSCALE_VERSION_MINOR 9
#define LIBSWSCALE_VERSION_MINOR 7
#define LIBSWSCALE_VERSION_MICRO 100
#define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \

View File

@@ -92,7 +92,7 @@ static int chr_planar_vscale(SwsContext *c, SwsFilterDescriptor *desc, int slice
uint16_t *filter = inst->filter[0] + (inst->isMMX ? 0 : chrSliceY * inst->filter_size);
if (c->yuv2nv12cX) {
inst->pfn.yuv2interleavedX(c->dstFormat, c->chrDither8, filter, inst->filter_size, (const int16_t**)src1, (const int16_t**)src2, dst1[0], dstW);
inst->pfn.yuv2interleavedX(c, filter, inst->filter_size, (const int16_t**)src1, (const int16_t**)src2, dst1[0], dstW);
} else if (inst->filter_size == 1) {
inst->pfn.yuv2planar1((const int16_t*)src1[0], dst1[0], dstW, c->chrDither8, 0);
inst->pfn.yuv2planar1((const int16_t*)src2[0], dst2[0], dstW, c->chrDither8, 3);

View File

@@ -13,4 +13,3 @@ X86ASM-OBJS += x86/input.o \
x86/scale.o \
x86/rgb_2_rgb.o \
x86/yuv_2_rgb.o \
x86/yuv2yuvX.o \

View File

@@ -21,7 +21,6 @@
#include "../swscale_internal.h"
#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
#include "libavutil/mem_internal.h"
#define RET 0xC3 // near return opcode for x86
#define PREFETCH "prefetchnta"

View File

@@ -2,7 +2,6 @@
;* x86-optimized vertical line scaling functions
;* Copyright (c) 2011 Ronald S. Bultje <rsbultje@gmail.com>
;* Kieran Kunhya <kieran@kunhya.com>
;* (c) 2020 Nelson Gomez <nelson.gomez@microsoft.com>
;*
;* This file is part of FFmpeg.
;*
@@ -23,7 +22,7 @@
%include "libavutil/x86/x86util.asm"
SECTION_RODATA 32
SECTION_RODATA
minshort: times 8 dw 0x8000
yuv2yuvX_16_start: times 4 dd 0x4000 - 0x40000000
@@ -35,20 +34,9 @@ pd_4: times 4 dd 4
pd_4min0x40000:times 4 dd 4 - (0x40000)
pw_16: times 8 dw 16
pw_32: times 8 dw 32
pd_255: times 8 dd 255
pw_512: times 8 dw 512
pw_1024: times 8 dw 1024
yuv2nv12_shuffle_mask: times 2 db 0, 4, 8, 12, \
-1, -1, -1, -1, \
-1, -1, -1, -1, \
-1, -1, -1, -1
yuv2nv21_shuffle_mask: times 2 db 4, 0, 12, 8, \
-1, -1, -1, -1, \
-1, -1, -1, -1, \
-1, -1, -1, -1
yuv2nv12_permute_mask: dd 0, 4, 1, 2, 3, 5, 6, 7
SECTION .text
;-----------------------------------------------------------------------------
@@ -435,117 +423,3 @@ yuv2plane1_fn 9, 5, 3
yuv2plane1_fn 10, 5, 3
yuv2plane1_fn 16, 5, 3
%endif
%undef movsx
;-----------------------------------------------------------------------------
; AVX2 yuv2nv12cX implementation
;
; void ff_yuv2nv12cX_avx2(enum AVPixelFormat format, const uint8_t *dither,
; const int16_t *filter, int filterSize,
; const int16_t **u, const int16_t **v,
; uint8_t *dst, int dstWidth)
;
; void ff_yuv2nv21cX_avx2(enum AVPixelFormat format, const uint8_t *dither,
; const int16_t *filter, int filterSize,
; const int16_t **u, const int16_t **v,
; uint8_t *dst, int dstWidth)
;-----------------------------------------------------------------------------
%if ARCH_X86_64
%macro yuv2nv12cX_fn 1
cglobal %1cX, 8, 11, 13, tmp1, dither, filter, filterSize, u, v, dst, dstWidth
mov tmp1q, qword [ditherq]
movq xm0, tmp1q
ror tmp1q, 24
movq xm1, tmp1q
pmovzxbd m0, xm0
pslld m0, m0, 12 ; ditherLo
pmovzxbd m1, xm1
pslld m1, m1, 12 ; ditherHi
pxor m9, m9 ; uint8_min dwords
mova m10, [pd_255] ; uint8_max dwords
mova m11, [%1_shuffle_mask] ; shuffle_mask
mova m12, [yuv2nv12_permute_mask] ; permute mask
DEFINE_ARGS tmp1, tmp2, filter, filterSize, u, v, dst, dstWidth
xor r8q, r8q
nv12_outer_%1:
mova m2, m0 ; resultLo
mova m3, m1 ; resultHi
xor r9q, r9q
nv12_inner_%1:
movsx r10d, word [filterq + (2 * r9q)]
movd xm4, r10d
vpbroadcastd m4, xm4 ; filter
mov tmp1q, [uq + (gprsize * r9q)]
mova xm7, oword [tmp1q + 2 * r8q]
mov tmp2q, [vq + (gprsize * r9q)]
mova xm8, oword [tmp2q + 2 * r8q]
punpcklwd xm5, xm7, xm8
pmovsxwd m5, xm5 ; multiplicandsLo
punpckhwd xm6, xm7, xm8
pmovsxwd m6, xm6 ; multiplicandsHi
pmulld m7, m5, m4 ; mulResultLo
pmulld m8, m6, m4 ; mulResultHi
paddd m2, m2, m7 ; resultLo += mulResultLo
paddd m3, m3, m8 ; resultHi += mulResultHi
inc r9d
cmp r9d, filterSized
jl nv12_inner_%1
; end of inner loop
psrad m2, m2, 19
psrad m3, m3, 19
; Vectorized av_clip_uint8
pmaxsd m2, m2, m9
pmaxsd m3, m3, m9
pminsd m2, m2, m10
pminsd m3, m3, m10
; At this point we have clamped uint8s arranged in this order:
; m2: u1 0 0 0 v1 0 0 0 [...]
; m3: u5 0 0 0 v5 0 0 0 [...]
;
; First, we shuffle the bytes to make the bytes semi-contiguous.
; AVX-2 doesn't have cross-lane shuffling, so we'll end up with:
; m2: u1 v1 u2 v2 0 0 0 0 0 0 0 0 u3 v3 u4 v4
; m3: u5 v5 u6 v6 0 0 0 0 0 0 0 0 u7 v7 u8 v8
pshufb m2, m2, m11
pshufb m3, m3, m11
; To fix the cross-lane shuffling issue, we'll then use cross-lane
; permutation to combine the two segments
vpermd m2, m12, m2
vpermd m3, m12, m3
; Now we have the final results in the lower 8 bytes of each register
movq [dstq], xm2
movq [dstq + 8], xm3
add r8d, 8
add dstq, 16
cmp r8d, dstWidthd
jl nv12_outer_%1
RET
%endmacro
%if HAVE_AVX2_EXTERNAL
INIT_YMM avx2
yuv2nv12cX_fn yuv2nv12
yuv2nv12cX_fn yuv2nv21
%endif
%endif ; ARCH_X86_64

View File

@@ -30,8 +30,6 @@
#include "libavutil/x86/cpu.h"
#include "libavutil/cpu.h"
#include "libavutil/bswap.h"
#include "libavutil/mem_internal.h"
#include "libswscale/rgb2rgb.h"
#include "libswscale/swscale.h"
#include "libswscale/swscale_internal.h"
@@ -40,7 +38,12 @@
DECLARE_ASM_CONST(8, uint64_t, mmx_ff) = 0x00000000000000FFULL;
DECLARE_ASM_CONST(8, uint64_t, mmx_null) = 0x0000000000000000ULL;
DECLARE_ASM_CONST(8, uint64_t, mmx_one) = 0xFFFFFFFFFFFFFFFFULL;
DECLARE_ASM_CONST(8, uint64_t, mask32b) = 0x000000FF000000FFULL;
DECLARE_ASM_CONST(8, uint64_t, mask32g) = 0x0000FF000000FF00ULL;
DECLARE_ASM_CONST(8, uint64_t, mask32r) = 0x00FF000000FF0000ULL;
DECLARE_ASM_CONST(8, uint64_t, mask32a) = 0xFF000000FF000000ULL;
DECLARE_ASM_CONST(8, uint64_t, mask32) = 0x00FFFFFF00FFFFFFULL;
DECLARE_ASM_CONST(8, uint64_t, mask3216br) = 0x00F800F800F800F8ULL;
DECLARE_ASM_CONST(8, uint64_t, mask3216g) = 0x0000FC000000FC00ULL;
DECLARE_ASM_CONST(8, uint64_t, mask3215g) = 0x0000F8000000F800ULL;
@@ -51,6 +54,9 @@ DECLARE_ASM_CONST(8, uint64_t, mask24g) = 0xFF0000FF0000FF00ULL;
DECLARE_ASM_CONST(8, uint64_t, mask24r) = 0x0000FF0000FF0000ULL;
DECLARE_ASM_CONST(8, uint64_t, mask24l) = 0x0000000000FFFFFFULL;
DECLARE_ASM_CONST(8, uint64_t, mask24h) = 0x0000FFFFFF000000ULL;
DECLARE_ASM_CONST(8, uint64_t, mask24hh) = 0xffff000000000000ULL;
DECLARE_ASM_CONST(8, uint64_t, mask24hhh) = 0xffffffff00000000ULL;
DECLARE_ASM_CONST(8, uint64_t, mask24hhhh) = 0xffffffffffff0000ULL;
DECLARE_ASM_CONST(8, uint64_t, mask15b) = 0x001F001F001F001FULL; /* 00000000 00011111 xxB */
DECLARE_ASM_CONST(8, uint64_t, mask15rg) = 0x7FE07FE07FE07FE0ULL; /* 01111111 11100000 RGx */
DECLARE_ASM_CONST(8, uint64_t, mask15s) = 0xFFE0FFE0FFE0FFE0ULL;

View File

@@ -27,7 +27,6 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/x86/cpu.h"
#include "libavutil/cpu.h"
#include "libavutil/mem_internal.h"
#include "libavutil/pixdesc.h"
const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
@@ -44,6 +43,15 @@ const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
DECLARE_ASM_CONST(8, uint64_t, bF8)= 0xF8F8F8F8F8F8F8F8LL;
DECLARE_ASM_CONST(8, uint64_t, bFC)= 0xFCFCFCFCFCFCFCFCLL;
DECLARE_ASM_CONST(8, uint64_t, w10)= 0x0010001000100010LL;
DECLARE_ASM_CONST(8, uint64_t, w02)= 0x0002000200020002LL;
DECLARE_ASM_CONST(8, uint64_t, b16Mask)= 0x001F001F001F001FLL;
DECLARE_ASM_CONST(8, uint64_t, g16Mask)= 0x07E007E007E007E0LL;
DECLARE_ASM_CONST(8, uint64_t, r16Mask)= 0xF800F800F800F800LL;
DECLARE_ASM_CONST(8, uint64_t, b15Mask)= 0x001F001F001F001FLL;
DECLARE_ASM_CONST(8, uint64_t, g15Mask)= 0x03E003E003E003E0LL;
DECLARE_ASM_CONST(8, uint64_t, r15Mask)= 0x7C007C007C007C00LL;
DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24A) = 0x00FF0000FF0000FFLL;
DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24B) = 0xFF0000FF0000FF00LL;
@@ -187,56 +195,87 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY)
}
}
}
#if HAVE_MMXEXT
static void yuv2yuvX_sse3(const int16_t *filter, int filterSize,
const int16_t **src, uint8_t *dest, int dstW,
const uint8_t *dither, int offset)
{
if(((uintptr_t)dest) & 15){
yuv2yuvX_mmxext(filter, filterSize, src, dest, dstW, dither, offset);
return;
}
filterSize--;
#define MAIN_FUNCTION \
"pxor %%xmm0, %%xmm0 \n\t" \
"punpcklbw %%xmm0, %%xmm3 \n\t" \
"movd %4, %%xmm1 \n\t" \
"punpcklwd %%xmm1, %%xmm1 \n\t" \
"punpckldq %%xmm1, %%xmm1 \n\t" \
"punpcklqdq %%xmm1, %%xmm1 \n\t" \
"psllw $3, %%xmm1 \n\t" \
"paddw %%xmm1, %%xmm3 \n\t" \
"psraw $4, %%xmm3 \n\t" \
"movdqa %%xmm3, %%xmm4 \n\t" \
"movdqa %%xmm3, %%xmm7 \n\t" \
"movl %3, %%ecx \n\t" \
"mov %0, %%"FF_REG_d" \n\t"\
"mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
".p2align 4 \n\t" /* FIXME Unroll? */\
"1: \n\t"\
"movddup 8(%%"FF_REG_d"), %%xmm0 \n\t" /* filterCoeff */\
"movdqa (%%"FF_REG_S", %%"FF_REG_c", 2), %%xmm2 \n\t" /* srcData */\
"movdqa 16(%%"FF_REG_S", %%"FF_REG_c", 2), %%xmm5 \n\t" /* srcData */\
"add $16, %%"FF_REG_d" \n\t"\
"mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
"test %%"FF_REG_S", %%"FF_REG_S" \n\t"\
"pmulhw %%xmm0, %%xmm2 \n\t"\
"pmulhw %%xmm0, %%xmm5 \n\t"\
"paddw %%xmm2, %%xmm3 \n\t"\
"paddw %%xmm5, %%xmm4 \n\t"\
" jnz 1b \n\t"\
"psraw $3, %%xmm3 \n\t"\
"psraw $3, %%xmm4 \n\t"\
"packuswb %%xmm4, %%xmm3 \n\t"\
"movntdq %%xmm3, (%1, %%"FF_REG_c") \n\t"\
"add $16, %%"FF_REG_c" \n\t"\
"cmp %2, %%"FF_REG_c" \n\t"\
"movdqa %%xmm7, %%xmm3 \n\t" \
"movdqa %%xmm7, %%xmm4 \n\t" \
"mov %0, %%"FF_REG_d" \n\t"\
"mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
"jb 1b \n\t"
if (offset) {
__asm__ volatile(
"movq %5, %%xmm3 \n\t"
"movdqa %%xmm3, %%xmm4 \n\t"
"psrlq $24, %%xmm3 \n\t"
"psllq $40, %%xmm4 \n\t"
"por %%xmm4, %%xmm3 \n\t"
MAIN_FUNCTION
:: "g" (filter),
"r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset),
"m"(filterSize), "m"(((uint64_t *) dither)[0])
: XMM_CLOBBERS("%xmm0" , "%xmm1" , "%xmm2" , "%xmm3" , "%xmm4" , "%xmm5" , "%xmm7" ,)
"%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_c
);
} else {
__asm__ volatile(
"movq %5, %%xmm3 \n\t"
MAIN_FUNCTION
:: "g" (filter),
"r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset),
"m"(filterSize), "m"(((uint64_t *) dither)[0])
: XMM_CLOBBERS("%xmm0" , "%xmm1" , "%xmm2" , "%xmm3" , "%xmm4" , "%xmm5" , "%xmm7" ,)
"%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_c
);
}
}
#endif
#endif /* HAVE_INLINE_ASM */
#define YUV2YUVX_FUNC_MMX(opt, step) \
void ff_yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, int srcOffset, \
uint8_t *dest, int dstW, \
const uint8_t *dither, int offset); \
static void yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, \
const int16_t **src, uint8_t *dest, int dstW, \
const uint8_t *dither, int offset) \
{ \
if(dstW > 0) \
ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, dstW + offset, dither, offset); \
return; \
}
#define YUV2YUVX_FUNC(opt, step) \
void ff_yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, int srcOffset, \
uint8_t *dest, int dstW, \
const uint8_t *dither, int offset); \
static void yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, \
const int16_t **src, uint8_t *dest, int dstW, \
const uint8_t *dither, int offset) \
{ \
int remainder = (dstW % step); \
int pixelsProcessed = dstW - remainder; \
if(((uintptr_t)dest) & 15){ \
yuv2yuvX_mmx(filter, filterSize, src, dest, dstW, dither, offset); \
return; \
} \
if(pixelsProcessed > 0) \
ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, pixelsProcessed + offset, dither, offset); \
if(remainder > 0){ \
ff_yuv2yuvX_mmx(filter, filterSize - 1, pixelsProcessed, dest - offset, pixelsProcessed + remainder + offset, dither, offset); \
} \
return; \
}
#if HAVE_MMX_EXTERNAL
YUV2YUVX_FUNC_MMX(mmx, 16)
#endif
#if HAVE_MMXEXT_EXTERNAL
YUV2YUVX_FUNC_MMX(mmxext, 16)
#endif
#if HAVE_SSE3_EXTERNAL
YUV2YUVX_FUNC(sse3, 32)
#endif
#if HAVE_AVX2_EXTERNAL
YUV2YUVX_FUNC(avx2, 64)
#endif
#define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
SwsContext *c, int16_t *data, \
@@ -341,17 +380,6 @@ INPUT_FUNCS(sse2);
INPUT_FUNCS(ssse3);
INPUT_FUNCS(avx);
#if ARCH_X86_64
#define YUV2NV_DECL(fmt, opt) \
void ff_yuv2 ## fmt ## cX_ ## opt(enum AVPixelFormat format, const uint8_t *dither, \
const int16_t *filter, int filterSize, \
const int16_t **u, const int16_t **v, \
uint8_t *dst, int dstWidth)
YUV2NV_DECL(nv12, avx2);
YUV2NV_DECL(nv21, avx2);
#endif
av_cold void ff_sws_init_swscale_x86(SwsContext *c)
{
int cpu_flags = av_get_cpu_flags();
@@ -363,25 +391,11 @@ av_cold void ff_sws_init_swscale_x86(SwsContext *c)
#if HAVE_MMXEXT_INLINE
if (INLINE_MMXEXT(cpu_flags))
sws_init_swscale_mmxext(c);
#endif
if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND)) {
#if HAVE_MMX_EXTERNAL
if (EXTERNAL_MMX(cpu_flags))
c->yuv2planeX = yuv2yuvX_mmx;
#endif
#if HAVE_MMXEXT_EXTERNAL
if (EXTERNAL_MMXEXT(cpu_flags))
c->yuv2planeX = yuv2yuvX_mmxext;
#endif
#if HAVE_SSE3_EXTERNAL
if (EXTERNAL_SSE3(cpu_flags))
if (cpu_flags & AV_CPU_FLAG_SSE3){
if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND))
c->yuv2planeX = yuv2yuvX_sse3;
#endif
#if HAVE_AVX2_EXTERNAL
if (EXTERNAL_AVX2_FAST(cpu_flags))
c->yuv2planeX = yuv2yuvX_avx2;
#endif
}
#endif
#define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
if (c->srcBpc == 8) { \
@@ -566,21 +580,4 @@ switch(c->dstBpc){ \
break;
}
}
#if ARCH_X86_64
if (EXTERNAL_AVX2_FAST(cpu_flags)) {
switch (c->dstFormat) {
case AV_PIX_FMT_NV12:
case AV_PIX_FMT_NV24:
c->yuv2nv12cX = ff_yuv2nv12cX_avx2;
break;
case AV_PIX_FMT_NV21:
case AV_PIX_FMT_NV42:
c->yuv2nv12cX = ff_yuv2nv21cX_avx2;
break;
default:
break;
}
}
#endif
}

View File

@@ -38,6 +38,88 @@
#endif
#define MOVNTQ(a,b) REAL_MOVNTQ(a,b)
#if !COMPILE_TEMPLATE_MMXEXT
static av_always_inline void
dither_8to16(const uint8_t *srcDither, int rot)
{
if (rot) {
__asm__ volatile("pxor %%mm0, %%mm0\n\t"
"movq (%0), %%mm3\n\t"
"movq %%mm3, %%mm4\n\t"
"psrlq $24, %%mm3\n\t"
"psllq $40, %%mm4\n\t"
"por %%mm4, %%mm3\n\t"
"movq %%mm3, %%mm4\n\t"
"punpcklbw %%mm0, %%mm3\n\t"
"punpckhbw %%mm0, %%mm4\n\t"
:: "r"(srcDither)
);
} else {
__asm__ volatile("pxor %%mm0, %%mm0\n\t"
"movq (%0), %%mm3\n\t"
"movq %%mm3, %%mm4\n\t"
"punpcklbw %%mm0, %%mm3\n\t"
"punpckhbw %%mm0, %%mm4\n\t"
:: "r"(srcDither)
);
}
}
#endif
static void RENAME(yuv2yuvX)(const int16_t *filter, int filterSize,
const int16_t **src, uint8_t *dest, int dstW,
const uint8_t *dither, int offset)
{
dither_8to16(dither, offset);
filterSize--;
__asm__ volatile(
"movd %0, %%mm1\n\t"
"punpcklwd %%mm1, %%mm1\n\t"
"punpckldq %%mm1, %%mm1\n\t"
"psllw $3, %%mm1\n\t"
"paddw %%mm1, %%mm3\n\t"
"paddw %%mm1, %%mm4\n\t"
"psraw $4, %%mm3\n\t"
"psraw $4, %%mm4\n\t"
::"m"(filterSize)
);
__asm__ volatile(\
"movq %%mm3, %%mm6\n\t"
"movq %%mm4, %%mm7\n\t"
"movl %3, %%ecx\n\t"
"mov %0, %%"FF_REG_d" \n\t"\
"mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
".p2align 4 \n\t" /* FIXME Unroll? */\
"1: \n\t"\
"movq 8(%%"FF_REG_d"), %%mm0 \n\t" /* filterCoeff */\
"movq (%%"FF_REG_S", %%"FF_REG_c", 2), %%mm2 \n\t" /* srcData */\
"movq 8(%%"FF_REG_S", %%"FF_REG_c", 2), %%mm5 \n\t" /* srcData */\
"add $16, %%"FF_REG_d" \n\t"\
"mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
"test %%"FF_REG_S", %%"FF_REG_S" \n\t"\
"pmulhw %%mm0, %%mm2 \n\t"\
"pmulhw %%mm0, %%mm5 \n\t"\
"paddw %%mm2, %%mm3 \n\t"\
"paddw %%mm5, %%mm4 \n\t"\
" jnz 1b \n\t"\
"psraw $3, %%mm3 \n\t"\
"psraw $3, %%mm4 \n\t"\
"packuswb %%mm4, %%mm3 \n\t"
MOVNTQ2 " %%mm3, (%1, %%"FF_REG_c")\n\t"
"add $8, %%"FF_REG_c" \n\t"\
"cmp %2, %%"FF_REG_c" \n\t"\
"movq %%mm6, %%mm3\n\t"
"movq %%mm7, %%mm4\n\t"
"mov %0, %%"FF_REG_d" \n\t"\
"mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
"jb 1b \n\t"\
:: "g" (filter),
"r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset)
: "%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_c
);
}
#define YSCALEYUV2PACKEDX_UV \
__asm__ volatile(\
"xor %%"FF_REG_a", %%"FF_REG_a" \n\t"\
@@ -1435,6 +1517,7 @@ static av_cold void RENAME(sws_init_swscale)(SwsContext *c)
}
} else {
c->use_mmx_vfilter= 1;
c->yuv2planeX = RENAME(yuv2yuvX );
if (!(c->flags & SWS_FULL_CHR_H_INT)) {
switch (c->dstFormat) {
case AV_PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break;

View File

@@ -41,6 +41,14 @@
#define DITHER1XBPP // only for MMX
/* hope these constant values are cache line aligned */
DECLARE_ASM_CONST(8, uint64_t, mmx_00ffw) = 0x00ff00ff00ff00ffULL;
DECLARE_ASM_CONST(8, uint64_t, mmx_redmask) = 0xf8f8f8f8f8f8f8f8ULL;
DECLARE_ASM_CONST(8, uint64_t, mmx_grnmask) = 0xfcfcfcfcfcfcfcfcULL;
DECLARE_ASM_CONST(8, uint64_t, pb_e0) = 0xe0e0e0e0e0e0e0e0ULL;
DECLARE_ASM_CONST(8, uint64_t, pb_03) = 0x0303030303030303ULL;
DECLARE_ASM_CONST(8, uint64_t, pb_07) = 0x0707070707070707ULL;
//MMX versions
#if HAVE_MMX
#undef RENAME
@@ -51,18 +59,22 @@
#endif /* HAVE_MMX */
// MMXEXT versions
#if HAVE_MMXEXT
#undef RENAME
#undef COMPILE_TEMPLATE_MMXEXT
#define COMPILE_TEMPLATE_MMXEXT 1
#define RENAME(a) a ## _mmxext
#include "yuv2rgb_template.c"
#endif /* HAVE_MMXEXT */
//SSSE3 versions
#if HAVE_SSSE3
#undef RENAME
#undef COMPILE_TEMPLATE_MMXEXT
#define COMPILE_TEMPLATE_MMXEXT 0
#define RENAME(a) a ## _ssse3
#include "yuv2rgb_template.c"
#endif
#endif /* HAVE_X86ASM */

View File

@@ -268,9 +268,9 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters
por m2, m7
por m1, m6 ; g5 b5 r6 g6 b6 r7 g7 b7 r8 g8 b8 r9 g9 b9 r10 g10
por m2, m3 ; b10 r11 g11 b11 r12 g12 b12 r13 g13 b13 r14 g14 b14 r15 g15 b15
movu [imageq], m0
movu [imageq + 16], m1
movu [imageq + 32], m2
mova [imageq], m0
mova [imageq + 16], m1
mova [imageq + 32], m2
%endif ; mmsize = 16
%else ; PACK RGB15/16/32
packuswb m0, m1
@@ -286,7 +286,7 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters
%ifidn %1, yuv
pcmpeqd m3, m3 ; Set alpha empty
%else
movu m3, [pa_2indexq + 2 * indexq] ; Load alpha
mova m3, [pa_2indexq + 2 * indexq] ; Load alpha
%endif
mova m5, m_blue
mova m6, m_red
@@ -300,10 +300,10 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters
punpckhwd m_green, m_red
punpcklwd m5, m6
punpckhwd m_alpha, m6
movu [imageq + 0], m_blue
movu [imageq + 8 * time_num], m_green
movu [imageq + 16 * time_num], m5
movu [imageq + 24 * time_num], m_alpha
mova [imageq + 0], m_blue
mova [imageq + 8 * time_num], m_green
mova [imageq + 16 * time_num], m5
mova [imageq + 24 * time_num], m_alpha
%else ; PACK RGB15/16
%define depth 2
%if cpuflag(ssse3)
@@ -342,8 +342,8 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters
mova m2, m0
punpcklbw m0, m1
punpckhbw m2, m1
movu [imageq], m0
movu [imageq + 8 * time_num], m2
mova [imageq], m0
mova [imageq + 8 * time_num], m2
%endif ; PACK RGB15/16
%endif ; PACK RGB15/16/32

View File

@@ -793,8 +793,7 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
c->dstFormat == AV_PIX_FMT_NE(RGB444LE, RGB444BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR565LE, BGR565BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR555LE, BGR555BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR444LE, BGR444BE) ||
c->dstFormat == AV_PIX_FMT_NE(X2RGB10LE, X2RGB10BE);
c->dstFormat == AV_PIX_FMT_NE(BGR444LE, BGR444BE);
const int bpp = c->dstFormatBpp;
uint8_t *y_table;
uint16_t *y_table16;
@@ -966,32 +965,6 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
fill_table(c->table_bU, 1, cbu, y_table + yoffs);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 30:
rbase = 20;
gbase = 10;
bbase = 0;
needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
if (!needAlpha)
abase = 30;
ALLOC_YUV_TABLE(table_plane_size * 3 * 4);
y_table32 = c->yuvTable;
yb = -(384 << 16) - YUVRGB_TABLE_LUMA_HEADROOM*cy - oy;
for (i = 0; i < table_plane_size; i++) {
unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table32[i]= (yval << rbase) + (needAlpha ? 0 : (255u << abase));
y_table32[i + table_plane_size] = yval << gbase;
y_table32[i + 2 * table_plane_size] = yval << bbase;
yb += cy;
}
if (isNotNe) {
for (i = 0; i < table_plane_size * 3; i++)
y_table32[i] = av_bswap32(y_table32[i]);
}
fill_table(c->table_rV, 4, crv, y_table32 + yoffs);
fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + table_plane_size);
fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2 * table_plane_size);
fill_gv_table(c->table_gV, 4, cgv);
break;
case 32:
case 64:
base = (c->dstFormat == AV_PIX_FMT_RGB32_1 ||