summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/decoder.cc19
-rw-r--r--client/decoder.h8
-rw-r--r--client/miav_client.cc6
-rw-r--r--client/player.cc7
-rw-r--r--lib/libdv_wrapper.cc12
-rw-r--r--lib/libdv_wrapper.h1
6 files changed, 34 insertions, 19 deletions
diff --git a/client/decoder.cc b/client/decoder.cc
index fd2464b..5c2cce5 100644
--- a/client/decoder.cc
+++ b/client/decoder.cc
@@ -42,7 +42,7 @@
Decoder::Decoder(): semaphore(1)
{
- frame = NULL;
+ frame = NULL;
running = true;
qApp->installEventFilter(this);
}
@@ -62,14 +62,25 @@ void Decoder::run()
#endif/* READ_DV_FROM_FILE*/
while(running) {
- frame = new Frame(reader.readFrame());
+ char *tmp = (char*)reader.readFrame();
+ mutex.lock();
+ if(frame) free(frame);
+ frame = tmp;
+ mutex.unlock();
}
semaphore.release(); // Unlock the shutdown process
}
-Frame *Decoder::getFrame()
+char *Decoder::getFrame()
{
- return frame;
+ char *tmp;
+
+ mutex.lock();
+ tmp = frame;
+ frame = NULL;
+ mutex.unlock();
+
+ return tmp;
}
bool Decoder::eventFilter(QObject *o, QEvent *e)
diff --git a/client/decoder.h b/client/decoder.h
index 3a1b30f..6638189 100644
--- a/client/decoder.h
+++ b/client/decoder.h
@@ -29,7 +29,7 @@
#include <QThread>
#include <QSemaphore>
-#include "frame.h"
+#include <QMutex>
class Decoder : public QThread
{
@@ -38,7 +38,7 @@ public:
Decoder();
~Decoder();
- Frame *getFrame();
+ char *getFrame();
void run();
@@ -47,9 +47,9 @@ protected:
private:
volatile bool running;
- volatile bool stopped;
- Frame *frame;
+ char *frame;
QSemaphore semaphore;
+ QMutex mutex;
};
#endif/*__MIAV_DECODER_H__*/
diff --git a/client/miav_client.cc b/client/miav_client.cc
index 6122093..81cde56 100644
--- a/client/miav_client.cc
+++ b/client/miav_client.cc
@@ -47,12 +47,14 @@ int main(int argc, char *argv[])
MainWindow mainwindow;
+ NetworkSender sender;
Decoder decoder;
Player player(mainwindow.getVideoWidget(), &decoder);
- NetworkSender sender;
+
+ int fps = 24;
decoder.start();
- player.start(40); // 100: 10fps, 40: 25fps
+ player.start(1000 / fps);
sender.start();
return app.exec();
diff --git a/client/player.cc b/client/player.cc
index 1689dcf..a8f6152 100644
--- a/client/player.cc
+++ b/client/player.cc
@@ -29,8 +29,6 @@
#define WIDTH 720
#define HEIGHT 576
-//#define COLORSPACE_YV12
-
static int num = 0;
Player::Player(QWidget *w, Decoder *d)
@@ -52,13 +50,14 @@ Player::~Player()
void Player::show_frame()
{
- Frame *frame;
+ char *frame;
fprintf(stderr, "Frame!%d\n", num++);
frame = decoder->getFrame();
if(!frame) return;
- dvdecoder.decode((char*)frame->data);
+ dvdecoder.decode(frame);
+ free(frame);
render.width = widget->width();
render.height = widget->height();
diff --git a/lib/libdv_wrapper.cc b/lib/libdv_wrapper.cc
index d570e2c..563c709 100644
--- a/lib/libdv_wrapper.cc
+++ b/lib/libdv_wrapper.cc
@@ -26,7 +26,7 @@
*/
#include "libdv_wrapper.h"
-static bool first = true;
+//#define COLORSPACE_YV12
LibDVWrapper::LibDVWrapper(DV::Quality quality,
DV::System system,
@@ -39,8 +39,11 @@ LibDVWrapper::LibDVWrapper(DV::Quality quality,
setSystem(system);
setSampling(sampling);
+ yuv[0] = yuv[1] = yuv[2] = NULL;
+
width = 720;
height = 576;
+ first = true;
}
@@ -74,19 +77,18 @@ void LibDVWrapper::setOutputBuffer(char *output)
pitches[1] = width / 2;
pitches[2] = width / 2;
#else
- yuv[0] = (unsigned char*)output;//render.getDisplayData(); // Decode directly to the XVideo buffer
+ yuv[0] = (unsigned char*)output;
pitches[0] = width * 2;
#endif
}
void LibDVWrapper::decode(char *input)
{
+ if(!yuv[0]) return; // outputbuffer not set!
+
if(first) {
dv_parse_header(decoder, (const uint8_t*)input);
//dv_parse_packs(decoder, frame->data); // Not needed anyway!
-
- // decoder->system = e_dv_system_625_50; // PAL lines, PAL framerate
- // decoder->sampling = e_dv_sample_422; // 4 bytes y, 2 bytes u, 2 bytes v
decoder->std = e_dv_std_iec_61834;
decoder->num_dif_seqs = 12;
first = false;
diff --git a/lib/libdv_wrapper.h b/lib/libdv_wrapper.h
index 995e8d7..d98cae6 100644
--- a/lib/libdv_wrapper.h
+++ b/lib/libdv_wrapper.h
@@ -96,6 +96,7 @@ public:
void decode(char *input);
private:
+ bool first;
int width, height;
int pitches[3];