diff options
| author | Tim Redfern <tim@herge.(none)> | 2013-04-08 17:28:37 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@herge.(none)> | 2013-04-08 17:28:37 +0100 |
| commit | 628a21f4e5785f9d52ac5c9c4bd483819fa9cf2a (patch) | |
| tree | 053739212d724636a842497197182d772f1b132e /rotord/rotor.cpp | |
| parent | 1d2d81d7a0b05d6ce14edd7c228f2026755140f1 (diff) | |
thumbnailing
Diffstat (limited to 'rotord/rotor.cpp')
| -rw-r--r-- | rotord/rotor.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp index 73577f4..2cd894f 100644 --- a/rotord/rotor.cpp +++ b/rotord/rotor.cpp @@ -259,7 +259,7 @@ Command_response Render_context::session_command(const std::vector<std::string>& //great to use c++11 features bool Render_context::load_audio(const string &filename,vector<Base_audio_processor*> processors){ - + av_register_all(); AVFrame* frame = avcodec_alloc_frame(); @@ -363,22 +363,22 @@ bool Render_context::load_audio(const string &filename,vector<Base_audio_process // the audio data, so I won't add any junk here that might confuse you. Typically, if I want to find // documentation on an FFmpeg structure or function, I just type "<name> doxygen" into google (like // "AVFrame doxygen" for AVFrame's docs) - + //av_get_channel_layout_string (char *buf, int buf_size, int nb_channels, uint64_t channel_layout) - - + + //now we can pass the data to the processor(s) for (auto p: processors) { sample_processed=p->process_frame(frame->data[0],frame->nb_samples); } - + mutex.lock(); progress=((double)sample_processed)/samples; mutex.unlock(); } } // You *must* call av_free_packet() after each call to av_read_frame() or else you'll leak memory - av_free_packet(&packet); + av_free_packet(&packet); } // Some codecs will cause frames to be buffered up in the decoding process. If the CODEC_CAP_DELAY flag @@ -399,14 +399,14 @@ bool Render_context::load_audio(const string &filename,vector<Base_audio_process mutex.unlock(); } } - + cerr << "finished processing: "<<sample_processed << " samples of "<<samples<<", "<<((double)sample_processed*100)/samples<<"%"<< std::endl; - + // Clean up! for (auto p: processors) { p->cleanup(); } - + av_free(frame); avcodec_close(codecContext); av_close_input_file(formatContext); @@ -471,7 +471,6 @@ bool Graph::load(string &filename){ } else return false; } - Node_factory::Node_factory(){ //for now, statically load prototype map in constructor add_type("audio_analysis",new Audio_analysis()); @@ -502,14 +501,13 @@ int Audio_thumbnailer::process_frame(uint8_t *_data,int samples_in_frame){ int stride=channels*bytes; int in_sample=0; while (in_sample<samples_in_frame&&column<width) { - //start a new column - + //continue the column while (sample<samples_per_column&&in_sample<samples_in_frame) { //accumulate samples for this column until we run out of samples for (int i=0;i<channels;i++) { unsigned int this_val=0; for (int j=0;j<bytes;j++) { - this_val+=_data[(sample*stride)+(i*bytes)+j]<<(j*8); + this_val+=_data[(in_sample*stride)+(i*bytes)+j]<<(j*8); } //convert from integer data format - i.e s16p - to audio signal in -1..1 range //presume 16 bits for now... @@ -557,7 +555,7 @@ bool Audio_analysis::init(int _channels,int _bits,int _samples, int _rate) { samples=_samples; return analyser.init(soname,id,_channels,_bits,_samples,_rate); - + //attempt to load vamp plugin and prepare to receive frames of data //should the audio analysis contain a vamphost or should it inherit? //maybe neater to contain it in terms of headers etc |
