FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
v210enc.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Henrik Gramner
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #include <string.h>
22 #include "checkasm.h"
23 #include "libavcodec/v210enc.h"
24 #include "libavutil/common.h"
25 #include "libavutil/internal.h"
26 #include "libavutil/intreadwrite.h"
27 
28 #define BUF_SIZE 512
29 
30 #define randomize_buffers(mask) \
31  do { \
32  int i, size = sizeof(*y0); \
33  for (i = 0; i < BUF_SIZE; i += 4 / size) { \
34  uint32_t r = rnd() & mask; \
35  AV_WN32A(y0 + i, r); \
36  AV_WN32A(y1 + i, r); \
37  } \
38  for (i = 0; i < BUF_SIZE / 2; i += 4 / size) { \
39  uint32_t r = rnd() & mask; \
40  AV_WN32A(u0 + i, r); \
41  AV_WN32A(u1 + i, r); \
42  r = rnd() & mask; \
43  AV_WN32A(v0 + i, r); \
44  AV_WN32A(v1 + i, r); \
45  } \
46  for (i = 0; i < width * 8 / 3; i += 4) { \
47  uint32_t r = rnd(); \
48  AV_WN32A(dst0 + i, r); \
49  AV_WN32A(dst1 + i, r); \
50  } \
51  } while (0)
52 
53 #define check_pack_line(type, mask) \
54  do { \
55  LOCAL_ALIGNED_16(type, y0, [BUF_SIZE]); \
56  LOCAL_ALIGNED_16(type, y1, [BUF_SIZE]); \
57  LOCAL_ALIGNED_16(type, u0, [BUF_SIZE / 2]); \
58  LOCAL_ALIGNED_16(type, u1, [BUF_SIZE / 2]); \
59  LOCAL_ALIGNED_16(type, v0, [BUF_SIZE / 2]); \
60  LOCAL_ALIGNED_16(type, v1, [BUF_SIZE / 2]); \
61  LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE * 8 / 3]); \
62  LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE * 8 / 3]); \
63  \
64  declare_func(void, const type * y, const type * u, const type * v, \
65  uint8_t * dst, ptrdiff_t width); \
66  ptrdiff_t width, step = 12 / sizeof(type); \
67  \
68  for (width = step; width < BUF_SIZE - 15; width += step) { \
69  int y_offset = rnd() & 15; \
70  int uv_offset = y_offset / 2; \
71  randomize_buffers(mask); \
72  call_ref(y0 + y_offset, u0 + uv_offset, v0 + uv_offset, dst0, width); \
73  call_new(y1 + y_offset, u1 + uv_offset, v1 + uv_offset, dst1, width); \
74  if (memcmp(y0, y1, BUF_SIZE) || memcmp(u0, u1, BUF_SIZE / 2) || \
75  memcmp(v0, v1, BUF_SIZE / 2) || memcmp(dst0, dst1, width * 8 / 3)) \
76  fail(); \
77  bench_new(y1 + y_offset, u1 + uv_offset, v1 + uv_offset, dst1, width); \
78  } \
79  } while (0)
80 
82 {
84 
85  ff_v210enc_init(&h);
86 
87  if (check_func(h.pack_line_8, "v210_planar_pack_8"))
88  check_pack_line(uint8_t, 0xffffffff);
89 
90  if (check_func(h.pack_line_10, "v210_planar_pack_10"))
91  check_pack_line(uint16_t, 0x03ff03ff);
92 
93  report("planar_pack");
94 }
#define report
Definition: checkasm.h:92
uint8_t
#define check_pack_line(type, mask)
Definition: v210enc.c:53
void(* pack_line_8)(const uint8_t *y, const uint8_t *u, const uint8_t *v, uint8_t *dst, ptrdiff_t width)
Definition: v210enc.h:27
av_cold void ff_v210enc_init(V210EncContext *s)
Definition: v210enc.c:85
common internal API header
void checkasm_check_v210enc(void)
Definition: v210enc.c:81
#define check_func(func,...)
Definition: checkasm.h:81
common internal and external API header
void(* pack_line_10)(const uint16_t *y, const uint16_t *u, const uint16_t *v, uint8_t *dst, ptrdiff_t width)
Definition: v210enc.h:29