FFmpeg  4.0
sw_rgb.c
Go to the documentation of this file.
1 /*
2  *
3  * This file is part of FFmpeg.
4  *
5  * FFmpeg is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * FFmpeg is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #include <string.h>
21 
22 #include "libavutil/common.h"
23 #include "libavutil/intreadwrite.h"
24 #include "libavutil/mem.h"
25 
26 #include "libswscale/rgb2rgb.h"
27 
28 #include "checkasm.h"
29 
30 #define randomize_buffers(buf, size) \
31  do { \
32  int j; \
33  for (j = 0; j < size; j+=4) \
34  AV_WN32(buf + j, rnd()); \
35  } while (0)
36 
37 static const uint8_t width[] = {12, 16, 20, 32, 36, 128};
38 
39 #define MAX_STRIDE 128
40 
41 static void check_shuffle_bytes(void * func, const char * report)
42 {
43  int i;
48 
49  declare_func_emms(AV_CPU_FLAG_MMX, void, const uint8_t *src, uint8_t *dst, int src_size);
50 
51  memset(dst0, 0, MAX_STRIDE);
52  memset(dst1, 0, MAX_STRIDE);
54  memcpy(src1, src0, MAX_STRIDE);
55 
56  if (check_func(func, "%s", report)) {
57  for (i = 0; i < 6; i ++) {
58  call_ref(src0, dst0, width[i]);
59  call_new(src1, dst1, width[i]);
60  if (memcmp(dst0, dst1, MAX_STRIDE))
61  fail();
62  }
63  bench_new(src0, dst0, width[5]);
64  }
65 }
66 
68 {
70 
71  check_shuffle_bytes(shuffle_bytes_2103, "shuffle_bytes_2103");
72  report("shuffle_bytes_2103");
73 
74  check_shuffle_bytes(shuffle_bytes_0321, "shuffle_bytes_0321");
75  report("shuffle_bytes_0321");
76 
77  check_shuffle_bytes(shuffle_bytes_1230, "shuffle_bytes_1230");
78  report("shuffle_bytes_1230");
79 
80  check_shuffle_bytes(shuffle_bytes_3012, "shuffle_bytes_3012");
81  report("shuffle_bytes_3012");
82 
83  check_shuffle_bytes(shuffle_bytes_3210, "shuffle_bytes_3210");
84  report("shuffle_bytes_3210");
85 }
Memory handling functions.
void(* shuffle_bytes_3012)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:57
static void check_shuffle_bytes(void *func, const char *report)
Definition: sw_rgb.c:41
#define src
Definition: vp8dsp.c:254
#define report
Definition: checkasm.h:119
void(* shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:55
uint8_t
void(* shuffle_bytes_3210)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:58
void(* shuffle_bytes_1230)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:56
#define fail()
Definition: checkasm.h:116
#define randomize_buffers(buf, size)
Definition: sw_rgb.c:30
void checkasm_check_sw_rgb(void)
Definition: sw_rgb.c:67
av_cold void ff_sws_rgb2rgb_init(void)
Definition: rgb2rgb.c:137
static const uint8_t width[]
Definition: sw_rgb.c:37
#define declare_func_emms(cpu_flags, ret,...)
Definition: checkasm.h:113
#define call_ref(...)
Definition: checkasm.h:122
#define src1
Definition: h264pred.c:139
#define AV_CPU_FLAG_MMX
standard MMX
Definition: cpu.h:31
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:67
#define check_func(func,...)
Definition: checkasm.h:107
#define src0
Definition: h264pred.c:138
void(* shuffle_bytes_0321)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:54
#define LOCAL_ALIGNED_32(t, v,...)
Definition: internal.h:137
common internal and external API header
#define bench_new(...)
Definition: checkasm.h:249
#define call_new(...)
Definition: checkasm.h:189
#define MAX_STRIDE
Definition: sw_rgb.c:39