#define md5byte unsigned char
+/*
+ * Due to an unholy abomination in libOggFLAC (it requires access to
+ * these internal MD5 functions) we have to #include "FLAC/export.h"
+ * and export them when building a DLL
+ */
+#include "FLAC/export.h"
#include "FLAC/ordinals.h"
-struct MD5Context {
+struct FLAC__MD5Context {
FLAC__uint32 buf[4];
FLAC__uint32 bytes[2];
FLAC__uint32 in[16];
unsigned capacity;
};
-void MD5Init(struct MD5Context *context);
-void MD5Update(struct MD5Context *context, md5byte const *buf, unsigned len);
-void MD5Final(md5byte digest[16], struct MD5Context *context);
-void MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16]);
+FLAC_API void FLAC__MD5Init(struct FLAC__MD5Context *context);
+FLAC_API void FLAC__MD5Update(struct FLAC__MD5Context *context, md5byte const *buf, unsigned len);
+FLAC_API void FLAC__MD5Final(md5byte digest[16], struct FLAC__MD5Context *context);
+void FLAC__MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16]);
-FLAC__bool FLAC__MD5Accumulate(struct MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample);
+FLAC_API FLAC__bool FLAC__MD5Accumulate(struct FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample);
#endif /* !MD5_H */
*/
FLaC__INLINE
void
-MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16])
+FLAC__MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16])
{
register FLAC__uint32 a, b, c, d;
* initialization constants.
*/
void
-MD5Init(struct MD5Context *ctx)
+FLAC__MD5Init(struct FLAC__MD5Context *ctx)
{
FLAC__uint32 test = 1;
* of bytes.
*/
void
-MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len)
+FLAC__MD5Update(struct FLAC__MD5Context *ctx, md5byte const *buf, unsigned len)
{
FLAC__uint32 t;
/* First chunk is an odd size */
memcpy((md5byte *)ctx->in + 64 - t, buf, t);
byteSwap(ctx->in, 16);
- MD5Transform(ctx->buf, ctx->in);
+ FLAC__MD5Transform(ctx->buf, ctx->in);
buf += t;
len -= t;
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteSwap(ctx->in, 16);
- MD5Transform(ctx->buf, ctx->in);
+ FLAC__MD5Transform(ctx->buf, ctx->in);
buf += 64;
len -= 64;
}
}
/*
- * Convert the incoming audio signal to a byte stream and MD5Update it.
+ * Convert the incoming audio signal to a byte stream and FLAC__MD5Update it.
*/
FLAC__bool
-FLAC__MD5Accumulate(struct MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample)
+FLAC__MD5Accumulate(struct FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample)
{
unsigned channel, sample, a_byte;
FLAC__int32 a_word;
}
}
- MD5Update(ctx, ctx->internal_buf, bytes_needed);
+ FLAC__MD5Update(ctx, ctx->internal_buf, bytes_needed);
return true;
}
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void
-MD5Final(md5byte digest[16], struct MD5Context *ctx)
+FLAC__MD5Final(md5byte digest[16], struct FLAC__MD5Context *ctx)
{
int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
md5byte *p = (md5byte *)ctx->in + count;
if (count < 0) { /* Padding forces an extra block */
memset(p, 0, count + 8);
byteSwap(ctx->in, 16);
- MD5Transform(ctx->buf, ctx->in);
+ FLAC__MD5Transform(ctx->buf, ctx->in);
p = (md5byte *)ctx->in;
count = 56;
}
/* Append length in bits and transform */
ctx->in[14] = ctx->bytes[0] << 3;
ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
- MD5Transform(ctx->buf, ctx->in);
+ FLAC__MD5Transform(ctx->buf, ctx->in);
byteSwap(ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
void *client_data;
FLAC__StreamDecoder *stream_decoder;
FLAC__bool do_md5_checking; /* initially gets protected_->md5_checking but is turned off after a seek */
- struct MD5Context md5context;
+ struct FLAC__MD5Context md5context;
FLAC__byte stored_md5sum[16]; /* this is what is stored in the metadata */
FLAC__byte computed_md5sum[16]; /* this is the sum we computed from the decoded data */
/* the rest of these are only used for seeking: */
decoder->private_->do_md5_checking = decoder->protected_->md5_checking;
- /* We initialize the MD5Context even though we may never use it. This is
- * because md5 checking may be turned on to start and then turned off if a
- * seek occurs. So we always init the context here and finalize it in
+ /* We initialize the FLAC__MD5Context even though we may never use it. This
+ * is because md5 checking may be turned on to start and then turned off if
+ * a seek occurs. So we always init the context here and finalize it in
* FLAC__seekable_stream_decoder_finish() to make sure things are always
* cleaned up properly.
*/
- MD5Init(&decoder->private_->md5context);
+ FLAC__MD5Init(&decoder->private_->md5context);
FLAC__stream_decoder_set_read_callback(decoder->private_->stream_decoder, read_callback_);
FLAC__stream_decoder_set_write_callback(decoder->private_->stream_decoder, write_callback_);
FLAC__ASSERT(0 != decoder->private_->stream_decoder);
/* see the comment in FLAC__seekable_stream_decoder_init() as to why we
- * always call MD5Final()
+ * always call FLAC__MD5Final()
*/
- MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context);
+ FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context);
FLAC__stream_decoder_finish(decoder->private_->stream_decoder);
decoder->private_->do_md5_checking = decoder->protected_->md5_checking;
- /* We initialize the MD5Context even though we may never use it. This is
- * because md5 checking may be turned on to start and then turned off if a
- * seek occurs. So we always init the context here and finalize it in
+ /* We initialize the FLAC__MD5Context even though we may never use it. This
+ * is because md5 checking may be turned on to start and then turned off if
+ * a seek occurs. So we always init the context here and finalize it in
* FLAC__seekable_stream_decoder_finish() to make sure things are always
* cleaned up properly.
*/
- MD5Init(&decoder->private_->md5context);
+ FLAC__MD5Init(&decoder->private_->md5context);
decoder->protected_->state = FLAC__SEEKABLE_STREAM_DECODER_OK;
FLAC__StreamMetadata metadata;
unsigned current_sample_number;
unsigned current_frame_number;
- struct MD5Context md5context;
+ struct FLAC__MD5Context md5context;
FLAC__CPUInfo cpuinfo;
unsigned (*local_fixed_compute_best_predictor)(const FLAC__int32 data[], unsigned data_len, FLAC__real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
void (*local_lpc_compute_autocorrelation)(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
encoder->private_->metadata.data.stream_info.bits_per_sample = encoder->protected_->bits_per_sample;
encoder->private_->metadata.data.stream_info.total_samples = encoder->protected_->total_samples_estimate; /* we will replace this later with the real total */
memset(encoder->private_->metadata.data.stream_info.md5sum, 0, 16); /* we don't know this yet; have to fill it in later */
- MD5Init(&encoder->private_->md5context);
+ FLAC__MD5Init(&encoder->private_->md5context);
if(!FLAC__bitbuffer_clear(encoder->private_->frame))
return encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
if(!FLAC__add_metadata_block(&encoder->private_->metadata, encoder->private_->frame))
}
}
- MD5Final(encoder->private_->metadata.data.stream_info.md5sum, &encoder->private_->md5context);
+ FLAC__MD5Final(encoder->private_->metadata.data.stream_info.md5sum, &encoder->private_->md5context);
if(encoder->protected_->state == FLAC__STREAM_ENCODER_OK && !encoder->private_->is_being_deleted) {
encoder->private_->metadata_callback(encoder, &encoder->private_->metadata, encoder->private_->client_data);
frame_header.channel_assignment = channel_assignment;
- if(!FLAC__frame_add_header(&frame_header, encoder->protected_->streamable_subset, is_last_frame, encoder->private_->frame)) {
+ if(!FLAC__frame_add_header(&frame_header, encoder->protected_->streamable_subset, encoder->private_->frame)) {
encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
return false;
}
return false;
}
else {
- if(!FLAC__frame_add_header(&frame_header, encoder->protected_->streamable_subset, is_last_frame, encoder->private_->frame)) {
+ if(!FLAC__frame_add_header(&frame_header, encoder->protected_->streamable_subset, encoder->private_->frame)) {
encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
return false;
}
void *client_data;
OggFLAC__StreamDecoder *stream_decoder;
FLAC__bool do_md5_checking; /* initially gets protected_->md5_checking but is turned off after a seek */
- struct MD5Context md5context;
+ struct FLAC__MD5Context md5context;
FLAC__byte stored_md5sum[16]; /* this is what is stored in the metadata */
FLAC__byte computed_md5sum[16]; /* this is the sum we computed from the decoded data */
/* the rest of these are only used for seeking: */
decoder->private_->do_md5_checking = decoder->protected_->md5_checking;
- /* We initialize the MD5Context even though we may never use it. This is
- * because md5 checking may be turned on to start and then turned off if a
- * seek occurs. So we always init the context here and finalize it in
+ /* We initialize the FLAC__MD5Context even though we may never use it. This
+ * is because md5 checking may be turned on to start and then turned off if
+ * a seek occurs. So we always init the context here and finalize it in
* OggFLAC__seekable_stream_decoder_finish() to make sure things are always
* cleaned up properly.
*/
- MD5Init(&decoder->private_->md5context);
+ FLAC__MD5Init(&decoder->private_->md5context);
OggFLAC__stream_decoder_set_read_callback(decoder->private_->stream_decoder, read_callback_);
OggFLAC__stream_decoder_set_write_callback(decoder->private_->stream_decoder, write_callback_);
FLAC__ASSERT(0 != decoder->private_->stream_decoder);
/* see the comment in OggFLAC__seekable_stream_decoder_init() as to why we
- * always call MD5Final()
+ * always call FLAC__MD5Final()
*/
- MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context);
+ FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context);
OggFLAC__stream_decoder_finish(decoder->private_->stream_decoder);
decoder->private_->do_md5_checking = decoder->protected_->md5_checking;
- /* We initialize the MD5Context even though we may never use it. This is
- * because md5 checking may be turned on to start and then turned off if a
- * seek occurs. So we always init the context here and finalize it in
+ /* We initialize the FLAC__MD5Context even though we may never use it. This
+ * is because md5 checking may be turned on to start and then turned off if
+ * a seek occurs. So we always init the context here and finalize it in
* OggFLAC__seekable_stream_decoder_finish() to make sure things are always
* cleaned up properly.
*/
- MD5Init(&decoder->private_->md5context);
+ FLAC__MD5Init(&decoder->private_->md5context);
decoder->protected_->state = OggFLAC__SEEKABLE_STREAM_DECODER_OK;
if (iteration >= BINARY_SEARCH_AFTER_ITERATION)
pos = (right_pos + left_pos) / 2;
else
+#if defined _MSC_VER || defined __MINGW32__
+ /* with VC++ you have to spoon feed it the casting */
+ pos = (FLAC__uint64)((double)(FLAC__int64)(target_sample - left_sample) / (double)(FLAC__int64)(right_pos - left_pos));
+#else
pos = (FLAC__uint64)((double)(target_sample - left_sample) / (double)(right_pos - left_pos));
+#endif
if (this_frame_sample <= target_sample) {
/* The 'equal' case should not happen, since