From 628a21f4e5785f9d52ac5c9c4bd483819fa9cf2a Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 8 Apr 2013 17:28:37 +0100 Subject: thumbnailing --- rotord/rotor.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'rotord/rotor.cpp') 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& //great to use c++11 features bool Render_context::load_audio(const string &filename,vector processors){ - + av_register_all(); AVFrame* frame = avcodec_alloc_frame(); @@ -363,22 +363,22 @@ bool Render_context::load_audio(const string &filename,vector 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,vectorcleanup(); } - + 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