FFmpeg
Loading...
Searching...
No Matches
llvidencdsp.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Alexandra Hájková
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
23#include "libavutil/common.h"
26
28
29#include "checkasm.h"
30
31#define randomize_buffers(buf, size) \
32 do { \
33 for (size_t j = 0; j < (size & ~3); j += 4) \
34 AV_WN32(buf + j, rnd()); \
35 for (size_t j = size & ~3; j < size; ++j) \
36 buf[j] = rnd(); \
37 } while (0)
38
39static const struct {uint8_t w, h, s;} planes[] = {
40 {16,16,16}, {21,23,25}, {32,17,48}, {15,128,16}, {128,127,128}
41};
42
43#define MAX_STRIDE 128
44#define MAX_HEIGHT 127
45
47{
48 int i;
49 LOCAL_ALIGNED_32(uint8_t, dst0, [MAX_STRIDE]);
50 LOCAL_ALIGNED_32(uint8_t, dst1, [MAX_STRIDE]);
51 LOCAL_ALIGNED_32(uint8_t, src0, [MAX_STRIDE]);
52 LOCAL_ALIGNED_32(uint8_t, src1, [MAX_STRIDE]);
53 LOCAL_ALIGNED_32(uint8_t, src2, [MAX_STRIDE]);
54 LOCAL_ALIGNED_32(uint8_t, src3, [MAX_STRIDE]);
55
56 declare_func(void, uint8_t *dst, const uint8_t *src1,
57 const uint8_t *src2, intptr_t w);
58
59 memset(dst0, 0, MAX_STRIDE);
60 memset(dst1, 0, MAX_STRIDE);
62 memcpy(src1, src0, MAX_STRIDE);
64 memcpy(src3, src2, MAX_STRIDE);
65
66 if (check_func(c->diff_bytes, "diff_bytes")) {
67 for (i = 0; i < 5; i ++) {
68 call_ref(dst0, src0, src2, planes[i].w);
69 call_new(dst1, src1, src3, planes[i].w);
70 if (memcmp(dst0, dst1, planes[i].w))
71 fail();
72 }
73 bench_new(dst1, src0, src2, planes[4].w);
74 }
75}
76
78{
79 enum {
80 BUF_SIZE = MAX_STRIDE + 15 /* to test misalignment */
81 };
82 uint8_t dst_ref[BUF_SIZE], dst_new[BUF_SIZE];
83 uint8_t src1[BUF_SIZE], src2[BUF_SIZE];
84
85 declare_func(void, uint8_t *dst, const uint8_t *src1,
86 const uint8_t *src2, intptr_t w,
87 int *left, int *left_top);
88
89 if (check_func(c->sub_median_pred, "sub_median_pred")) {
90 size_t width = 1 + rnd() % MAX_STRIDE;
91 size_t offset = rnd() & 0xF;
92 int left_ref = rnd() & 0xFF, top_ref = rnd() & 0xFF;
93 int left_new = left_ref, top_new = top_ref;
94
95 memset(dst_ref, 0, sizeof(dst_ref));
96 memset(dst_new, 0, sizeof(dst_new));
97
98 randomize_buffers(src1, sizeof(src1));
99 randomize_buffers(src2, sizeof(src2));
100
101 call_ref(dst_ref + offset, src1 + offset, src2 + offset, width, &left_ref, &top_ref);
102 call_new(dst_new + offset, src1 + offset, src2 + offset, width, &left_new, &top_new);
103 if (left_new != left_ref || top_ref != top_new ||
104 memcmp(dst_ref, dst_new, width + offset))
105 fail();
106 bench_new(dst_new, src1, src2, MAX_STRIDE, &left_new, &top_new);
107 }
108}
109
111{
112 LOCAL_ALIGNED_32(uint8_t, dst0, [MAX_STRIDE * MAX_HEIGHT]);
113 LOCAL_ALIGNED_32(uint8_t, dst1, [MAX_STRIDE * MAX_HEIGHT]);
115
116 declare_func(void, uint8_t *dst, const uint8_t *src,
117 ptrdiff_t stride, ptrdiff_t width, int height);
118
119 if (check_func(c->sub_left_predict, "sub_left_predict")) {
121
122 for (size_t i = 0; i < FF_ARRAY_ELEMS(planes); i ++) {
123 memset(dst0, 0, MAX_STRIDE * MAX_HEIGHT);
124 memset(dst1, 0, MAX_STRIDE * MAX_HEIGHT);
125 call_ref(dst0, src, planes[i].s, planes[i].w, planes[i].h);
126 call_new(dst1, src, planes[i].s, planes[i].w, planes[i].h);
127 if (memcmp(dst0, dst1, planes[i].w * planes[i].h))
128 fail();
129 }
130 bench_new(dst1, src, planes[4].s, planes[4].w, planes[4].h);
131 }
132}
133
135{
138
140 report("diff_bytes");
141
143 report("sub_median_pred");
144
146 report("sub_left_predict");
147}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define rnd
Definition checkasm.h:136
common internal and external API header
#define declare_func
Definition test.h:489
#define fail
Definition test.h:479
#define bench_new
Definition test.h:487
#define check_func
Definition test.h:481
#define call_new
Definition test.h:486
#define call_ref
Definition test.h:485
#define report
Definition test.h:480
const pixel * src2
unsigned offset
Definition libaomenc.c:763
static void check_sub_left_pred(LLVidEncDSPContext *c)
static const struct @257111027162314367033347246032313251342043035002 planes[]
void checkasm_check_llvidencdsp(void)
#define randomize_buffers(buf, size)
Definition llvidencdsp.c:31
static void check_diff_bytes(LLVidEncDSPContext *c)
Definition llvidencdsp.c:46
static void check_sub_median_pred(LLVidEncDSPContext *c)
Definition llvidencdsp.c:77
uint8_t w
Definition llvidencdsp.c:39
av_cold void ff_llvidencdsp_init(LLVidEncDSPContext *c)
#define LOCAL_ALIGNED_32(t, v,...)
#define BUF_SIZE
Definition setpts.c:159
#define FF_ARRAY_ELEMS(a)
#define stride
#define src1
Definition h264pred.c:141
#define src0
Definition h264pred.c:140
#define MAX_HEIGHT
Definition hpeldsp.c:30
#define MAX_STRIDE
Definition hpeldsp.c:31
#define src
Definition vp8dsp.c:248
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89
static double c[64]