本文整理汇总了C++中DB_decoder_t::read方法的典型用法代码示例。如果您正苦于以下问题:C++ DB_decoder_t::read方法的具体用法?C++ DB_decoder_t::read怎么用?C++ DB_decoder_t::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_decoder_t
的用法示例。
在下文中一共展示了DB_decoder_t::read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
}
if (!temp_file) {
temp_file = enc_pipe;
}
// write wave header
char wavehdr_int[] = {
0x52, 0x49, 0x46, 0x46, 0x24, 0x70, 0x0d, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6d, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x44, 0xac, 0x00, 0x00, 0x10, 0xb1, 0x02, 0x00, 0x04, 0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61
};
char wavehdr_float[] = {
0x52, 0x49, 0x46, 0x46, 0x2a, 0xdf, 0x02, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6d, 0x74, 0x20, 0x28, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x02, 0x00, 0x40, 0x1f, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x00, 0x08, 0x00, 0x20, 0x00, 0x16, 0x00, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71, 0x66, 0x61, 0x63, 0x74, 0x04, 0x00, 0x00, 0x00, 0xc5, 0x5b, 0x00, 0x00, 0x64, 0x61, 0x74, 0x61
};
char *wavehdr = output_is_float ? wavehdr_float : wavehdr_int;
int wavehdr_size = output_is_float ? sizeof (wavehdr_float) : sizeof (wavehdr_int);
int header_written = 0;
uint32_t outsize = 0;
uint32_t outsr = fileinfo->fmt.samplerate;
uint16_t outch = fileinfo->fmt.channels;
int samplesize = fileinfo->fmt.channels * fileinfo->fmt.bps / 8;
int bs = 10250 * samplesize;
char buffer[bs * 4];
int dspsize = bs / samplesize * sizeof (float) * fileinfo->fmt.channels;
char dspbuffer[dspsize * 4];
int eof = 0;
for (;;) {
if (eof) {
break;
}
if (abort && *abort) {
break;
}
int sz = dec->read (fileinfo, buffer, bs);
if (sz != bs) {
eof = 1;
}
if (dsp_preset) {
ddb_waveformat_t fmt;
ddb_waveformat_t outfmt;
memcpy (&fmt, &fileinfo->fmt, sizeof (fmt));
memcpy (&outfmt, &fileinfo->fmt, sizeof (fmt));
fmt.bps = 32;
fmt.is_float = 1;
deadbeef->pcm_convert (&fileinfo->fmt, buffer, &fmt, dspbuffer, sz);
ddb_dsp_context_t *dsp = dsp_preset->chain;
int frames = sz / samplesize;
while (dsp) {
frames = dsp->plugin->process (dsp, (float *)dspbuffer, frames, sizeof (dspbuffer) / (fmt.channels * 4), &fmt, NULL);
dsp = dsp->next;
}
outsr = fmt.samplerate;
outch = fmt.channels;
outfmt.bps = output_bps;
outfmt.is_float = output_is_float;
outfmt.channels = outch;
outfmt.samplerate = outsr;
int n = deadbeef->pcm_convert (&fmt, dspbuffer, &outfmt, buffer, frames * sizeof (float) * fmt.channels);
sz = n;
}
else if (fileinfo->fmt.bps != output_bps || fileinfo->fmt.is_float != output_is_float) {
示例2: if
//.........这里部分代码省略.........
}
// write wave header
char wavehdr_int[] = {
0x52, 0x49, 0x46, 0x46, 0x00, 0x00, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6d, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x44, 0xac, 0x00, 0x00, 0x10, 0xb1, 0x02, 0x00, 0x04, 0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61
};
char wavehdr_float[] = {
0x52, 0x49, 0x46, 0x46, 0x00, 0x00, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6d, 0x74, 0x20, 0x28, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x02, 0x00, 0x40, 0x1f, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x00, 0x08, 0x00, 0x20, 0x00, 0x16, 0x00, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71, 0x66, 0x61, 0x63, 0x74, 0x04, 0x00, 0x00, 0x00, 0xc5, 0x5b, 0x00, 0x00, 0x64, 0x61, 0x74, 0x61
};
char *wavehdr = output_is_float ? wavehdr_float : wavehdr_int;
int wavehdr_size = output_is_float ? sizeof (wavehdr_float) : sizeof (wavehdr_int);
int header_written = 0;
uint32_t outsize = 0;
uint32_t outsr = fileinfo->fmt.samplerate;
uint16_t outch = fileinfo->fmt.channels;
int samplesize = fileinfo->fmt.channels * fileinfo->fmt.bps / 8;
// block size
int bs = 2000 * samplesize;
// expected buffer size after worst-case dsp
int dspsize = bs/samplesize*sizeof(float)*8*48;
buffer = malloc (dspsize);
// account for up to float32 7.1 resampled to 48x ratio
dspbuffer = malloc (dspsize);
int eof = 0;
for (;;) {
if (eof) {
break;
}
if (abort && *abort) {
break;
}
int sz = dec->read (fileinfo, buffer, bs);
if (sz != bs) {
eof = 1;
}
if (dsp_preset) {
ddb_waveformat_t fmt;
ddb_waveformat_t outfmt;
memcpy (&fmt, &fileinfo->fmt, sizeof (fmt));
memcpy (&outfmt, &fileinfo->fmt, sizeof (fmt));
fmt.bps = 32;
fmt.is_float = 1;
deadbeef->pcm_convert (&fileinfo->fmt, buffer, &fmt, dspbuffer, sz);
ddb_dsp_context_t *dsp = dsp_preset->chain;
int frames = sz / samplesize;
while (dsp) {
frames = dsp->plugin->process (dsp, (float *)dspbuffer, frames, dspsize / (fmt.channels * 4), &fmt, NULL);
if (frames <= 0) {
break;
}
dsp = dsp->next;
}
if (frames <= 0) {
fprintf (stderr, "converter: dsp error, please check you dsp preset\n");
goto error;
}
outsr = fmt.samplerate;
outch = fmt.channels;
outfmt.bps = output_bps;
outfmt.is_float = output_is_float;
示例3: malloc
void
rg_calc_thread(void *ctx) {
DB_decoder_t *dec = NULL;
DB_fileinfo_t *fileinfo = NULL;
char *buffer = NULL;
char *bufferf = NULL;
track_state_t *st = (track_state_t *)ctx;
if (st->settings->pabort && *(st->settings->pabort)) {
return;
}
if (deadbeef->pl_get_item_duration (st->settings->tracks[st->track_index]) <= 0) {
st->settings->results[st->track_index].scan_result = DDB_RG_SCAN_RESULT_INVALID_FILE;
return;
}
deadbeef->pl_lock ();
dec = (DB_decoder_t *)deadbeef->plug_get_for_id (deadbeef->pl_find_meta (st->settings->tracks[st->track_index], ":DECODER"));
deadbeef->pl_unlock ();
if (dec) {
fileinfo = dec->open (DDB_DECODER_HINT_RAW_SIGNAL);
if (fileinfo && dec->init (fileinfo, DB_PLAYITEM (st->settings->tracks[st->track_index])) != 0) {
st->settings->results[st->track_index].scan_result = DDB_RG_SCAN_RESULT_FILE_NOT_FOUND;
goto error;
}
if (fileinfo) {
st->gain_state[st->track_index] = ebur128_init(fileinfo->fmt.channels, fileinfo->fmt.samplerate, EBUR128_MODE_I);
st->peak_state[st->track_index] = ebur128_init(fileinfo->fmt.channels, fileinfo->fmt.samplerate, EBUR128_MODE_SAMPLE_PEAK);
// speaker mask mapping from WAV to EBUR128
static const int chmap[18] = {
EBUR128_LEFT,
EBUR128_RIGHT,
EBUR128_CENTER,
EBUR128_UNUSED,
EBUR128_LEFT_SURROUND,
EBUR128_RIGHT_SURROUND,
EBUR128_LEFT_SURROUND,
EBUR128_RIGHT_SURROUND,
EBUR128_CENTER,
EBUR128_LEFT_SURROUND,
EBUR128_RIGHT_SURROUND,
EBUR128_CENTER,
EBUR128_LEFT_SURROUND,
EBUR128_CENTER,
EBUR128_RIGHT_SURROUND,
EBUR128_LEFT_SURROUND,
EBUR128_CENTER,
EBUR128_RIGHT_SURROUND,
};
uint32_t channelmask = fileinfo->fmt.channelmask;
// first 18 speaker positions are known, the rest will be marked as UNUSED
int ch = 0;
for (int i = 0; i < 32 && ch < fileinfo->fmt.channels; i++) {
if (i < 18) {
if (channelmask & (1<<i))
{
ebur128_set_channel (st->gain_state[st->track_index], ch, chmap[i]);
ebur128_set_channel (st->peak_state[st->track_index], ch, chmap[i]);
ch++;
}
}
else {
ebur128_set_channel (st->gain_state[st->track_index], ch, EBUR128_UNUSED);
ebur128_set_channel (st->peak_state[st->track_index], ch, EBUR128_UNUSED);
ch++;
}
}
int samplesize = fileinfo->fmt.channels * fileinfo->fmt.bps / 8;
int bs = 2000 * samplesize;
ddb_waveformat_t fmt;
buffer = malloc (bs);
if (!fileinfo->fmt.is_float) {
bufferf = malloc (2000 * sizeof (float) * fileinfo->fmt.channels);
memcpy (&fmt, &fileinfo->fmt, sizeof (fmt));
fmt.bps = 32;
fmt.is_float = 1;
}
else {
bufferf = buffer;
}
int eof = 0;
for (;;) {
if (eof) {
break;
}
if (st->settings->pabort && *(st->settings->pabort)) {
break;
//.........这里部分代码省略.........