FFmpeg
Loading...
Searching...
No Matches
huffyuvencdsp.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 <stddef.h>
20#include <stdint.h>
21#include <string.h>
22
23#include "checkasm.h"
25#include "libavutil/cpu.h"
26#include "libavutil/macros.h"
28
29enum {
30 MAX_WIDTH = 4096, ///< maximum test width, must be a power of two smaller than the maximum alignment
31};
32
33#define randomize_buffers(buf, size, mask) \
34 do { \
35 for (size_t j = 0; j < size; ++j) \
36 buf[j] = rnd() & mask; \
37 } while (0)
38
39
40static void check_sub_hfyu_median_pred_int16(const char *aligned, unsigned width)
41{
42 static const int bpps[] = { 9, 16, };
44
45 declare_func(void, uint16_t *dst, const uint16_t *src1,
46 const uint16_t *src2, unsigned mask, int w, int *left, int *left_top);
47
48 for (size_t i = 0; i < FF_ARRAY_ELEMS(bpps); ++i) {
49 const int bpp = bpps[i];
50
52
53 if (check_func(c.sub_hfyu_median_pred_int16, "sub_hfyu_median_pred_int16_%dbpp%s", bpp, aligned)) {
54 DECLARE_ALIGNED(32, uint16_t, dst0)[MAX_WIDTH];
55 DECLARE_ALIGNED(32, uint16_t, dst1)[MAX_WIDTH];
56 uint16_t src1[MAX_WIDTH];
57 uint16_t src2[MAX_WIDTH];
58 const unsigned mask = (1 << bpp) - 1;
59 int l1 = rnd() & mask, lt1 = rnd() & mask, l2 = l1, lt2 = lt1;
60
63
64 call_ref(dst0, src1, src2, mask, width, &l1, &lt1);
65 call_new(dst1, src1, src2, mask, width, &l2, &lt2);
66 if (l1 != l2 || lt1 != lt2 || memcmp(dst0, dst1, width * sizeof(dst0[0])))
67 fail();
68 bench_new(dst1, src1, src2, mask, width, &l2, &lt2);
69 }
70 }
71}
72
74{
75 const size_t align = av_cpu_max_align();
76 unsigned width = 1 + rnd() % MAX_WIDTH;
77
78 check_sub_hfyu_median_pred_int16("_aligned", FFALIGN(width, align / sizeof(uint16_t)));
79 report("sub_hfyu_median_pred_int16_aligned");
80
82 report("sub_hfyu_median_pred_int16");
83}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static const uint8_t *BS_FUNC align(BSCTX *bc)
Skip bits to a byte boundary.
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 rnd
Definition checkasm.h:136
static int aligned(int val)
Definition dashdec.c:178
#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
av_cold void ff_huffyuvencdsp_init(HuffYUVEncDSPContext *c, int bpp, int width)
size_t av_cpu_max_align(void)
Get the maximum data alignment that may be required by FFmpeg.
Definition cpu.c:287
uint8_t w
Definition llvidencdsp.c:39
static const uint16_t mask[17]
Definition lzw.c:38
Utility Preprocessor macros.
#define FFALIGN(x, a)
Definition macros.h:78
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
#define FF_ARRAY_ELEMS(a)
#define src1
Definition h264pred.c:141
@ MAX_WIDTH
arbitrary limit used for the tests
Definition huffyuvdsp.c:32
void checkasm_check_huffyuvencdsp(void)
#define randomize_buffers(buf, size, mask)
static void check_sub_hfyu_median_pred_int16(const char *aligned, unsigned width)
#define width
Definition dsp.h:89
static double c[64]