summaryrefslogtreecommitdiff
path: root/rotord/src/libavwrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/src/libavwrapper.cpp')
-rw-r--r--rotord/src/libavwrapper.cpp36
1 files changed, 28 insertions, 8 deletions
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));