FFmpeg
Loading...
Searching...
No Matches
sw_xyz2rgb.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Arpad Panyik <Arpad.Panyik@arm.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
25#include "libavutil/pixdesc.h"
26#include "libavutil/pixfmt.h"
27
28#include "libswscale/swscale.h"
30
31#include "checkasm.h"
32
33#define NUM_LINES 4
34#define MAX_LINE_SIZE 1920
35
36#define randomize_buffers(buf, size) \
37 do { \
38 for (int j = 0; j < size; j += 2) \
39 AV_WN32(buf + j, rnd()); \
40 } while (0)
41
42static void check_xyz12Torgb48le(void)
43{
44 static const int input_sizes[] = {1, 2, 3, 4, 5, 6, 7, 8, 16, 17, 21, 31,
45 32, 64, 128, 256, 512, 1024,
47
48 const int src_stride = 3 * sizeof(uint16_t) * MAX_LINE_SIZE;
49 const int dst_stride = src_stride;
50
51 const int src_pix_fmt = AV_PIX_FMT_XYZ12LE;
52 const int dst_pix_fmt = AV_PIX_FMT_RGB48LE;
53
54 const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(src_pix_fmt);
55 const AVPixFmtDescriptor *dst_desc = av_pix_fmt_desc_get(dst_pix_fmt);
56
57 LOCAL_ALIGNED_8(uint16_t, src, [3 * MAX_LINE_SIZE * NUM_LINES]);
58 LOCAL_ALIGNED_8(uint16_t, dst_ref, [3 * MAX_LINE_SIZE * NUM_LINES]);
59 LOCAL_ALIGNED_8(uint16_t, dst_new, [3 * MAX_LINE_SIZE * NUM_LINES]);
60
61 declare_func(void, const SwsInternal *, uint8_t *, int, const uint8_t *,
62 int, int, int);
63
65 memset(&c, 0, sizeof(c));
66 c.opts.src_format = src_pix_fmt;
69
71
72 for (int height = 1; height <= NUM_LINES; height++) {
73 for (int isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++) {
74 int width = input_sizes[isi];
75
76 if (check_func(c.xyz12Torgb48, "%s_%s_%dx%d", src_desc->name,
77 dst_desc->name, width, height)) {
78 memset(dst_ref, 0xFE,
79 3 * sizeof(uint16_t) * MAX_LINE_SIZE * NUM_LINES);
80 memset(dst_new, 0xFE,
81 3 * sizeof(uint16_t) * MAX_LINE_SIZE * NUM_LINES);
82
83 call_ref(&c, (uint8_t *)dst_ref, dst_stride,
84 (const uint8_t *)src, src_stride, width, height);
85 call_new(&c, (uint8_t *)dst_new, dst_stride,
86 (const uint8_t *)src, src_stride, width, height);
87
88 checkasm_check(uint16_t, dst_ref, dst_stride, dst_new,
89 dst_stride, width, height, "dst_rgb");
90
91 if (!(width & 3) && height == NUM_LINES) {
92 bench_new(&c, (uint8_t *)dst_new,
93 dst_stride, (const uint8_t *)src, src_stride,
94 width, height);
95 }
96 }
97 }
98 }
99}
100
101#undef NUM_LINES
102#undef MAX_LINE_SIZE
103
105{
107 report("xyz12Torgb48le");
108}
#define declare_func
Definition test.h:489
#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 LOCAL_ALIGNED_8(t, v,...)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3460
pixel format definitions
@ AV_PIX_FMT_XYZ12LE
packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as lit...
Definition pixfmt.h:196
@ AV_PIX_FMT_RGB48LE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
Definition pixfmt.h:110
#define FF_ARRAY_ELEMS(a)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
const char * name
Definition pixdesc.h:70
static const int input_sizes[]
Definition sw_rgb.c:351
#define randomize_buffers(buf, size)
Definition sw_xyz2rgb.c:36
void checkasm_check_sw_xyz2rgb(void)
Definition sw_xyz2rgb.c:104
static void check_xyz12Torgb48le(void)
Definition sw_xyz2rgb.c:42
av_cold void ff_sws_init_xyzdsp(SwsInternal *c)
Definition swscale.c:863
external API header
av_cold int ff_sws_fill_xyztables(SwsInternal *c)
Definition utils.c:735
#define NUM_LINES
#define src
Definition vp8dsp.c:248
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89
#define MAX_LINE_SIZE
Definition vf_lut3d.c:547
static double c[64]