diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-09-10 12:56:08 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-09-10 12:56:08 +0100 |
| commit | 959b4591baa048b692e38c39c8db89317023ccea (patch) | |
| tree | f819b7b5ecc614bbe5c4e40fd573b33b55fb5edc /rotord/src | |
| parent | 1ba984e17672dd214e4e239c6806ee2e739432e8 (diff) | |
cvimage release
Diffstat (limited to 'rotord/src')
| -rw-r--r-- | rotord/src/cvimage.cpp | 1 | ||||
| -rw-r--r-- | rotord/src/cvimage.h | 2 | ||||
| -rw-r--r-- | rotord/src/graph.h | 2 | ||||
| -rw-r--r-- | rotord/src/libavwrapper.cpp | 36 | ||||
| -rw-r--r-- | rotord/src/libavwrapper.h | 10 | ||||
| -rw-r--r-- | rotord/src/nodes_audio_analysis.cpp | 28 | ||||
| -rw-r--r-- | rotord/src/nodes_audio_analysis.h | 21 | ||||
| -rw-r--r-- | rotord/src/rotor.h | 55 |
8 files changed, 77 insertions, 78 deletions
diff --git a/rotord/src/cvimage.cpp b/rotord/src/cvimage.cpp index e5ea50b..0bf30a6 100644 --- a/rotord/src/cvimage.cpp +++ b/rotord/src/cvimage.cpp @@ -200,5 +200,4 @@ namespace Rotor { other->rgb=rgb/amount; return other; } - } diff --git a/rotord/src/cvimage.h b/rotord/src/cvimage.h index 6323d4d..0f0f931 100644 --- a/rotord/src/cvimage.h +++ b/rotord/src/cvimage.h @@ -78,6 +78,8 @@ namespace Rotor { if (RGBdata&&ownsRGBdata) delete[] RGBdata; if (Adata&&ownsAdata) delete[] Adata; if (Zdata&&ownsZdata) delete[] Zdata; + rgb.release(); + alpha.release(); zero(); } void zero(){ diff --git a/rotord/src/graph.h b/rotord/src/graph.h index 4c68eab..d614b3b 100644 --- a/rotord/src/graph.h +++ b/rotord/src/graph.h @@ -2,6 +2,8 @@ #define GRAPH_H #include "rotor.h" +#include "nodes_audio_analysis.h" + /*------------------------ diff --git a/rotord/src/libavwrapper.cpp b/rotord/src/libavwrapper.cpp index b97467b..0ba76ea 100644 --- a/rotord/src/libavwrapper.cpp +++ b/rotord/src/libavwrapper.cpp @@ -130,9 +130,16 @@ void AVPacketWrapper::free() libav::decoder::decoder(PixelFormat pixelFormat) : isOpen(false) { + Sctx = NULL; + pRaw = NULL; + pFrameRGB = NULL; + pCtx = NULL; + container = NULL; + buffer = NULL; + blank = NULL; + format = pixelFormat; mutex.lock(); initialize(); - format = pixelFormat; mutex.unlock(); } @@ -260,6 +267,7 @@ bool libav::decoder::openUsingInitializedContainer(enum PixelFormat formatParam) return true; } bool libav::decoder::reinit_buffers_and_scaler(){ + mutex.lock(); if (NULL != Sctx) { sws_freeContext(Sctx); @@ -273,7 +281,16 @@ bool libav::decoder::reinit_buffers_and_scaler(){ av_free(pFrameRGB); pFrameRGB = NULL; } + if (NULL != buffer) { + av_free(buffer); + buffer = NULL; + } + if (NULL != blank) { + av_free(blank); + blank = NULL; + } mutex.unlock(); + init_buffers_and_scaler(); } @@ -890,6 +907,15 @@ bool libav::exporter::setup(int w,int h, int bitRate, int frameRate, std::string this->frameRate=frameRate; this->container=container; + if (NULL != sws_ctx) { + sws_freeContext(sws_ctx); + sws_ctx = NULL; + } + + sws_ctx = sws_getContext(w, h, AV_PIX_FMT_RGB24, + w, h, AV_PIX_FMT_YUV420P, + sws_flags, NULL, NULL, NULL); + return true; } @@ -1365,9 +1391,7 @@ void libav::exporter::open_video(AVFormatContext *oc, AVCodec *codec, AVStream * //should be context allocated once per render instead of per frame?? // // - sws_ctx = sws_getContext(c->width, c->height, AV_PIX_FMT_RGB24, - c->width, c->height, AV_PIX_FMT_YUV420P, - sws_flags, NULL, NULL, NULL); + //sws_get_context was here avpicture_fill(&src_picture, pixels, PIX_FMT_RGB24, c->width,c->height); //avpicture_fill(&dst_picture, outPixels, PIX_FMT_YUV420P, c->width,c->height); @@ -1412,10 +1436,6 @@ void libav::exporter::open_video(AVFormatContext *oc, AVCodec *codec, AVStream * } } - // - // added 22 may in memory leak run - // - sws_freeContext(sws_ctx); //should be done once per render instead of per frame?? if (ret != 0) { //fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret)); diff --git a/rotord/src/libavwrapper.h b/rotord/src/libavwrapper.h index 7f3d549..ed538d2 100644 --- a/rotord/src/libavwrapper.h +++ b/rotord/src/libavwrapper.h @@ -190,7 +190,15 @@ namespace libav { class exporter { public: - virtual ~exporter(){}; + exporter(){ + sws_ctx = NULL; + } + virtual ~exporter(){ + if (NULL != sws_ctx) { + sws_freeContext(sws_ctx); + sws_ctx = NULL; + } + }; bool setup(int w,int h, int bitRate, int frameRate, std::string container); bool record(std::string filename); bool encodeFrame(unsigned char *pixels, uint16_t *samples); diff --git a/rotord/src/nodes_audio_analysis.cpp b/rotord/src/nodes_audio_analysis.cpp index 74b0574..7e735f8 100644 --- a/rotord/src/nodes_audio_analysis.cpp +++ b/rotord/src/nodes_audio_analysis.cpp @@ -45,14 +45,6 @@ namespace Rotor{ if (sample==samples_per_column) { //finished a column //get root-mean double mean=pow(accum/samples,0.5); - //if (column==0) { - // cerr << "first column total: "<< accum << " in " << samples << " samples, average " << (accum/samples)<<endl; - //} - int colheight=height*mean*0.5; - int hh=height>>1; - for (int i=0;i<height;i++) { - data[i*width+column]=abs(i-hh)<colheight?0xff:0x00; - } vectordata[column]=mean; column++; sample=0; @@ -62,26 +54,6 @@ namespace Rotor{ } return out_sample; } - string Audio_thumbnailer::print(){ - //base64 encode the image data output it - - stringstream output; - Poco::Base64Encoder *enc=new Poco::Base64Encoder(output); - - enc->write((char*)data,width*height); - //tring output; - /* - for (int j=0;j<height;j++) { - for (int i=0;i<width;i++) { - output+=data[j*width+i]<0x7f?"0":"1"; - } - output +="\n"; - } - */ - enc->close(); - delete enc; - return output.str(); - } void Audio_thumbnailer::print_vector(xmlIO XML){ string vdata; for (int i=0;i<width;i++){ diff --git a/rotord/src/nodes_audio_analysis.h b/rotord/src/nodes_audio_analysis.h index 89d6c9d..ca7c204 100644 --- a/rotord/src/nodes_audio_analysis.h +++ b/rotord/src/nodes_audio_analysis.h @@ -9,6 +9,27 @@ namespace Rotor { #define VAMPHOST_Timesteps 2 #define VAMPHOST_Valueline 3 #define VAMPHOST_Values 4 + class Audio_thumbnailer: public Audio_processor { + public: + Audio_thumbnailer(){ + height=128; + width=512; //fit + vectordata =new float[width]; + }; + ~Audio_thumbnailer(){ + delete[] vectordata; + }; + Audio_thumbnailer* clone(map<string,string> &_settings) { return new Audio_thumbnailer();}; + bool init(int _channels,int _bits,int _samples,int _rate); + void cleanup(){}; + int process_frame(uint8_t *data,int samples_in_frame); + void print_vector(xmlIO XML); + float *vectordata; + int height,width,samples_per_column; + int column,out_sample,sample,samples; + int offset; + double scale,accum; + }; class Vamp_node: public Audio_processor { //base class for vamp plugin hosts public: diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index 7a26a5b..fbefa66 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -255,17 +255,6 @@ namespace Rotor { float image_time; //? could be used to detect image reuse? }; - class Audio_processor: public Signal_node { - public: - virtual Audio_processor(){}; - virtual ~Audio_processor(){}; - virtual int process_frame(uint8_t *data,int samples)=0; - virtual bool init(int _channels,int _bits,int _samples,int _rate)=0; - virtual void cleanup()=0; - virtual void print_summary(){}; - virtual string get_features(){}; - int channels,bits,samples,rate; - }; class LUT { LUT(){ lut=nullptr; @@ -289,6 +278,17 @@ namespace Rotor { protected: unsigned char *lut; }; + class Audio_processor: public Signal_node { + public: + virtual Audio_processor(){}; + virtual ~Audio_processor(){}; + virtual int process_frame(uint8_t *data,int samples)=0; + virtual bool init(int _channels,int _bits,int _samples,int _rate)=0; + virtual void cleanup()=0; + virtual void print_summary(){}; + virtual string get_features(){}; + int channels,bits,samples,rate; + }; //actual nodes------------------------------------------------- class Time: public Signal_node { public: @@ -605,10 +605,11 @@ namespace Rotor { image=image.add_wrap(*in2); break; case BLEND_blend: //has to be last because of initialser of *in? go figure + //problem here with leak image*=(1.0f-parameters["amount"]->value); - Image in=(*in2); - in*=parameters["amount"]->value; - image+=in; + Image *in=(*in2)*parameters["amount"]->value; + image+=(*in); + delete in; break; } return ℑ @@ -1121,32 +1122,6 @@ namespace Rotor { private: unordered_map<string,Node*> type_map; }; - class Audio_thumbnailer: public Audio_processor { - public: - Audio_thumbnailer(){ - height=128; - width=512; //fit - data=new uint8_t[height*width]; - memset(data,0,height*width); - vectordata =new float[width]; - }; - ~Audio_thumbnailer(){ - delete[] data; - delete[] vectordata; - }; - Audio_thumbnailer* clone(map<string,string> &_settings) { return new Audio_thumbnailer();}; - bool init(int _channels,int _bits,int _samples,int _rate); - void cleanup(){}; - int process_frame(uint8_t *data,int samples_in_frame); - string print(); - void print_vector(xmlIO XML); - uint8_t *data; - float *vectordata; - int height,width,samples_per_column; - int column,out_sample,sample,samples; - int offset; - double scale,accum; - }; } #endif |
