49 const uint8_t *src_buffer,
size_t src_size)
51 FLAC__StreamDecoder *decoder = NULL;
52 FLAC__StreamDecoderInitStatus init_status = FLAC__STREAM_DECODER_INIT_STATUS_OK;
66 decoder = FLAC__stream_decoder_new();
74 FLAC__stream_decoder_set_md5_checking(decoder,
false);
79 if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK)
86 FLAC__stream_decoder_process_until_end_of_stream(decoder);
88 FLAC__stream_decoder_delete(decoder);
176 uint8_t *dst_buffer,
size_t dst_size,
const uint8_t *src_buffer,
size_t src_size, uint32_t blocksize,
177 int32_t do_mid_side_stereo, int32_t loose_mid_side_stereo,
const char *apodization, uint32_t max_lpc_order,
178 uint32_t qlp_coeff_precision, int32_t do_qlp_coeff_prec_search, int32_t do_exhaustive_model_search,
179 uint32_t min_residual_partition_order, uint32_t max_residual_partition_order,
const char *application_id,
180 uint32_t application_id_len)
182 FLAC__StreamEncoder *encoder = NULL;
184 FLAC__StreamEncoderInitStatus init_status = FLAC__STREAM_ENCODER_INIT_STATUS_OK;
186 FLAC__int32 *pcm = NULL;
188 int16_t *buffer16 = (int16_t *)src_buffer;
189 FLAC__StreamMetadata *metadata[1];
201 encoder = FLAC__stream_encoder_new();
210 FLAC__stream_encoder_set_verify(encoder,
false);
211 FLAC__stream_encoder_set_streamable_subset(encoder,
false);
212 FLAC__stream_encoder_set_channels(encoder, 2);
213 FLAC__stream_encoder_set_bits_per_sample(encoder, 16);
214 FLAC__stream_encoder_set_sample_rate(encoder, 44100);
215 FLAC__stream_encoder_set_blocksize(encoder, blocksize);
217 FLAC__stream_encoder_set_do_mid_side_stereo(encoder, do_mid_side_stereo);
219 FLAC__stream_encoder_set_loose_mid_side_stereo(encoder, loose_mid_side_stereo);
221 FLAC__stream_encoder_set_apodization(encoder, apodization);
222 FLAC__stream_encoder_set_max_lpc_order(encoder, max_lpc_order);
223 FLAC__stream_encoder_set_qlp_coeff_precision(encoder, qlp_coeff_precision);
224 FLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder, do_qlp_coeff_prec_search);
225 FLAC__stream_encoder_set_do_exhaustive_model_search(encoder, do_exhaustive_model_search);
226 FLAC__stream_encoder_set_min_residual_partition_order(encoder, min_residual_partition_order);
227 FLAC__stream_encoder_set_max_residual_partition_order(encoder, max_residual_partition_order);
228 FLAC__stream_encoder_set_total_samples_estimate(encoder, src_size / 4);
241 if(application_id_len > 0 && application_id != NULL)
242 if((metadata[0] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION)) != NULL)
243 FLAC__metadata_object_application_set_data(metadata[0], (
unsigned char *)application_id, application_id_len,
246 FLAC__stream_encoder_set_metadata(encoder, metadata, 1);
250 if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK)
256 pcm = malloc((src_size / 2) *
sizeof(FLAC__int32));
258 for(i = 0; i < src_size / 2; i++) pcm[i] = (FLAC__int32) * (buffer16++);
260 FLAC__stream_encoder_process_interleaved(encoder, pcm, src_size / 4);
262 FLAC__stream_encoder_finish(encoder);
264 FLAC__stream_encoder_delete(encoder);
270 FLAC__metadata_object_delete(metadata[0]);
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.