1c74663799493f2b1e6123c18def94295d0afab7Kenny Root#if HAVE_CONFIG_H
2c74663799493f2b1e6123c18def94295d0afab7Kenny Root#  include <config.h>
3c74663799493f2b1e6123c18def94295d0afab7Kenny Root#endif
4c74663799493f2b1e6123c18def94295d0afab7Kenny Root
5c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include <stdlib.h>		/* for malloc() */
6c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include <string.h>		/* for memcpy() */
7c74663799493f2b1e6123c18def94295d0afab7Kenny Root
8c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include "private/md5.h"
9c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include "share/alloc.h"
10c74663799493f2b1e6123c18def94295d0afab7Kenny Root
11c74663799493f2b1e6123c18def94295d0afab7Kenny Root#ifndef FLaC__INLINE
12c74663799493f2b1e6123c18def94295d0afab7Kenny Root#define FLaC__INLINE
13c74663799493f2b1e6123c18def94295d0afab7Kenny Root#endif
14c74663799493f2b1e6123c18def94295d0afab7Kenny Root
15c74663799493f2b1e6123c18def94295d0afab7Kenny Root/*
16c74663799493f2b1e6123c18def94295d0afab7Kenny Root * This code implements the MD5 message-digest algorithm.
17c74663799493f2b1e6123c18def94295d0afab7Kenny Root * The algorithm is due to Ron Rivest.  This code was
18c74663799493f2b1e6123c18def94295d0afab7Kenny Root * written by Colin Plumb in 1993, no copyright is claimed.
19c74663799493f2b1e6123c18def94295d0afab7Kenny Root * This code is in the public domain; do with it what you wish.
20c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
21c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Equivalent code is available from RSA Data Security, Inc.
22c74663799493f2b1e6123c18def94295d0afab7Kenny Root * This code has been tested against that, and is equivalent,
23c74663799493f2b1e6123c18def94295d0afab7Kenny Root * except that you don't need to include two pages of legalese
24c74663799493f2b1e6123c18def94295d0afab7Kenny Root * with every copy.
25c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
26c74663799493f2b1e6123c18def94295d0afab7Kenny Root * To compute the message digest of a chunk of bytes, declare an
27c74663799493f2b1e6123c18def94295d0afab7Kenny Root * MD5Context structure, pass it to MD5Init, call MD5Update as
28c74663799493f2b1e6123c18def94295d0afab7Kenny Root * needed on buffers full of bytes, and then call MD5Final, which
29c74663799493f2b1e6123c18def94295d0afab7Kenny Root * will fill a supplied 16-byte array with the digest.
30c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
31c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Changed so as no longer to depend on Colin Plumb's `usual.h' header
32c74663799493f2b1e6123c18def94295d0afab7Kenny Root * definitions; now uses stuff from dpkg's config.h.
33c74663799493f2b1e6123c18def94295d0afab7Kenny Root *  - Ian Jackson <ijackson@nyx.cs.du.edu>.
34c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Still in the public domain.
35c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
36c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Josh Coalson: made some changes to integrate with libFLAC.
37c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Still in the public domain.
38c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
39c74663799493f2b1e6123c18def94295d0afab7Kenny Root
40c74663799493f2b1e6123c18def94295d0afab7Kenny Root/* The four core functions - F1 is optimized somewhat */
41c74663799493f2b1e6123c18def94295d0afab7Kenny Root
42c74663799493f2b1e6123c18def94295d0afab7Kenny Root/* #define F1(x, y, z) (x & y | ~x & z) */
43c74663799493f2b1e6123c18def94295d0afab7Kenny Root#define F1(x, y, z) (z ^ (x & (y ^ z)))
44c74663799493f2b1e6123c18def94295d0afab7Kenny Root#define F2(x, y, z) F1(z, x, y)
45c74663799493f2b1e6123c18def94295d0afab7Kenny Root#define F3(x, y, z) (x ^ y ^ z)
46c74663799493f2b1e6123c18def94295d0afab7Kenny Root#define F4(x, y, z) (y ^ (x | ~z))
47c74663799493f2b1e6123c18def94295d0afab7Kenny Root
48c74663799493f2b1e6123c18def94295d0afab7Kenny Root/* This is the central step in the MD5 algorithm. */
49c74663799493f2b1e6123c18def94295d0afab7Kenny Root#define MD5STEP(f,w,x,y,z,in,s) \
50c74663799493f2b1e6123c18def94295d0afab7Kenny Root	 (w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
51c74663799493f2b1e6123c18def94295d0afab7Kenny Root
52c74663799493f2b1e6123c18def94295d0afab7Kenny Root/*
53c74663799493f2b1e6123c18def94295d0afab7Kenny Root * The core of the MD5 algorithm, this alters an existing MD5 hash to
54c74663799493f2b1e6123c18def94295d0afab7Kenny Root * reflect the addition of 16 longwords of new data.  MD5Update blocks
55c74663799493f2b1e6123c18def94295d0afab7Kenny Root * the data and converts bytes into longwords for this routine.
56c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
57c74663799493f2b1e6123c18def94295d0afab7Kenny Rootstatic void FLAC__MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16])
58c74663799493f2b1e6123c18def94295d0afab7Kenny Root{
59c74663799493f2b1e6123c18def94295d0afab7Kenny Root	register FLAC__uint32 a, b, c, d;
60c74663799493f2b1e6123c18def94295d0afab7Kenny Root
61c74663799493f2b1e6123c18def94295d0afab7Kenny Root	a = buf[0];
62c74663799493f2b1e6123c18def94295d0afab7Kenny Root	b = buf[1];
63c74663799493f2b1e6123c18def94295d0afab7Kenny Root	c = buf[2];
64c74663799493f2b1e6123c18def94295d0afab7Kenny Root	d = buf[3];
65c74663799493f2b1e6123c18def94295d0afab7Kenny Root
66c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
67c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
68c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
69c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
70c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
71c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
72c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
73c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
74c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
75c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
76c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
77c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
78c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
79c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
80c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
81c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
82c74663799493f2b1e6123c18def94295d0afab7Kenny Root
83c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
84c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
85c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
86c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
87c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
88c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
89c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
90c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
91c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
92c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
93c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
94c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
95c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
96c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
97c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
98c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
99c74663799493f2b1e6123c18def94295d0afab7Kenny Root
100c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
101c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
102c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
103c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
104c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
105c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
106c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
107c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
108c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
109c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
110c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
111c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
112c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
113c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
114c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
115c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
116c74663799493f2b1e6123c18def94295d0afab7Kenny Root
117c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
118c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
119c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
120c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
121c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
122c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
123c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
124c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
125c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
126c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
127c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
128c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
129c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
130c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
131c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
132c74663799493f2b1e6123c18def94295d0afab7Kenny Root	MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
133c74663799493f2b1e6123c18def94295d0afab7Kenny Root
134c74663799493f2b1e6123c18def94295d0afab7Kenny Root	buf[0] += a;
135c74663799493f2b1e6123c18def94295d0afab7Kenny Root	buf[1] += b;
136c74663799493f2b1e6123c18def94295d0afab7Kenny Root	buf[2] += c;
137c74663799493f2b1e6123c18def94295d0afab7Kenny Root	buf[3] += d;
138c74663799493f2b1e6123c18def94295d0afab7Kenny Root}
139c74663799493f2b1e6123c18def94295d0afab7Kenny Root
140c74663799493f2b1e6123c18def94295d0afab7Kenny Root#if WORDS_BIGENDIAN
141c74663799493f2b1e6123c18def94295d0afab7Kenny Root//@@@@@@ OPT: use bswap/intrinsics
142c74663799493f2b1e6123c18def94295d0afab7Kenny Rootstatic void byteSwap(FLAC__uint32 *buf, unsigned words)
143c74663799493f2b1e6123c18def94295d0afab7Kenny Root{
144c74663799493f2b1e6123c18def94295d0afab7Kenny Root	register FLAC__uint32 x;
145c74663799493f2b1e6123c18def94295d0afab7Kenny Root	do {
146c74663799493f2b1e6123c18def94295d0afab7Kenny Root		x = *buf;
147c74663799493f2b1e6123c18def94295d0afab7Kenny Root		x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff);
148c74663799493f2b1e6123c18def94295d0afab7Kenny Root		*buf++ = (x >> 16) | (x << 16);
149c74663799493f2b1e6123c18def94295d0afab7Kenny Root	} while (--words);
150c74663799493f2b1e6123c18def94295d0afab7Kenny Root}
151c74663799493f2b1e6123c18def94295d0afab7Kenny Rootstatic void byteSwapX16(FLAC__uint32 *buf)
152c74663799493f2b1e6123c18def94295d0afab7Kenny Root{
153c74663799493f2b1e6123c18def94295d0afab7Kenny Root	register FLAC__uint32 x;
154c74663799493f2b1e6123c18def94295d0afab7Kenny Root
155c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
156c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
157c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
158c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
159c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
160c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
161c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
162c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
163c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
164c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
165c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
166c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
167c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
168c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
169c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
170c74663799493f2b1e6123c18def94295d0afab7Kenny Root	x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf   = (x >> 16) | (x << 16);
171c74663799493f2b1e6123c18def94295d0afab7Kenny Root}
172c74663799493f2b1e6123c18def94295d0afab7Kenny Root#else
173c74663799493f2b1e6123c18def94295d0afab7Kenny Root#define byteSwap(buf, words)
174c74663799493f2b1e6123c18def94295d0afab7Kenny Root#define byteSwapX16(buf)
175c74663799493f2b1e6123c18def94295d0afab7Kenny Root#endif
176c74663799493f2b1e6123c18def94295d0afab7Kenny Root
177c74663799493f2b1e6123c18def94295d0afab7Kenny Root/*
178c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Update context to reflect the concatenation of another buffer full
179c74663799493f2b1e6123c18def94295d0afab7Kenny Root * of bytes.
180c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
181c74663799493f2b1e6123c18def94295d0afab7Kenny Rootstatic void FLAC__MD5Update(FLAC__MD5Context *ctx, FLAC__byte const *buf, unsigned len)
182c74663799493f2b1e6123c18def94295d0afab7Kenny Root{
183c74663799493f2b1e6123c18def94295d0afab7Kenny Root	FLAC__uint32 t;
184c74663799493f2b1e6123c18def94295d0afab7Kenny Root
185c74663799493f2b1e6123c18def94295d0afab7Kenny Root	/* Update byte count */
186c74663799493f2b1e6123c18def94295d0afab7Kenny Root
187c74663799493f2b1e6123c18def94295d0afab7Kenny Root	t = ctx->bytes[0];
188c74663799493f2b1e6123c18def94295d0afab7Kenny Root	if ((ctx->bytes[0] = t + len) < t)
189c74663799493f2b1e6123c18def94295d0afab7Kenny Root		ctx->bytes[1]++;	/* Carry from low to high */
190c74663799493f2b1e6123c18def94295d0afab7Kenny Root
191c74663799493f2b1e6123c18def94295d0afab7Kenny Root	t = 64 - (t & 0x3f);	/* Space available in ctx->in (at least 1) */
192c74663799493f2b1e6123c18def94295d0afab7Kenny Root	if (t > len) {
193c74663799493f2b1e6123c18def94295d0afab7Kenny Root		memcpy((FLAC__byte *)ctx->in + 64 - t, buf, len);
194c74663799493f2b1e6123c18def94295d0afab7Kenny Root		return;
195c74663799493f2b1e6123c18def94295d0afab7Kenny Root	}
196c74663799493f2b1e6123c18def94295d0afab7Kenny Root	/* First chunk is an odd size */
197c74663799493f2b1e6123c18def94295d0afab7Kenny Root	memcpy((FLAC__byte *)ctx->in + 64 - t, buf, t);
198c74663799493f2b1e6123c18def94295d0afab7Kenny Root	byteSwapX16(ctx->in);
199c74663799493f2b1e6123c18def94295d0afab7Kenny Root	FLAC__MD5Transform(ctx->buf, ctx->in);
200c74663799493f2b1e6123c18def94295d0afab7Kenny Root	buf += t;
201c74663799493f2b1e6123c18def94295d0afab7Kenny Root	len -= t;
202c74663799493f2b1e6123c18def94295d0afab7Kenny Root
203c74663799493f2b1e6123c18def94295d0afab7Kenny Root	/* Process data in 64-byte chunks */
204c74663799493f2b1e6123c18def94295d0afab7Kenny Root	while (len >= 64) {
205c74663799493f2b1e6123c18def94295d0afab7Kenny Root		memcpy(ctx->in, buf, 64);
206c74663799493f2b1e6123c18def94295d0afab7Kenny Root		byteSwapX16(ctx->in);
207c74663799493f2b1e6123c18def94295d0afab7Kenny Root		FLAC__MD5Transform(ctx->buf, ctx->in);
208c74663799493f2b1e6123c18def94295d0afab7Kenny Root		buf += 64;
209c74663799493f2b1e6123c18def94295d0afab7Kenny Root		len -= 64;
210c74663799493f2b1e6123c18def94295d0afab7Kenny Root	}
211c74663799493f2b1e6123c18def94295d0afab7Kenny Root
212c74663799493f2b1e6123c18def94295d0afab7Kenny Root	/* Handle any remaining bytes of data. */
213c74663799493f2b1e6123c18def94295d0afab7Kenny Root	memcpy(ctx->in, buf, len);
214c74663799493f2b1e6123c18def94295d0afab7Kenny Root}
215c74663799493f2b1e6123c18def94295d0afab7Kenny Root
216c74663799493f2b1e6123c18def94295d0afab7Kenny Root/*
217c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious
218c74663799493f2b1e6123c18def94295d0afab7Kenny Root * initialization constants.
219c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
220c74663799493f2b1e6123c18def94295d0afab7Kenny Rootvoid FLAC__MD5Init(FLAC__MD5Context *ctx)
221c74663799493f2b1e6123c18def94295d0afab7Kenny Root{
222c74663799493f2b1e6123c18def94295d0afab7Kenny Root	ctx->buf[0] = 0x67452301;
223c74663799493f2b1e6123c18def94295d0afab7Kenny Root	ctx->buf[1] = 0xefcdab89;
224c74663799493f2b1e6123c18def94295d0afab7Kenny Root	ctx->buf[2] = 0x98badcfe;
225c74663799493f2b1e6123c18def94295d0afab7Kenny Root	ctx->buf[3] = 0x10325476;
226c74663799493f2b1e6123c18def94295d0afab7Kenny Root
227c74663799493f2b1e6123c18def94295d0afab7Kenny Root	ctx->bytes[0] = 0;
228c74663799493f2b1e6123c18def94295d0afab7Kenny Root	ctx->bytes[1] = 0;
229c74663799493f2b1e6123c18def94295d0afab7Kenny Root
230c74663799493f2b1e6123c18def94295d0afab7Kenny Root	ctx->internal_buf = 0;
231c74663799493f2b1e6123c18def94295d0afab7Kenny Root	ctx->capacity = 0;
232c74663799493f2b1e6123c18def94295d0afab7Kenny Root}
233c74663799493f2b1e6123c18def94295d0afab7Kenny Root
234c74663799493f2b1e6123c18def94295d0afab7Kenny Root/*
235c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Final wrapup - pad to 64-byte boundary with the bit pattern
236c74663799493f2b1e6123c18def94295d0afab7Kenny Root * 1 0* (64-bit count of bits processed, MSB-first)
237c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
238c74663799493f2b1e6123c18def94295d0afab7Kenny Rootvoid FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *ctx)
239c74663799493f2b1e6123c18def94295d0afab7Kenny Root{
240c74663799493f2b1e6123c18def94295d0afab7Kenny Root	int count = ctx->bytes[0] & 0x3f;	/* Number of bytes in ctx->in */
241c74663799493f2b1e6123c18def94295d0afab7Kenny Root	FLAC__byte *p = (FLAC__byte *)ctx->in + count;
242c74663799493f2b1e6123c18def94295d0afab7Kenny Root
243c74663799493f2b1e6123c18def94295d0afab7Kenny Root	/* Set the first char of padding to 0x80.  There is always room. */
244c74663799493f2b1e6123c18def94295d0afab7Kenny Root	*p++ = 0x80;
245c74663799493f2b1e6123c18def94295d0afab7Kenny Root
246c74663799493f2b1e6123c18def94295d0afab7Kenny Root	/* Bytes of padding needed to make 56 bytes (-8..55) */
247c74663799493f2b1e6123c18def94295d0afab7Kenny Root	count = 56 - 1 - count;
248c74663799493f2b1e6123c18def94295d0afab7Kenny Root
249c74663799493f2b1e6123c18def94295d0afab7Kenny Root	if (count < 0) {	/* Padding forces an extra block */
250c74663799493f2b1e6123c18def94295d0afab7Kenny Root		memset(p, 0, count + 8);
251c74663799493f2b1e6123c18def94295d0afab7Kenny Root		byteSwapX16(ctx->in);
252c74663799493f2b1e6123c18def94295d0afab7Kenny Root		FLAC__MD5Transform(ctx->buf, ctx->in);
253c74663799493f2b1e6123c18def94295d0afab7Kenny Root		p = (FLAC__byte *)ctx->in;
254c74663799493f2b1e6123c18def94295d0afab7Kenny Root		count = 56;
255c74663799493f2b1e6123c18def94295d0afab7Kenny Root	}
256c74663799493f2b1e6123c18def94295d0afab7Kenny Root	memset(p, 0, count);
257c74663799493f2b1e6123c18def94295d0afab7Kenny Root	byteSwap(ctx->in, 14);
258c74663799493f2b1e6123c18def94295d0afab7Kenny Root
259c74663799493f2b1e6123c18def94295d0afab7Kenny Root	/* Append length in bits and transform */
260c74663799493f2b1e6123c18def94295d0afab7Kenny Root	ctx->in[14] = ctx->bytes[0] << 3;
261c74663799493f2b1e6123c18def94295d0afab7Kenny Root	ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
262c74663799493f2b1e6123c18def94295d0afab7Kenny Root	FLAC__MD5Transform(ctx->buf, ctx->in);
263c74663799493f2b1e6123c18def94295d0afab7Kenny Root
264c74663799493f2b1e6123c18def94295d0afab7Kenny Root	byteSwap(ctx->buf, 4);
265c74663799493f2b1e6123c18def94295d0afab7Kenny Root	memcpy(digest, ctx->buf, 16);
266c74663799493f2b1e6123c18def94295d0afab7Kenny Root	memset(ctx, 0, sizeof(ctx));	/* In case it's sensitive */
267c74663799493f2b1e6123c18def94295d0afab7Kenny Root	if(0 != ctx->internal_buf) {
268c74663799493f2b1e6123c18def94295d0afab7Kenny Root		free(ctx->internal_buf);
269c74663799493f2b1e6123c18def94295d0afab7Kenny Root		ctx->internal_buf = 0;
270c74663799493f2b1e6123c18def94295d0afab7Kenny Root		ctx->capacity = 0;
271c74663799493f2b1e6123c18def94295d0afab7Kenny Root	}
272c74663799493f2b1e6123c18def94295d0afab7Kenny Root}
273c74663799493f2b1e6123c18def94295d0afab7Kenny Root
274c74663799493f2b1e6123c18def94295d0afab7Kenny Root/*
275c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Convert the incoming audio signal to a byte stream
276c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
277c74663799493f2b1e6123c18def94295d0afab7Kenny Rootstatic void format_input_(FLAC__byte *buf, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample)
278c74663799493f2b1e6123c18def94295d0afab7Kenny Root{
279c74663799493f2b1e6123c18def94295d0afab7Kenny Root	unsigned channel, sample;
280c74663799493f2b1e6123c18def94295d0afab7Kenny Root	register FLAC__int32 a_word;
281c74663799493f2b1e6123c18def94295d0afab7Kenny Root	register FLAC__byte *buf_ = buf;
282c74663799493f2b1e6123c18def94295d0afab7Kenny Root
283c74663799493f2b1e6123c18def94295d0afab7Kenny Root#if WORDS_BIGENDIAN
284c74663799493f2b1e6123c18def94295d0afab7Kenny Root#else
285c74663799493f2b1e6123c18def94295d0afab7Kenny Root	if(channels == 2 && bytes_per_sample == 2) {
286c74663799493f2b1e6123c18def94295d0afab7Kenny Root		FLAC__int16 *buf1_ = ((FLAC__int16*)buf_) + 1;
287c74663799493f2b1e6123c18def94295d0afab7Kenny Root		memcpy(buf_, signal[0], sizeof(FLAC__int32) * samples);
288c74663799493f2b1e6123c18def94295d0afab7Kenny Root		for(sample = 0; sample < samples; sample++, buf1_+=2)
289c74663799493f2b1e6123c18def94295d0afab7Kenny Root			*buf1_ = (FLAC__int16)signal[1][sample];
290c74663799493f2b1e6123c18def94295d0afab7Kenny Root	}
291c74663799493f2b1e6123c18def94295d0afab7Kenny Root	else if(channels == 1 && bytes_per_sample == 2) {
292c74663799493f2b1e6123c18def94295d0afab7Kenny Root		FLAC__int16 *buf1_ = (FLAC__int16*)buf_;
293c74663799493f2b1e6123c18def94295d0afab7Kenny Root		for(sample = 0; sample < samples; sample++)
294c74663799493f2b1e6123c18def94295d0afab7Kenny Root			*buf1_++ = (FLAC__int16)signal[0][sample];
295c74663799493f2b1e6123c18def94295d0afab7Kenny Root	}
296c74663799493f2b1e6123c18def94295d0afab7Kenny Root	else
297c74663799493f2b1e6123c18def94295d0afab7Kenny Root#endif
298c74663799493f2b1e6123c18def94295d0afab7Kenny Root	if(bytes_per_sample == 2) {
299c74663799493f2b1e6123c18def94295d0afab7Kenny Root		if(channels == 2) {
300c74663799493f2b1e6123c18def94295d0afab7Kenny Root			for(sample = 0; sample < samples; sample++) {
301c74663799493f2b1e6123c18def94295d0afab7Kenny Root				a_word = signal[0][sample];
302c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
303c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word;
304c74663799493f2b1e6123c18def94295d0afab7Kenny Root				a_word = signal[1][sample];
305c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
306c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word;
307c74663799493f2b1e6123c18def94295d0afab7Kenny Root			}
308c74663799493f2b1e6123c18def94295d0afab7Kenny Root		}
309c74663799493f2b1e6123c18def94295d0afab7Kenny Root		else if(channels == 1) {
310c74663799493f2b1e6123c18def94295d0afab7Kenny Root			for(sample = 0; sample < samples; sample++) {
311c74663799493f2b1e6123c18def94295d0afab7Kenny Root				a_word = signal[0][sample];
312c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
313c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word;
314c74663799493f2b1e6123c18def94295d0afab7Kenny Root			}
315c74663799493f2b1e6123c18def94295d0afab7Kenny Root		}
316c74663799493f2b1e6123c18def94295d0afab7Kenny Root		else {
317c74663799493f2b1e6123c18def94295d0afab7Kenny Root			for(sample = 0; sample < samples; sample++) {
318c74663799493f2b1e6123c18def94295d0afab7Kenny Root				for(channel = 0; channel < channels; channel++) {
319c74663799493f2b1e6123c18def94295d0afab7Kenny Root					a_word = signal[channel][sample];
320c74663799493f2b1e6123c18def94295d0afab7Kenny Root					*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
321c74663799493f2b1e6123c18def94295d0afab7Kenny Root					*buf_++ = (FLAC__byte)a_word;
322c74663799493f2b1e6123c18def94295d0afab7Kenny Root				}
323c74663799493f2b1e6123c18def94295d0afab7Kenny Root			}
324c74663799493f2b1e6123c18def94295d0afab7Kenny Root		}
325c74663799493f2b1e6123c18def94295d0afab7Kenny Root	}
326c74663799493f2b1e6123c18def94295d0afab7Kenny Root	else if(bytes_per_sample == 3) {
327c74663799493f2b1e6123c18def94295d0afab7Kenny Root		if(channels == 2) {
328c74663799493f2b1e6123c18def94295d0afab7Kenny Root			for(sample = 0; sample < samples; sample++) {
329c74663799493f2b1e6123c18def94295d0afab7Kenny Root				a_word = signal[0][sample];
330c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
331c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
332c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word;
333c74663799493f2b1e6123c18def94295d0afab7Kenny Root				a_word = signal[1][sample];
334c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
335c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
336c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word;
337c74663799493f2b1e6123c18def94295d0afab7Kenny Root			}
338c74663799493f2b1e6123c18def94295d0afab7Kenny Root		}
339c74663799493f2b1e6123c18def94295d0afab7Kenny Root		else if(channels == 1) {
340c74663799493f2b1e6123c18def94295d0afab7Kenny Root			for(sample = 0; sample < samples; sample++) {
341c74663799493f2b1e6123c18def94295d0afab7Kenny Root				a_word = signal[0][sample];
342c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
343c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
344c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word;
345c74663799493f2b1e6123c18def94295d0afab7Kenny Root			}
346c74663799493f2b1e6123c18def94295d0afab7Kenny Root		}
347c74663799493f2b1e6123c18def94295d0afab7Kenny Root		else {
348c74663799493f2b1e6123c18def94295d0afab7Kenny Root			for(sample = 0; sample < samples; sample++) {
349c74663799493f2b1e6123c18def94295d0afab7Kenny Root				for(channel = 0; channel < channels; channel++) {
350c74663799493f2b1e6123c18def94295d0afab7Kenny Root					a_word = signal[channel][sample];
351c74663799493f2b1e6123c18def94295d0afab7Kenny Root					*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
352c74663799493f2b1e6123c18def94295d0afab7Kenny Root					*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
353c74663799493f2b1e6123c18def94295d0afab7Kenny Root					*buf_++ = (FLAC__byte)a_word;
354c74663799493f2b1e6123c18def94295d0afab7Kenny Root				}
355c74663799493f2b1e6123c18def94295d0afab7Kenny Root			}
356c74663799493f2b1e6123c18def94295d0afab7Kenny Root		}
357c74663799493f2b1e6123c18def94295d0afab7Kenny Root	}
358c74663799493f2b1e6123c18def94295d0afab7Kenny Root	else if(bytes_per_sample == 1) {
359c74663799493f2b1e6123c18def94295d0afab7Kenny Root		if(channels == 2) {
360c74663799493f2b1e6123c18def94295d0afab7Kenny Root			for(sample = 0; sample < samples; sample++) {
361c74663799493f2b1e6123c18def94295d0afab7Kenny Root				a_word = signal[0][sample];
362c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word;
363c74663799493f2b1e6123c18def94295d0afab7Kenny Root				a_word = signal[1][sample];
364c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word;
365c74663799493f2b1e6123c18def94295d0afab7Kenny Root			}
366c74663799493f2b1e6123c18def94295d0afab7Kenny Root		}
367c74663799493f2b1e6123c18def94295d0afab7Kenny Root		else if(channels == 1) {
368c74663799493f2b1e6123c18def94295d0afab7Kenny Root			for(sample = 0; sample < samples; sample++) {
369c74663799493f2b1e6123c18def94295d0afab7Kenny Root				a_word = signal[0][sample];
370c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word;
371c74663799493f2b1e6123c18def94295d0afab7Kenny Root			}
372c74663799493f2b1e6123c18def94295d0afab7Kenny Root		}
373c74663799493f2b1e6123c18def94295d0afab7Kenny Root		else {
374c74663799493f2b1e6123c18def94295d0afab7Kenny Root			for(sample = 0; sample < samples; sample++) {
375c74663799493f2b1e6123c18def94295d0afab7Kenny Root				for(channel = 0; channel < channels; channel++) {
376c74663799493f2b1e6123c18def94295d0afab7Kenny Root					a_word = signal[channel][sample];
377c74663799493f2b1e6123c18def94295d0afab7Kenny Root					*buf_++ = (FLAC__byte)a_word;
378c74663799493f2b1e6123c18def94295d0afab7Kenny Root				}
379c74663799493f2b1e6123c18def94295d0afab7Kenny Root			}
380c74663799493f2b1e6123c18def94295d0afab7Kenny Root		}
381c74663799493f2b1e6123c18def94295d0afab7Kenny Root	}
382c74663799493f2b1e6123c18def94295d0afab7Kenny Root	else { /* bytes_per_sample == 4, maybe optimize more later */
383c74663799493f2b1e6123c18def94295d0afab7Kenny Root		for(sample = 0; sample < samples; sample++) {
384c74663799493f2b1e6123c18def94295d0afab7Kenny Root			for(channel = 0; channel < channels; channel++) {
385c74663799493f2b1e6123c18def94295d0afab7Kenny Root				a_word = signal[channel][sample];
386c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
387c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
388c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
389c74663799493f2b1e6123c18def94295d0afab7Kenny Root				*buf_++ = (FLAC__byte)a_word;
390c74663799493f2b1e6123c18def94295d0afab7Kenny Root			}
391c74663799493f2b1e6123c18def94295d0afab7Kenny Root		}
392c74663799493f2b1e6123c18def94295d0afab7Kenny Root	}
393c74663799493f2b1e6123c18def94295d0afab7Kenny Root}
394c74663799493f2b1e6123c18def94295d0afab7Kenny Root
395c74663799493f2b1e6123c18def94295d0afab7Kenny Root/*
396c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Convert the incoming audio signal to a byte stream and FLAC__MD5Update it.
397c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
398c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample)
399c74663799493f2b1e6123c18def94295d0afab7Kenny Root{
400c74663799493f2b1e6123c18def94295d0afab7Kenny Root	const size_t bytes_needed = (size_t)channels * (size_t)samples * (size_t)bytes_per_sample;
401c74663799493f2b1e6123c18def94295d0afab7Kenny Root
402c74663799493f2b1e6123c18def94295d0afab7Kenny Root	/* overflow check */
403c74663799493f2b1e6123c18def94295d0afab7Kenny Root	if((size_t)channels > SIZE_MAX / (size_t)bytes_per_sample)
404c74663799493f2b1e6123c18def94295d0afab7Kenny Root		return false;
405c74663799493f2b1e6123c18def94295d0afab7Kenny Root	if((size_t)channels * (size_t)bytes_per_sample > SIZE_MAX / (size_t)samples)
406c74663799493f2b1e6123c18def94295d0afab7Kenny Root		return false;
407c74663799493f2b1e6123c18def94295d0afab7Kenny Root
408c74663799493f2b1e6123c18def94295d0afab7Kenny Root	if(ctx->capacity < bytes_needed) {
409c74663799493f2b1e6123c18def94295d0afab7Kenny Root		FLAC__byte *tmp = (FLAC__byte*)realloc(ctx->internal_buf, bytes_needed);
410c74663799493f2b1e6123c18def94295d0afab7Kenny Root		if(0 == tmp) {
411c74663799493f2b1e6123c18def94295d0afab7Kenny Root			free(ctx->internal_buf);
412c74663799493f2b1e6123c18def94295d0afab7Kenny Root			if(0 == (ctx->internal_buf = (FLAC__byte*)safe_malloc_(bytes_needed)))
413c74663799493f2b1e6123c18def94295d0afab7Kenny Root				return false;
414c74663799493f2b1e6123c18def94295d0afab7Kenny Root		}
415c74663799493f2b1e6123c18def94295d0afab7Kenny Root		ctx->internal_buf = tmp;
416c74663799493f2b1e6123c18def94295d0afab7Kenny Root		ctx->capacity = bytes_needed;
417c74663799493f2b1e6123c18def94295d0afab7Kenny Root	}
418c74663799493f2b1e6123c18def94295d0afab7Kenny Root
419c74663799493f2b1e6123c18def94295d0afab7Kenny Root	format_input_(ctx->internal_buf, signal, channels, samples, bytes_per_sample);
420c74663799493f2b1e6123c18def94295d0afab7Kenny Root
421c74663799493f2b1e6123c18def94295d0afab7Kenny Root	FLAC__MD5Update(ctx, ctx->internal_buf, bytes_needed);
422c74663799493f2b1e6123c18def94295d0afab7Kenny Root
423c74663799493f2b1e6123c18def94295d0afab7Kenny Root	return true;
424c74663799493f2b1e6123c18def94295d0afab7Kenny Root}
425