FFmpeg
Loading...
Searching...
No Matches
proresdsp.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
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (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 GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include <string.h>
20
21#include "checkasm.h"
22
24
25#include "libavutil/common.h"
26#include "libavutil/internal.h"
28
29#define IN_IDCT_DEPTH 16
30#define PRORES_ONLY
31
32#define BIT_DEPTH 12
34#undef BIT_DEPTH
35#undef IN_IDCT_DEPTH
36
37#define CLIP_MIN (1 << 2)
38#define CLIP_MAX_12 ((1 << 12) - CLIP_MIN - 1)
39
40#define BLOCK_SIZE 64
41
42static void permute_block(int16_t *dst, const int16_t *src, const uint8_t *perm)
43{
44 for (int i = 0; i < BLOCK_SIZE; i++)
45 dst[i] = src[perm[i]];
46}
47
48static void ref_idct_put_12(uint16_t *dst, ptrdiff_t linesize,
49 const int16_t *src_block, const int16_t *src_qmat)
50{
51 int16_t block[BLOCK_SIZE];
52
53 for (int i = 0; i < BLOCK_SIZE; i++)
54 block[i] = src_block[i] * src_qmat[i];
55
56 for (int i = 0; i < 8; i++)
57 idctRowCondDC_int16_12bit(block + i * 8, 0);
58
59 for (int i = 0; i < 8; i++) {
60 block[i] += 8192;
61 idctSparseCol_int16_12bit(block + i);
62 }
63
64 for (int y = 0; y < 8; y++)
65 for (int x = 0; x < 8; x++)
66 dst[y * (linesize >> 1) + x] = av_clip(block[y * 8 + x], CLIP_MIN, CLIP_MAX_12);
67}
68
70{
72 LOCAL_ALIGNED_32(int16_t, qmat, [BLOCK_SIZE]);
73 LOCAL_ALIGNED_16(uint16_t, dst_ref, [BLOCK_SIZE]);
74 LOCAL_ALIGNED_16(uint16_t, dst_new, [BLOCK_SIZE]);
75 int16_t src_block[BLOCK_SIZE];
76 int16_t src_qmat[BLOCK_SIZE];
77 ProresDSPContext dsp = { 0 };
78
79 ff_proresdsp_init(&dsp, 12);
80
81 if (check_func(dsp.idct_put, "prores_idct_put_12")) {
82 declare_func(void, uint16_t *dst, ptrdiff_t linesize, int16_t *block, const int16_t *qmat);
83
84 for (int i = 0; i < BLOCK_SIZE; i++) {
85 src_qmat[i] = 1 + (rnd() % 255);
86 src_block[i] = (int16_t)rnd();
87 }
88
89 permute_block(block, src_block, dsp.idct_permutation);
90 permute_block(qmat, src_qmat, dsp.idct_permutation);
91
92 ref_idct_put_12(dst_ref, 16, src_block, src_qmat);
93
94 call_new(dst_new, 16, block, qmat);
95
96 if (memcmp(dst_ref, dst_new, BLOCK_SIZE * sizeof(*dst_ref)))
97 fail();
98
99 bench_new(dst_new, 16, block, qmat);
100 }
101
102 report("prores_idct_put_12");
103}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
#define BLOCK_SIZE
Definition adx.h:51
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define rnd
Definition checkasm.h:137
common internal and external API header
#define av_clip
Definition common.h:100
static int16_t block[64]
Definition dct.c:125
perm
Definition f_perms.c:75
#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 report
Definition test.h:480
#define CLIP_MAX_12
maximum value for clipping resulting pixels
Definition proresdsp.c:102
av_cold void ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample)
Definition proresdsp.c:172
#define CLIP_MIN
minimum value for clipping resulting pixels
Definition proresdsp.c:100
common internal API header
#define LOCAL_ALIGNED_32(t, v,...)
#define LOCAL_ALIGNED_16(t, v,...)
simpleidct in C.
void(* idct_put)(uint16_t *out, ptrdiff_t linesize, int16_t *block, const int16_t *qmat)
Definition proresdsp.h:32
uint8_t idct_permutation[64]
Definition proresdsp.h:31
static void ref_idct_put_12(uint16_t *dst, ptrdiff_t linesize, const int16_t *src_block, const int16_t *src_qmat)
Definition proresdsp.c:48
static void permute_block(int16_t *dst, const int16_t *src, const uint8_t *perm)
Definition proresdsp.c:42
void checkasm_check_proresdsp(void)
Definition proresdsp.c:69
#define src
Definition vp8dsp.c:248