FFmpeg
Loading...
Searching...
No Matches
vvc_sao.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Yingming Fan <yingmingfan@gmail.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
23#include "checkasm.h"
26
27#include "libavcodec/vvc/dsp.h"
28#include "libavcodec/vvc/ctu.h"
29
30static const uint32_t pixel_mask[3] = { 0xffffffff, 0x03ff03ff, 0x0fff0fff };
31static const uint32_t sao_size[] = {8, 16, 32, 48, 64, 80, 96, 112, 128};
32
33#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
34#define PIXEL_STRIDE (2*MAX_CTU_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) //same with sao_edge src_stride
35#define BUF_SIZE (PIXEL_STRIDE * (MAX_CTU_SIZE+2) * 2) //+2 for top and bottom row, *2 for high bit depth
36#define OFFSET_THRESH (1 << (bit_depth - 5))
37#define OFFSET_LENGTH 5
38
39#define randomize_buffers(buf0, buf1, size) \
40 do { \
41 uint32_t mask = pixel_mask[(bit_depth - 8) >> 1]; \
42 int k; \
43 for (k = 0; k < size; k += 4) { \
44 uint32_t r = rnd() & mask; \
45 AV_WN32A(buf0 + k, r); \
46 AV_WN32A(buf1 + k, r); \
47 } \
48 } while (0)
49
50#define randomize_buffers2(buf, size) \
51 do { \
52 uint32_t max_offset = OFFSET_THRESH; \
53 int k; \
54 if (bit_depth == 8) { \
55 for (k = 0; k < size; k++) { \
56 uint8_t r = rnd() % max_offset; \
57 buf[k] = r; \
58 } \
59 } else { \
60 for (k = 0; k < size; k++) { \
61 uint16_t r = rnd() % max_offset; \
62 buf[k] = r; \
63 } \
64 } \
65 } while (0)
66
68{
71 LOCAL_ALIGNED_32(uint8_t, src0, [BUF_SIZE]);
72 LOCAL_ALIGNED_32(uint8_t, src1, [BUF_SIZE]);
73 int16_t offset_val[OFFSET_LENGTH];
74 const int left_class = rnd()%32;
75 const int walign = 16;
76
77 for (int i = 0; i < FF_ARRAY_ELEMS(sao_size); i++) {
78 const int block_size = sao_size[i];
79 const int prev_size = i > 0 ? sao_size[i - 1] : 0;
81 declare_func(void, uint8_t *dst, const uint8_t *src, ptrdiff_t dst_stride, ptrdiff_t src_stride,
82 const int16_t *sao_offset_val, int sao_left_class, int width, int height);
83
84 if (check_func(h->sao.band_filter[i], "vvc_sao_band_%d_%d", block_size, bit_depth)) {
85
86 for (int w = prev_size + 4; w <= block_size; w += 4) {
89 CLEAR_PIXEL_RECT(dst0);
90 CLEAR_PIXEL_RECT(dst1);
91
92 call_ref(dst0, src0, dst0_stride, stride, offset_val, left_class, w, block_size);
93 call_new(dst1, src1, dst1_stride, stride, offset_val, left_class, w, block_size);
94 checkasm_check_pixel_padded_align(dst0, dst0_stride, dst1, dst1_stride, w, block_size, "dst", walign, 1);
95 }
96 bench_new(dst1, src1, dst1_stride, stride, offset_val, left_class, block_size, block_size);
97 }
98 }
99}
100
102{
105 LOCAL_ALIGNED_32(uint8_t, src0, [BUF_SIZE]);
106 LOCAL_ALIGNED_32(uint8_t, src1, [BUF_SIZE]);
107 int16_t offset_val[OFFSET_LENGTH];
108 const int eo = rnd()%4;
109 const int walign = 16;
110
111 for (int i = 0; i < FF_ARRAY_ELEMS(sao_size); i++) {
112 int block_size = sao_size[i];
113 int prev_size = i > 0 ? sao_size[i - 1] : 0;
115 declare_func(void, uint8_t *dst, const uint8_t *src, ptrdiff_t stride_dst,
116 const int16_t *sao_offset_val, int eo, int width, int height);
117
118 if (check_func(h->sao.edge_filter[i], "vvc_sao_edge_%d_%d", block_size, bit_depth)) {
119 for (int w = prev_size + 4; w <= block_size; w += 4) {
122 CLEAR_PIXEL_RECT(dst0);
123 CLEAR_PIXEL_RECT(dst1);
124
125 call_ref(dst0, src0 + offset, dst0_stride, offset_val, eo, w, block_size);
126 call_new(dst1, src1 + offset, dst1_stride, offset_val, eo, w, block_size);
127 checkasm_check_pixel_padded_align(dst0, dst0_stride, dst1, dst1_stride, w, block_size, "dst", walign, 1);
128 }
129 bench_new(dst1, src1 + offset, dst1_stride, offset_val, eo, block_size, block_size);
130 }
131 }
132}
133
135{
136 int bit_depth;
137
138 for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) {
140
143 }
144 report("sao_band");
145
146 for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) {
148
151 }
152 report("sao_edge");
153}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Definition af_astats.c:246
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define rnd
Definition checkasm.h:136
#define CLEAR_PIXEL_RECT(name)
Definition checkasm.h:152
#define checkasm_check_pixel_padded_align(...)
Definition checkasm.h:169
#define PIXEL_RECT(name, w, h)
Definition checkasm.h:145
#define MAX_CTU_SIZE
Definition ctu.h:33
#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 AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
Definition defs.h:40
#define OFFSET_LENGTH
Definition hevc_sao.c:37
static const uint32_t sao_size[5]
Definition hevc_sao.c:31
unsigned offset
Definition libaomenc.c:763
uint8_t w
Definition llvidencdsp.c:39
#define LOCAL_ALIGNED_32(t, v,...)
#define BUF_SIZE
Definition setpts.c:159
#define FF_ARRAY_ELEMS(a)
#define stride
#define SIZEOF_PIXEL
Definition h264chroma.c:28
static const uint32_t pixel_mask[5]
Definition h264dsp.c:31
#define PIXEL_STRIDE
Definition h264dsp.c:36
#define src1
Definition h264pred.c:141
#define src0
Definition h264pred.c:140
#define src
Definition vp8dsp.c:248
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89
void ff_vvc_dsp_init(VVCDSPContext *vvcdsp, int bit_depth)
Definition dsp.c:86
#define randomize_buffers2(buf, size)
Definition vvc_sao.c:50
#define randomize_buffers(buf0, buf1, size)
Definition vvc_sao.c:39
void checkasm_check_vvc_sao(void)
Definition vvc_sao.c:134
static void check_sao_edge(VVCDSPContext *h, int bit_depth)
Definition vvc_sao.c:101
static void check_sao_band(VVCDSPContext *h, int bit_depth)
Definition vvc_sao.c:67