Mercurial > audlegacy
annotate src/libSAD/dither_ops.c @ 4618:76573253fa55
Configure option '--enable-one-plugin-dir' is unused in core, so we'll remove it.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 05 Jun 2008 09:20:37 +0300 |
parents | 21008f43bb93 |
children | bb0638143fc8 |
rev | line source |
---|---|
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
1 /* Scale & Dither library (libSAD) |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
2 * High-precision bit depth converter with ReplayGain support |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
3 * |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
4 * Copyright (c) 2007-2008 Eugene Zagidullin (e.asphyx@gmail.com) |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
5 * |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
9 * (at your option) any later version. |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
10 * |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
16 * along with this program; if not, write to the Free Software |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
18 */ |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
19 |
4242
21008f43bb93
RG improved. It f... works.
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4241
diff
changeset
|
20 /* WARNING: reading this can damage your brain */ |
21008f43bb93
RG improved. It f... works.
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4241
diff
changeset
|
21 |
4234 | 22 #include "common.h" |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
23 #include "dither_ops.h" |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
24 #include "dither.h" |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
25 |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
26 #define SAD_GET_LE16(a) ( (uint16_t)(((uint8_t*)(a))[0]) | (uint16_t)(((uint8_t*)(a))[1]) << 8 ) |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
27 #define SAD_GET_BE16(a) ( (uint16_t)(((uint8_t*)(a))[0]) << 8 | (uint16_t)(((uint8_t*)(a))[1]) ) |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
28 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
29 #define SAD_GET_LE32(a) ( (uint32_t)(((uint8_t*)(a))[0]) | (uint32_t)(((uint8_t*)(a))[1]) << 8 | \ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
30 (uint32_t)(((uint8_t*)(a))[2]) << 16 | (uint32_t)(((uint8_t*)(a))[3]) << 24 ) |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
31 #define SAD_GET_BE32(a) ( (uint32_t)(((uint8_t*)(a))[0]) << 24 | (uint32_t)(((uint8_t*)(a))[1]) << 16 | \ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
32 (uint32_t)(((uint8_t*)(a))[2]) << 8 | (uint32_t)(((uint8_t*)(a))[3]) ) |
4234 | 33 |
34 #define SAD_PUT_LE16(a,b) { \ | |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
35 ((uint8_t*)(a))[0] = (uint8_t)((uint32_t)(b) & 0x000000ff); \ |
4234 | 36 ((uint8_t*)(a))[1] = (uint8_t)(((uint32_t)(b) & 0x0000ff00) >> 8); \ |
37 } | |
38 | |
39 #define SAD_PUT_BE16(a,b) { \ | |
4238
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
40 ((uint8_t*)(a))[0] = (uint8_t)(((uint32_t)(b) & 0x0000ff00) >> 8); \ |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
41 ((uint8_t*)(a))[1] = (uint8_t)((uint32_t)(b) & 0x000000ff); \ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
42 } |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
43 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
44 #define SAD_PUT_LE32(a,b) { \ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
45 ((uint8_t*)(a))[0] = (uint8_t)((uint32_t)(b) & 0x000000ff); \ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
46 ((uint8_t*)(a))[1] = (uint8_t)(((uint32_t)(b) & 0x0000ff00) >> 8); \ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
47 ((uint8_t*)(a))[2] = (uint8_t)(((uint32_t)(b) & 0x00ff0000) >> 16); \ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
48 ((uint8_t*)(a))[3] = (uint8_t)(((uint32_t)(b) & 0xff000000) >> 24); \ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
49 } |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
50 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
51 #define SAD_PUT_BE32(a,b) { \ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
52 ((uint8_t*)(a))[0] = (uint8_t)(((uint32_t)(b) & 0xff000000) >> 24); \ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
53 ((uint8_t*)(a))[1] = (uint8_t)(((uint32_t)(b) & 0x00ff0000) >> 16); \ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
54 ((uint8_t*)(a))[2] = (uint8_t)(((uint32_t)(b) & 0x0000ff00) >> 8); \ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
55 ((uint8_t*)(a))[3] = (uint8_t)((uint32_t)(b) & 0x000000ff); \ |
4234 | 56 } |
57 | |
58 | |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
59 /* buffer ops: */ |
4234 | 60 /**************************************************************************************************************** |
61 * 8-bit * | |
62 ****************************************************************************************************************/ | |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
63 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
64 /* signed */ |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
65 static int32_t get_s8_i_sample (void *buf, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
66 return ((int8_t*)buf)[i*nch+ch]; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
67 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
68 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
69 static int32_t get_s8_s_sample (void *buf, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
70 return ((int8_t**)buf)[ch][i]; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
71 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
72 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
73 static void put_s8_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
74 ((int8_t*)buf)[i*nch+ch] = (int8_t)sample; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
75 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
76 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
77 static void put_s8_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
78 ((int8_t**)buf)[ch][i] = (int8_t)sample; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
79 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
80 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
81 /* unsigned */ |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
82 static int32_t get_u8_i_sample (void *buf, int nch, int ch, int i) { |
4234 | 83 return (int32_t)(((uint8_t*)buf)[i*nch+ch]) - 128; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
84 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
85 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
86 static int32_t get_u8_s_sample (void *buf, int nch, int ch, int i) { |
4234 | 87 return (int32_t)(((uint8_t**)buf)[ch][i]) - 128; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
88 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
89 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
90 static void put_u8_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
4234 | 91 ((uint8_t*)buf)[i*nch+ch] = (uint8_t)sample + 128; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
92 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
93 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
94 static void put_u8_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
4234 | 95 ((uint8_t**)buf)[ch][i] = (uint8_t)sample + 128; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
96 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
97 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
98 static SAD_buffer_ops buf_s8_i_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
99 &get_s8_i_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
100 &put_s8_i_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
101 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
102 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
103 static SAD_buffer_ops buf_s8_s_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
104 &get_s8_s_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
105 &put_s8_s_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
106 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
107 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
108 static SAD_buffer_ops buf_u8_i_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
109 &get_u8_i_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
110 &put_u8_i_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
111 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
112 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
113 static SAD_buffer_ops buf_u8_s_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
114 &get_u8_s_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
115 &put_u8_s_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
116 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
117 |
4234 | 118 /**************************************************************************************************************** |
119 * 16-bit * | |
120 ****************************************************************************************************************/ | |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
121 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
122 /* signed */ |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
123 static int32_t get_s16_i_sample (void *buf, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
124 return (int32_t)(((int16_t*)buf)[i*nch+ch]); |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
125 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
126 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
127 static int32_t get_s16_s_sample (void *buf, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
128 return (int32_t)(((int16_t**)buf)[ch][i]); |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
129 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
130 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
131 static void put_s16_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
132 ((int16_t*)buf)[i*nch+ch] = (int16_t)sample; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
133 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
134 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
135 static void put_s16_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
136 ((int16_t**)buf)[ch][i] = (int16_t)sample; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
137 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
138 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
139 /* unsigned */ |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
140 static int32_t get_u16_i_sample (void *buf, int nch, int ch, int i) { |
4234 | 141 return ((int32_t)(((uint16_t*)buf)[i*nch+ch])) - 32768; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
142 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
143 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
144 static int32_t get_u16_s_sample (void *buf, int nch, int ch, int i) { |
4234 | 145 return ((int32_t)(((uint16_t**)buf)[ch][i])) - 32768; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
146 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
147 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
148 static void put_u16_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
4234 | 149 ((uint16_t*)buf)[i*nch+ch] = (uint16_t)(sample + 32768); |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
150 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
151 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
152 static void put_u16_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
4234 | 153 ((uint16_t**)buf)[ch][i] = (uint16_t)(sample + 32768); |
154 } | |
155 | |
156 /* LE: signed */ | |
157 static int32_t get_s16_le_i_sample (void *buf, int nch, int ch, int i) { | |
158 int16_t *tmp = (int16_t*)buf+i*nch+ch; | |
159 return (int16_t)SAD_GET_LE16(tmp); | |
160 } | |
161 | |
162 static int32_t get_s16_le_s_sample (void *buf, int nch, int ch, int i) { | |
163 int16_t *tmp = ((int16_t**)buf)[ch]+i; | |
164 return (int16_t)SAD_GET_LE16(tmp); | |
165 } | |
166 | |
167 static void put_s16_le_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { | |
168 int16_t *tmp = (int16_t*)buf+i*nch+ch; | |
169 SAD_PUT_LE16(tmp, sample); | |
170 } | |
171 | |
172 static void put_s16_le_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { | |
173 int16_t *tmp = ((int16_t**)buf)[ch]+i; | |
174 SAD_PUT_LE16(tmp, sample); | |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
175 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
176 |
4238
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
177 /* BE: signed */ |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
178 static int32_t get_s16_be_i_sample (void *buf, int nch, int ch, int i) { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
179 int16_t *tmp = (int16_t*)buf+i*nch+ch; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
180 return (int16_t)SAD_GET_BE16(tmp); |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
181 } |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
182 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
183 static int32_t get_s16_be_s_sample (void *buf, int nch, int ch, int i) { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
184 int16_t *tmp = ((int16_t**)buf)[ch]+i; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
185 return (int16_t)SAD_GET_BE16(tmp); |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
186 } |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
187 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
188 static void put_s16_be_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
189 int16_t *tmp = (int16_t*)buf+i*nch+ch; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
190 SAD_PUT_BE16(tmp, sample); |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
191 } |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
192 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
193 static void put_s16_be_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
194 int16_t *tmp = ((int16_t**)buf)[ch]+i; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
195 SAD_PUT_BE16(tmp, sample); |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
196 } |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
197 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
198 /* LE: unsigned */ |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
199 static int32_t get_u16_le_i_sample (void *buf, int nch, int ch, int i) { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
200 int16_t *tmp = (int16_t*)buf+i*nch+ch; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
201 return (int16_t)SAD_GET_LE16(tmp) - 32768; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
202 } |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
203 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
204 static int32_t get_u16_le_s_sample (void *buf, int nch, int ch, int i) { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
205 int16_t *tmp = ((int16_t**)buf)[ch]+i; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
206 return (int16_t)SAD_GET_LE16(tmp) - 32768; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
207 } |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
208 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
209 static void put_u16_le_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
210 int16_t *tmp = (int16_t*)buf+i*nch+ch; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
211 SAD_PUT_LE16(tmp, sample + 32768); |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
212 } |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
213 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
214 static void put_u16_le_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
215 int16_t *tmp = ((int16_t**)buf)[ch]+i; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
216 SAD_PUT_LE16(tmp, sample + 32768); |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
217 } |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
218 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
219 /* BE: unsigned */ |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
220 static int32_t get_u16_be_i_sample (void *buf, int nch, int ch, int i) { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
221 int16_t *tmp = (int16_t*)buf+i*nch+ch; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
222 return (int16_t)SAD_GET_BE16(tmp) - 32768; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
223 } |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
224 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
225 static int32_t get_u16_be_s_sample (void *buf, int nch, int ch, int i) { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
226 int16_t *tmp = ((int16_t**)buf)[ch]+i; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
227 return (int16_t)SAD_GET_BE16(tmp) - 32768; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
228 } |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
229 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
230 static void put_u16_be_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
231 int16_t *tmp = (int16_t*)buf+i*nch+ch; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
232 SAD_PUT_BE16(tmp, sample + 32768); |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
233 } |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
234 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
235 static void put_u16_be_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
236 int16_t *tmp = ((int16_t**)buf)[ch]+i; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
237 SAD_PUT_BE16(tmp, sample + 32768); |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
238 } |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
239 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
240 |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
241 static SAD_buffer_ops buf_s16_i_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
242 &get_s16_i_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
243 &put_s16_i_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
244 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
245 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
246 static SAD_buffer_ops buf_s16_s_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
247 &get_s16_s_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
248 &put_s16_s_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
249 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
250 |
4234 | 251 static SAD_buffer_ops buf_s16_le_i_ops = { |
252 &get_s16_le_i_sample, | |
253 &put_s16_le_i_sample | |
254 }; | |
255 | |
256 static SAD_buffer_ops buf_s16_le_s_ops = { | |
257 &get_s16_le_s_sample, | |
258 &put_s16_le_s_sample | |
259 }; | |
260 | |
4238
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
261 static SAD_buffer_ops buf_s16_be_i_ops = { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
262 &get_s16_be_i_sample, |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
263 &put_s16_be_i_sample |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
264 }; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
265 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
266 static SAD_buffer_ops buf_s16_be_s_ops = { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
267 &get_s16_be_s_sample, |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
268 &put_s16_be_s_sample |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
269 }; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
270 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
271 /* unsigned */ |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
272 |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
273 static SAD_buffer_ops buf_u16_i_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
274 &get_u16_i_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
275 &put_u16_i_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
276 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
277 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
278 static SAD_buffer_ops buf_u16_s_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
279 &get_u16_s_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
280 &put_u16_s_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
281 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
282 |
4238
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
283 static SAD_buffer_ops buf_u16_le_i_ops = { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
284 &get_u16_le_i_sample, |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
285 &put_u16_le_i_sample |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
286 }; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
287 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
288 static SAD_buffer_ops buf_u16_le_s_ops = { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
289 &get_u16_le_s_sample, |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
290 &put_u16_le_s_sample |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
291 }; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
292 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
293 static SAD_buffer_ops buf_u16_be_i_ops = { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
294 &get_u16_be_i_sample, |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
295 &put_u16_be_i_sample |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
296 }; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
297 |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
298 static SAD_buffer_ops buf_u16_be_s_ops = { |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
299 &get_u16_be_s_sample, |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
300 &put_u16_be_s_sample |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
301 }; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
302 |
4234 | 303 /**************************************************************************************************************** |
304 * 24-bit * | |
305 ****************************************************************************************************************/ | |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
306 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
307 /*expand 24-bit signed value to 32-bit*/ |
4240
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
308 #define EXPAND_S24_TO_32(x) (((int32_t)(((x) & 0x00ffffff) << 8)) >> 8) |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
309 #define EXPAND_U24_TO_32(x) ((int32_t)(x) & 0x00ffffff) |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
310 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
311 /* signed */ |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
312 static int32_t get_s24_i_sample (void *buf, int nch, int ch, int i) { |
4240
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
313 return (int32_t)EXPAND_S24_TO_32(((int32_t*)buf)[i*nch+ch]); |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
314 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
315 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
316 static int32_t get_s24_s_sample (void *buf, int nch, int ch, int i) { |
4240
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
317 return (int32_t)EXPAND_S24_TO_32(((int32_t**)buf)[ch][i]); |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
318 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
319 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
320 static void put_s24_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
321 ((int32_t*)buf)[i*nch+ch] = (int32_t)sample & 0x00ffffff; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
322 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
323 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
324 static void put_s24_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
325 ((int32_t**)buf)[ch][i] = (int32_t)sample & 0x00ffffff; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
326 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
327 |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
328 /* LE signed */ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
329 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
330 static int32_t get_s24_le_i_sample (void *buf, int nch, int ch, int i) { |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
331 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
4240
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
332 return (int32_t)EXPAND_S24_TO_32(SAD_GET_LE32(tmp)); |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
333 } |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
334 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
335 static int32_t get_s24_le_s_sample (void *buf, int nch, int ch, int i) { |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
336 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
4240
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
337 return (int32_t)EXPAND_S24_TO_32(SAD_GET_LE32(tmp)); |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
338 } |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
339 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
340 static void put_s24_le_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
341 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
342 SAD_PUT_LE32(tmp, sample & 0x00ffffff); |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
343 } |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
344 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
345 static void put_s24_le_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
346 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
347 SAD_PUT_LE32(tmp, sample & 0x00ffffff); |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
348 } |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
349 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
350 /* BE signed */ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
351 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
352 static int32_t get_s24_be_i_sample (void *buf, int nch, int ch, int i) { |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
353 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
4240
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
354 return (int32_t)EXPAND_S24_TO_32(SAD_GET_BE32(tmp)); |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
355 } |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
356 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
357 static int32_t get_s24_be_s_sample (void *buf, int nch, int ch, int i) { |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
358 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
4240
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
359 return (int32_t)EXPAND_S24_TO_32(SAD_GET_BE32(tmp)); |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
360 } |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
361 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
362 static void put_s24_be_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
363 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
364 SAD_PUT_BE32(tmp, sample & 0x00ffffff); |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
365 } |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
366 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
367 static void put_s24_be_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
368 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
369 SAD_PUT_BE32(tmp, sample & 0x00ffffff); |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
370 } |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
371 |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
372 /* unsigned */ |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
373 static int32_t get_u24_i_sample (void *buf, int nch, int ch, int i) { |
4240
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
374 return (int32_t)EXPAND_U24_TO_32(((uint32_t*)buf)[i*nch+ch]) - 8388608; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
375 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
376 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
377 static int32_t get_u24_s_sample (void *buf, int nch, int ch, int i) { |
4240
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
378 return (int32_t)EXPAND_U24_TO_32(((uint32_t**)buf)[ch][i]) - 8388608; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
379 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
380 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
381 static void put_u24_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
4234 | 382 ((uint32_t*)buf)[i*nch+ch] = ((uint32_t)sample + 8388608) & 0x00ffffff; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
383 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
384 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
385 static void put_u24_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
4234 | 386 ((uint32_t**)buf)[ch][i] = ((uint32_t)sample + 8388608) & 0x00ffffff; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
387 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
388 |
4240
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
389 /* LE unsigned */ |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
390 |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
391 static int32_t get_u24_le_i_sample (void *buf, int nch, int ch, int i) { |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
392 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
393 /*fprintf(stderr, "%d\n", (int32_t)EXPAND_U24_TO_32(SAD_GET_LE32(tmp)) - 8388608);*/ |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
394 return (int32_t)EXPAND_U24_TO_32(SAD_GET_LE32(tmp)) - 8388608; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
395 } |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
396 |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
397 static int32_t get_u24_le_s_sample (void *buf, int nch, int ch, int i) { |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
398 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
399 return (int32_t)EXPAND_U24_TO_32(SAD_GET_LE32(tmp)) - 8388608; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
400 } |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
401 |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
402 static void put_u24_le_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
403 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
404 SAD_PUT_LE32(tmp, (uint32_t)(sample + 8388608) & 0x00ffffff); |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
405 } |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
406 |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
407 static void put_u24_le_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
408 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
409 SAD_PUT_LE32(tmp, (uint32_t)(sample + 8388608) & 0x00ffffff); |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
410 } |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
411 |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
412 /* BE unsigned */ |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
413 |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
414 static int32_t get_u24_be_i_sample (void *buf, int nch, int ch, int i) { |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
415 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
416 return (int32_t)EXPAND_U24_TO_32(SAD_GET_BE32(tmp)) - 8388608; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
417 } |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
418 |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
419 static int32_t get_u24_be_s_sample (void *buf, int nch, int ch, int i) { |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
420 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
421 return (int32_t)EXPAND_U24_TO_32(SAD_GET_BE32(tmp)) - 8388608; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
422 } |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
423 |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
424 static void put_u24_be_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
425 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
426 SAD_PUT_BE32(tmp, (uint32_t)(sample + 8388608) & 0x00ffffff); |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
427 } |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
428 |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
429 static void put_u24_be_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
430 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
431 SAD_PUT_BE32(tmp, (uint32_t)(sample + 8388608) & 0x00ffffff); |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
432 } |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
433 |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
434 static SAD_buffer_ops buf_s24_i_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
435 &get_s24_i_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
436 &put_s24_i_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
437 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
438 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
439 static SAD_buffer_ops buf_s24_s_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
440 &get_s24_s_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
441 &put_s24_s_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
442 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
443 |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
444 static SAD_buffer_ops buf_s24_le_i_ops = { |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
445 &get_s24_le_i_sample, |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
446 &put_s24_le_i_sample |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
447 }; |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
448 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
449 static SAD_buffer_ops buf_s24_le_s_ops = { |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
450 &get_s24_le_s_sample, |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
451 &put_s24_le_s_sample |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
452 }; |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
453 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
454 static SAD_buffer_ops buf_s24_be_i_ops = { |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
455 &get_s24_be_i_sample, |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
456 &put_s24_be_i_sample |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
457 }; |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
458 |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
459 static SAD_buffer_ops buf_s24_be_s_ops = { |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
460 &get_s24_be_s_sample, |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
461 &put_s24_be_s_sample |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
462 }; |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
463 |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
464 static SAD_buffer_ops buf_u24_i_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
465 &get_u24_i_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
466 &put_u24_i_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
467 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
468 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
469 static SAD_buffer_ops buf_u24_s_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
470 &get_u24_s_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
471 &put_u24_s_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
472 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
473 |
4240
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
474 static SAD_buffer_ops buf_u24_le_i_ops = { |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
475 &get_u24_le_i_sample, |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
476 &put_u24_le_i_sample |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
477 }; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
478 |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
479 static SAD_buffer_ops buf_u24_le_s_ops = { |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
480 &get_u24_le_s_sample, |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
481 &put_u24_le_s_sample |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
482 }; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
483 |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
484 static SAD_buffer_ops buf_u24_be_i_ops = { |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
485 &get_u24_be_i_sample, |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
486 &put_u24_be_i_sample |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
487 }; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
488 |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
489 static SAD_buffer_ops buf_u24_be_s_ops = { |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
490 &get_u24_be_s_sample, |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
491 &put_u24_be_s_sample |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
492 }; |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
493 |
4234 | 494 /**************************************************************************************************************** |
495 * 32-bit * | |
496 ****************************************************************************************************************/ | |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
497 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
498 /* signed */ |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
499 static int32_t get_s32_i_sample (void *buf, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
500 return ((int32_t*)buf)[i*nch+ch]; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
501 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
502 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
503 static int32_t get_s32_s_sample (void *buf, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
504 return ((int32_t**)buf)[ch][i]; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
505 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
506 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
507 static void put_s32_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
508 ((int32_t*)buf)[i*nch+ch] = (int32_t)sample; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
509 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
510 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
511 static void put_s32_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
512 ((int32_t**)buf)[ch][i] = (int32_t)sample; |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
513 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
514 |
4241
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
515 /* LE: signed */ |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
516 static int32_t get_s32_le_i_sample (void *buf, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
517 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
518 return (int32_t)SAD_GET_LE32(tmp); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
519 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
520 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
521 static int32_t get_s32_le_s_sample (void *buf, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
522 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
523 return (int32_t)SAD_GET_LE32(tmp); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
524 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
525 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
526 static void put_s32_le_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
527 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
528 SAD_PUT_LE32(tmp, sample); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
529 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
530 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
531 static void put_s32_le_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
532 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
533 SAD_PUT_LE32(tmp, sample); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
534 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
535 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
536 /* BE: signed */ |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
537 static int32_t get_s32_be_i_sample (void *buf, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
538 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
539 return (int32_t)SAD_GET_BE32(tmp); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
540 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
541 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
542 static int32_t get_s32_be_s_sample (void *buf, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
543 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
544 return (int32_t)SAD_GET_BE32(tmp); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
545 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
546 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
547 static void put_s32_be_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
548 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
549 SAD_PUT_BE32(tmp, sample); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
550 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
551 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
552 static void put_s32_be_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
553 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
554 SAD_PUT_BE32(tmp, sample); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
555 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
556 |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
557 /* unsigned */ |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
558 static int32_t get_u32_i_sample (void *buf, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
559 return ((int32_t*)buf)[i*nch+ch] - (int32_t)(1L<<31); |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
560 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
561 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
562 static int32_t get_u32_s_sample (void *buf, int nch, int ch, int i) { |
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
563 return ((int32_t**)buf)[ch][i] - (int32_t)(1L<<31); |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
564 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
565 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
566 static void put_u32_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
4234 | 567 ((uint32_t*)buf)[i*nch+ch] = (uint32_t)(sample + (int32_t)(1L<<31)); |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
568 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
569 |
4233
74c6f3d3cf1d
it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4232
diff
changeset
|
570 static void put_u32_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
4234 | 571 ((uint32_t**)buf)[ch][i] = (uint32_t)(sample + (int32_t)(1L<<31)); |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
572 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
573 |
4241
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
574 /* LE: unsigned */ |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
575 static int32_t get_u32_le_i_sample (void *buf, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
576 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
577 return (int32_t)SAD_GET_LE32(tmp) - (int32_t)(1L<<31); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
578 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
579 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
580 static int32_t get_u32_le_s_sample (void *buf, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
581 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
582 return (int32_t)SAD_GET_LE32(tmp) - (int32_t)(1L<<31); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
583 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
584 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
585 static void put_u32_le_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
586 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
587 SAD_PUT_LE32(tmp, sample + (int32_t)(1L<<31)); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
588 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
589 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
590 static void put_u32_le_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
591 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
592 SAD_PUT_LE32(tmp, sample + (int32_t)(1L<<31)); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
593 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
594 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
595 /* BE: unsigned */ |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
596 static int32_t get_u32_be_i_sample (void *buf, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
597 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
598 return (int32_t)SAD_GET_BE32(tmp) - (int32_t)(1L<<31); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
599 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
600 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
601 static int32_t get_u32_be_s_sample (void *buf, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
602 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
603 return (int32_t)SAD_GET_BE32(tmp) - (int32_t)(1L<<31); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
604 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
605 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
606 static void put_u32_be_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
607 int32_t *tmp = (int32_t*)buf+i*nch+ch; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
608 SAD_PUT_BE32(tmp, sample + (int32_t)(1L<<31)); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
609 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
610 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
611 static void put_u32_be_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
612 int32_t *tmp = ((int32_t**)buf)[ch]+i; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
613 SAD_PUT_BE32(tmp, sample + (int32_t)(1L<<31)); |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
614 } |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
615 |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
616 static SAD_buffer_ops buf_s32_i_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
617 &get_s32_i_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
618 &put_s32_i_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
619 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
620 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
621 static SAD_buffer_ops buf_s32_s_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
622 &get_s32_s_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
623 &put_s32_s_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
624 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
625 |
4241
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
626 static SAD_buffer_ops buf_s32_le_i_ops = { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
627 &get_s32_le_i_sample, |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
628 &put_s32_le_i_sample |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
629 }; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
630 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
631 static SAD_buffer_ops buf_s32_le_s_ops = { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
632 &get_s32_le_s_sample, |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
633 &put_s32_le_s_sample |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
634 }; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
635 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
636 static SAD_buffer_ops buf_s32_be_i_ops = { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
637 &get_s32_be_i_sample, |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
638 &put_s32_be_i_sample |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
639 }; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
640 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
641 static SAD_buffer_ops buf_s32_be_s_ops = { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
642 &get_s32_be_s_sample, |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
643 &put_s32_be_s_sample |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
644 }; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
645 |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
646 static SAD_buffer_ops buf_u32_i_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
647 &get_u32_i_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
648 &put_u32_i_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
649 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
650 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
651 static SAD_buffer_ops buf_u32_s_ops = { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
652 &get_u32_s_sample, |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
653 &put_u32_s_sample |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
654 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
655 |
4241
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
656 static SAD_buffer_ops buf_u32_le_i_ops = { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
657 &get_u32_le_i_sample, |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
658 &put_u32_le_i_sample |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
659 }; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
660 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
661 static SAD_buffer_ops buf_u32_le_s_ops = { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
662 &get_u32_le_s_sample, |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
663 &put_u32_le_s_sample |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
664 }; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
665 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
666 static SAD_buffer_ops buf_u32_be_i_ops = { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
667 &get_u32_be_i_sample, |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
668 &put_u32_be_i_sample |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
669 }; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
670 |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
671 static SAD_buffer_ops buf_u32_be_s_ops = { |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
672 &get_u32_be_s_sample, |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
673 &put_u32_be_s_sample |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
674 }; |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
675 |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
676 static SAD_buffer_ops *SAD_buffer_optable[SAD_SAMPLE_MAX][SAD_CHORDER_MAX] = { |
4234 | 677 {&buf_s8_i_ops, &buf_s8_s_ops}, /* SAD_SAMPLE_S8 */ |
678 {&buf_u8_i_ops, &buf_u8_s_ops}, /* SAD_SAMPLE_U8 */ | |
4238
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
679 |
4234 | 680 {&buf_s16_i_ops, &buf_s16_s_ops}, /* SAD_SAMPLE_S16 */ |
681 {&buf_s16_le_i_ops, &buf_s16_le_s_ops}, /* SAD_SAMPLE_S16_LE */ | |
4238
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
682 {&buf_s16_be_i_ops, &buf_s16_be_s_ops}, /* SAD_SAMPLE_S16_BE */ |
4234 | 683 {&buf_u16_i_ops, &buf_u16_s_ops}, /* SAD_SAMPLE_U16 */ |
4238
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
684 {&buf_u16_le_i_ops, &buf_u16_le_s_ops}, /* SAD_SAMPLE_U16_LE */ |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
685 {&buf_u16_be_i_ops, &buf_u16_be_s_ops}, /* SAD_SAMPLE_U16_BE */ |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
686 |
4234 | 687 {&buf_s24_i_ops, &buf_s24_s_ops}, /* SAD_SAMPLE_S24 */ |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
688 {&buf_s24_le_i_ops, &buf_s24_le_s_ops}, /* SAD_SAMPLE_S24_LE */ |
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
689 {&buf_s24_be_i_ops, &buf_s24_be_s_ops}, /* SAD_SAMPLE_S24_BE */ |
4234 | 690 {&buf_u24_i_ops, &buf_u24_s_ops}, /* SAD_SAMPLE_U24 */ |
4240
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
691 {&buf_u24_le_i_ops, &buf_u24_le_s_ops}, /* SAD_SAMPLE_U24_LE */ |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
692 {&buf_u24_be_i_ops, &buf_u24_be_s_ops}, /* SAD_SAMPLE_U24_BE */ |
4238
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
693 |
4234 | 694 {&buf_s32_i_ops, &buf_s32_s_ops}, /* SAD_SAMPLE_S32 */ |
4241
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
695 {&buf_s32_le_i_ops, &buf_s32_le_s_ops}, /* SAD_SAMPLE_S32_LE */ |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
696 {&buf_s32_be_i_ops, &buf_s32_be_s_ops}, /* SAD_SAMPLE_S32_BE */ |
4234 | 697 {&buf_u32_i_ops, &buf_u32_s_ops}, /* SAD_SAMPLE_U32 */ |
4241
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
698 {&buf_u32_le_i_ops, &buf_u32_le_s_ops}, /* SAD_SAMPLE_U32_LE */ |
63eb5966f105
prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
699 {&buf_u32_be_i_ops, &buf_u32_be_s_ops}, /* SAD_SAMPLE_U32_BE */ |
4238
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
700 |
4234 | 701 {&buf_s32_i_ops, &buf_s32_s_ops}, /* SAD_SAMPLE_FIXED32*/ |
4238
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
702 |
4234 | 703 {NULL, NULL} /* SAD_SAMPLE_FLOAT */ |
4232
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
704 }; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
705 |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
706 SAD_buffer_ops* SAD_assign_buf_ops (SAD_buffer_format *format) { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
707 #ifdef DEBUG |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
708 printf("f: SAD_assign_buf_ops\n"); |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
709 #endif |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
710 if (format->sample_format < SAD_SAMPLE_MAX && format->channels_order < SAD_CHORDER_MAX) { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
711 return SAD_buffer_optable[format->sample_format][format->channels_order]; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
712 } else { |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
713 return NULL; |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
714 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
715 } |
704607c1f858
1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff
changeset
|
716 |