FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
tests
checkasm
alacdsp.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 James Almer
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
#include "
checkasm.h
"
23
#include "
libavcodec/alacdsp.h
"
24
#include "
libavcodec/mathops.h
"
25
#include "
libavutil/common.h
"
26
#include "
libavutil/internal.h
"
27
28
#define BUF_SIZE 256
29
#define MAX_CHANNELS 2
30
31
#define randomize_buffers() \
32
do { \
33
int i; \
34
for (i = 0; i < BUF_SIZE*MAX_CHANNELS; i++) { \
35
int32_t r = sign_extend(rnd(), 24); \
36
ref_buf[i] = r; \
37
new_buf[i] = r; \
38
} \
39
} while (0)
40
41
static
void
check_decorrelate_stereo
(
void
)
42
{
43
LOCAL_ALIGNED_16
(
int32_t
, ref_buf, [
BUF_SIZE
*
MAX_CHANNELS
]);
44
LOCAL_ALIGNED_16
(
int32_t
, new_buf, [
BUF_SIZE
*MAX_CHANNELS]);
45
int32_t
*ref[2] = { &ref_buf[
BUF_SIZE
*0], &ref_buf[
BUF_SIZE
*1] };
46
int32_t
*
new
[2] = { &new_buf[
BUF_SIZE
*0], &new_buf[
BUF_SIZE
*1] };
47
ALACDSPContext
c
;
48
49
ff_alacdsp_init
(&c);
50
if
(
check_func
(c.
decorrelate_stereo
,
"alac_decorrelate_stereo"
)) {
51
int
len
= (
rnd
() & 0xFF) + 1;
52
int
shift
=
rnd
() & 0x1F;
53
int
weight
=
rnd
() & 0xFF;
54
declare_func
(
void
,
int32_t
*
buf
[2],
int
len,
int
shift,
int
weight);
55
56
randomize_buffers
();
57
call_ref
(ref, len, shift, weight);
58
call_new
(
new
, len, shift, weight);
59
if
(memcmp(ref[0],
new
[0], len *
sizeof
(
int32_t
)) ||
60
memcmp(ref[1],
new
[1], len *
sizeof
(
int32_t
)))
61
fail
();
62
bench_new
(
new
,
BUF_SIZE
, shift, weight);
63
}
64
65
report
(
"decorrelate_stereo"
);
66
}
67
68
#undef randomize_buffers
69
#define randomize_buffers() \
70
do { \
71
int i, j; \
72
for (i = 0; i < BUF_SIZE; i++) { \
73
for (j = 0; j < ch; j++) { \
74
int32_t r = sign_extend(rnd(), 24); \
75
ref[j][i] = r; \
76
new[j][i] = r; \
77
r = rnd() & 0xFF; \
78
ref_ebb[j][i] = r; \
79
new_ebb[j][i] = r; \
80
} \
81
} \
82
} while (0)
83
84
static
void
check_append_extra_bits
(
void
)
85
{
86
LOCAL_ALIGNED_16
(
int32_t
, ref_buf, [
BUF_SIZE
*
MAX_CHANNELS
*2]);
87
LOCAL_ALIGNED_16
(
int32_t
, new_buf, [
BUF_SIZE
*MAX_CHANNELS*2]);
88
int32_t
*ref[2] = { &ref_buf[
BUF_SIZE
*0], &ref_buf[
BUF_SIZE
*1] };
89
int32_t
*
new
[2] = { &new_buf[
BUF_SIZE
*0], &new_buf[
BUF_SIZE
*1] };
90
int32_t
*ref_ebb[2] = { &ref_buf[
BUF_SIZE
*2], &ref_buf[
BUF_SIZE
*3] };
91
int32_t
*new_ebb[2] = { &new_buf[
BUF_SIZE
*2], &new_buf[
BUF_SIZE
*3] };
92
ALACDSPContext
c
;
93
static
const
char
*
const
channels[2] = {
"mono"
,
"stereo"
};
94
int
ch;
95
96
ff_alacdsp_init
(&c);
97
for
(ch = 1; ch <= 2; ch++) {
98
if
(
check_func
(c.
append_extra_bits
[ch-1],
"alac_append_extra_bits_%s"
, channels[ch-1])) {
99
int
len
= (
rnd
() & 0xFF) + 1;
100
declare_func
(
void
,
int32_t
*
buf
[2],
int32_t
*ebb[2],
int
ebits,
int
ch,
int
len);
101
102
randomize_buffers
();
103
call_ref
(ref, ref_ebb, 8, ch, len);
104
call_new
(
new
, new_ebb, 8, ch, len);
105
if
( memcmp(ref[0],
new
[0], len *
sizeof
(
int32_t
)) ||
106
(ch == 2 && memcmp(ref[1],
new
[1], len *
sizeof
(
int32_t
))))
107
fail
();
108
bench_new
(
new
, new_ebb, 8, ch,
BUF_SIZE
);
109
}
110
}
111
112
report
(
"append_extra_bits"
);
113
}
114
115
void
checkasm_check_alacdsp
(
void
)
116
{
117
check_decorrelate_stereo
();
118
check_append_extra_bits
();
119
}
shift
static int shift(int a, int b)
Definition:
sonic.c:82
BUF_SIZE
#define BUF_SIZE
Definition:
alacdsp.c:28
MAX_CHANNELS
#define MAX_CHANNELS
Definition:
alacdsp.c:29
checkasm_check_alacdsp
void checkasm_check_alacdsp(void)
Definition:
alacdsp.c:115
report
#define report
Definition:
checkasm.h:83
checkasm.h
declare_func
#define declare_func(ret,...)
Definition:
checkasm.h:76
ALACDSPContext
Definition:
alacdsp.h:24
check_decorrelate_stereo
static void check_decorrelate_stereo(void)
Definition:
alacdsp.c:41
fail
#define fail()
Definition:
checkasm.h:80
internal.h
common internal API header
check_append_extra_bits
static void check_append_extra_bits(void)
Definition:
alacdsp.c:84
randomize_buffers
#define randomize_buffers()
Definition:
alacdsp.c:69
mathops.h
int32_t
int32_t
Definition:
audio_convert.c:194
call_ref
#define call_ref(...)
Definition:
checkasm.h:86
buf
void * buf
Definition:
avisynth_c.h:553
check_func
#define check_func(func,...)
Definition:
checkasm.h:72
ALACDSPContext::append_extra_bits
void(* append_extra_bits[2])(int32_t *buffer[2], int32_t *extra_bits_buffer[2], int extra_bits, int channels, int nb_samples)
Definition:
alacdsp.h:27
weight
static int weight(int i, int blen, int offset)
Definition:
diracdec.c:1413
common.h
common internal and external API header
c
static double c[64]
Definition:
vsrc_mptestsrc.c:87
rnd
#define rnd()
Definition:
checkasm.h:65
ALACDSPContext::decorrelate_stereo
void(* decorrelate_stereo)(int32_t *buffer[2], int nb_samples, int decorr_shift, int decorr_left_weight)
Definition:
alacdsp.h:25
len
int len
Definition:
vorbis_enc_data.h:452
bench_new
#define bench_new(...)
Definition:
checkasm.h:172
alacdsp.h
LOCAL_ALIGNED_16
#define LOCAL_ALIGNED_16(t, v,...)
Definition:
internal.h:121
call_new
#define call_new(...)
Definition:
checkasm.h:141
ff_alacdsp_init
av_cold void ff_alacdsp_init(ALACDSPContext *c)
Definition:
alacdsp.c:55
Generated on Mon Feb 15 2016 15:20:36 for FFmpeg by
1.8.6