annotate src/libSAD/dither_ops.c @ 4783:ae3ed045e5aa

Replace deprecated g_strcasecmp with g_ascii_strncasecmp.
author Tony Vroon <chainsaw@gentoo.org>
date Sat, 27 Sep 2008 17:56:22 +0100
parents bb0638143fc8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
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
4757
bb0638143fc8 move libSAD's DEBUG_MSG out of global scope, as it breaks timidity and possible something else
Andrew O. Shadoura <bugzilla@tut.by>
parents: 4242
diff changeset
26 #include "debug.h"
bb0638143fc8 move libSAD's DEBUG_MSG out of global scope, as it breaks timidity and possible something else
Andrew O. Shadoura <bugzilla@tut.by>
parents: 4242
diff changeset
27
4239
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
28 #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
29 #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
30
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
31 #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
32 (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
33 #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
34 (uint32_t)(((uint8_t*)(a))[2]) << 8 | (uint32_t)(((uint8_t*)(a))[3]) )
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
35
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
36 #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
37 ((uint8_t*)(a))[0] = (uint8_t)((uint32_t)(b) & 0x000000ff); \
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
38 ((uint8_t*)(a))[1] = (uint8_t)(((uint32_t)(b) & 0x0000ff00) >> 8); \
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
39 }
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
40
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
41 #define SAD_PUT_BE16(a,b) { \
4238
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
42 ((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
43 ((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
44 }
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
45
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
46 #define SAD_PUT_LE32(a,b) { \
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
47 ((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
48 ((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
49 ((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
50 ((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
51 }
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
52
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
53 #define SAD_PUT_BE32(a,b) { \
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
54 ((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
55 ((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
56 ((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
57 ((uint8_t*)(a))[3] = (uint8_t)((uint32_t)(b) & 0x000000ff); \
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
58 }
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
59
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
60
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
61 /* buffer ops: */
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
62 /****************************************************************************************************************
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
63 * 8-bit *
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
64 ****************************************************************************************************************/
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
65
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
66 /* signed */
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
67 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
68 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
69 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
70
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
71 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
72 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
73 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
74
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
75 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
76 ((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
77 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
78
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
79 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
80 ((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
81 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
82
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
83 /* unsigned */
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
84 static int32_t get_u8_i_sample (void *buf, int nch, int ch, int i) {
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
85 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
86 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
87
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
88 static int32_t get_u8_s_sample (void *buf, int nch, int ch, int i) {
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
89 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
90 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
91
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
92 static void put_u8_i_sample (void *buf, int32_t sample, int nch, int ch, int i) {
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
93 ((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
94 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
95
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
96 static void put_u8_s_sample (void *buf, int32_t sample, int nch, int ch, int i) {
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
97 ((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
98 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
99
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
100 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
101 &get_s8_i_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
102 &put_s8_i_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
103 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
104
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
105 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
106 &get_s8_s_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
107 &put_s8_s_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
108 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
109
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
110 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
111 &get_u8_i_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
112 &put_u8_i_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
113 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
114
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
115 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
116 &get_u8_s_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
117 &put_u8_s_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
118 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
119
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
120 /****************************************************************************************************************
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
121 * 16-bit *
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
122 ****************************************************************************************************************/
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
123
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
124 /* signed */
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
125 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
126 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
127 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
128
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
129 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
130 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
131 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
132
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
133 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
134 ((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
135 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
136
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
137 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
138 ((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
139 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
140
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
141 /* unsigned */
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
142 static int32_t get_u16_i_sample (void *buf, int nch, int ch, int i) {
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
143 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
144 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
145
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
146 static int32_t get_u16_s_sample (void *buf, int nch, int ch, int i) {
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
147 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
148 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
149
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
150 static void put_u16_i_sample (void *buf, int32_t sample, int nch, int ch, int i) {
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
151 ((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
152 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
153
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
154 static void put_u16_s_sample (void *buf, int32_t sample, int nch, int ch, int i) {
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
155 ((uint16_t**)buf)[ch][i] = (uint16_t)(sample + 32768);
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
156 }
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
157
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
158 /* LE: signed */
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
159 static int32_t get_s16_le_i_sample (void *buf, int nch, int ch, int i) {
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
160 int16_t *tmp = (int16_t*)buf+i*nch+ch;
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
161 return (int16_t)SAD_GET_LE16(tmp);
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
162 }
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
163
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
164 static int32_t get_s16_le_s_sample (void *buf, int nch, int ch, int i) {
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
165 int16_t *tmp = ((int16_t**)buf)[ch]+i;
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
166 return (int16_t)SAD_GET_LE16(tmp);
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
167 }
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
168
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
169 static void put_s16_le_i_sample (void *buf, int32_t sample, int nch, int ch, int i) {
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
170 int16_t *tmp = (int16_t*)buf+i*nch+ch;
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
171 SAD_PUT_LE16(tmp, sample);
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
172 }
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
173
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
174 static void put_s16_le_s_sample (void *buf, int32_t sample, int nch, int ch, int i) {
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
175 int16_t *tmp = ((int16_t**)buf)[ch]+i;
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
176 SAD_PUT_LE16(tmp, sample);
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
177 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
178
4238
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
179 /* BE: signed */
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
180 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
181 int16_t *tmp = (int16_t*)buf+i*nch+ch;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
182 return (int16_t)SAD_GET_BE16(tmp);
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
183 }
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
184
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
185 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
186 int16_t *tmp = ((int16_t**)buf)[ch]+i;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
187 return (int16_t)SAD_GET_BE16(tmp);
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
188 }
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
189
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
190 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
191 int16_t *tmp = (int16_t*)buf+i*nch+ch;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
192 SAD_PUT_BE16(tmp, sample);
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
193 }
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
194
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
195 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
196 int16_t *tmp = ((int16_t**)buf)[ch]+i;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
197 SAD_PUT_BE16(tmp, sample);
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
198 }
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
199
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
200 /* LE: unsigned */
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
201 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
202 int16_t *tmp = (int16_t*)buf+i*nch+ch;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
203 return (int16_t)SAD_GET_LE16(tmp) - 32768;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
204 }
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
205
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
206 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
207 int16_t *tmp = ((int16_t**)buf)[ch]+i;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
208 return (int16_t)SAD_GET_LE16(tmp) - 32768;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
209 }
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
210
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
211 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
212 int16_t *tmp = (int16_t*)buf+i*nch+ch;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
213 SAD_PUT_LE16(tmp, sample + 32768);
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
214 }
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
215
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
216 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
217 int16_t *tmp = ((int16_t**)buf)[ch]+i;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
218 SAD_PUT_LE16(tmp, sample + 32768);
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
219 }
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
220
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
221 /* BE: unsigned */
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
222 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
223 int16_t *tmp = (int16_t*)buf+i*nch+ch;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
224 return (int16_t)SAD_GET_BE16(tmp) - 32768;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
225 }
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
226
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
227 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
228 int16_t *tmp = ((int16_t**)buf)[ch]+i;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
229 return (int16_t)SAD_GET_BE16(tmp) - 32768;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
230 }
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
231
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
232 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
233 int16_t *tmp = (int16_t*)buf+i*nch+ch;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
234 SAD_PUT_BE16(tmp, sample + 32768);
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
235 }
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
236
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
237 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
238 int16_t *tmp = ((int16_t**)buf)[ch]+i;
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
239 SAD_PUT_BE16(tmp, sample + 32768);
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
240 }
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
241
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
242
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
243 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
244 &get_s16_i_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
245 &put_s16_i_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
246 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
247
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
248 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
249 &get_s16_s_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
250 &put_s16_s_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
251 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
252
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
253 static SAD_buffer_ops buf_s16_le_i_ops = {
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
254 &get_s16_le_i_sample,
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
255 &put_s16_le_i_sample
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
256 };
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
257
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
258 static SAD_buffer_ops buf_s16_le_s_ops = {
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
259 &get_s16_le_s_sample,
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
260 &put_s16_le_s_sample
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
261 };
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
262
4238
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
263 static SAD_buffer_ops buf_s16_be_i_ops = {
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
264 &get_s16_be_i_sample,
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
265 &put_s16_be_i_sample
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
266 };
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
267
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
268 static SAD_buffer_ops buf_s16_be_s_ops = {
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
269 &get_s16_be_s_sample,
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
270 &put_s16_be_s_sample
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
271 };
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
272
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
273 /* unsigned */
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
274
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
275 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
276 &get_u16_i_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
277 &put_u16_i_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
278 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
279
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
280 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
281 &get_u16_s_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
282 &put_u16_s_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
283 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
284
4238
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
285 static SAD_buffer_ops buf_u16_le_i_ops = {
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
286 &get_u16_le_i_sample,
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
287 &put_u16_le_i_sample
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
288 };
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
289
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
290 static SAD_buffer_ops buf_u16_le_s_ops = {
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
291 &get_u16_le_s_sample,
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
292 &put_u16_le_s_sample
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
293 };
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
294
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
295 static SAD_buffer_ops buf_u16_be_i_ops = {
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
296 &get_u16_be_i_sample,
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
297 &put_u16_be_i_sample
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
298 };
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
299
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
300 static SAD_buffer_ops buf_u16_be_s_ops = {
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
301 &get_u16_be_s_sample,
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
302 &put_u16_be_s_sample
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
303 };
75ea2083e744 some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
304
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
305 /****************************************************************************************************************
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
306 * 24-bit *
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
307 ****************************************************************************************************************/
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
308
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
309 /*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
310 #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
311 #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
312
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
313 /* signed */
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
314 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
315 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
316 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
317
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
318 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
319 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
320 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
321
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
322 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
323 ((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
324 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
325
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
326 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
327 ((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
328 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
329
4239
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
330 /* LE signed */
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
331
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
332 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
333 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
334 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
335 }
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
336
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
337 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
338 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
339 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
340 }
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
341
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
342 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
343 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
344 SAD_PUT_LE32(tmp, sample & 0x00ffffff);
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
345 }
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
346
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
347 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
348 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
349 SAD_PUT_LE32(tmp, sample & 0x00ffffff);
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
350 }
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 /* BE signed */
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
353
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
354 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
355 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
356 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
357 }
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
358
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
359 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
360 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
361 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
362 }
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
363
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
364 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
365 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
366 SAD_PUT_BE32(tmp, sample & 0x00ffffff);
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
367 }
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
368
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
369 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
370 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
371 SAD_PUT_BE32(tmp, sample & 0x00ffffff);
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
372 }
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
373
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
374 /* unsigned */
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
375 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
376 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
377 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
378
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
379 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
380 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
381 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
382
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
383 static void put_u24_i_sample (void *buf, int32_t sample, int nch, int ch, int i) {
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
384 ((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
385 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
386
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
387 static void put_u24_s_sample (void *buf, int32_t sample, int nch, int ch, int i) {
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
388 ((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
389 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
390
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
391 /* 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
392
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 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
394 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
395 /*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
396 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
397 }
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
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 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
400 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
401 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
402 }
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
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 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
405 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
406 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
407 }
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
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 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
410 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
411 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
412 }
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 /* 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
415
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 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
417 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
418 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
419 }
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
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 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
422 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
423 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
424 }
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
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 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
427 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
428 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
429 }
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
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 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
432 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
433 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
434 }
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
435
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
436 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
437 &get_s24_i_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
438 &put_s24_i_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
439 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
440
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
441 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
442 &get_s24_s_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
443 &put_s24_s_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
444 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
445
4239
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
446 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
447 &get_s24_le_i_sample,
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
448 &put_s24_le_i_sample
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
449 };
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
450
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
451 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
452 &get_s24_le_s_sample,
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
453 &put_s24_le_s_sample
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
454 };
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
455
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
456 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
457 &get_s24_be_i_sample,
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
458 &put_s24_be_i_sample
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
459 };
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
460
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
461 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
462 &get_s24_be_s_sample,
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
463 &put_s24_be_s_sample
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
464 };
51291ce4eb54 some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4238
diff changeset
465
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
466 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
467 &get_u24_i_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
468 &put_u24_i_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
469 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
470
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
471 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
472 &get_u24_s_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
473 &put_u24_s_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
474 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
475
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
476 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
477 &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
478 &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
479 };
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
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 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
482 &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
483 &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
484 };
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
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 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
487 &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
488 &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
489 };
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
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 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
492 &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
493 &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
494 };
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
495
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
496 /****************************************************************************************************************
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
497 * 32-bit *
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
498 ****************************************************************************************************************/
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
499
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
500 /* signed */
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
501 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
502 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
503 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
504
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
505 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
506 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
507 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
508
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
509 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
510 ((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
511 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
512
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
513 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
514 ((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
515 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
516
4241
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
517 /* LE: signed */
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
518 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
519 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
520 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
521 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
522
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
523 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
524 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
525 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
526 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
527
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
528 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
529 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
530 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
531 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
532
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
533 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
534 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
535 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
536 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
537
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
538 /* BE: signed */
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
539 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
540 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
541 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
542 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
543
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
544 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
545 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
546 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
547 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
548
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
549 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
550 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
551 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
552 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
553
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
554 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
555 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
556 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
557 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
558
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
559 /* unsigned */
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
560 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
561 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
562 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
563
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
564 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
565 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
566 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
567
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
568 static void put_u32_i_sample (void *buf, int32_t sample, int nch, int ch, int i) {
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
569 ((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
570 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
571
4233
74c6f3d3cf1d it buids successfully :)
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4232
diff changeset
572 static void put_u32_s_sample (void *buf, int32_t sample, int nch, int ch, int i) {
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
573 ((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
574 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
575
4241
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
576 /* LE: unsigned */
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
577 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
578 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
579 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
580 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
581
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
582 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
583 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
584 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
585 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
586
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
587 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
588 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
589 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
590 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
591
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
592 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
593 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
594 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
595 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
596
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
597 /* BE: unsigned */
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
598 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
599 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
600 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
601 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
602
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
603 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
604 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
605 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
606 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
607
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
608 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
609 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
610 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
611 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
612
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
613 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
614 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
615 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
616 }
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
617
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
618 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
619 &get_s32_i_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
620 &put_s32_i_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
621 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
622
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
623 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
624 &get_s32_s_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
625 &put_s32_s_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
626 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
627
4241
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
628 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
629 &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
630 &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
631 };
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
632
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
633 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
634 &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
635 &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
636 };
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
637
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
638 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
639 &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
640 &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
641 };
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
642
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
643 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
644 &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
645 &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
646 };
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
647
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
648 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
649 &get_u32_i_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
650 &put_u32_i_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
651 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
652
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
653 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
654 &get_u32_s_sample,
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
655 &put_u32_s_sample
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
656 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
657
4241
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
658 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
659 &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
660 &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
661 };
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
662
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
663 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
664 &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
665 &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
666 };
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
667
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
668 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
669 &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
670 &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
671 };
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
672
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
673 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
674 &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
675 &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
676 };
63eb5966f105 prevented clipping for FMT_*32_*; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4240
diff changeset
677
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
678 static SAD_buffer_ops *SAD_buffer_optable[SAD_SAMPLE_MAX][SAD_CHORDER_MAX] = {
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
679 {&buf_s8_i_ops, &buf_s8_s_ops}, /* SAD_SAMPLE_S8 */
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
680 {&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
681
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
682 {&buf_s16_i_ops, &buf_s16_s_ops}, /* SAD_SAMPLE_S16 */
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
683 {&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
684 {&buf_s16_be_i_ops, &buf_s16_be_s_ops}, /* SAD_SAMPLE_S16_BE */
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
685 {&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
686 {&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
687 {&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
688
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
689 {&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
690 {&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
691 {&buf_s24_be_i_ops, &buf_s24_be_s_ops}, /* SAD_SAMPLE_S24_BE */
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
692 {&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
693 {&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
694 {&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
695
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
696 {&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
697 {&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
698 {&buf_s32_be_i_ops, &buf_s32_be_s_ops}, /* SAD_SAMPLE_S32_BE */
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
699 {&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
700 {&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
701 {&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
702
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
703 {&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
704
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4233
diff changeset
705 {NULL, NULL} /* SAD_SAMPLE_FLOAT */
4232
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
706 };
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
707
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
708 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
709 #ifdef DEBUG
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
710 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
711 #endif
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
712 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
713 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
714 } else {
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
715 return NULL;
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
716 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
717 }
704607c1f858 1st attempt to integrate dithering and RG engine
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
718