FFmpeg
vf_hflip.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #include <string.h>
20 #include "checkasm.h"
21 #include "libavfilter/hflip.h"
23 #include "libavutil/intreadwrite.h"
24 #include "libavutil/mem_internal.h"
25 
26 #define WIDTH 256
27 #define WIDTH_PADDED 256 + 32
28 
29 #define randomize_buffers(buf, size) \
30  do { \
31  int j; \
32  uint8_t *tmp_buf = (uint8_t *)buf;\
33  for (j = 0; j < size; j++) \
34  tmp_buf[j] = rnd() & 0xFF; \
35  } while (0)
36 
37 static void check_hflip(int step, const char * report_name){
38  LOCAL_ALIGNED_32(uint8_t, src, [WIDTH_PADDED]);
39  LOCAL_ALIGNED_32(uint8_t, dst_ref, [WIDTH_PADDED]);
40  LOCAL_ALIGNED_32(uint8_t, dst_new, [WIDTH_PADDED]);
41  int w = WIDTH;
42  int i;
43  int step_array[4] = {1, 1, 1, 1};
44  FlipContext s;
45 
46  declare_func(void, const uint8_t *src, uint8_t *dst, int w);
47 
48  s.bayer_plus1 = 1;
49  memset(src, 0, WIDTH_PADDED);
50  memset(dst_ref, 0, WIDTH_PADDED);
51  memset(dst_new, 0, WIDTH_PADDED);
53 
54  if (step == 2) {
55  w /= 2;
56  for (i = 0; i < 4; i++)
57  step_array[i] = step;
58  }
59 
60  ff_hflip_init(&s, step_array, 4);
61 
62  if (check_func(s.flip_line[0], "hflip_%s", report_name)) {
63  for (i = 1; i < w; i++) {
64  call_ref(src + (w - 1) * step, dst_ref, i);
65  call_new(src + (w - 1) * step, dst_new, i);
66  if (memcmp(dst_ref, dst_new, i * step))
67  fail();
68  }
69  bench_new(src + (w - 1) * step, dst_new, w);
70  }
71 }
73 {
74  check_hflip(1, "byte");
75  report("hflip_byte");
76 
77  check_hflip(2, "short");
78  report("hflip_short");
79 }
mem_internal.h
step
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
Definition: rate_distortion.txt:58
w
uint8_t w
Definition: llviddspenc.c:38
check_func
#define check_func(func,...)
Definition: checkasm.h:122
call_ref
#define call_ref(...)
Definition: checkasm.h:137
fail
#define fail()
Definition: checkasm.h:131
checkasm.h
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:256
vf_hflip_init.h
call_new
#define call_new(...)
Definition: checkasm.h:209
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition: mem_internal.h:136
check_hflip
static void check_hflip(int step, const char *report_name)
Definition: vf_hflip.c:37
hflip.h
WIDTH_PADDED
#define WIDTH_PADDED
Definition: vf_hflip.c:27
checkasm_check_vf_hflip
void checkasm_check_vf_hflip(void)
Definition: vf_hflip.c:72
WIDTH
#define WIDTH
Definition: vf_hflip.c:26
report
#define report
Definition: checkasm.h:134
bench_new
#define bench_new(...)
Definition: checkasm.h:272
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
FlipContext
Definition: hflip.h:27
randomize_buffers
#define randomize_buffers(buf, size)
Definition: vf_hflip.c:29
declare_func
#define declare_func(ret,...)
Definition: checkasm.h:126
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
ff_hflip_init
static av_unused int ff_hflip_init(FlipContext *s, int step[4], int nb_planes)
Definition: vf_hflip_init.h:89