FFmpeg
Loading...
Searching...
No Matches
vp6dsp.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 <assert.h>
20#include <stddef.h>
21#include <string.h>
22
23#include "checkasm.h"
25#include "libavutil/macros.h"
27#include "libavcodec/vp6data.h"
28#include "libavcodec/vp56dsp.h"
29
30#define randomize_buffer(buf) \
31 do { \
32 for (size_t k = 0; k < (sizeof(buf) & ~3); k += 4) \
33 AV_WN32A(buf + k, rnd()); \
34 for (size_t k = sizeof(buf) & ~3; k < sizeof(buf); ++k) \
35 buf[k] = rnd(); \
36 } while (0)
37
38
40{
41 enum {
42 BLOCK_SIZE_1D = 8,
43 SRC_ROWS_ABOVE = 1,
44 SRC_ROWS_BELOW = 2,
45 SRC_COLS_LEFT = 1,
46 SRC_COLS_RIGHT = 2,
47 SRC_ROWS = SRC_ROWS_ABOVE + BLOCK_SIZE_1D + SRC_ROWS_BELOW,
48 SRC_ROW_SIZE = SRC_COLS_LEFT + BLOCK_SIZE_1D + SRC_COLS_RIGHT,
49 MAX_STRIDE = 64, ///< arbitrary
50 SRC_BUF_SIZE = (SRC_ROWS - 1) * MAX_STRIDE + SRC_ROW_SIZE + 7 /* to vary misalignment */,
51 DST_BUF_SIZE = (BLOCK_SIZE_1D - 1) * MAX_STRIDE + BLOCK_SIZE_1D,
52 };
53 VP6DSPContext vp6dsp;
54
55 ff_vp6dsp_init(&vp6dsp);
56
57 declare_func(void, uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
58 const int16_t *h_weights, const int16_t *v_weights);
59
60 if (check_func(vp6dsp.vp6_filter_diag4, "filter_diag4")) {
61 DECLARE_ALIGNED(8, uint8_t, dstbuf_ref)[DST_BUF_SIZE];
62 DECLARE_ALIGNED(8, uint8_t, dstbuf_new)[DST_BUF_SIZE];
63 DECLARE_ALIGNED(8, uint8_t, srcbuf)[SRC_BUF_SIZE];
64
65 randomize_buffer(dstbuf_ref);
66 randomize_buffer(srcbuf);
67 memcpy(dstbuf_new, dstbuf_ref, sizeof(dstbuf_new));
68
69 ptrdiff_t stride = (rnd() % (MAX_STRIDE / 16) + 1) * 16;
70 const uint8_t *src = srcbuf + SRC_COLS_LEFT + rnd() % 8U;
71 uint8_t *dst_new = dstbuf_new, *dst_ref = dstbuf_ref;
72
73 if (rnd() & 1) {
74 dst_new += (BLOCK_SIZE_1D - 1) * stride;
75 dst_ref += (BLOCK_SIZE_1D - 1) * stride;
76 src += (SRC_ROWS - 1) * stride;
77 stride *= -1;
78 }
79 src += SRC_ROWS_ABOVE * stride;
80
81 unsigned select = rnd() % FF_ARRAY_ELEMS(vp6_block_copy_filter);
82 unsigned x8 = 1 + rnd() % (FF_ARRAY_ELEMS(vp6_block_copy_filter[0]) - 1);
83 unsigned y8 = 1 + rnd() % (FF_ARRAY_ELEMS(vp6_block_copy_filter[0]) - 1);
84 const int16_t *h_weights = vp6_block_copy_filter[select][x8];
85 const int16_t *v_weights = vp6_block_copy_filter[select][y8];
86
87 call_ref(dst_ref, src, stride, h_weights, v_weights);
88 call_new(dst_new, src, stride, h_weights, v_weights);
89 if (memcmp(dstbuf_new, dstbuf_ref, sizeof(dstbuf_new)))
90 fail();
91 bench_new(dst_new, src, stride, h_weights, v_weights);
92 }
93 report("filter_diag4");
94}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
#define rnd
Definition checkasm.h:135
#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
av_cold void ff_vp6dsp_init(VP6DSPContext *s)
Definition vp6dsp.c:63
Utility Preprocessor macros.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
#define FF_ARRAY_ELEMS(a)
void(* vp6_filter_diag4)(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, const int16_t *h_weights, const int16_t *v_weights)
Definition vp56dsp.h:33
#define stride
#define MAX_STRIDE
Definition hpeldsp.c:31
void checkasm_check_vp6dsp(void)
Definition vp6dsp.c:39
#define randomize_buffer(buf)
Definition vp6dsp.c:30
#define src
Definition vp8dsp.c:248
#define SRC_BUF_SIZE
Definition hash.c:26
#define DST_BUF_SIZE
Definition hash.c:27
VP6 compatible video decoder.
static const int16_t vp6_block_copy_filter[17][8][4]
Definition vp6data.h:162