void MainWindow::create_file() { std::string filename = run_open_file_dialog("Select png file to create stegocontener", Gtk::FILE_CHOOSER_ACTION_OPEN); if(filename != "") { m_png = Cairo::ImageSurface::create_from_png(filename); if(!m_png) { Gtk::MessageDialog err(*this, "Open file failed", false, Gtk::MESSAGE_ERROR); err.set_secondary_text("Open file failed"); err.run(); } else { switch(m_png->get_format()) { case Cairo::FORMAT_ARGB32: std::cout << "Image format ARGB32\n"; break; case Cairo::FORMAT_RGB24: std::cout << "Image format RGB24\n"; break; case Cairo::FORMAT_A8: std::cout << "Image format A8\n"; break; case Cairo::FORMAT_A1: std::cout << "Image format A1\n"; break; case Cairo::FORMAT_RGB16_565: std::cout << "Image format RGB16_565\n"; break; } m_wavelet = Wavelet(Image(m_png)); std::ostringstream ostr; ostr << "Size: " << m_png->get_width() << "x" << m_png->get_height() << ", 'bits' to write: " << m_wavelet.count_bytes_to_write(); m_statusbar.push(ostr.str()); m_first.set_size_request(m_png->get_width(), m_png->get_height()); m_first.show(); m_text_window.set_size_request(m_png->get_width(), m_png->get_height()); m_text_window.show(); m_save.set_sensitive(true); } } }
WaveletAnalysis::WaveletAnalysis(int f0, int fmax) { period = 44100 / f0; numFilters = fmax / f0; envelopes.resize(numFilters); for(auto i = 1; i < numFilters; i++) { wavelets.emplace_back(Wavelet(period / i, HANNING)); } }
int Spectral_ExecuteAnalysis(signal_t *orig_signal, int target_iters, int windowing_type, Period_t ***DetectedPeriods) { signal_t *signal = NULL; spectral_time_t timeShifted = 0, totalTime = 0; /* Input signal is cloned because shifting (and windowing) modifies it */ signal = Spectral_CloneSignal( orig_signal ); timeShifted = Spectral_ShiftSignal( signal ); #if defined(DEBUG_MODE) fprintf(stdout, "Signal shifted " FORMAT_TIME " ns\n", timeShifted); #endif totalTime = Spectral_GetSignalTime( signal ); if (windowing_type != WINDOWING_NONE) { applyWindowing( signal, windowing_type ); } spectral_value_t *wavelet_samples = NULL; Sampler_wavelet(signal, &wavelet_samples, 1024, NULL); /* 1024 or 4096 */ int sizeSig2; Wavelet(wavelet_samples, 1024, &sizeSig2, "wavelet.txt"); int m = 0; int pfound; long long int period; FILE *out; FILE *err; long long int t0, t1; char *signalout = "/dev/null"; int numPeriods = 0; Period_t **listPeriods = NULL, *foundPeriod = NULL; while (m < sizeSig2) { double f1 = wavelet_samples[m]; double f2 = wavelet_samples[m+1]; if (f1 < f2) { spectral_time_t c = signal->data[0].time + totalTime * f1; spectral_time_t d = signal->data[0].time + totalTime * f2; out = fopen ("report.out", "w"); err = fopen ("report.err", "w"); foundPeriod = Analysis(signal, c/1000000, d/1000000, (d-c)/1000000, c/1000000, d/1000000, NULL, NULL, 1, NULL, &pfound, &period, signalout, &t0, &t1, NULL, out, err, 0, target_iters, 0, 0); if (foundPeriod != NULL) { numPeriods ++; listPeriods = realloc(listPeriods, numPeriods * sizeof(Period_t *)); listPeriods[numPeriods - 1] = foundPeriod; /* Reapply the time shift to the results */ foundPeriod->ini += timeShifted; foundPeriod->end += timeShifted; foundPeriod->best_ini += timeShifted; foundPeriod->best_end += timeShifted; fprintf(stdout, "PERIOD %d: iters=%f length=%lld g=%lf g2=%lf g3=%lf ini=%lld end=%lld best_ini=%lld best_end=%lld\n", numPeriods, foundPeriod->iters, foundPeriod->length, foundPeriod->goodness, foundPeriod->goodness2, foundPeriod->goodness3, foundPeriod->ini, foundPeriod->end, foundPeriod->best_ini, foundPeriod->best_end); } fclose(out); fclose(err); } m += 2; } fprintf(stdout, "%d period(s) found.\n", numPeriods); Spectral_FreeSignal(signal); *DetectedPeriods = listPeriods; return numPeriods; }