Go to the documentation of this file.
33 #define randomize_buffers(buf, size) \
36 for (j = 0; j < size; j+=4) \
37 AV_WN32(buf + j, rnd()); \
40 static const uint8_t
width[] = {12, 16, 20, 32, 36, 128};
41 static 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}
46 #define MAX_STRIDE 128
47 #define MAX_HEIGHT 128
65 for (
i = 0;
i < 6;
i ++) {
88 declare_func(
void, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
90 int lumStride,
int chromStride,
int srcStride);
98 int srcStride = 2 *
w + (
w & 1 ? odd_tail : 0);
122 #define MAX_LINE_SIZE 1920
123 #define BUFSIZE (NUM_LINES * MAX_LINE_SIZE)
127 for (
size_t i = 0;
i < n;
i++) {
148 uint8_t *vdst,
int width,
int height,
int lumStride,
155 int negstride = input_size < 0;
156 const char *negstride_str = negstride ?
"_negstride" :
"";
158 int linesize =
width + 32;
163 uint8_t *dst_y_0 = buf_y_0;
164 uint8_t *dst_y_1 = buf_y_1;
165 uint8_t *dst_u_0 = buf_u_0;
166 uint8_t *dst_u_1 = buf_u_1;
167 uint8_t *dst_v_0 = buf_v_0;
168 uint8_t *dst_v_1 = buf_v_1;
173 dst_y_0 += (
height - 1) * linesize;
174 dst_y_1 += (
height - 1) * linesize;
175 dst_u_0 += ((
height / 2) - 1) * (linesize / 2);
176 dst_u_1 += ((
height / 2) - 1) * (linesize / 2);
177 dst_v_0 += ((
height / 2) - 1) * (linesize / 2);
178 dst_v_1 += ((
height / 2) - 1) * (linesize / 2);
183 memset(buf_y_0, 0xFF,
BUFSIZE);
184 memset(buf_y_1, 0xFF,
BUFSIZE);
185 memset(buf_u_0, 0xFF,
BUFSIZE / 4);
186 memset(buf_u_1, 0xFF,
BUFSIZE / 4);
187 memset(buf_v_0, 0xFF,
BUFSIZE / 4);
188 memset(buf_v_1, 0xFF,
BUFSIZE / 4);
191 linesize, linesize / 2, linesize * 3,
ctx->input_rgb2yuv_table);
193 linesize, linesize / 2, linesize * 3,
ctx->input_rgb2yuv_table);
199 linesize, linesize / 2, linesize * 3,
ctx->input_rgb2yuv_table);
216 uint8_t *
src0 = src0_buf + 1;
217 uint8_t *
src1 = src1_buf + 1;
218 uint8_t *dst0 = dst0_buf + 2;
219 uint8_t *dst1 = dst1_buf + 2;
222 uint8_t *,
int,
int,
int,
int,
int);
228 for (
int i = 0;
i <= 16;
i++) {
234 int src0_offset = 0, src0_stride =
MAX_STRIDE;
235 int src1_offset = 0, src1_stride =
MAX_STRIDE;
236 int dst_offset = 0, dst_stride = 2 *
MAX_STRIDE;
243 src0_offset = (
h-1)*src0_stride;
244 src0_stride = -src0_stride;
247 src1_offset = (
h-1)*src1_stride;
248 src1_stride = -src1_stride;
251 dst_offset = (
h-1)*dst_stride;
252 dst_stride = -dst_stride;
256 w,
h, src0_stride, src1_stride, dst_stride);
258 w,
h, src0_stride, src1_stride, dst_stride);
262 2 *
w + 2,
h + 1,
"dst");
285 uint8_t *
src = src_buf + 2;
286 uint8_t *dst0_u = dst0_u_buf + 1;
287 uint8_t *dst0_v = dst0_v_buf + 1;
288 uint8_t *dst1_u = dst1_u_buf + 1;
289 uint8_t *dst1_v = dst1_v_buf + 1;
293 int dst1Stride,
int dst2Stride);
298 for (
int i = 0;
i <= 16;
i++) {
304 int src_offset = 0, src_stride = 2 *
MAX_STRIDE;
305 int dst_u_offset = 0, dst_u_stride =
MAX_STRIDE;
306 int dst_v_offset = 0, dst_v_stride =
MAX_STRIDE;
315 src_offset = (
h-1)*src_stride;
316 src_stride = -src_stride;
319 dst_u_offset = (
h-1)*dst_u_stride;
320 dst_u_stride = -dst_u_stride;
323 dst_v_offset = (
h-1)*dst_v_stride;
324 dst_v_stride = -dst_v_stride;
327 call_ref(
src + src_offset, dst0_u + dst_u_offset, dst0_v + dst_v_offset,
328 w,
h, src_stride, dst_u_stride, dst_v_stride);
329 call_new(
src + src_offset, dst1_u + dst_u_offset, dst1_v + dst_v_offset,
330 w,
h, src_stride, dst_u_stride, dst_v_stride);
334 w + 1,
h + 1,
"dst_u");
336 w + 1,
h + 1,
"dst_v");
350 #define MAX_LINE_SIZE 1920
371 const uint8_t *unused1,
const uint8_t *unused2,
int width,
387 const uint8_t *
src =
desc->nb_components == 3 ? src24 : src32;
394 if (memcmp(dst0_y, dst1_y,
w * 2))
397 if (
desc->nb_components == 3 ||
418 const uint8_t *
src1,
const uint8_t *
src2,
const uint8_t *src3,
419 int width, uint32_t *pal,
void *opq);
428 ctx->chrSrcHSubSample = (
i % 2) ? 0 : 1;
437 ctx->chrSrcHSubSample ?
"_half" :
"",
439 const uint8_t *
src =
desc->nb_components == 3 ? src24 : src32;
448 if (memcmp(dst0_u, dst1_u,
w * 2) || memcmp(dst0_v, dst1_v,
w * 2))
451 if (
desc->nb_components == 3 ||
469 const uint8_t *
src2,
const uint8_t *src3,
int width,
476 if (
desc->nb_components < 4)
492 if (memcmp(dst0_y, dst1_y,
w * 2))
539 #define INPUT_SIZE 512
543 static const int alpha_values[] = {0, 2048, 4096};
547 const int16_t *chrUSrc[2],
const int16_t *chrVSrc[2],
548 const int16_t *alpSrc, uint8_t *dest,
549 int dstW,
int uvalpha,
int y);
552 const int16_t *chru[2];
553 const int16_t *chrv[2];
554 const int16_t *
alpha;
571 src_y[
i] &= 0x3FFF3FFF;
572 src_a[
i] &= 0x3FFF3FFF;
573 src_u[
i] &= 0x3FFF3FFF;
574 src_v[
i] &= 0x3FFF3FFF;
577 luma = (int16_t *)src_y;
578 alpha = (int16_t *)src_a;
579 for (
int i = 0;
i < 2;
i++) {
602 const int chr_alpha = alpha_values[ai];
610 if (memcmp(dst0, dst1, line_size))
623 static const int alpha_values[] = {0, 2048, 4096};
627 const int16_t *chrUSrc[2],
const int16_t *chrVSrc[2],
628 const int16_t *alpSrc[2], uint8_t *dest,
629 int dstW,
int yalpha,
int uvalpha,
int y);
631 const int16_t *luma[2];
632 const int16_t *chru[2];
633 const int16_t *chrv[2];
634 const int16_t *
alpha[2];
651 src_y[
i] &= 0x3FFF3FFF;
652 src_u[
i] &= 0x3FFF3FFF;
653 src_v[
i] &= 0x3FFF3FFF;
654 src_a[
i] &= 0x3FFF3FFF;
657 for (
int i = 0;
i < 2;
i++) {
682 const int lum_alpha = alpha_values[ai];
683 const int chr_alpha = alpha_values[ai];
691 if (memcmp(dst0, dst1, line_size))
704 #define LARGEST_FILTER 16
705 static const int filter_sizes[] = {2, 16};
709 const int16_t **lumSrcx,
int lumFilterSize,
710 const int16_t *chrFilter,
const int16_t **chrUSrcx,
711 const int16_t **chrVSrcx,
int chrFilterSize,
712 const int16_t **alpSrcx, uint8_t *dest,
738 src_y[
i] &= 0x3FFF3FFF;
739 src_u[
i] &= 0x3FFF3FFF;
740 src_v[
i] &= 0x3FFF3FFF;
741 src_a[
i] &= 0x3FFF3FFF;
769 const int luma_filter_size = filter_sizes[fsi];
770 const int chr_filter_size = filter_sizes[fsi];
772 for (
int i = 0;
i < luma_filter_size;
i++)
773 luma_filter[
i] = -((1 << 12) / (luma_filter_size - 1));
774 luma_filter[
rnd() % luma_filter_size] = (1 << 13) - 1;
776 for (
int i = 0;
i < chr_filter_size;
i++)
777 chr_filter[
i] = -((1 << 12) / (chr_filter_size - 1));
778 chr_filter[
rnd() % chr_filter_size] = (1 << 13) - 1;
784 call_ref(
c, luma_filter, luma, luma_filter_size,
785 chr_filter, chru, chrv, chr_filter_size,
788 call_new(
c, luma_filter, luma, luma_filter_size,
789 chr_filter, chru, chrv, chr_filter_size,
792 if (memcmp(dst0, dst1, line_size))
795 bench_new(
c, luma_filter, luma, luma_filter_size,
796 chr_filter, chru, chrv, chr_filter_size,
806 #undef LARGEST_FILTER
815 report(
"shuffle_bytes_2103");
818 report(
"shuffle_bytes_0321");
821 report(
"shuffle_bytes_1230");
824 report(
"shuffle_bytes_3012");
827 report(
"shuffle_bytes_3210");
830 report(
"shuffle_bytes_3102");
833 report(
"shuffle_bytes_2013");
836 report(
"shuffle_bytes_1203");
839 report(
"shuffle_bytes_2130");
844 static const int rgb24_width[] = {3, 12, 24, 36, 48, 126, 1920 * 3};
846 #define RGB24_BENCH_WIDTH (1920 * 3)
863 if (memcmp(dst0, dst1, rgb24_width[
i]))
868 #undef RGB24_BENCH_WIDTH
886 static const int rgb32_widths[] = {4, 16, 32, 48, 64, 68, 100, 128, 1920 * 4};
887 #define RGB32_BENCH_WIDTH (1920 * 4)
888 #define RGB32_DST_SIZE (RGB32_BENCH_WIDTH * 3 / 4 + 8)
913 #undef RGB32_DST_SIZE
914 #undef RGB32_BENCH_WIDTH
931 static const int rgb24to32_widths[] = {3, 12, 24, 36, 48, 51, 126, 1920 * 3};
932 #define RGB24TO32_BENCH_WIDTH (1920 * 3)
933 #define RGB24TO32_DST_SIZE (RGB24TO32_BENCH_WIDTH * 4 / 3 + 8)
946 int out_size = rgb24to32_widths[
i] * 4 / 3;
958 #undef RGB24TO32_DST_SIZE
959 #undef RGB24TO32_BENCH_WIDTH
969 report(
"interleave_bytes");
972 report(
"deinterleave_bytes");
int(* func)(AVBPrint *dst, const char *in, const char *arg)
AVPixelFormat
Pixel format.
@ 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...
void(* rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
void(* shuffle_bytes_3012)(const uint8_t *src, uint8_t *dst, int src_size)
@ 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...
static const struct @608 planes[]
@ AV_PIX_FMT_RGB444LE
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), little-endian, X=unused/undefined
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_CPU_FLAG_MMXEXT
SSE integer functions or AMD MMX ext.
static enum AVPixelFormat rgb_formats[]
void sws_freeContext(SwsContext *swsContext)
Free the swscaler context swsContext.
@ 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...
void(* shuffle_bytes_3210)(const uint8_t *src, uint8_t *dst, int src_size)
static const char rgb2yuv[]
#define AV_PIX_FMT_RGB32_1
#define RGB32_BENCH_WIDTH
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)
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
static void check_shuffle_bytes(void *func, const char *report)
@ AV_PIX_FMT_RGB555BE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
static void check_yuv2packedX(void)
void(* shuffle_bytes_2130)(const uint8_t *src, uint8_t *dst, int src_size)
static void check_yuv2packed1(void)
#define RGB24TO32_BENCH_WIDTH
static int cmp_off_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int accuracy)
#define declare_func_emms
@ AV_PIX_FMT_BGR8
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
#define randomize_buffers(buf, size)
#define FF_ARRAY_ELEMS(a)
static void check_rgb_to_y(SwsContext *sws)
#define AV_CEIL_RSHIFT(a, b)
static const int input_sizes[]
void(* shuffle_bytes_1230)(const uint8_t *src, uint8_t *dst, int src_size)
#define LOCAL_ALIGNED_16(t, v,...)
static AVFormatContext * ctx
@ 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 ...
void(* shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
#define LOCAL_ALIGNED_8(t, v,...)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
void(* interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst, int width, int height, int src1Stride, int src2Stride, int dstStride)
void checkasm_check_sw_rgb(void)
@ AV_PIX_FMT_RGB565LE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
void(* shuffle_bytes_3102)(const uint8_t *src, uint8_t *dst, int src_size)
#define LOCAL_ALIGNED_32(t, v,...)
@ 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_BGR565LE
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
@ 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...
#define RGB24TO32_DST_SIZE
static void check_rgb24toyv12(SwsContext *sws)
@ AV_PIX_FMT_RGB8
packed RGB 3:3:2, 8bpp, (msb)3R 3G 2B(lsb)
av_cold void ff_sws_rgb2rgb_init(void)
@ 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 ...
@ AV_PIX_FMT_BGR555BE
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), big-endian , X=unused/undefined
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
@ AV_PIX_FMT_BGR4_BYTE
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
void(* rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size)
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
static void check_interleave_bytes(void)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define i(width, name, range_min, range_max)
@ AV_PIX_FMT_RGB444BE
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), big-endian, X=unused/undefined
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
void(* shuffle_bytes_0321)(const uint8_t *src, uint8_t *dst, int src_size)
@ AV_PIX_FMT_BGR444BE
packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), big-endian, X=unused/undefined
@ AV_PIX_FMT_BGR565BE
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
static void check_rgba_to_a(SwsContext *sws)
int dst_format
Destination pixel format.
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ 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...
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)
@ AV_PIX_FMT_RGB555LE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined
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.
@ 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...
static const int packed_rgb_fmts[]
void ff_sws_init_scale(SwsInternal *c)
static const uint8_t width[]
@ AV_PIX_FMT_RGB4_BYTE
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
#define AV_CPU_FLAG_MMX
standard MMX
static void check_rgb_to_uv(SwsContext *sws)
void(* deinterleaveBytes)(const uint8_t *src, uint8_t *dst1, uint8_t *dst2, int width, int height, int srcStride, int dst1Stride, int dst2Stride)
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.
static void check_yuv2packed2(void)
void(* shuffle_bytes_2013)(const uint8_t *src, uint8_t *dst, int src_size)
void(* shuffle_bytes_1203)(const uint8_t *src, uint8_t *dst, int src_size)
static int ref[MAX_W *MAX_W]
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
void(* rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
@ AV_PIX_FMT_RGB565BE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
int src_format
Source pixel format.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
@ AV_PIX_FMT_BGR555LE
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined
static const int16_t alpha[]
#define RGB24_BENCH_WIDTH
static SwsInternal * sws_internal(const SwsContext *sws)
@ SWS_ACCURATE_RND
Force bit-exact output.
static void check_deinterleave_bytes(void)
Main external API structure.
@ AV_PIX_FMT_BGR444LE
packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), little-endian, X=unused/undefined
static void check_interleaved_to_planar(void *func, const char *report, int odd_tail)
@ 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...