void ZamEQ2Plugin::d_run(const float** inputs, float** outputs, uint32_t frames) { float srate = d_getSampleRate(); lowshelf(0, 0, srate, freql, gainl); peq(1, 0, srate, freq1, gain1, q1); peq(2, 0, srate, freq2, gain2, q2); highshelf(3, 0, srate, freqh, gainh); for (uint32_t i = 0; i < frames; i++) { double tmp,tmpl, tmph; double in = inputs[0][i]; in = sanitize_denormal(in); //lowshelf tmpl = (gainl == 0.f) ? in : run_filter(0, 0, in); //highshelf tmph = (gainh == 0.f) ? tmpl : run_filter(3, 0, tmpl); //parametric1 tmp = (gain1 == 0.f) ? tmph : run_filter(1, 0, tmph); //parametric2 tmpl = (gain2 == 0.f) ? tmp : run_filter(2, 0, tmp); outputs[0][i] = inputs[0][i]; outputs[0][i] = (float) tmpl; outputs[0][i] *= from_dB(master); } }
/** * \brief Callback when the menu item is clicked. */ static void item_activate(GtkMenuItem *menuitem, gpointer gdata) { GeanyDocument *doc = document_get_current(); ScintillaObject *sci = doc->editor->sci ; if ( gms_hnd == NULL ) return ; if ( gms_dlg( gms_hnd ) == 0 ) return ; gms_create_filter_file( gms_hnd ) ; switch ( gms_get_input_mode(gms_hnd) ) { case IN_CURRENT_DOC : select_entirely_doc( sci ) ; create_selection_2_input_file(sci) ; run_filter( sci ) ; delete_tmp_files() ; break; case IN_SELECTION : create_selection_2_input_file(sci) ; run_filter( sci ) ; delete_tmp_files() ; break; case IN_DOCS_SESSION : { guint nb_doc = 0 , i=0; /* find the opened document in the geany session */ while ( (doc = document_get_from_page(nb_doc))!=NULL ) nb_doc++; /* For each document */ for( i=0; i<nb_doc;i++) { doc = document_get_from_page(i) ; sci = doc->editor->sci ; select_entirely_doc( sci ) ; create_selection_2_input_file(sci) ; if ( run_filter( sci ) ) break ; /* if error then stop the loop */ } } delete_tmp_files() ; break; default: delete_tmp_files() ; return ; } }
int main(int argc, char ** argv) { (void)argc; (void)argv; AudioOptions audio_options = { 48000, 0, 0, 2, NULL, 1, 3, 4, 1024 * 1024, 1, 0.5, NULL, 0.10, pthread_self() }; audio_options.filters = (NUMERIC *)malloc(sizeof(NUMERIC) * audio_options.num_filters * audio_options.filter_size); for (int i = 0; i < audio_options.num_filters * audio_options.filter_size; ++i) { audio_options.filters[i] = 1 / ((double) audio_options.filter_size); } int ret_val = run_filter(audio_options); free(audio_options.filters); return ret_val; }
int lsx_process_threaded_noninterleaved_double(lsx_thread_state_t *state, const double * const *ibuf, double **obuf, size_t *ilen, size_t *olen, size_t istride, size_t ostride) { int n; size_t i; size_t count = ilen ? min(*ilen, IO_BUFSIZE) : 0; for (n = 0; n < state->count; ++n) { state->pth[n].ilen = count; state->pth[n].olen = min(*olen, IO_BUFSIZE); } for (n = 0; n < state->count; ++n) for (i = 0; i < count; ++i) state->pth[n].ibuf[i] = ibuf[n][i * istride]; if (run_filter(state) < 0) return -1; for (n = 0; n < state->count; ++n) for (i = 0; i < state->pth[0].olen; ++i) obuf[n][i * ostride] = state->pth[n].obuf[i]; if (ilen && *ilen) *ilen = state->pth[0].ilen; *olen = state->pth[0].olen; return 0; }
static int mixmaster(jack_nframes_t nframes, void *arg) { sample_t *outs[QMX_CHANNELS], *ch; size_t n, i; if (use_jack && need_init_guile) { scm_init_guile(); need_init_guile = 0; } for (n = 0; n < QMX_CHANNELS; n++) { // zero the mix buffers if (use_jack) ch = outs[n] = jack_port_get_buffer(jack_cauldron[n], nframes); else ch = outs[n] = fixed_cauldron + n * nframes; for (i = 0; i < nframes; i++) ch[i] = 0.0; } // mix from sources alsa_mix(nframes, outs); audio_files_mix(nframes, outs); feeds_mix(nframes, outs); if (use_jack) jack_ports_mix(nframes, outs); unit_gens_mix(nframes, outs); // process mix; e.g. fade run_filter(fader, nframes, outs, outs, 0); // deliver mix buffer_out(nframes, outs); record(nframes, outs); return 0; }
int vcf_tool_filter(int argc, char *argv[], const char *configuration_file) { /* ****************************** * Modifiable options * * ******************************/ shared_options_t *shared_options = new_shared_cli_options(0); filter_options_t *filter_options = new_filter_cli_options(); // If no arguments or only --help are provided, show usage void **argtable; if (argc == 1 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { argtable = merge_filter_options(filter_options, shared_options, arg_end(NUM_FILTER_OPTIONS)); show_usage("hpg-var-vcf filter", argtable); arg_freetable(argtable, NUM_FILTER_OPTIONS); return 0; } /* ****************************** * Execution steps * * ******************************/ // Step 1: read options from configuration file int config_errors = read_shared_configuration(configuration_file, shared_options); config_errors &= read_filter_configuration(configuration_file, filter_options, shared_options); if (config_errors) { LOG_FATAL("Configuration file read with errors\n"); return CANT_READ_CONFIG_FILE; } // Step 2: parse command-line options argtable = parse_filter_options(argc, argv, filter_options, shared_options); // Step 3: check that all options are set with valid values // Mandatory that couldn't be read from the config file must be set via command-line // If not, return error code! int check_vcf_tools_opts = verify_filter_options(filter_options, shared_options); if (check_vcf_tools_opts > 0) { return check_vcf_tools_opts; } // Step 4: Create XXX_options_data_t structures from valid XXX_options_t shared_options_data_t *shared_options_data = new_shared_options_data(shared_options); filter_options_data_t *options_data = new_filter_options_data(filter_options, shared_options); init_log_custom(shared_options_data->log_level, 1, "hpg-var-vcf.log", "w"); // Step 5: Perform the requested task int result = run_filter(shared_options_data, options_data); free_filter_options_data(options_data); free_shared_options_data(shared_options_data); arg_freetable(argtable, NUM_FILTER_OPTIONS); return 0; }
NVENCSTATUS NVEncFilter::filter(FrameInfo *pInputFrame, FrameInfo **ppOutputFrames, int *pOutputFrameNum) { cudaError_t cudaerr = cudaSuccess; if (m_bCheckPerformance) { cudaerr = cudaEventRecord(*m_peFilterStart.get()); if (cudaerr != cudaSuccess) { AddMessage(RGY_LOG_ERROR, _T("failed cudaEventRecord(m_peFilterStart): %s.\n"), char_to_tstring(cudaGetErrorString(cudaerr)).c_str()); } } if (pInputFrame == nullptr) { *pOutputFrameNum = 0; ppOutputFrames[0] = nullptr; } if (m_pParam && m_pParam->bOutOverwrite //上書きか? && pInputFrame != nullptr && pInputFrame->ptr != nullptr //入力が存在するか? && ppOutputFrames != nullptr && ppOutputFrames[0] == nullptr) { //出力先がセット可能か? ppOutputFrames[0] = pInputFrame; *pOutputFrameNum = 1; } const auto ret = run_filter(pInputFrame, ppOutputFrames, pOutputFrameNum); const int nOutFrame = *pOutputFrameNum; if (!m_pParam->bOutOverwrite && nOutFrame > 0) { if (m_nPathThrough & FILTER_PATHTHROUGH_TIMESTAMP) { if (nOutFrame != 1) { AddMessage(RGY_LOG_ERROR, _T("timestamp path through can only be applied to 1-in/1-out filter.\n")); return NV_ENC_ERR_INVALID_CALL; } else { ppOutputFrames[0]->timestamp = pInputFrame->timestamp; ppOutputFrames[0]->duration = pInputFrame->duration; } } for (int i = 0; i < nOutFrame; i++) { if (m_nPathThrough & FILTER_PATHTHROUGH_FLAGS) ppOutputFrames[i]->flags = pInputFrame->flags; if (m_nPathThrough & FILTER_PATHTHROUGH_PICSTRUCT) ppOutputFrames[i]->picstruct = pInputFrame->picstruct; } } if (m_bCheckPerformance) { cudaerr = cudaEventRecord(*m_peFilterFin.get()); if (cudaerr != cudaSuccess) { AddMessage(RGY_LOG_ERROR, _T("failed cudaEventRecord(m_peFilterFin): %s.\n"), char_to_tstring(cudaGetErrorString(cudaerr)).c_str()); } cudaerr = cudaEventSynchronize(*m_peFilterFin.get()); if (cudaerr != cudaSuccess) { AddMessage(RGY_LOG_ERROR, _T("failed cudaEventSynchronize(m_peFilterFin): %s.\n"), char_to_tstring(cudaGetErrorString(cudaerr)).c_str()); } float time_ms = 0.0f; cudaerr = cudaEventElapsedTime(&time_ms, *m_peFilterStart.get(), *m_peFilterFin.get()); if (cudaerr != cudaSuccess) { AddMessage(RGY_LOG_ERROR, _T("failed cudaEventElapsedTime(m_peFilterStart - m_peFilterFin): %s.\n"), char_to_tstring(cudaGetErrorString(cudaerr)).c_str()); } m_dFilterTimeMs += time_ms; m_nFilterRunCount++; } return ret; }
int lsx_process_threaded_noninterleaved_double(lsx_thread_state_t *state, const double * const *ibuf, double **obuf, size_t *ilen, size_t *olen, size_t istride, size_t ostride) { int n; size_t i; unsigned count = ilen ? *ilen : 0; if (count > state->pth[0].ibuf.size) { for (n = 0; n < state->count; ++n) { unsigned size = state->pth[n].ibuf.size = roundup(count); state->pth[n].ibuf._ = realloc(state->pth[n].ibuf._, sizeof(double) * size); } } if (*olen > state->pth[0].obuf.size) { for (n = 0; n < state->count; ++n) { unsigned size = state->pth[n].obuf.size = roundup(*olen); state->pth[n].obuf._ = realloc(state->pth[n].obuf._, sizeof(double) * size); } } for (n = 0; n < state->count; ++n) { state->pth[n].ilen = count; state->pth[n].olen = min(*olen, state->pth[n].obuf.size); } for (n = 0; n < state->count; ++n) for (i = 0; i < count; ++i) state->pth[n].ibuf._[i] = ibuf[n][i * istride]; if (run_filter(state) < 0) return -1; for (n = 0; n < state->count; ++n) for (i = 0; i < state->pth[0].olen; ++i) obuf[n][i * ostride] = state->pth[n].obuf._[i]; if (ilen && *ilen) *ilen = state->pth[0].ilen; *olen = state->pth[0].olen; return 0; }
void alsa_mix(jack_nframes_t nframes, sample_t *outs[]) { // contribute a block of audio to the collection plate size_t i, j, bytes; ALSA_CARD *card; sample_t sample[QMX_CHANNELS]; sample_t *out[QMX_CHANNELS]; sample_t *in[QMX_CHANNELS]; for (card = cards; card != NULL; card = card->link) { if (!card->running) continue; for (i = 0; i < nframes; i++) { bytes = jack_ringbuffer_read(card->ringbuf, (void *)sample, sizeof(sample_t) * QMX_CHANNELS); if (bytes < (sizeof(sample_t) * QMX_CHANNELS)) sample[0] = sample[1] = 0.0; for (j = 0; j < QMX_CHANNELS; j++) { out[j] = &(outs[j][i]); in[j] = &sample[j]; } run_filter(&card->base, 1, in, out, 1); } } return; }
static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) { struct sock *sk; struct packet_sock *po; struct sockaddr_ll *sll; struct tpacket_hdr *h; u8 * skb_head = skb->data; int skb_len = skb->len; unsigned snaplen; unsigned long status = TP_STATUS_LOSING|TP_STATUS_USER; unsigned short macoff, netoff; struct sk_buff *copy_skb = NULL; if (skb->pkt_type == PACKET_LOOPBACK) goto drop; sk = pt->af_packet_priv; po = pkt_sk(sk); if (dev->hard_header) { if (sk->sk_type != SOCK_DGRAM) skb_push(skb, skb->data - skb->mac.raw); else if (skb->pkt_type == PACKET_OUTGOING) { /* Special case: outgoing packets have ll header at head */ skb_pull(skb, skb->nh.raw - skb->data); if (skb->ip_summed == CHECKSUM_HW) status |= TP_STATUS_CSUMNOTREADY; } } snaplen = skb->len; if (sk->sk_filter) { unsigned res = run_filter(skb, sk, snaplen); if (res == 0) goto drop_n_restore; if (snaplen > res) snaplen = res; } if (sk->sk_type == SOCK_DGRAM) { macoff = netoff = TPACKET_ALIGN(TPACKET_HDRLEN) + 16; } else { unsigned maclen = skb->nh.raw - skb->data; netoff = TPACKET_ALIGN(TPACKET_HDRLEN + (maclen < 16 ? 16 : maclen)); macoff = netoff - maclen; } if (macoff + snaplen > po->frame_size) { if (po->copy_thresh && atomic_read(&sk->sk_rmem_alloc) + skb->truesize < (unsigned)sk->sk_rcvbuf) { if (skb_shared(skb)) { copy_skb = skb_clone(skb, GFP_ATOMIC); } else { copy_skb = skb_get(skb); skb_head = skb->data; } if (copy_skb) skb_set_owner_r(copy_skb, sk); } snaplen = po->frame_size - macoff; if ((int)snaplen < 0) snaplen = 0; } if (snaplen > skb->len-skb->data_len) snaplen = skb->len-skb->data_len; spin_lock(&sk->sk_receive_queue.lock); h = (struct tpacket_hdr *)packet_lookup_frame(po, po->head); if (h->tp_status) goto ring_is_full; po->head = po->head != po->frame_max ? po->head+1 : 0; po->stats.tp_packets++; if (copy_skb) { status |= TP_STATUS_COPY; __skb_queue_tail(&sk->sk_receive_queue, copy_skb); } if (!po->stats.tp_drops) status &= ~TP_STATUS_LOSING; spin_unlock(&sk->sk_receive_queue.lock); memcpy((u8*)h + macoff, skb->data, snaplen); h->tp_len = skb->len; h->tp_snaplen = snaplen; h->tp_mac = macoff; h->tp_net = netoff; if (skb->stamp.tv_sec == 0) { do_gettimeofday(&skb->stamp); sock_enable_timestamp(sk); } h->tp_sec = skb->stamp.tv_sec; h->tp_usec = skb->stamp.tv_usec; sll = (struct sockaddr_ll*)((u8*)h + TPACKET_ALIGN(sizeof(*h))); sll->sll_halen = 0; if (dev->hard_header_parse) sll->sll_halen = dev->hard_header_parse(skb, sll->sll_addr); sll->sll_family = AF_PACKET; sll->sll_hatype = dev->type; sll->sll_protocol = skb->protocol; sll->sll_pkttype = skb->pkt_type; sll->sll_ifindex = dev->ifindex; h->tp_status = status; mb(); { struct page *p_start, *p_end; u8 *h_end = (u8 *)h + macoff + snaplen - 1; p_start = virt_to_page(h); p_end = virt_to_page(h_end); while (p_start <= p_end) { flush_dcache_page(p_start); p_start++; } } sk->sk_data_ready(sk, 0); drop_n_restore: if (skb_head != skb->data && skb_shared(skb)) { skb->data = skb_head; skb->len = skb_len; } drop: kfree_skb(skb); return 0; ring_is_full: po->stats.tp_drops++; spin_unlock(&sk->sk_receive_queue.lock); sk->sk_data_ready(sk, 0); if (copy_skb) kfree_skb(copy_skb); goto drop_n_restore; }
static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) { struct sock *sk; struct sockaddr_ll *sll; struct packet_sock *po; u8 * skb_head = skb->data; int skb_len = skb->len; unsigned snaplen; if (skb->pkt_type == PACKET_LOOPBACK) goto drop; sk = pt->af_packet_priv; po = pkt_sk(sk); skb->dev = dev; if (dev->hard_header) { /* The device has an explicit notion of ll header, exported to higher levels. Otherwise, the device hides datails of it frame structure, so that corresponding packet head never delivered to user. */ if (sk->sk_type != SOCK_DGRAM) skb_push(skb, skb->data - skb->mac.raw); else if (skb->pkt_type == PACKET_OUTGOING) { /* Special case: outgoing packets have ll header at head */ skb_pull(skb, skb->nh.raw - skb->data); } } snaplen = skb->len; if (sk->sk_filter) { unsigned res = run_filter(skb, sk, snaplen); if (res == 0) goto drop_n_restore; if (snaplen > res) snaplen = res; } if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >= (unsigned)sk->sk_rcvbuf) goto drop_n_acct; if (skb_shared(skb)) { struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC); if (nskb == NULL) goto drop_n_acct; if (skb_head != skb->data) { skb->data = skb_head; skb->len = skb_len; } kfree_skb(skb); skb = nskb; } sll = (struct sockaddr_ll*)skb->cb; sll->sll_family = AF_PACKET; sll->sll_hatype = dev->type; sll->sll_protocol = skb->protocol; sll->sll_pkttype = skb->pkt_type; sll->sll_ifindex = dev->ifindex; sll->sll_halen = 0; if (dev->hard_header_parse) sll->sll_halen = dev->hard_header_parse(skb, sll->sll_addr); if (pskb_trim(skb, snaplen)) goto drop_n_acct; skb_set_owner_r(skb, sk); skb->dev = NULL; dst_release(skb->dst); skb->dst = NULL; spin_lock(&sk->sk_receive_queue.lock); po->stats.tp_packets++; __skb_queue_tail(&sk->sk_receive_queue, skb); spin_unlock(&sk->sk_receive_queue.lock); sk->sk_data_ready(sk, skb->len); return 0; drop_n_acct: spin_lock(&sk->sk_receive_queue.lock); po->stats.tp_drops++; spin_unlock(&sk->sk_receive_queue.lock); drop_n_restore: if (skb_head != skb->data && skb_shared(skb)) { skb->data = skb_head; skb->len = skb_len; } drop: kfree_skb(skb); return 0; }
void ZaMultiCompX2Plugin::d_run(const float** inputs, float** outputs, uint32_t frames) { float srate = d_getSampleRate(); float maxxL = maxL; float maxxR = maxR; int tog1 = (toggle[0] > 0.5f) ? 1 : 0; int tog2 = (toggle[1] > 0.5f) ? 1 : 0; int tog3 = (toggle[2] > 0.5f) ? 1 : 0; int listen1 = (listen[0] > 0.5f) ? 1 : 0; int listen2 = (listen[1] > 0.5f) ? 1 : 0; int listen3 = (listen[2] > 0.5f) ? 1 : 0; set_lp_coeffs(xover1, ONEOVERROOT2, srate, 0, 0); set_lp_coeffs(xover1, ONEOVERROOT2, srate, 1, 0); set_hp_coeffs(xover1, ONEOVERROOT2, srate, 2, 0); set_hp_coeffs(xover1, ONEOVERROOT2, srate, 3, 0); set_lp_coeffs(xover2, ONEOVERROOT2, srate, 4, 0); set_lp_coeffs(xover2, ONEOVERROOT2, srate, 5, 0); set_hp_coeffs(xover2, ONEOVERROOT2, srate, 6, 0); set_hp_coeffs(xover2, ONEOVERROOT2, srate, 7, 0); set_lp_coeffs(xover1, ONEOVERROOT2, srate, 0, 1); set_lp_coeffs(xover1, ONEOVERROOT2, srate, 1, 1); set_hp_coeffs(xover1, ONEOVERROOT2, srate, 2, 1); set_hp_coeffs(xover1, ONEOVERROOT2, srate, 3, 1); set_lp_coeffs(xover2, ONEOVERROOT2, srate, 4, 1); set_lp_coeffs(xover2, ONEOVERROOT2, srate, 5, 1); set_hp_coeffs(xover2, ONEOVERROOT2, srate, 6, 1); set_hp_coeffs(xover2, ONEOVERROOT2, srate, 7, 1); for (uint32_t i = 0; i < frames; ++i) { float tmp1[2], tmp2[2], tmp3[2], tmp4[2], tmp5[2], tmp6[2]; float fil1[2], fil2[2], fil3[2], fil4[2]; float outL[MAX_COMP+1] = {0.f}; float outR[MAX_COMP+1] = {0.f}; float inl = sanitize_denormal(inputs[0][i]); float inr = sanitize_denormal(inputs[1][i]); inl = (fabs(inl) < DANGER) ? inl : 0.f; inr = (fabs(inr) < DANGER) ? inr : 0.f; int listenmode = 0; // Interleaved channel processing fil1[0] = run_filter(0, 0, inl); fil1[1] = run_filter(0, 1, inr); tmp1[0] = run_filter(1, 0, fil1[0]); tmp1[1] = run_filter(1, 1, fil1[1]); if (tog1) run_comp(0, tmp1[0], tmp1[1], &outL[0], &outR[0]); tmp2[0] = tog1 ? outL[0] * from_dB(makeup[0]) : tmp1[0]; tmp2[1] = tog1 ? outR[0] * from_dB(makeup[0]) : tmp1[1]; fil2[0] = run_filter(2, 0, inl); fil2[1] = run_filter(2, 1, inr); tmp3[0] = run_filter(3, 0, fil2[0]); tmp3[1] = run_filter(3, 1, fil2[1]); fil3[0] = run_filter(4, 0, tmp3[0]); fil3[1] = run_filter(4, 1, tmp3[1]); tmp4[0] = run_filter(5, 0, fil3[0]); tmp4[1] = run_filter(5, 1, fil3[1]); if (tog2) run_comp(1, tmp4[0], tmp4[1], &outL[1], &outR[1]); tmp3[0] = tog2 ? outL[1] * from_dB(makeup[1]) : tmp4[0]; tmp3[1] = tog2 ? outR[1] * from_dB(makeup[1]) : tmp4[1]; fil4[0] = run_filter(6, 0, inl); fil4[1] = run_filter(6, 1, inr); tmp5[0] = run_filter(7, 0, fil4[0]); tmp5[1] = run_filter(7, 1, fil4[1]); if (tog3) run_comp(2, tmp5[0], tmp5[1], &outL[2], &outR[2]); tmp6[0] = tog3 ? outL[2] * from_dB(makeup[2]) : tmp5[0]; tmp6[1] = tog3 ? outR[2] * from_dB(makeup[2]) : tmp5[1]; outputs[0][i] = outputs[1][i] = 0.f; if (listen1) { listenmode = 1; outputs[0][i] += outL[0] * tog1*from_dB(makeup[0]) + (1.-tog1) * tmp1[0]; outputs[1][i] += outR[0] * tog1*from_dB(makeup[0]) + (1.-tog1) * tmp1[1]; } if (listen2) { listenmode = 1; outputs[0][i] += outL[1] * tog2*from_dB(makeup[1]) + (1.-tog2) * tmp4[0]; outputs[1][i] += outR[1] * tog2*from_dB(makeup[1]) + (1.-tog2) * tmp4[1]; } if (listen3) { listenmode = 1; outputs[0][i] += outL[2] * tog3*from_dB(makeup[2]) + (1.-tog3) * tmp5[0]; outputs[1][i] += outR[2] * tog3*from_dB(makeup[2]) + (1.-tog3) * tmp5[1]; } if (!listenmode) { outputs[0][i] = tmp2[0] + tmp3[0] + tmp6[0]; outputs[1][i] = tmp2[1] + tmp3[1] + tmp6[1]; } outputs[0][i] = sanitize_denormal(outputs[0][i]); outputs[1][i] = sanitize_denormal(outputs[1][i]); outputs[0][i] *= from_dB(globalgain); outputs[1][i] *= from_dB(globalgain); tmp1[0] = outputs[0][i]; tmp1[1] = outputs[1][i]; run_limit(tmp1[0], tmp1[1], &outL[3], &outR[3]); outputs[0][i] = outL[3]; outputs[1][i] = outR[3]; if (resetl) { maxL = fabsf(outputs[0][i]); resetl = false; } else { maxxL = (fabsf(outputs[0][i]) > maxxL) ? fabsf(outputs[0][i]) : sanitize_denormal(maxxL); } if (resetr) { maxR = fabsf(outputs[1][i]); resetr = false; } else { maxxR = (fabsf(outputs[1][i]) > maxxR) ? fabsf(outputs[1][i]) : sanitize_denormal(maxxR); } } outl = (maxxL <= 0.f) ? -160.f : to_dB(maxxL+limit); outr = (maxxR <= 0.f) ? -160.f : to_dB(maxxR+limit); }
int SubmitFile::MessageEnd(unsigned rcptnum, int iswhitelisted, int filter_enabled) { int is8bit=0, dorewrite=0, rwmode=0; const char *mime=getenv("MIME"); unsigned n; struct stat stat_buf; if (sizelimit && bytecount > sizelimit) { std::cout << "523 Message length (" << sizelimit << " bytes) exceeds administrative limit." << std::endl << std::flush; return (1); } if (diskfull) { std::cout << "431 Mail system full." << std::endl << std::flush; return (1); } if (spamtrap_flag) { std::cout << "550 Spam refused." << std::endl << std::flush; return (1); } if (rwrfcptr->rfcviolation & RFC2045_ERR2COMPLEX) { std::cout << "550 Message MIME complexity exceeds the policy maximum." << std::endl << std::flush; return (1); } datfile << std::flush; if (datfile.fail()) clog_msg_errno(); ctlfile << std::flush; if (ctlfile.fail()) clog_msg_errno(); /* Run global filters for this message */ std::string dfile=namefile("D", 0); if (!mime || strcmp(mime, "none")) { if (mime && strcmp(mime, "7bit") == 0) { rwmode=RFC2045_RW_7BIT; is8bit=0; } if (mime && strcmp(mime, "8bit") == 0) rwmode=RFC2045_RW_8BIT; if (rfc2045_ac_check(rwrfcptr, rwmode)) dorewrite=1; } else (void)rfc2045_ac_check(rwrfcptr, 0); if (rwrfcptr->has8bitchars) is8bit=1; unlink(namefile("D", 1).c_str()); // Might be the GDBM file // if receipients read from headers. if (dorewrite) { int fd1=dup(datfile.fd()); int fd2; if (fd1 < 0) clog_msg_errno(); datfile.close(); if (datfile.fail()) clog_msg_errno(); if ((fd2=open(namefile("D", 1).c_str(), O_RDWR|O_CREAT|O_TRUNC, PERMISSION)) < 0) clog_msg_errno(); if (call_rfc2045_rewrite(rwrfcptr, fd1, fd2, PACKAGE " " VERSION)) { clog_msg_errno(); std::cout << "431 Mail system full." << std::endl << std::flush; return (1); } close(fd1); #if EXPLICITSYNC fsync(fd2); #endif fstat(fd2, &stat_buf); close(fd2); std::string p=namefile("D", 0); unlink(p.c_str()); if (rename(namefile("D", 1).c_str(), p.c_str()) != 0) clog_msg_errno(); } else { datfile.sync(); #if EXPLICITSYNC fsync(datfile.fd()); #endif fstat(datfile.fd(), &stat_buf); datfile.close(); if (datfile.fail()) clog_msg_errno(); } if (is8bit) { ctlfile << COMCTLFILE_8BIT << "\n" << std::flush; closectl(); if (num_control_files_created > 1) { for (n=1; n < num_control_files_created; n++) { std::string p=namefile("C", n); int nfd=open(p.c_str(), O_WRONLY | O_APPEND); if (nfd < 0) clog_msg_errno(); ctlfile.fd(nfd); ctlfile << COMCTLFILE_8BIT << "\n" << std::flush; if (ctlfile.fail()) clog_msg_errno(); #if EXPLICITSYNC ctlfile.sync(); fsync(ctlfile.fd()); #endif ctlfile.close(); if (ctlfile.fail()) clog_msg_errno(); } } } else { closectl(); } SubmitFile *voidp=this; if (filter_enabled && run_filter(dfile.c_str(), num_control_files_created, iswhitelisted, &SubmitFile::get_msgid_for_filtering, &voidp)) return (1); std::string cfile=namefile("C", 0); for (n=2; n <= num_control_files_created; n++) { if (link(dfile.c_str(), namefile("D", n).c_str()) != 0) clog_msg_errno(); } std::string okmsg("250 Ok. "); okmsg += basemsgid; int hasxerror=datafilter(dfile.c_str(), rcptnum, okmsg.c_str()); current_submit_file=0; if (num_control_files_created == 1) { if (rename(name1stctlfile().c_str(), cfile.c_str()) != 0) clog_msg_errno(); } else { if (rename(namefile("C", 1).c_str(), cfile.c_str()) != 0) clog_msg_errno(); } if (!hasxerror) { #if EXPLICITDIRSYNC size_t p=cfile.rfind('/'); if (p != std::string::npos) { std::string dir=cfile.substr(0, p); int fd=open(dir.c_str(), O_RDONLY); if (fd >= 0) { fsync(fd); close(fd); } } #endif std::cout << okmsg << std::endl << std::flush; } trigger(TRIGGER_NEWMSG); return (0); }