17 #include <FLAC/stream_encoder.h>
18 #include <FLAC/assert.h>
22 :
Encoder(outfile, qualitylevel, metadata)
24 bool streamable_subset =
true;
25 bool do_mid_side =
true;
26 bool loose_mid_side =
false;
27 int bits_per_sample = 16;
28 int sample_rate = 44100;
30 int max_lpc_order = 8;
31 int qlp_coeff_precision = 0;
32 bool qlp_coeff_prec_search =
false;
33 bool do_escape_coding =
false;
34 bool do_exhaustive_model_search =
false;
35 int min_residual_partition_order = 3;
36 int max_residual_partition_order = 3;
37 int rice_parameter_search_dist = 0;
40 FLAC__stream_encoder_set_streamable_subset(
m_encoder, streamable_subset);
41 FLAC__stream_encoder_set_do_mid_side_stereo(
m_encoder, do_mid_side);
42 FLAC__stream_encoder_set_loose_mid_side_stereo(
m_encoder, loose_mid_side);
44 FLAC__stream_encoder_set_bits_per_sample(
m_encoder, bits_per_sample);
45 FLAC__stream_encoder_set_sample_rate(
m_encoder, sample_rate);
46 FLAC__stream_encoder_set_blocksize(
m_encoder, blocksize);
47 FLAC__stream_encoder_set_max_lpc_order(
m_encoder, max_lpc_order);
48 FLAC__stream_encoder_set_qlp_coeff_precision(
m_encoder, qlp_coeff_precision);
49 FLAC__stream_encoder_set_do_qlp_coeff_prec_search(
m_encoder, qlp_coeff_prec_search);
50 FLAC__stream_encoder_set_do_escape_coding(
m_encoder, do_escape_coding);
51 FLAC__stream_encoder_set_do_exhaustive_model_search(
m_encoder, do_exhaustive_model_search);
52 FLAC__stream_encoder_set_min_residual_partition_order(
m_encoder, min_residual_partition_order);
53 FLAC__stream_encoder_set_max_residual_partition_order(
m_encoder, max_residual_partition_order);
54 FLAC__stream_encoder_set_rice_parameter_search_dist(
m_encoder, rice_parameter_search_dist);
56 QByteArray ofile = outfile.toLocal8Bit();
57 int ret = FLAC__stream_encoder_init_file(
58 m_encoder, ofile.constData(),
nullptr,
nullptr);
59 if (ret != FLAC__STREAM_ENCODER_INIT_STATUS_OK)
61 LOG(VB_GENERAL, LOG_ERR,
62 QString(
"Error initializing FLAC encoder. Got return code: %1")
89 unsigned int index = 0;
91 length /=
sizeof(int16_t);
103 if (!FLAC__stream_encoder_process(
m_encoder,
104 (
const FLAC__int32 *
const *)
m_input.data(),
107 LOG(VB_GENERAL, LOG_ERR,
108 QString(
"Failed to write flac data. Aborting."));
113 }
while (index < length);