summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2006-06-15 20:18:21 +0000
committerdeva <deva>2006-06-15 20:18:21 +0000
commit0f07334126048f16cf631e72e8708c2bf3c8a8e6 (patch)
tree6c9c5e71a92aaf1a47b78d8247078d0696f285af
parent897867cc9d3bc869317666993a9cc6ef38c163e2 (diff)
Fixed the last pieces of the YUV drawin on the client, as well as a couple of huge memory leaks.
-rw-r--r--client/decoder.cc10
-rw-r--r--client/player.cc3
-rw-r--r--lib/frame.cc5
-rw-r--r--lib/libdv_wrapper.cc14
4 files changed, 19 insertions, 13 deletions
diff --git a/client/decoder.cc b/client/decoder.cc
index c7a5097..ebd5087 100644
--- a/client/decoder.cc
+++ b/client/decoder.cc
@@ -75,6 +75,11 @@ void Decoder::run()
if(!dvframe) continue; // An empty frame
Frame *yuvframe = dvdecoder.decode(dvframe); // Decode the DV frame to YUV422 and PCM audio
+
+ if(dvframe->vframe) delete dvframe->vframe;
+ if(dvframe->aframe) delete dvframe->aframe;
+ delete dvframe;
+
if(!yuvframe) continue; // An error ocurred
if(MIaV::control.isFrozen() == false) {
@@ -126,7 +131,10 @@ void Decoder::run()
sendersmutex.unlock();
- // free(frame);
+ if(yuvframe->vframe) delete yuvframe->vframe;
+ if(yuvframe->aframe) delete yuvframe->aframe;
+ delete yuvframe;
+
newconnection = true;
}
diff --git a/client/player.cc b/client/player.cc
index dc3002d..3485a27 100644
--- a/client/player.cc
+++ b/client/player.cc
@@ -41,13 +41,10 @@ Player::Player(QWidget *w, Decoder *d) :
Player::~Player()
{
- // delete dvdecoder;
}
void Player::show_frame()
{
- // char *frame;
-
decoder->pframeAcquire(); // Acquire frame data
// Scale the video in aspect:
diff --git a/lib/frame.cc b/lib/frame.cc
index b3ad28f..472a03a 100644
--- a/lib/frame.cc
+++ b/lib/frame.cc
@@ -42,6 +42,9 @@ Frame::Frame(char *vframe, int vframesize, int vformat,
this->aframe = aframe;
this->aframesize = aframesize;
this->aformat = aformat;
+
+ // FIX... remove when old code is removed
+ data = NULL;
}
@@ -70,7 +73,7 @@ Frame::Frame(unsigned char *d, int sz)
Frame::~Frame()
{
- delete data;
+ if(data) delete data;
data = NULL;
size = 0;
}
diff --git a/lib/libdv_wrapper.cc b/lib/libdv_wrapper.cc
index cb9cc7c..11c641d 100644
--- a/lib/libdv_wrapper.cc
+++ b/lib/libdv_wrapper.cc
@@ -100,7 +100,7 @@ Frame *LibDVWrapper::decode(Frame *input, DV::ColorSpace c)
case DV::YUV:
#ifdef COLORSPACE_YV12
size = width*height*2;
- buf = (char*)malloc(size);
+ buf = new char[size];
type = VF_YV12;
yuv[0] = (unsigned char*)buf;
yuv[1] = (unsigned char*)yuv[0] + (width * height);
@@ -111,7 +111,7 @@ Frame *LibDVWrapper::decode(Frame *input, DV::ColorSpace c)
#else
printf("!\n");
size = width*height*2;
- buf = (char*)malloc(size);
+ buf = new char[size];
type = VF_YUV422;
yuv[0] = (unsigned char*)buf;
yuv[1] = yuv[2] = NULL;
@@ -122,7 +122,7 @@ Frame *LibDVWrapper::decode(Frame *input, DV::ColorSpace c)
case DV::RGB:
size = width*height*3;
- buf = (char*)malloc(size);
+ buf = new char[size];
type = VF_RGB;
yuv[0] = (unsigned char*)buf;
yuv[1] = yuv[2] = NULL;
@@ -132,7 +132,7 @@ Frame *LibDVWrapper::decode(Frame *input, DV::ColorSpace c)
case DV::BGR0:
size = width*height*4;
- buf = (char*)malloc(size);
+ buf = new char[size];
type = VF_BRG0;
yuv[0] = (unsigned char*)buf;
yuv[1] = yuv[2] = NULL;
@@ -143,13 +143,11 @@ Frame *LibDVWrapper::decode(Frame *input, DV::ColorSpace c)
dv_decode_full_frame(decoder,
- (const uint8_t*)input,
+ (const uint8_t*)input->vframe,
(dv_color_space_t)colorspace,
yuv,
pitches);
- // memset(buf, 1, width*height);
- // memset(buf+width*height, 100, width*height/2);
- // memset(buf+width*height+width*height/2, 200, width*height/2);
+
Frame *frame = new Frame(buf, size, type, NULL, 0, AF_NONE);
return frame;
}