summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authordeva <deva>2006-06-15 17:35:33 +0000
committerdeva <deva>2006-06-15 17:35:33 +0000
commit897867cc9d3bc869317666993a9cc6ef38c163e2 (patch)
tree49127ab698c52d0a7a2c7749081f15784cddf4bc /lib
parentd8404ce282917ef81418387f20fc5ee3607be391 (diff)
Prepared for the client to use uncompressed frames (YUV422 instead of DV).
Still a lot of work to do though!
Diffstat (limited to 'lib')
-rw-r--r--lib/frame.cc24
-rw-r--r--lib/frame.h35
-rw-r--r--lib/frame_stream.h6
-rw-r--r--lib/libdv_wrapper.cc68
-rw-r--r--lib/libdv_wrapper.h8
5 files changed, 113 insertions, 28 deletions
diff --git a/lib/frame.cc b/lib/frame.cc
index caab521..b3ad28f 100644
--- a/lib/frame.cc
+++ b/lib/frame.cc
@@ -30,6 +30,30 @@
#include <memory.h>
#include <stdlib.h>
+Frame::Frame(char *vframe, int vframesize, int vformat,
+ char *aframe, int aframesize, int aformat)
+{
+ // Video
+ this->vframe = vframe;
+ this->vframesize = vframesize;
+ this->vformat = vformat;
+
+ // Audio
+ this->aframe = aframe;
+ this->aframesize = aframesize;
+ this->aformat = aformat;
+}
+
+
+
+
+
+
+
+
+/**
+ * Old frame code... to be removed shortly
+ */
Frame::Frame(unsigned char *d, int sz)
{
if(sz) data = new unsigned char[sz];
diff --git a/lib/frame.h b/lib/frame.h
index 66c2ce7..ecfa308 100644
--- a/lib/frame.h
+++ b/lib/frame.h
@@ -28,14 +28,45 @@
#ifndef __FRAME_H__
#define __FRAME_H__
-#define START_USE_FRAME(x) x->usage++
-#define STOP_USE_FRAME(x) if(--x->usage == 0) delete x; x = NULL
+//#define START_USE_FRAME(x) x->usage++
+//#define STOP_USE_FRAME(x) if(--x->usage == 0) delete x; x = NULL
// Definition of vector
#include <vector>
+// VIDEO FORMATS
+#define VF_NONE 0x00
+#define VF_DV 0x01
+#define VF_YUV422 0x02
+#define VF_YV12 0x03
+#define VF_RGB 0x04
+#define VF_BRG0 0x05
+
+// AUDIO FORMATS
+#define AF_NONE 0x00 // Dummy
+#define AF_DV 0x01 // Audio data is in the DV video frame
+#define AF_PCM_48KHZ_16BIT 0x02 // Raw pcm data in 48khz and 16bit
+#define AF_MP3 0x03 // Lame encoded audio
+
class Frame {
public:
+ Frame(char *aframe, int aframesize, int aformat,
+ char *vframe, int vframesize, int vformat);
+
+ // Video
+ char* vframe;
+ int vframesize;
+ int vformat;
+
+ // Audio
+ char *aframe;
+ int aframesize;
+ int aformat;
+
+ /**
+ * Old frame code... to be removed shortly
+ */
+public:
Frame(unsigned char *d, int sz = 0);
~Frame();
diff --git a/lib/frame_stream.h b/lib/frame_stream.h
index bc0b9a2..32fea15 100644
--- a/lib/frame_stream.h
+++ b/lib/frame_stream.h
@@ -26,14 +26,16 @@
*/
#include "config.h"
#ifndef __MIAV_FRAME_STREAM_H__
-#define __MIAV_FRAME_STREAM_H__
+#define __MIAV_FRAME_STREAM_H_
+
+#include "frame.h"
class frame_stream {
public:
frame_stream() {}
virtual ~frame_stream() {}
- virtual unsigned char *readFrame() = 0;
+ virtual Frame *readFrame() = 0;
};
diff --git a/lib/libdv_wrapper.cc b/lib/libdv_wrapper.cc
index df624b6..cb9cc7c 100644
--- a/lib/libdv_wrapper.cc
+++ b/lib/libdv_wrapper.cc
@@ -40,6 +40,7 @@ LibDVWrapper::LibDVWrapper(DV::Quality quality,
setSampling(sampling);
yuv[0] = yuv[1] = yuv[2] = NULL;
+ pitches[0] = pitches[1] = pitches[2] = 0;
width = 720;
height = 576;
@@ -73,56 +74,83 @@ void LibDVWrapper::setSampling(DV::Sampling sampling)
decoder->sampling = (dv_sample_t)sampling;
}
-void LibDVWrapper::setOutputBuffer(char *output, DV::ColorSpace c)
+Frame *LibDVWrapper::decode(Frame *input, DV::ColorSpace c)
{
- colorspace = c;
+ if(input->vformat != VF_DV) {
+ fprintf(stderr, "Wrong format in LibDVWrapper, expected VF_DV, got: %i\n", input->vformat);
+ return NULL;
+ }
+
+ /*
+ if(first) {
+ dv_parse_header(decoder, (const uint8_t*)input);
+ //dv_parse_packs(decoder, frame->data); // Not needed anyway!
+ decoder->std = e_dv_std_iec_61834;
+ decoder->num_dif_seqs = 12;
+ first = false;
+ }
+ */
+
+
+ int size = 0;
+ char* buf = NULL;
+ int type = VF_NONE;
+ DV::ColorSpace colorspace = c;
switch(colorspace) {
case DV::YUV:
#ifdef COLORSPACE_YV12
- yuv[0] = (unsigned char*)output;
+ size = width*height*2;
+ buf = (char*)malloc(size);
+ type = VF_YV12;
+ yuv[0] = (unsigned char*)buf;
yuv[1] = (unsigned char*)yuv[0] + (width * height);
yuv[2] = (unsigned char*)yuv[1] + (width * height / 4);
pitches[0] = width;
pitches[1] = width / 2;
pitches[2] = width / 2;
#else
- yuv[0] = (unsigned char*)output;
+ printf("!\n");
+ size = width*height*2;
+ buf = (char*)malloc(size);
+ type = VF_YUV422;
+ yuv[0] = (unsigned char*)buf;
+ yuv[1] = yuv[2] = NULL;
pitches[0] = width * 2;
+ pitches[1] = pitches[2] = 0;
#endif
break;
case DV::RGB:
- yuv[0] = (unsigned char*)output;
+ size = width*height*3;
+ buf = (char*)malloc(size);
+ type = VF_RGB;
+ yuv[0] = (unsigned char*)buf;
yuv[1] = yuv[2] = NULL;
pitches[0] = width * 3;
+ pitches[1] = pitches[2] = 0;
break;
case DV::BGR0:
- yuv[0] = (unsigned char*)output;
+ size = width*height*4;
+ buf = (char*)malloc(size);
+ type = VF_BRG0;
+ yuv[0] = (unsigned char*)buf;
yuv[1] = yuv[2] = NULL;
pitches[0] = width * 4;
+ pitches[1] = pitches[2] = 0;
break;
}
-}
-
-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->std = e_dv_std_iec_61834;
- decoder->num_dif_seqs = 12;
- first = false;
- }
- */
dv_decode_full_frame(decoder,
(const uint8_t*)input,
(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;
}
diff --git a/lib/libdv_wrapper.h b/lib/libdv_wrapper.h
index 16a7d94..bde5620 100644
--- a/lib/libdv_wrapper.h
+++ b/lib/libdv_wrapper.h
@@ -31,6 +31,8 @@
#include <libdv/dv.h>
#include <libdv/dv_types.h>
+#include "frame.h"
+
namespace DV {
/*
#define DV_QUALITY_COLOR 1 // Clear this bit to make monochrome
@@ -104,9 +106,7 @@ public:
void setSystem(DV::System system);
void setSampling(DV::Sampling sampling);
- void setOutputBuffer(char *output, DV::ColorSpace colorspace = DV::YUV);
-
- void decode(char *input);
+ Frame *decode(Frame *input, DV::ColorSpace colorspace = DV::YUV);
private:
bool first;
@@ -116,7 +116,7 @@ private:
unsigned char* yuv[3];
dv_decoder_t *decoder;
- DV::ColorSpace colorspace;
+ // DV::ColorSpace colorspace;
};
#endif/*__MIAV_LIBDV_WRAPPER_H__*/