33#define randomize_buffers(buf, size) \
36 for (j = 0; j < size; j+=4) \
37 AV_WN32(buf + j, rnd()); \
40static const uint8_t
width[] = {12, 16, 20, 32, 36, 128};
41static const struct {uint8_t
w,
h;}
planes[] = {
42 {12,16}, {16,16}, {20,23}, {32,18}, {8,128}, {128,128},
43 {1,1}, {1,4}, {3,8}, {13,16}, {21,9}, {63,7}, {127,5},
44 {13,1}, {32,1}, {66,1}
66 for (
i = 0;
i < 6;
i ++) {
89 declare_func(
void, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
91 int lumStride,
int chromStride,
int srcStride);
99 int srcStride = 2 *
w + (
w & 1 ? odd_tail : 0);
123#define MAX_LINE_SIZE 1920
124#define BUFSIZE (NUM_LINES * MAX_LINE_SIZE)
128 for (
size_t i = 0;
i < n;
i++) {
149 uint8_t *vdst,
int width,
int height,
int lumStride,
156 int negstride = input_size < 0;
157 const char *negstride_str = negstride ?
"_negstride" :
"";
159 int linesize =
width + 32;
164 uint8_t *dst_y_0 = buf_y_0;
165 uint8_t *dst_y_1 = buf_y_1;
166 uint8_t *dst_u_0 = buf_u_0;
167 uint8_t *dst_u_1 = buf_u_1;
168 uint8_t *dst_v_0 = buf_v_0;
169 uint8_t *dst_v_1 = buf_v_1;
174 dst_y_0 += (
height - 1) * linesize;
175 dst_y_1 += (
height - 1) * linesize;
176 dst_u_0 += ((
height / 2) - 1) * (linesize / 2);
177 dst_u_1 += ((
height / 2) - 1) * (linesize / 2);
178 dst_v_0 += ((
height / 2) - 1) * (linesize / 2);
179 dst_v_1 += ((
height / 2) - 1) * (linesize / 2);
184 memset(buf_y_0, 0xFF,
BUFSIZE);
185 memset(buf_y_1, 0xFF,
BUFSIZE);
186 memset(buf_u_0, 0xFF,
BUFSIZE / 4);
187 memset(buf_u_1, 0xFF,
BUFSIZE / 4);
188 memset(buf_v_0, 0xFF,
BUFSIZE / 4);
189 memset(buf_v_1, 0xFF,
BUFSIZE / 4);
192 linesize, linesize / 2, linesize * 3,
ctx->input_rgb2yuv_table);
194 linesize, linesize / 2, linesize * 3,
ctx->input_rgb2yuv_table);
200 linesize, linesize / 2, linesize * 3,
ctx->input_rgb2yuv_table);
217 uint8_t *
src0 = src0_buf + 1;
218 uint8_t *
src1 = src1_buf + 1;
219 uint8_t *dst0 = dst0_buf + 2;
220 uint8_t *dst1 = dst1_buf + 2;
223 uint8_t *,
int,
int,
int,
int,
int);
229 for (
int i = 0;
i <= 16;
i++) {
235 int src0_offset = 0, src0_stride =
MAX_STRIDE;
236 int src1_offset = 0, src1_stride =
MAX_STRIDE;
237 int dst_offset = 0, dst_stride = 2 *
MAX_STRIDE;
244 src0_offset = (
h-1)*src0_stride;
245 src0_stride = -src0_stride;
248 src1_offset = (
h-1)*src1_stride;
249 src1_stride = -src1_stride;
252 dst_offset = (
h-1)*dst_stride;
253 dst_stride = -dst_stride;
257 w,
h, src0_stride, src1_stride, dst_stride);
259 w,
h, src0_stride, src1_stride, dst_stride);
263 2 *
w + 2,
h + 1,
"dst");
286 uint8_t *
src = src_buf + 2;
287 uint8_t *dst0_u = dst0_u_buf + 1;
288 uint8_t *dst0_v = dst0_v_buf + 1;
289 uint8_t *dst1_u = dst1_u_buf + 1;
290 uint8_t *dst1_v = dst1_v_buf + 1;
294 int dst1Stride,
int dst2Stride);
299 for (
int i = 0;
i <= 16;
i++) {
305 int src_offset = 0, src_stride = 2 *
MAX_STRIDE;
306 int dst_u_offset = 0, dst_u_stride =
MAX_STRIDE;
307 int dst_v_offset = 0, dst_v_stride =
MAX_STRIDE;
316 src_offset = (
h-1)*src_stride;
317 src_stride = -src_stride;
320 dst_u_offset = (
h-1)*dst_u_stride;
321 dst_u_stride = -dst_u_stride;
324 dst_v_offset = (
h-1)*dst_v_stride;
325 dst_v_stride = -dst_v_stride;
328 call_ref(
src + src_offset, dst0_u + dst_u_offset, dst0_v + dst_v_offset,
329 w,
h, src_stride, dst_u_stride, dst_v_stride);
330 call_new(
src + src_offset, dst1_u + dst_u_offset, dst1_v + dst_v_offset,
331 w,
h, src_stride, dst_u_stride, dst_v_stride);
335 w + 1,
h + 1,
"dst_u");
337 w + 1,
h + 1,
"dst_v");
351#define MAX_LINE_SIZE 1920
372 const uint8_t *unused1,
const uint8_t *unused2,
int width,
388 const uint8_t *
src =
desc->nb_components == 3 ? src24 : src32;
395 if (memcmp(dst0_y, dst1_y,
w * 2))
398 if (
desc->nb_components == 3 ||
419 const uint8_t *
src1,
const uint8_t *
src2,
const uint8_t *src3,
420 int width, uint32_t *pal,
void *opq);
429 ctx->chrSrcHSubSample = (
i % 2) ? 0 : 1;
438 ctx->chrSrcHSubSample ?
"_half" :
"",
440 const uint8_t *
src =
desc->nb_components == 3 ? src24 : src32;
449 if (memcmp(dst0_u, dst1_u,
w * 2) || memcmp(dst0_v, dst1_v,
w * 2))
452 if (
desc->nb_components == 3 ||
470 const uint8_t *
src2,
const uint8_t *src3,
int width,
477 if (
desc->nb_components < 4)
493 if (memcmp(dst0_y, dst1_y,
w * 2))
540#define INPUT_SIZE 512
544 static const int alpha_values[] = {0, 2048, 4096};
548 const int16_t *chrUSrc[2],
const int16_t *chrVSrc[2],
549 const int16_t *alpSrc, uint8_t *dest,
550 int dstW,
int uvalpha,
int y);
553 const int16_t *chru[2];
554 const int16_t *chrv[2];
555 const int16_t *
alpha;
572 src_y[
i] &= 0x3FFF3FFF;
573 src_a[
i] &= 0x3FFF3FFF;
574 src_u[
i] &= 0x3FFF3FFF;
575 src_v[
i] &= 0x3FFF3FFF;
578 luma = (int16_t *)src_y;
579 alpha = (int16_t *)src_a;
580 for (
int i = 0;
i < 2;
i++) {
603 const int chr_alpha = alpha_values[ai];
611 if (memcmp(dst0, dst1, line_size))
624 static const int alpha_values[] = {0, 2048, 4096};
628 const int16_t *chrUSrc[2],
const int16_t *chrVSrc[2],
629 const int16_t *alpSrc[2], uint8_t *dest,
630 int dstW,
int yalpha,
int uvalpha,
int y);
632 const int16_t *luma[2];
633 const int16_t *chru[2];
634 const int16_t *chrv[2];
635 const int16_t *
alpha[2];
652 src_y[
i] &= 0x3FFF3FFF;
653 src_u[
i] &= 0x3FFF3FFF;
654 src_v[
i] &= 0x3FFF3FFF;
655 src_a[
i] &= 0x3FFF3FFF;
658 for (
int i = 0;
i < 2;
i++) {
683 const int lum_alpha = alpha_values[ai];
684 const int chr_alpha = alpha_values[ai];
692 if (memcmp(dst0, dst1, line_size))
705#define LARGEST_FILTER 16
706 static const int filter_sizes[] = {2, 16};
710 const int16_t **lumSrcx,
int lumFilterSize,
711 const int16_t *chrFilter,
const int16_t **chrUSrcx,
712 const int16_t **chrVSrcx,
int chrFilterSize,
713 const int16_t **alpSrcx, uint8_t *dest,
739 src_y[
i] &= 0x3FFF3FFF;
740 src_u[
i] &= 0x3FFF3FFF;
741 src_v[
i] &= 0x3FFF3FFF;
742 src_a[
i] &= 0x3FFF3FFF;
770 const int luma_filter_size = filter_sizes[fsi];
771 const int chr_filter_size = filter_sizes[fsi];
773 for (
int i = 0;
i < luma_filter_size;
i++)
774 luma_filter[
i] = -((1 << 12) / (luma_filter_size - 1));
775 luma_filter[
rnd() % luma_filter_size] = (1 << 13) - 1;
777 for (
int i = 0;
i < chr_filter_size;
i++)
778 chr_filter[
i] = -((1 << 12) / (chr_filter_size - 1));
779 chr_filter[
rnd() % chr_filter_size] = (1 << 13) - 1;
785 call_ref(
c, luma_filter, luma, luma_filter_size,
786 chr_filter, chru, chrv, chr_filter_size,
789 call_new(
c, luma_filter, luma, luma_filter_size,
790 chr_filter, chru, chrv, chr_filter_size,
793 if (memcmp(dst0, dst1, line_size))
796 bench_new(
c, luma_filter, luma, luma_filter_size,
797 chr_filter, chru, chrv, chr_filter_size,
816 report(
"shuffle_bytes_2103");
819 report(
"shuffle_bytes_0321");
822 report(
"shuffle_bytes_1230");
825 report(
"shuffle_bytes_3012");
828 report(
"shuffle_bytes_3210");
831 report(
"shuffle_bytes_3102");
834 report(
"shuffle_bytes_2013");
837 report(
"shuffle_bytes_1203");
840 report(
"shuffle_bytes_2130");
845 static const int rgb24_width[] = {3, 12, 24, 36, 48, 126, 1920 * 3};
847#define RGB24_BENCH_WIDTH (1920 * 3)
864 if (memcmp(dst0, dst1, rgb24_width[
i]))
869#undef RGB24_BENCH_WIDTH
887 static const int rgb32_widths[] = {4, 16, 32, 48, 64, 68, 100, 128, 1920 * 4};
888#define RGB32_BENCH_WIDTH (1920 * 4)
889#define RGB32_DST_SIZE (RGB32_BENCH_WIDTH * 3 / 4 + 8)
915#undef RGB32_BENCH_WIDTH
932 static const int rgb24to32_widths[] = {3, 12, 24, 36, 48, 51, 126, 1920 * 3};
933#define RGB24TO32_BENCH_WIDTH (1920 * 3)
934#define RGB24TO32_DST_SIZE (RGB24TO32_BENCH_WIDTH * 4 / 3 + 8)
947 int out_size = rgb24to32_widths[
i] * 4 / 3;
959#undef RGB24TO32_DST_SIZE
960#undef RGB24TO32_BENCH_WIDTH
974 report(
"interleave_bytes");
977 report(
"deinterleave_bytes");
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static AVFormatContext * ctx
#define i(width, name, range_min, range_max)
static void fn rgb2yuv(uint8_t *_yuv[3], const ptrdiff_t yuv_stride[3], int16_t *rgb[3], ptrdiff_t s, int w, int h, const int16_t rgb2yuv_coeffs[3][3][8], const int16_t yuv_offset[8])
common internal and external API header
#define AV_CEIL_RSHIFT(a, b)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define declare_func_emms
SwsContext * sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, enum AVPixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
Allocate and return an SwsContext.
void sws_freeContext(SwsContext *swsContext)
Free the swscaler context swsContext.
@ SWS_ACCURATE_RND
Force bit-exact output.
static const int16_t alpha[]
int(* func)(AVBPrint *dst, const char *in, const char *arg)
#define AV_CPU_FLAG_MMXEXT
SSE integer functions or AMD MMX ext.
#define AV_CPU_FLAG_MMX
standard MMX
static const struct @257111027162314367033347246032313251342043035002 planes[]
#define LOCAL_ALIGNED_32(t, v,...)
#define LOCAL_ALIGNED_16(t, v,...)
#define LOCAL_ALIGNED_8(t, v,...)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_BGR565BE
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ AV_PIX_FMT_RGB555BE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_BGR48BE
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
@ AV_PIX_FMT_RGB48BE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
@ AV_PIX_FMT_RGBA64BE
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
@ AV_PIX_FMT_RGB8
packed RGB 3:3:2, 8bpp, (msb)3R 3G 2B(lsb)
@ AV_PIX_FMT_RGBA64LE
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
@ AV_PIX_FMT_BGR8
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
@ AV_PIX_FMT_RGB444LE
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), little-endian, X=unused/undefined
@ AV_PIX_FMT_RGB4_BYTE
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
@ AV_PIX_FMT_BGR4_BYTE
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_BGRA64BE
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
@ AV_PIX_FMT_RGB565LE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
@ AV_PIX_FMT_RGB555LE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined
@ AV_PIX_FMT_BGR444BE
packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), big-endian, X=unused/undefined
@ AV_PIX_FMT_RGB48LE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
@ AV_PIX_FMT_BGR555BE
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), big-endian , X=unused/undefined
@ AV_PIX_FMT_BGR444LE
packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), little-endian, X=unused/undefined
@ AV_PIX_FMT_RGB444BE
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), big-endian, X=unused/undefined
@ AV_PIX_FMT_BGR48LE
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
@ AV_PIX_FMT_RGB565BE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
@ AV_PIX_FMT_BGR555LE
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined
@ AV_PIX_FMT_BGRA64LE
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_BGR565LE
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
@ AV_PIX_FMT_RGB4
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
@ AV_PIX_FMT_BGR4
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
#define AV_PIX_FMT_RGB32_1
void(* rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size)
av_cold void ff_sws_rgb2rgb_init(void)
void(* shuffle_bytes_2013)(const uint8_t *src, uint8_t *dst, int src_size)
void(* ff_rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, int width, int height, int lumStride, int chromStride, int srcStride, const int32_t *rgb2yuv)
Height should be a multiple of 2 and width should be a multiple of 2.
void(* shuffle_bytes_3102)(const uint8_t *src, uint8_t *dst, int src_size)
void(* uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
void(* shuffle_bytes_2130)(const uint8_t *src, uint8_t *dst, int src_size)
void(* shuffle_bytes_3210)(const uint8_t *src, uint8_t *dst, int src_size)
void(* shuffle_bytes_3012)(const uint8_t *src, uint8_t *dst, int src_size)
void(* shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size)
void(* shuffle_bytes_1203)(const uint8_t *src, uint8_t *dst, int src_size)
void(* yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
void(* interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst, int width, int height, int src1Stride, int src2Stride, int dstStride)
void(* shuffle_bytes_1230)(const uint8_t *src, uint8_t *dst, int src_size)
void(* rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
void(* deinterleaveBytes)(const uint8_t *src, uint8_t *dst1, uint8_t *dst2, int width, int height, int srcStride, int dst1Stride, int dst2Stride)
void(* yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
void(* uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
void(* rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
void(* shuffle_bytes_0321)(const uint8_t *src, uint8_t *dst, int src_size)
#define FF_ARRAY_ELEMS(a)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Main external API structure.
int dst_format
Destination pixel format.
int src_format
Source pixel format.
#define RGB24TO32_DST_SIZE
static const int input_sizes[]
static void check_rgb_to_uv(SwsContext *sws)
void checkasm_check_sw_rgb(void)
static void check_rgb_to_y(SwsContext *sws)
static int cmp_off_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int accuracy)
#define RGB32_BENCH_WIDTH
static void check_deinterleave_bytes(void)
#define randomize_buffers(buf, size)
static void check_yuv2packed2(void)
#define RGB24TO32_BENCH_WIDTH
static void check_rgba_to_a(SwsContext *sws)
#define RGB24_BENCH_WIDTH
static void check_rgb24toyv12(SwsContext *sws)
static void check_yuv2packedX(void)
static enum AVPixelFormat rgb_formats[]
static void check_yuv2packed1(void)
static void check_interleave_bytes(void)
static void check_interleaved_to_planar(void *func, const char *report, int odd_tail)
static void check_shuffle_bytes(void *func, const char *report)
void ff_sws_init_scale(SwsInternal *c)
static SwsInternal * sws_internal(const SwsContext *sws)
static int ref[MAX_W *MAX_W]
static enum AVPixelFormat packed_rgb_fmts[]