FFmpeg
Loading...
Searching...
No Matches
bitpackeddec.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 Devin Heitmueller <dheitmueller@ltnglobal.com>
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
24
25#include "checkasm.h"
27
28#define MAX_WIDTH 3840
29
30static void randomize_buffers(uint8_t *src0, uint8_t *src1, int len)
31{
32 for (int i = 0; i < len; i++) {
33 uint8_t value = rnd();
34 src0[i] = value;
35 src1[i] = value;
36 }
37}
38
40{
41 static const int widths[] = { 8, 16, 24, 32, 40, 48, 56, MAX_WIDTH };
42 static const int tail_widths[] = { 2, 6, 10, 14, 16 };
43 struct BitpackedContext h;
44
46
47 if (check_func(h.unpack_yuv422p10, "bitpacked_unpack_yuv422p10")) {
48 LOCAL_ALIGNED_16(uint8_t, src0, [MAX_WIDTH * 5 / 2]);
49 LOCAL_ALIGNED_16(uint8_t, src1, [MAX_WIDTH * 5 / 2]);
50 LOCAL_ALIGNED_16(uint16_t, y0, [MAX_WIDTH]);
51 LOCAL_ALIGNED_16(uint16_t, y1, [MAX_WIDTH]);
52 LOCAL_ALIGNED_16(uint16_t, u0, [MAX_WIDTH / 2]);
53 LOCAL_ALIGNED_16(uint16_t, u1, [MAX_WIDTH / 2]);
54 LOCAL_ALIGNED_16(uint16_t, v0, [MAX_WIDTH / 2]);
55 LOCAL_ALIGNED_16(uint16_t, v1, [MAX_WIDTH / 2]);
56 declare_func(void, const uint8_t *src, uint16_t *y, uint16_t *u,
57 uint16_t *v, int width);
58
59 for (int i = 0; i < FF_ARRAY_ELEMS(widths); i++) {
60 const int width = widths[i];
61 const int src_size = width * 5 / 2;
62
63 randomize_buffers(src0, src1, src_size);
64 memset(y0, 0, width * sizeof(*y0));
65 memset(y1, 0, width * sizeof(*y1));
66 memset(u0, 0, width / 2 * sizeof(*u0));
67 memset(u1, 0, width / 2 * sizeof(*u1));
68 memset(v0, 0, width / 2 * sizeof(*v0));
69 memset(v1, 0, width / 2 * sizeof(*v1));
70
71 call_ref(src0, y0, u0, v0, width);
72 call_new(src1, y1, u1, v1, width);
73 if (memcmp(src0, src1, src_size) ||
74 memcmp(y0, y1, width * sizeof(*y0)) ||
75 memcmp(u0, u1, width / 2 * sizeof(*u0)) ||
76 memcmp(v0, v1, width / 2 * sizeof(*v0)))
77 fail();
78 }
79
80 for (int i = 0; i < FF_ARRAY_ELEMS(tail_widths); i++) {
81 const int width = tail_widths[i];
82 const int bulk = width & ~7;
83 const int src_size = width * 5 / 2;
84
85 randomize_buffers(src0, src1, src_size);
87 if (bulk)
88 h.unpack_yuv422p10(src1, y1, u1, v1, bulk);
90 y1 + bulk, u1 + bulk / 2, v1 + bulk / 2,
91 width - bulk);
92 if (memcmp(src0, src1, src_size) ||
93 memcmp(y0, y1, width * sizeof(*y0)) ||
94 memcmp(u0, u1, width / 2 * sizeof(*u0)) ||
95 memcmp(v0, v1, width / 2 * sizeof(*v0)))
96 fail();
97 }
98
100 bench_new(src1, y1, u1, v1, MAX_WIDTH);
101 }
102 report("bitpacked_unpack_yuv422p10");
103}
static void bitpacked_unpack_yuv422p10_c(const uint8_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width)
static av_unused av_cold void ff_bitpackeddec_init(struct BitpackedContext *s)
#define MAX_WIDTH
void checkasm_check_bitpackeddec(void)
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define rnd
Definition checkasm.h:138
double value
Definition eval.c:102
#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
#define u(width, name, range_min, range_max)
Definition cbs_apv.c:68
#define LOCAL_ALIGNED_16(t, v,...)
#define FF_ARRAY_ELEMS(a)
#define randomize_buffers()
Definition alacdsp.c:32
#define src1
Definition h264pred.c:141
#define src0
Definition h264pred.c:140
#define src
Definition vp8dsp.c:248
#define width
Definition dsp.h:99
int len