diff options
Diffstat (limited to 'client/decoder.cc')
-rw-r--r-- | client/decoder.cc | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/client/decoder.cc b/client/decoder.cc index 11cee08..c7a5097 100644 --- a/client/decoder.cc +++ b/client/decoder.cc @@ -47,7 +47,7 @@ Decoder::Decoder() { running = true; - memset(pframe, 0, sizeof(pframe)); // Init an empty frame + pframe = NULL; qApp->installEventFilter(this); } @@ -68,16 +68,29 @@ void Decoder::run() reader.connect(); #endif/* READ_DV_FROM_FILE*/ + LibDVWrapper dvdecoder(DV::ColorBest, DV::PAL, DV::YUV_422); + while(running) { - char *frame = (char*)reader.readFrame(); - if(!frame) continue; // An empty frame + Frame *dvframe = reader.readFrame(); + if(!dvframe) continue; // An empty frame + + Frame *yuvframe = dvdecoder.decode(dvframe); // Decode the DV frame to YUV422 and PCM audio + if(!yuvframe) continue; // An error ocurred if(MIaV::control.isFrozen() == false) { - pmutex.lock(); - memcpy(pframe, frame, DVPACKAGE_SIZE); - pmutex.unlock(); + if(yuvframe->vformat != VF_YUV422) { + fprintf(stderr, "Wrong videoformat in Decoder, expected VF_YUV422, got %i\n", yuvframe->vformat); + } else { + if(!pframe) { + fprintf(stderr, "PFrame data not set!\n"); + } else { + pmutex.lock(); + memcpy(pframe, yuvframe->vframe, yuvframe->vframesize); + pmutex.unlock(); + } + } } - + if(MIaV::control.isRecording()) { if(newconnection) { NetworkSender *sender = new NetworkSender(MIaV::control.getCpr()); @@ -92,7 +105,7 @@ void Decoder::run() sendersmutex.lock(); if(senders.isEmpty() == false) - senders.back()->pushFrame(frame, + senders.back()->pushFrame(yuvframe, MIaV::control.getShot(), MIaV::control.getFreeze()); sendersmutex.unlock(); @@ -113,17 +126,24 @@ void Decoder::run() sendersmutex.unlock(); - free(frame); + // free(frame); newconnection = true; + } } // closesem.release(); // Unlock the shutdown process } -char *Decoder::pframeAcquire() +void Decoder::setPFrameData(char *pframe) +{ + pmutex.lock(); + this->pframe = pframe; + pmutex.unlock(); +} + +void Decoder::pframeAcquire() { pmutex.lock();; - return pframe; } void Decoder::pframeRelease() @@ -133,12 +153,14 @@ void Decoder::pframeRelease() void Decoder::snapshot(char *rgb) { + /* LibDVWrapper dv; dv.setOutputBuffer(rgb, DV::BGR0); pmutex.lock(); dv.decode(pframe); pmutex.unlock(); + */ } bool Decoder::eventFilter(QObject *o, QEvent *e) |