libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
Loading...
Searching...
No Matches
flac.c File Reference
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "aaruformat.h"
#include "flac.h"
#include "FLAC/metadata.h"
#include "FLAC/stream_decoder.h"
#include "FLAC/stream_encoder.h"

Go to the source code of this file.

Functions

static FLAC__StreamDecoderReadStatus read_callback (const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
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)
size_t aaruf_flac_decode_redbook_buffer (uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size)
 Decodes a FLAC-compressed Red Book audio buffer.
static FLAC__StreamEncoderWriteStatus encoder_write_callback (const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data)
size_t aaruf_flac_encode_redbook_buffer (uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size, 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)
 Encodes a Red Book audio buffer to FLAC format.

Function Documentation

◆ aaruf_flac_decode_redbook_buffer()

size_t aaruf_flac_decode_redbook_buffer ( uint8_t * dst_buffer,
size_t dst_size,
const uint8_t * src_buffer,
size_t src_size )

Decodes a FLAC-compressed Red Book audio buffer.

Decompresses FLAC-compressed Red Book audio data into the destination buffer.

Parameters
dst_bufferPointer to the destination buffer.
dst_sizeSize of the destination buffer.
src_bufferPointer to the source (compressed) buffer.
src_sizeSize of the source buffer.
Returns
Number of bytes written to the destination buffer.

Definition at line 48 of file flac.c.

References AARU_CALL, AARU_EXPORT, aaru_flac_ctx::dst_buffer, aaru_flac_ctx::dst_len, aaru_flac_ctx::dst_pos, aaru_flac_ctx::error, error_callback(), read_callback(), aaru_flac_ctx::src_buffer, aaru_flac_ctx::src_len, aaru_flac_ctx::src_pos, and write_callback().

Referenced by aaruf_read_sector().

◆ aaruf_flac_encode_redbook_buffer()

size_t aaruf_flac_encode_redbook_buffer ( uint8_t * dst_buffer,
size_t dst_size,
const uint8_t * src_buffer,
size_t src_size,
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 )

Encodes a Red Book audio buffer to FLAC format.

Parameters
dst_bufferPointer to the destination buffer for FLAC data.
dst_sizeSize of the destination buffer in bytes.
src_bufferPointer to the source Red Book audio buffer.
src_sizeSize of the source buffer in bytes.
blocksizeFLAC block size.
do_mid_side_stereoEnable mid-side stereo encoding.
loose_mid_side_stereoEnable loose mid-side stereo encoding.
apodizationApodization string for FLAC encoder.
max_lpc_orderMaximum LPC order.
qlp_coeff_precisionQLP coefficient precision.
do_qlp_coeff_prec_searchEnable QLP coefficient precision search.
do_exhaustive_model_searchEnable exhaustive model search.
min_residual_partition_orderMinimum residual partition order.
max_residual_partition_orderMaximum residual partition order.
application_idApplication ID string for FLAC encoder.
application_id_lenLength of the application ID string.
Returns
Number of bytes written to the destination buffer.

Definition at line 175 of file flac.c.

References AARU_CALL, AARU_EXPORT, aaru_flac_ctx::dst_buffer, aaru_flac_ctx::dst_len, aaru_flac_ctx::dst_pos, encoder_write_callback(), aaru_flac_ctx::error, aaru_flac_ctx::src_buffer, aaru_flac_ctx::src_len, and aaru_flac_ctx::src_pos.

Referenced by aaruf_close_current_block().

◆ encoder_write_callback()

FLAC__StreamEncoderWriteStatus encoder_write_callback ( const FLAC__StreamEncoder * encoder,
const FLAC__byte buffer[],
size_t bytes,
uint32_t samples,
uint32_t current_frame,
void * client_data )
static

◆ error_callback()

void error_callback ( const FLAC__StreamDecoder * decoder,
FLAC__StreamDecoderErrorStatus status,
void * client_data )
static

Definition at line 141 of file flac.c.

References aaru_flac_ctx::error.

Referenced by aaruf_flac_decode_redbook_buffer().

◆ read_callback()

FLAC__StreamDecoderReadStatus read_callback ( const FLAC__StreamDecoder * decoder,
FLAC__byte buffer[],
size_t * bytes,
void * client_data )
static

◆ write_callback()

FLAC__StreamDecoderWriteStatus write_callback ( const FLAC__StreamDecoder * decoder,
const FLAC__Frame * frame,
const FLAC__int32 *const buffer[],
void * client_data )
static