FFmpeg
hevc_idct.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Alexandra Hájková
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 "libavutil/intreadwrite.h"
24 #include "libavutil/mem_internal.h"
25 
26 #include "libavcodec/hevcdsp.h"
27 
28 #include "checkasm.h"
29 
30 #define randomize_buffers(buf, size) \
31  do { \
32  int j; \
33  for (j = 0; j < size; j++) { \
34  int16_t r = rnd(); \
35  AV_WN16A(buf + j, r); \
36  } \
37  } while (0)
38 
40 {
41  int i;
42  LOCAL_ALIGNED(32, int16_t, coeffs0, [32 * 32]);
43  LOCAL_ALIGNED(32, int16_t, coeffs1, [32 * 32]);
44 
45  for (i = 2; i <= 5; i++) {
46  int block_size = 1 << i;
47  int size = block_size * block_size;
48  int col_limit = block_size;
49  declare_func(void, int16_t *coeffs, int col_limit);
50 
51  randomize_buffers(coeffs0, size);
52  memcpy(coeffs1, coeffs0, sizeof(*coeffs0) * size);
53  if (check_func(h.idct[i - 2], "hevc_idct_%dx%d_%d", block_size, block_size, bit_depth)) {
54  call_ref(coeffs0, col_limit);
55  call_new(coeffs1, col_limit);
56  if (memcmp(coeffs0, coeffs1, sizeof(*coeffs0) * size))
57  fail();
58  bench_new(coeffs1, col_limit);
59  }
60  }
61 }
62 
64 {
65  int i;
66  LOCAL_ALIGNED(32, int16_t, coeffs0, [32 * 32]);
67  LOCAL_ALIGNED(32, int16_t, coeffs1, [32 * 32]);
68 
69  for (i = 2; i <= 5; i++) {
70  int block_size = 1 << i;
71  int size = block_size * block_size;
72  declare_func_emms(AV_CPU_FLAG_MMXEXT, void, int16_t *coeffs);
73 
74  randomize_buffers(coeffs0, size);
75  memcpy(coeffs1, coeffs0, sizeof(*coeffs0) * size);
76 
77  if (check_func(h.idct_dc[i - 2], "hevc_idct_%dx%d_dc_%d", block_size, block_size, bit_depth)) {
78  call_ref(coeffs0);
79  call_new(coeffs1);
80  if (memcmp(coeffs0, coeffs1, sizeof(*coeffs0) * size))
81  fail();
82  bench_new(coeffs1);
83  }
84  }
85 }
86 
88 {
89  int bit_depth;
90 
91  for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) {
93 
94  ff_hevc_dsp_init(&h, bit_depth);
95  check_idct_dc(h, bit_depth);
96  }
97  report("idct_dc");
98 
99  for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) {
101 
102  ff_hevc_dsp_init(&h, bit_depth);
103  check_idct(h, bit_depth);
104  }
105  report("idct");
106 }
#define LOCAL_ALIGNED(a, t, v,...)
Definition: mem_internal.h:113
#define report
Definition: checkasm.h:136
void(* idct[4])(int16_t *coeffs, int col_limit)
Definition: hevcdsp.h:59
#define AV_CPU_FLAG_MMXEXT
SSE integer functions or AMD MMX ext.
Definition: cpu.h:32
ptrdiff_t size
Definition: opengl_enc.c:100
void checkasm_check_hevc_idct(void)
Definition: hevc_idct.c:87
#define declare_func(ret,...)
Definition: checkasm.h:128
#define fail()
Definition: checkasm.h:133
static void bit_depth(AudioStatsContext *s, uint64_t mask, uint64_t imask, AVRational *depth)
Definition: af_astats.c:254
#define randomize_buffers(buf, size)
Definition: hevc_idct.c:30
void(* idct_dc[4])(int16_t *coeffs)
Definition: hevcdsp.h:61
#define declare_func_emms(cpu_flags, ret,...)
Definition: checkasm.h:130
#define call_ref(...)
Definition: checkasm.h:139
void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
Definition: hevcdsp.c:126
#define check_func(func,...)
Definition: checkasm.h:124
static void check_idct_dc(HEVCDSPContext h, int bit_depth)
Definition: hevc_idct.c:63
#define bench_new(...)
Definition: checkasm.h:271
#define call_new(...)
Definition: checkasm.h:211
int i
Definition: input.c:407
static void check_idct(HEVCDSPContext h, int bit_depth)
Definition: hevc_idct.c:39