mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-07 11:13:41 +02:00
52f7026164
sse2 only operates on 2 lanes per loop for to_y and to_uv functions, due to the lack of pmulld instruction. Emulating pmulld with 2 pmuludq and shuffles proved too costly and made to_uv functions slower then the c implementation. For to_y on sse2 only float functions are generated, I was are not able outperform the c implementation on the integer pixel formats. For to_a on see4 only the float functions are generated. sse2 and sse4 generated nearly identical performing code on integer pixel formats, so only sse2/avx2 versions are generated. planar_gbrp_to_y_512_c: 1197.5 planar_gbrp_to_y_512_sse4: 444.5 planar_gbrp_to_y_512_avx2: 287.5 planar_gbrap_to_y_512_c: 1204.5 planar_gbrap_to_y_512_sse4: 447.5 planar_gbrap_to_y_512_avx2: 289.5 planar_gbrp9be_to_y_512_c: 1380.0 planar_gbrp9be_to_y_512_sse4: 543.5 planar_gbrp9be_to_y_512_avx2: 340.0 planar_gbrp9le_to_y_512_c: 1200.5 planar_gbrp9le_to_y_512_sse4: 442.0 planar_gbrp9le_to_y_512_avx2: 282.0 planar_gbrp10be_to_y_512_c: 1378.5 planar_gbrp10be_to_y_512_sse4: 544.0 planar_gbrp10be_to_y_512_avx2: 337.5 planar_gbrp10le_to_y_512_c: 1200.0 planar_gbrp10le_to_y_512_sse4: 448.0 planar_gbrp10le_to_y_512_avx2: 285.5 planar_gbrap10be_to_y_512_c: 1380.0 planar_gbrap10be_to_y_512_sse4: 542.0 planar_gbrap10be_to_y_512_avx2: 340.5 planar_gbrap10le_to_y_512_c: 1199.0 planar_gbrap10le_to_y_512_sse4: 446.0 planar_gbrap10le_to_y_512_avx2: 289.5 planar_gbrp12be_to_y_512_c: 10563.0 planar_gbrp12be_to_y_512_sse4: 542.5 planar_gbrp12be_to_y_512_avx2: 339.0 planar_gbrp12le_to_y_512_c: 1201.0 planar_gbrp12le_to_y_512_sse4: 440.5 planar_gbrp12le_to_y_512_avx2: 286.0 planar_gbrap12be_to_y_512_c: 1701.5 planar_gbrap12be_to_y_512_sse4: 917.0 planar_gbrap12be_to_y_512_avx2: 338.5 planar_gbrap12le_to_y_512_c: 1201.0 planar_gbrap12le_to_y_512_sse4: 444.5 planar_gbrap12le_to_y_512_avx2: 288.0 planar_gbrp14be_to_y_512_c: 1370.5 planar_gbrp14be_to_y_512_sse4: 545.0 planar_gbrp14be_to_y_512_avx2: 338.5 planar_gbrp14le_to_y_512_c: 1199.0 planar_gbrp14le_to_y_512_sse4: 444.0 planar_gbrp14le_to_y_512_avx2: 279.5 planar_gbrp16be_to_y_512_c: 1364.0 planar_gbrp16be_to_y_512_sse4: 544.5 planar_gbrp16be_to_y_512_avx2: 339.5 planar_gbrp16le_to_y_512_c: 1201.0 planar_gbrp16le_to_y_512_sse4: 445.5 planar_gbrp16le_to_y_512_avx2: 280.5 planar_gbrap16be_to_y_512_c: 1377.0 planar_gbrap16be_to_y_512_sse4: 545.0 planar_gbrap16be_to_y_512_avx2: 338.5 planar_gbrap16le_to_y_512_c: 1201.0 planar_gbrap16le_to_y_512_sse4: 442.0 planar_gbrap16le_to_y_512_avx2: 279.0 planar_gbrpf32be_to_y_512_c: 4113.0 planar_gbrpf32be_to_y_512_sse2: 2438.0 planar_gbrpf32be_to_y_512_sse4: 1068.0 planar_gbrpf32be_to_y_512_avx2: 904.5 planar_gbrpf32le_to_y_512_c: 3818.5 planar_gbrpf32le_to_y_512_sse2: 2024.5 planar_gbrpf32le_to_y_512_sse4: 1241.5 planar_gbrpf32le_to_y_512_avx2: 657.0 planar_gbrapf32be_to_y_512_c: 3707.0 planar_gbrapf32be_to_y_512_sse2: 2444.0 planar_gbrapf32be_to_y_512_sse4: 1077.0 planar_gbrapf32be_to_y_512_avx2: 909.0 planar_gbrapf32le_to_y_512_c: 3822.0 planar_gbrapf32le_to_y_512_sse2: 2024.5 planar_gbrapf32le_to_y_512_sse4: 1176.0 planar_gbrapf32le_to_y_512_avx2: 658.5 planar_gbrp_to_uv_512_c: 2325.8 planar_gbrp_to_uv_512_sse2: 1726.8 planar_gbrp_to_uv_512_sse4: 771.8 planar_gbrp_to_uv_512_avx2: 506.8 planar_gbrap_to_uv_512_c: 2281.8 planar_gbrap_to_uv_512_sse2: 1726.3 planar_gbrap_to_uv_512_sse4: 768.3 planar_gbrap_to_uv_512_avx2: 496.3 planar_gbrp9be_to_uv_512_c: 2336.8 planar_gbrp9be_to_uv_512_sse2: 1924.8 planar_gbrp9be_to_uv_512_sse4: 852.3 planar_gbrp9be_to_uv_512_avx2: 552.8 planar_gbrp9le_to_uv_512_c: 2270.3 planar_gbrp9le_to_uv_512_sse2: 1512.3 planar_gbrp9le_to_uv_512_sse4: 764.3 planar_gbrp9le_to_uv_512_avx2: 491.3 planar_gbrp10be_to_uv_512_c: 2281.8 planar_gbrp10be_to_uv_512_sse2: 1917.8 planar_gbrp10be_to_uv_512_sse4: 855.3 planar_gbrp10be_to_uv_512_avx2: 541.3 planar_gbrp10le_to_uv_512_c: 2269.8 planar_gbrp10le_to_uv_512_sse2: 1515.3 planar_gbrp10le_to_uv_512_sse4: 759.8 planar_gbrp10le_to_uv_512_avx2: 487.8 planar_gbrap10be_to_uv_512_c: 2382.3 planar_gbrap10be_to_uv_512_sse2: 1924.8 planar_gbrap10be_to_uv_512_sse4: 855.3 planar_gbrap10be_to_uv_512_avx2: 540.8 planar_gbrap10le_to_uv_512_c: 2382.3 planar_gbrap10le_to_uv_512_sse2: 1512.3 planar_gbrap10le_to_uv_512_sse4: 759.3 planar_gbrap10le_to_uv_512_avx2: 484.8 planar_gbrp12be_to_uv_512_c: 2283.8 planar_gbrp12be_to_uv_512_sse2: 1936.8 planar_gbrp12be_to_uv_512_sse4: 858.3 planar_gbrp12be_to_uv_512_avx2: 541.3 planar_gbrp12le_to_uv_512_c: 2278.8 planar_gbrp12le_to_uv_512_sse2: 1507.3 planar_gbrp12le_to_uv_512_sse4: 760.3 planar_gbrp12le_to_uv_512_avx2: 485.8 planar_gbrap12be_to_uv_512_c: 2385.3 planar_gbrap12be_to_uv_512_sse2: 1927.8 planar_gbrap12be_to_uv_512_sse4: 855.3 planar_gbrap12be_to_uv_512_avx2: 539.8 planar_gbrap12le_to_uv_512_c: 2377.3 planar_gbrap12le_to_uv_512_sse2: 1516.3 planar_gbrap12le_to_uv_512_sse4: 759.3 planar_gbrap12le_to_uv_512_avx2: 484.8 planar_gbrp14be_to_uv_512_c: 2283.8 planar_gbrp14be_to_uv_512_sse2: 1935.3 planar_gbrp14be_to_uv_512_sse4: 852.3 planar_gbrp14be_to_uv_512_avx2: 540.3 planar_gbrp14le_to_uv_512_c: 2276.8 planar_gbrp14le_to_uv_512_sse2: 1514.8 planar_gbrp14le_to_uv_512_sse4: 762.3 planar_gbrp14le_to_uv_512_avx2: 484.8 planar_gbrp16be_to_uv_512_c: 2383.3 planar_gbrp16be_to_uv_512_sse2: 1881.8 planar_gbrp16be_to_uv_512_sse4: 852.3 planar_gbrp16be_to_uv_512_avx2: 541.8 planar_gbrp16le_to_uv_512_c: 2378.3 planar_gbrp16le_to_uv_512_sse2: 1476.8 planar_gbrp16le_to_uv_512_sse4: 765.3 planar_gbrp16le_to_uv_512_avx2: 485.8 planar_gbrap16be_to_uv_512_c: 2382.3 planar_gbrap16be_to_uv_512_sse2: 1886.3 planar_gbrap16be_to_uv_512_sse4: 853.8 planar_gbrap16be_to_uv_512_avx2: 550.8 planar_gbrap16le_to_uv_512_c: 2381.8 planar_gbrap16le_to_uv_512_sse2: 1488.3 planar_gbrap16le_to_uv_512_sse4: 765.3 planar_gbrap16le_to_uv_512_avx2: 491.8 planar_gbrpf32be_to_uv_512_c: 4863.0 planar_gbrpf32be_to_uv_512_sse2: 3347.5 planar_gbrpf32be_to_uv_512_sse4: 1800.0 planar_gbrpf32be_to_uv_512_avx2: 1199.0 planar_gbrpf32le_to_uv_512_c: 4725.0 planar_gbrpf32le_to_uv_512_sse2: 2753.0 planar_gbrpf32le_to_uv_512_sse4: 1474.5 planar_gbrpf32le_to_uv_512_avx2: 927.5 planar_gbrapf32be_to_uv_512_c: 4859.0 planar_gbrapf32be_to_uv_512_sse2: 3269.0 planar_gbrapf32be_to_uv_512_sse4: 1802.0 planar_gbrapf32be_to_uv_512_avx2: 1201.5 planar_gbrapf32le_to_uv_512_c: 6338.0 planar_gbrapf32le_to_uv_512_sse2: 2756.5 planar_gbrapf32le_to_uv_512_sse4: 1476.0 planar_gbrapf32le_to_uv_512_avx2: 908.5 planar_gbrap_to_a_512_c: 383.3 planar_gbrap_to_a_512_sse2: 66.8 planar_gbrap_to_a_512_avx2: 43.8 planar_gbrap10be_to_a_512_c: 601.8 planar_gbrap10be_to_a_512_sse2: 86.3 planar_gbrap10be_to_a_512_avx2: 34.8 planar_gbrap10le_to_a_512_c: 602.3 planar_gbrap10le_to_a_512_sse2: 48.8 planar_gbrap10le_to_a_512_avx2: 31.3 planar_gbrap12be_to_a_512_c: 601.8 planar_gbrap12be_to_a_512_sse2: 111.8 planar_gbrap12be_to_a_512_avx2: 41.3 planar_gbrap12le_to_a_512_c: 385.8 planar_gbrap12le_to_a_512_sse2: 75.3 planar_gbrap12le_to_a_512_avx2: 39.8 planar_gbrap16be_to_a_512_c: 386.8 planar_gbrap16be_to_a_512_sse2: 79.8 planar_gbrap16be_to_a_512_avx2: 31.3 planar_gbrap16le_to_a_512_c: 600.3 planar_gbrap16le_to_a_512_sse2: 40.3 planar_gbrap16le_to_a_512_avx2: 30.3 planar_gbrapf32be_to_a_512_c: 1148.8 planar_gbrapf32be_to_a_512_sse2: 611.3 planar_gbrapf32be_to_a_512_sse4: 234.8 planar_gbrapf32be_to_a_512_avx2: 183.3 planar_gbrapf32le_to_a_512_c: 851.3 planar_gbrapf32le_to_a_512_sse2: 263.3 planar_gbrapf32le_to_a_512_sse4: 199.3 planar_gbrapf32le_to_a_512_avx2: 156.8 Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
415 lines
15 KiB
C
415 lines
15 KiB
C
/*
|
|
*
|
|
* This file is part of FFmpeg.
|
|
*
|
|
* FFmpeg is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with FFmpeg; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*/
|
|
|
|
#include <string.h>
|
|
|
|
#include "libavutil/common.h"
|
|
#include "libavutil/intreadwrite.h"
|
|
#include "libavutil/mem_internal.h"
|
|
#include "libavutil/pixdesc.h"
|
|
|
|
#include "libswscale/swscale.h"
|
|
#include "libswscale/swscale_internal.h"
|
|
|
|
#include "checkasm.h"
|
|
|
|
#define randomize_buffers(buf, size) \
|
|
do { \
|
|
int j; \
|
|
for (j = 0; j < size; j+=4) \
|
|
AV_WN32(buf + j, rnd()); \
|
|
} while (0)
|
|
|
|
static const int planar_fmts[] = {
|
|
AV_PIX_FMT_GBRP,
|
|
AV_PIX_FMT_GBRP9BE,
|
|
AV_PIX_FMT_GBRP9LE,
|
|
AV_PIX_FMT_GBRP10BE,
|
|
AV_PIX_FMT_GBRP10LE,
|
|
AV_PIX_FMT_GBRP12BE,
|
|
AV_PIX_FMT_GBRP12LE,
|
|
AV_PIX_FMT_GBRP14BE,
|
|
AV_PIX_FMT_GBRP14LE,
|
|
AV_PIX_FMT_GBRAP,
|
|
AV_PIX_FMT_GBRAP10BE,
|
|
AV_PIX_FMT_GBRAP10LE,
|
|
AV_PIX_FMT_GBRAP12BE,
|
|
AV_PIX_FMT_GBRAP12LE,
|
|
AV_PIX_FMT_GBRP16BE,
|
|
AV_PIX_FMT_GBRP16LE,
|
|
AV_PIX_FMT_GBRAP16BE,
|
|
AV_PIX_FMT_GBRAP16LE,
|
|
AV_PIX_FMT_GBRPF32BE,
|
|
AV_PIX_FMT_GBRPF32LE,
|
|
AV_PIX_FMT_GBRAPF32BE,
|
|
AV_PIX_FMT_GBRAPF32LE
|
|
};
|
|
|
|
static void check_output_yuv2gbrp(void)
|
|
{
|
|
struct SwsContext *ctx;
|
|
const AVPixFmtDescriptor *desc;
|
|
int fmi, fsi, isi, i;
|
|
int dstW, byte_size, luma_filter_size, chr_filter_size;
|
|
#define LARGEST_FILTER 16
|
|
#define FILTER_SIZES 4
|
|
static const int filter_sizes[] = {1, 4, 8, 16};
|
|
#define LARGEST_INPUT_SIZE 512
|
|
#define INPUT_SIZES 6
|
|
static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
|
|
uint8_t *dst0[4];
|
|
uint8_t *dst1[4];
|
|
|
|
declare_func(void, void *c, const int16_t *lumFilter,
|
|
const int16_t **lumSrcx, int lumFilterSize,
|
|
const int16_t *chrFilter, const int16_t **chrUSrcx,
|
|
const int16_t **chrVSrcx, int chrFilterSize,
|
|
const int16_t **alpSrcx, uint8_t **dest,
|
|
int dstW, int y);
|
|
|
|
const int16_t *luma[LARGEST_FILTER];
|
|
const int16_t *chru[LARGEST_FILTER];
|
|
const int16_t *chrv[LARGEST_FILTER];
|
|
const int16_t *alpha[LARGEST_FILTER];
|
|
|
|
LOCAL_ALIGNED_8(int16_t, luma_filter, [LARGEST_FILTER]);
|
|
LOCAL_ALIGNED_8(int16_t, chr_filter, [LARGEST_FILTER]);
|
|
|
|
LOCAL_ALIGNED_8(int32_t, src_y, [LARGEST_FILTER * LARGEST_INPUT_SIZE]);
|
|
LOCAL_ALIGNED_8(int32_t, src_u, [LARGEST_FILTER * LARGEST_INPUT_SIZE]);
|
|
LOCAL_ALIGNED_8(int32_t, src_v, [LARGEST_FILTER * LARGEST_INPUT_SIZE]);
|
|
LOCAL_ALIGNED_8(int32_t, src_a, [LARGEST_FILTER * LARGEST_INPUT_SIZE]);
|
|
|
|
LOCAL_ALIGNED_8(uint8_t, dst0_r, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
LOCAL_ALIGNED_8(uint8_t, dst0_g, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
LOCAL_ALIGNED_8(uint8_t, dst0_b, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
LOCAL_ALIGNED_8(uint8_t, dst0_a, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
|
|
LOCAL_ALIGNED_8(uint8_t, dst1_r, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
LOCAL_ALIGNED_8(uint8_t, dst1_g, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
LOCAL_ALIGNED_8(uint8_t, dst1_b, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
LOCAL_ALIGNED_8(uint8_t, dst1_a, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
|
|
randomize_buffers((uint8_t*)src_y, LARGEST_FILTER * LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)src_u, LARGEST_FILTER * LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)src_v, LARGEST_FILTER * LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)src_a, LARGEST_FILTER * LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)luma_filter, LARGEST_FILTER * sizeof(int16_t));
|
|
randomize_buffers((uint8_t*)chr_filter, LARGEST_FILTER * sizeof(int16_t));
|
|
|
|
dst0[0] = (uint8_t*)dst0_g;
|
|
dst0[1] = (uint8_t*)dst0_b;
|
|
dst0[2] = (uint8_t*)dst0_r;
|
|
dst0[3] = (uint8_t*)dst0_a;
|
|
|
|
dst1[0] = (uint8_t*)dst1_g;
|
|
dst1[1] = (uint8_t*)dst1_b;
|
|
dst1[2] = (uint8_t*)dst1_r;
|
|
dst1[3] = (uint8_t*)dst1_a;
|
|
|
|
for (i = 0; i < LARGEST_FILTER; i++) {
|
|
luma[i] = (int16_t *)(src_y + i*LARGEST_INPUT_SIZE);
|
|
chru[i] = (int16_t *)(src_u + i*LARGEST_INPUT_SIZE);
|
|
chrv[i] = (int16_t *)(src_v + i*LARGEST_INPUT_SIZE);
|
|
alpha[i] = (int16_t *)(src_a + i*LARGEST_INPUT_SIZE);
|
|
}
|
|
|
|
ctx = sws_alloc_context();
|
|
if (sws_init_context(ctx, NULL, NULL) < 0)
|
|
fail();
|
|
|
|
ctx->flags |= SWS_FULL_CHR_H_INT;
|
|
ctx->yuv2rgb_y_offset = rnd();
|
|
ctx->yuv2rgb_y_coeff = rnd();
|
|
ctx->yuv2rgb_v2r_coeff = rnd();
|
|
ctx->yuv2rgb_v2g_coeff = rnd();
|
|
ctx->yuv2rgb_u2g_coeff = rnd();
|
|
ctx->yuv2rgb_u2b_coeff = rnd();
|
|
|
|
for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {
|
|
for (fsi = 0; fsi < FILTER_SIZES; fsi++) {
|
|
for (isi = 0; isi < INPUT_SIZES; isi++ ) {
|
|
desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
|
|
ctx->dstFormat = planar_fmts[fmi];
|
|
|
|
dstW = input_sizes[isi];
|
|
luma_filter_size = filter_sizes[fsi];
|
|
chr_filter_size = filter_sizes[fsi];
|
|
|
|
if (desc->comp[0].depth > 16) {
|
|
byte_size = 4;
|
|
} else if (desc->comp[0].depth > 8) {
|
|
byte_size = 2;
|
|
} else {
|
|
byte_size = 1;
|
|
}
|
|
|
|
ff_sws_init_scale(ctx);
|
|
if (check_func(ctx->yuv2anyX, "yuv2%s_full_X_%d_%d", desc->name, luma_filter_size, dstW)) {
|
|
for (i = 0; i < 4; i ++) {
|
|
memset(dst0[i], 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
memset(dst1[i], 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
}
|
|
|
|
call_ref(ctx, luma_filter, luma, luma_filter_size,
|
|
chr_filter, chru, chrv, chr_filter_size,
|
|
alpha, dst0, dstW, 0);
|
|
call_new(ctx, luma_filter, luma, luma_filter_size,
|
|
chr_filter, chru, chrv, chr_filter_size,
|
|
alpha, dst1, dstW, 0);
|
|
|
|
if (memcmp(dst0[0], dst1[0], dstW * byte_size) ||
|
|
memcmp(dst0[1], dst1[1], dstW * byte_size) ||
|
|
memcmp(dst0[2], dst1[2], dstW * byte_size) ||
|
|
memcmp(dst0[3], dst1[3], dstW * byte_size) )
|
|
fail();
|
|
|
|
bench_new(ctx, luma_filter, luma, luma_filter_size,
|
|
chr_filter, chru, chrv, chr_filter_size,
|
|
alpha, dst1, dstW, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
sws_freeContext(ctx);
|
|
}
|
|
|
|
#undef LARGEST_INPUT_SIZE
|
|
#undef INPUT_SIZES
|
|
|
|
static void check_input_planar_rgb_to_y(void)
|
|
{
|
|
struct SwsContext *ctx;
|
|
const AVPixFmtDescriptor *desc;
|
|
int fmi, isi;
|
|
int dstW, byte_size;
|
|
#define LARGEST_INPUT_SIZE 512
|
|
#define INPUT_SIZES 6
|
|
static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
|
|
uint8_t *src[4];
|
|
int32_t rgb2yuv[9] = {0};
|
|
|
|
declare_func(void, uint8_t *dst, uint8_t *src[4], int w, int32_t *rgb2yuv);
|
|
|
|
LOCAL_ALIGNED_8(int32_t, src_r, [LARGEST_INPUT_SIZE]);
|
|
LOCAL_ALIGNED_8(int32_t, src_g, [LARGEST_INPUT_SIZE]);
|
|
LOCAL_ALIGNED_8(int32_t, src_b, [LARGEST_INPUT_SIZE]);
|
|
LOCAL_ALIGNED_8(int32_t, src_a, [LARGEST_INPUT_SIZE]);
|
|
|
|
LOCAL_ALIGNED_8(uint8_t, dst0_y, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
LOCAL_ALIGNED_8(uint8_t, dst1_y, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
|
|
randomize_buffers((uint8_t*)src_r, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)src_g, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)src_b, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)src_a, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)rgb2yuv, 9 * sizeof(int32_t));
|
|
|
|
src[0] = (uint8_t*)src_g;
|
|
src[1] = (uint8_t*)src_b;
|
|
src[2] = (uint8_t*)src_r;
|
|
src[3] = (uint8_t*)src_a;
|
|
|
|
ctx = sws_alloc_context();
|
|
if (sws_init_context(ctx, NULL, NULL) < 0)
|
|
fail();
|
|
|
|
for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {
|
|
for (isi = 0; isi < INPUT_SIZES; isi++ ) {
|
|
desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
|
|
ctx->srcFormat = planar_fmts[fmi];
|
|
ctx->dstFormat = AV_PIX_FMT_YUVA444P16;
|
|
byte_size = 2;
|
|
dstW = input_sizes[isi];
|
|
|
|
ff_sws_init_scale(ctx);
|
|
if(check_func(ctx->readLumPlanar, "planar_%s_to_y_%d", desc->name, dstW)) {
|
|
memset(dst0_y, 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
memset(dst1_y, 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
|
|
call_ref(dst0_y, src, dstW, rgb2yuv);
|
|
call_new(dst1_y, src, dstW, rgb2yuv);
|
|
|
|
if (memcmp(dst0_y, dst1_y, dstW * byte_size))
|
|
fail();
|
|
|
|
bench_new(dst1_y, src, dstW, rgb2yuv);
|
|
|
|
}
|
|
}
|
|
}
|
|
sws_freeContext(ctx);
|
|
}
|
|
|
|
#undef LARGEST_INPUT_SIZE
|
|
#undef INPUT_SIZES
|
|
|
|
static void check_input_planar_rgb_to_uv(void)
|
|
{
|
|
struct SwsContext *ctx;
|
|
const AVPixFmtDescriptor *desc;
|
|
int fmi, isi;
|
|
int dstW, byte_size;
|
|
#define LARGEST_INPUT_SIZE 512
|
|
#define INPUT_SIZES 6
|
|
static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
|
|
uint8_t *src[4];
|
|
int32_t rgb2yuv[9] = {0};
|
|
|
|
declare_func(void, uint8_t *dstU, uint8_t *dstV,
|
|
uint8_t *src[4], int w, int32_t *rgb2yuv);
|
|
|
|
LOCAL_ALIGNED_8(int32_t, src_r, [LARGEST_INPUT_SIZE]);
|
|
LOCAL_ALIGNED_8(int32_t, src_g, [LARGEST_INPUT_SIZE]);
|
|
LOCAL_ALIGNED_8(int32_t, src_b, [LARGEST_INPUT_SIZE]);
|
|
LOCAL_ALIGNED_8(int32_t, src_a, [LARGEST_INPUT_SIZE]);
|
|
|
|
LOCAL_ALIGNED_8(uint8_t, dst0_u, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
LOCAL_ALIGNED_8(uint8_t, dst0_v, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
|
|
LOCAL_ALIGNED_8(uint8_t, dst1_u, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
LOCAL_ALIGNED_8(uint8_t, dst1_v, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
|
|
randomize_buffers((uint8_t*)src_r, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)src_g, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)src_b, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)src_a, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)rgb2yuv, 9 * sizeof(int32_t));
|
|
|
|
src[0] = (uint8_t*)src_g;
|
|
src[1] = (uint8_t*)src_b;
|
|
src[2] = (uint8_t*)src_r;
|
|
src[3] = (uint8_t*)src_a;
|
|
|
|
ctx = sws_alloc_context();
|
|
if (sws_init_context(ctx, NULL, NULL) < 0)
|
|
fail();
|
|
|
|
for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {
|
|
for (isi = 0; isi < INPUT_SIZES; isi++ ) {
|
|
desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
|
|
ctx->srcFormat = planar_fmts[fmi];
|
|
ctx->dstFormat = AV_PIX_FMT_YUVA444P16;
|
|
byte_size = 2;
|
|
dstW = input_sizes[isi];
|
|
|
|
ff_sws_init_scale(ctx);
|
|
if(check_func(ctx->readChrPlanar, "planar_%s_to_uv_%d", desc->name, dstW)) {
|
|
memset(dst0_u, 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
memset(dst0_v, 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
memset(dst1_u, 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
memset(dst1_v, 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
|
|
call_ref(dst0_u, dst0_v, src, dstW, rgb2yuv);
|
|
call_new(dst1_u, dst1_v, src, dstW, rgb2yuv);
|
|
|
|
if (memcmp(dst0_u, dst1_u, dstW * byte_size) ||
|
|
memcmp(dst0_v, dst1_v, dstW * byte_size))
|
|
fail();
|
|
|
|
bench_new(dst1_u, dst1_v, src, dstW, rgb2yuv);
|
|
}
|
|
}
|
|
}
|
|
sws_freeContext(ctx);
|
|
}
|
|
|
|
#undef LARGEST_INPUT_SIZE
|
|
#undef INPUT_SIZES
|
|
|
|
static void check_input_planar_rgb_to_a(void)
|
|
{
|
|
struct SwsContext *ctx;
|
|
const AVPixFmtDescriptor *desc;
|
|
int fmi, isi;
|
|
int dstW, byte_size;
|
|
#define LARGEST_INPUT_SIZE 512
|
|
#define INPUT_SIZES 6
|
|
static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
|
|
uint8_t *src[4];
|
|
int32_t rgb2yuv[9] = {0};
|
|
|
|
declare_func(void, uint8_t *dst, uint8_t *src[4], int w, int32_t *rgb2yuv);
|
|
|
|
LOCAL_ALIGNED_8(int32_t, src_r, [LARGEST_INPUT_SIZE]);
|
|
LOCAL_ALIGNED_8(int32_t, src_g, [LARGEST_INPUT_SIZE]);
|
|
LOCAL_ALIGNED_8(int32_t, src_b, [LARGEST_INPUT_SIZE]);
|
|
LOCAL_ALIGNED_8(int32_t, src_a, [LARGEST_INPUT_SIZE]);
|
|
|
|
LOCAL_ALIGNED_8(uint8_t, dst0_a, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
LOCAL_ALIGNED_8(uint8_t, dst1_a, [LARGEST_INPUT_SIZE * sizeof(int32_t)]);
|
|
|
|
randomize_buffers((uint8_t*)src_r, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)src_g, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)src_b, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)src_a, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
randomize_buffers((uint8_t*)rgb2yuv, 9 * sizeof(int32_t));
|
|
|
|
src[0] = (uint8_t*)src_g;
|
|
src[1] = (uint8_t*)src_b;
|
|
src[2] = (uint8_t*)src_r;
|
|
src[3] = (uint8_t*)src_a;
|
|
|
|
ctx = sws_alloc_context();
|
|
if (sws_init_context(ctx, NULL, NULL) < 0)
|
|
fail();
|
|
|
|
for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {
|
|
for (isi = 0; isi < INPUT_SIZES; isi++ ) {
|
|
desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
|
|
if (!(desc->flags & AV_PIX_FMT_FLAG_ALPHA))
|
|
continue;
|
|
|
|
ctx->srcFormat = planar_fmts[fmi];
|
|
ctx->dstFormat = AV_PIX_FMT_YUVA444P16;
|
|
byte_size = 2;
|
|
dstW = input_sizes[isi];
|
|
|
|
ff_sws_init_scale(ctx);
|
|
if(check_func(ctx->readAlpPlanar, "planar_%s_to_a_%d", desc->name, dstW)) {
|
|
memset(dst0_a, 0x00, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
memset(dst1_a, 0x00, LARGEST_INPUT_SIZE * sizeof(int32_t));
|
|
|
|
call_ref(dst0_a, src, dstW, rgb2yuv);
|
|
call_new(dst1_a, src, dstW, rgb2yuv);
|
|
|
|
if (memcmp(dst0_a, dst1_a, dstW * byte_size))
|
|
fail();
|
|
bench_new(dst1_a, src, dstW, rgb2yuv);
|
|
}
|
|
}
|
|
}
|
|
sws_freeContext(ctx);
|
|
}
|
|
|
|
void checkasm_check_sw_gbrp(void)
|
|
{
|
|
check_output_yuv2gbrp();
|
|
report("output_yuv2gbrp");
|
|
|
|
check_input_planar_rgb_to_y();
|
|
report("input_planar_rgb_y");
|
|
|
|
check_input_planar_rgb_to_uv();
|
|
report("input_planar_rgb_uv");
|
|
|
|
check_input_planar_rgb_to_a();
|
|
report("input_planar_rgb_a");
|
|
}
|