mirror of
https://github.com/aaru-dps/Aaru.Compression.Native.git
synced 2025-12-16 19:24:31 +00:00
Updated flac to new API.
This commit is contained in:
85
flac.c
85
flac.c
@@ -6,23 +6,30 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "library.h"
|
|
||||||
#include "3rdparty/flac/include/FLAC/metadata.h"
|
#include "3rdparty/flac/include/FLAC/metadata.h"
|
||||||
#include "3rdparty/flac/include/FLAC/stream_decoder.h"
|
#include "3rdparty/flac/include/FLAC/stream_decoder.h"
|
||||||
#include "3rdparty/flac/include/FLAC/stream_encoder.h"
|
#include "3rdparty/flac/include/FLAC/stream_encoder.h"
|
||||||
|
#include "library.h"
|
||||||
#include "flac.h"
|
#include "flac.h"
|
||||||
|
|
||||||
static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[],
|
static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder,
|
||||||
size_t *bytes, void *client_data);
|
FLAC__byte buffer[],
|
||||||
|
size_t * bytes,
|
||||||
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame,
|
|
||||||
const FLAC__int32 const *buffer[], void *client_data);
|
|
||||||
|
|
||||||
static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status,
|
|
||||||
void * client_data);
|
void * client_data);
|
||||||
|
|
||||||
AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t *dst_buffer, size_t dst_size,
|
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder,
|
||||||
const uint8_t *src_buffer, size_t src_size)
|
const FLAC__Frame * frame,
|
||||||
|
const FLAC__int32 *const buffer[],
|
||||||
|
void * client_data);
|
||||||
|
|
||||||
|
static void error_callback(const FLAC__StreamDecoder * decoder,
|
||||||
|
FLAC__StreamDecoderErrorStatus status,
|
||||||
|
void * client_data);
|
||||||
|
|
||||||
|
AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t * dst_buffer,
|
||||||
|
size_t dst_size,
|
||||||
|
const uint8_t *src_buffer,
|
||||||
|
size_t src_size)
|
||||||
{
|
{
|
||||||
FLAC__StreamDecoder * decoder;
|
FLAC__StreamDecoder * decoder;
|
||||||
FLAC__StreamDecoderInitStatus init_status;
|
FLAC__StreamDecoderInitStatus init_status;
|
||||||
@@ -49,8 +56,16 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t *dst_buffer
|
|||||||
|
|
||||||
FLAC__stream_decoder_set_md5_checking(decoder, false);
|
FLAC__stream_decoder_set_md5_checking(decoder, false);
|
||||||
|
|
||||||
init_status = FLAC__stream_decoder_init_stream(decoder, read_callback, NULL, NULL, NULL, NULL, write_callback, NULL,
|
init_status = FLAC__stream_decoder_init_stream(decoder, read_callback, // 1
|
||||||
error_callback, ctx);
|
NULL, // 2 seek
|
||||||
|
NULL, // 3 tell
|
||||||
|
NULL, // 4 length
|
||||||
|
NULL, // 5 eof
|
||||||
|
write_callback, // 6 write
|
||||||
|
NULL, // 7 metadata
|
||||||
|
error_callback, // 8 error
|
||||||
|
ctx // 9 client_data
|
||||||
|
);
|
||||||
|
|
||||||
if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK)
|
if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK)
|
||||||
{
|
{
|
||||||
@@ -70,8 +85,10 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t *dst_buffer
|
|||||||
return ret_size;
|
return ret_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[],
|
static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder,
|
||||||
size_t *bytes, void *client_data)
|
FLAC__byte buffer[],
|
||||||
|
size_t * bytes,
|
||||||
|
void * client_data)
|
||||||
{
|
{
|
||||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
||||||
|
|
||||||
@@ -85,8 +102,10 @@ static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *de
|
|||||||
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame,
|
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder,
|
||||||
const FLAC__int32 const *buffer[], void *client_data)
|
const FLAC__Frame * frame,
|
||||||
|
const FLAC__int32 *const buffer[],
|
||||||
|
void * client_data)
|
||||||
{
|
{
|
||||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
||||||
size_t i;
|
size_t i;
|
||||||
@@ -125,14 +144,27 @@ static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecod
|
|||||||
}
|
}
|
||||||
|
|
||||||
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder *encoder,
|
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder *encoder,
|
||||||
const FLAC__byte buffer[], size_t bytes, uint32_t samples,
|
const FLAC__byte buffer[],
|
||||||
uint32_t current_frame, void *client_data);
|
size_t bytes,
|
||||||
|
uint32_t samples,
|
||||||
|
uint32_t current_frame,
|
||||||
|
void * client_data);
|
||||||
|
|
||||||
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(
|
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t * dst_buffer,
|
||||||
uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size, uint32_t blocksize,
|
size_t dst_size,
|
||||||
int32_t do_mid_side_stereo, int32_t loose_mid_side_stereo, const char *apodization, uint32_t max_lpc_order,
|
const uint8_t *src_buffer,
|
||||||
uint32_t qlp_coeff_precision, int32_t do_qlp_coeff_prec_search, int32_t do_exhaustive_model_search,
|
size_t src_size,
|
||||||
uint32_t min_residual_partition_order, uint32_t max_residual_partition_order, const char *application_id,
|
uint32_t blocksize,
|
||||||
|
int32_t do_mid_side_stereo,
|
||||||
|
int32_t loose_mid_side_stereo,
|
||||||
|
const char * apodization,
|
||||||
|
uint32_t max_lpc_order,
|
||||||
|
uint32_t qlp_coeff_precision,
|
||||||
|
int32_t do_qlp_coeff_prec_search,
|
||||||
|
int32_t do_exhaustive_model_search,
|
||||||
|
uint32_t min_residual_partition_order,
|
||||||
|
uint32_t max_residual_partition_order,
|
||||||
|
const char * application_id,
|
||||||
uint32_t application_id_len)
|
uint32_t application_id_len)
|
||||||
{
|
{
|
||||||
FLAC__StreamEncoder * encoder;
|
FLAC__StreamEncoder * encoder;
|
||||||
@@ -229,8 +261,11 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder *encoder,
|
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder *encoder,
|
||||||
const FLAC__byte buffer[], size_t bytes, uint32_t samples,
|
const FLAC__byte buffer[],
|
||||||
uint32_t current_frame, void *client_data)
|
size_t bytes,
|
||||||
|
uint32_t samples,
|
||||||
|
uint32_t current_frame,
|
||||||
|
void * client_data)
|
||||||
{
|
{
|
||||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user