summaryrefslogtreecommitdiff
path: root/remux
diff options
context:
space:
mode:
authorAndreas Regel <andreas.regel@powarman.de>2004-01-28 19:11:00 +0100
committerAndreas Regel <andreas.regel@powarman.de>2004-01-28 19:11:00 +0100
commit64fe6b70d0a5b34a80ff458fbf1664018d5c0182 (patch)
tree4fe036adaf90fef0d0dc910b84dbc11269e40008 /remux
parent310f5b2a62343d0c9b7624c09efe35828785ef26 (diff)
downloadvdr-plugin-osdpip-64fe6b70d0a5b34a80ff458fbf1664018d5c0182.tar.gz
vdr-plugin-osdpip-64fe6b70d0a5b34a80ff458fbf1664018d5c0182.tar.bz2
Release version 0.0.3v0.0.3
- new TS->ES remuxer: now using VDR's cRemux for TS->PES and some own code for PES->ES - now using libavcodec from ffmpeg instead of mpeg2dec - frames to decode configurable (I-frames, I-/P-frames, all frames) - frame dropping configurable - added new color depths: - 128 shades greyscale - 128 colors with variable palette using Wu's quantizer (patch needed) - changed osd size setting to 6 configurable values
Diffstat (limited to 'remux')
-rw-r--r--remux/ts2es.c87
-rw-r--r--remux/ts2es.h21
-rw-r--r--remux/ts2ps.c104
-rw-r--r--remux/ts2ps.h22
-rw-r--r--remux/tsremux.c185
-rw-r--r--remux/tsremux.h30
6 files changed, 0 insertions, 449 deletions
diff --git a/remux/ts2es.c b/remux/ts2es.c
deleted file mode 100644
index 2f27d4f..0000000
--- a/remux/ts2es.c
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "remux/ts2es.h"
-
-// from VDR's remux.c
-#define MAXNONUSEFULDATA (10*1024*1024)
-
-class cTS2ES: public ipack {
- friend void PutES(uint8_t *Buffer, int Size, void *Data);
-
-private:
- uint8_t *m_ResultBuffer;
- int *m_ResultCount;
-
-public:
- cTS2ES(uint8_t *ResultBuffer, int *ResultCount);
- ~cTS2ES();
-
- void PutTSPacket(const uint8_t *Buffer);
-};
-
-void PutES(uint8_t *Buffer, int Size, void *Data) {
- cTS2ES *This = (cTS2ES*)Data;
- uint8_t payl = Buffer[8] + 9 + This->start - 1;
- int count = Size - payl;
-
- if (*This->m_ResultCount + count > RESULTBUFFERSIZE) {
- esyslog("ERROR: result buffer overflow (%d + %d > %d)",
- *This->m_ResultCount, count, RESULTBUFFERSIZE);
- count = RESULTBUFFERSIZE - *This->m_ResultCount;
- }
- memcpy(This->m_ResultBuffer + *This->m_ResultCount, Buffer + payl, count);
- *This->m_ResultCount += count;
- This->start = 1;
-}
-
-cTS2ES::cTS2ES(uint8_t *ResultBuffer, int *ResultCount) {
- m_ResultBuffer = ResultBuffer;
- m_ResultCount = ResultCount;
-
- init_ipack(this, IPACKS, PutES, 0);
- data = (void*)this;
-}
-
-cTS2ES::~cTS2ES() {
-}
-
-void cTS2ES::PutTSPacket(const uint8_t *Buffer) {
- if (!Buffer)
- return;
-
- if (Buffer[1] & 0x80) { // ts error
- // TODO
- }
-
- if (Buffer[1] & 0x40) { // payload start
- if (plength == MMAX_PLENGTH - 6) {
- plength = found - 6;
- found = 0;
- send_ipack(this);
- reset_ipack(this);
- }
- }
-
- uint8_t off = 0;
-
- if (Buffer[3] & 0x20) { // adaptation field?
- off = Buffer[4] + 1;
- if (off + 4 > TS_SIZE - 1)
- return;
- }
-
- instant_repack((uint8_t*)(Buffer + 4 + off), TS_SIZE - 4 - off, this);
-}
-
-cTS2ESRemux::cTS2ESRemux(int Pid):
- cTSRemux(false) {
- m_Pid = Pid;
- m_Remux = new cTS2ES(m_ResultBuffer, &m_ResultCount);
-}
-
-cTS2ESRemux::~cTS2ESRemux() {
- delete m_Remux;
-}
-
-void cTS2ESRemux::PutTSPacket(int Pid, const uint8_t *Data) {
- if (Pid == m_Pid) m_Remux->PutTSPacket(Data);
-}
-
diff --git a/remux/ts2es.h b/remux/ts2es.h
deleted file mode 100644
index 8026a1b..0000000
--- a/remux/ts2es.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef VDR_STREAMDEV_TS2ESREMUX_H
-#define VDR_STREAMDEV_TS2ESREMUX_H
-
-#include "remux/tsremux.h"
-
-class cTS2ES;
-
-class cTS2ESRemux: public cTSRemux {
-private:
- int m_Pid;
- cTS2ES *m_Remux;
-
-protected:
- virtual void PutTSPacket(int Pid, const uint8_t *Data);
-
-public:
- cTS2ESRemux(int Pid);
- virtual ~cTS2ESRemux();
-};
-
-#endif // VDR_STREAMDEV_TS2ESREMUX_H
diff --git a/remux/ts2ps.c b/remux/ts2ps.c
deleted file mode 100644
index 222c39a..0000000
--- a/remux/ts2ps.c
+++ /dev/null
@@ -1,104 +0,0 @@
-#include "remux/ts2ps.h"
-
-class cTS2PS {
- friend void PutPES(uint8_t *Buffer, int Size, void *Data);
-
-private:
- ipack m_Ipack;
- uint8_t *m_ResultBuffer;
- int *m_ResultCount;
-
-public:
- cTS2PS(uint8_t *ResultBuffer, int *ResultCount, uint8_t AudioCid = 0x00,
- bool PS = false);
- ~cTS2PS();
-
- void PutTSPacket(const uint8_t *Buffer);
-};
-
-void PutPES(uint8_t *Buffer, int Size, void *Data) {
- cTS2PS *This = (cTS2PS*)Data;
- if (*This->m_ResultCount + Size > RESULTBUFFERSIZE) {
- esyslog("ERROR: result buffer overflow (%d + %d > %d)",
- *This->m_ResultCount, Size, RESULTBUFFERSIZE);
- Size = RESULTBUFFERSIZE - *This->m_ResultCount;
- }
- memcpy(This->m_ResultBuffer + *This->m_ResultCount, Buffer, Size);
- *This->m_ResultCount += Size;
-}
-
-cTS2PS::cTS2PS(uint8_t *ResultBuffer, int *ResultCount, uint8_t AudioCid,
- bool PS) {
- m_ResultBuffer = ResultBuffer;
- m_ResultCount = ResultCount;
-
- init_ipack(&m_Ipack, IPACKS, PutPES, PS);
- m_Ipack.cid = AudioCid;
- m_Ipack.data = (void*)this;
-}
-
-cTS2PS::~cTS2PS() {
-}
-
-void cTS2PS::PutTSPacket(const uint8_t *Buffer) {
- if (!Buffer)
- return;
-
- if (Buffer[1] & 0x80) { // ts error
- // TODO
- }
-
- if (Buffer[1] & 0x40) { // payload start
- if (m_Ipack.plength == MMAX_PLENGTH - 6 && m_Ipack.found > 6) {
- m_Ipack.plength = m_Ipack.found - 6;
- m_Ipack.found = 0;
- send_ipack(&m_Ipack);
- reset_ipack(&m_Ipack);
- }
- }
-
- uint8_t off = 0;
-
- if (Buffer[3] & 0x20) { // adaptation field?
- off = Buffer[4] + 1;
- if (off + 4 > TS_SIZE - 1)
- return;
- }
-
- instant_repack((uint8_t*)(Buffer + 4 + off), TS_SIZE - 4 - off, &m_Ipack);
-}
-
-cTS2PSRemux::cTS2PSRemux(int VPid, int APid1, int APid2, int DPid1,
- int DPid2, bool PS) {
- m_VPid = VPid;
- m_APid1 = APid1;
- m_APid2 = APid2;
- m_DPid1 = DPid1;
- m_DPid2 = DPid2;
- m_VRemux = new cTS2PS(m_ResultBuffer, &m_ResultCount, 0x00, PS);
- m_ARemux1 = new cTS2PS(m_ResultBuffer, &m_ResultCount, 0xC0, PS);
- m_ARemux2 = APid2 ? new cTS2PS(m_ResultBuffer, &m_ResultCount, 0xC1, PS)
- : NULL;
- m_DRemux1 = DPid1 ? new cTS2PS(m_ResultBuffer, &m_ResultCount, 0x00, PS)
- : NULL;
- //XXX don't yet know how to tell apart primary and secondary DD data...
- m_DRemux2 = /*XXX m_DPid2 ? new cTS2PS(m_ResultBuffer, &m_ResultCount,
- 0x00, PS) : XXX*/ NULL;
-}
-
-cTS2PSRemux::~cTS2PSRemux() {
- if (m_DRemux2) delete m_DRemux2;
- if (m_DRemux1) delete m_DRemux1;
- if (m_ARemux2) delete m_ARemux2;
- delete m_ARemux1;
- delete m_VRemux;
-}
-
-void cTS2PSRemux::PutTSPacket(int Pid, const uint8_t *Data) {
- if (Pid == m_VPid) m_VRemux->PutTSPacket(Data);
- else if (Pid == m_APid1) m_ARemux1->PutTSPacket(Data);
- else if (Pid == m_APid2 && m_ARemux2) m_ARemux2->PutTSPacket(Data);
- else if (Pid == m_DPid1 && m_DRemux1) m_DRemux1->PutTSPacket(Data);
- else if (Pid == m_DPid2 && m_DRemux2) m_DRemux2->PutTSPacket(Data);
-}
-
diff --git a/remux/ts2ps.h b/remux/ts2ps.h
deleted file mode 100644
index 4e43ed2..0000000
--- a/remux/ts2ps.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef VDR_STREAMDEV_TS2PESREMUX_H
-#define VDR_STREAMDEV_TS2PESREMUX_H
-
-#include "remux/tsremux.h"
-
-class cTS2PS;
-
-class cTS2PSRemux: public cTSRemux {
-private:
- int m_VPid, m_APid1, m_APid2, m_DPid1, m_DPid2;
- cTS2PS *m_VRemux, *m_ARemux1, *m_ARemux2, *m_DRemux1, *m_DRemux2;
-
-protected:
- virtual void PutTSPacket(int Pid, const uint8_t *Data);
-
-public:
- cTS2PSRemux(int VPid, int APid1, int APid2, int DPid1, int DPid2,
- bool PS = false);
- virtual ~cTS2PSRemux();
-};
-
-#endif // VDR_STREAMDEV_TS2PESREMUX_H
diff --git a/remux/tsremux.c b/remux/tsremux.c
deleted file mode 100644
index 93f513b..0000000
--- a/remux/tsremux.c
+++ /dev/null
@@ -1,185 +0,0 @@
-#include "remux/tsremux.h"
-
-// from VDR's remux.c
-#define MAXNONUSEFULDATA (10*1024*1024)
-#define SC_PICTURE 0x00 // "picture header"
-#define VIDEO_STREAM_S 0xE0
-
-cTSRemux::cTSRemux(bool Sync) {
- m_ResultCount = 0;
- m_ResultDelivered = 0;
- m_Synced = false;
- m_Skipped = 0;
- m_Sync = Sync;
-}
-
-cTSRemux::~cTSRemux(void) {
-}
-
-uchar *cTSRemux::Process(const uchar *Data, int &Count, int &Result) {
- // Remove any previously delivered data from the result buffer:
- if (m_ResultDelivered) {
- if (m_ResultDelivered < m_ResultCount)
- memmove(m_ResultBuffer, m_ResultBuffer + m_ResultDelivered, m_ResultCount
- - m_ResultDelivered);
- m_ResultCount -= m_ResultDelivered;
- m_ResultDelivered = 0;
- }
-
- int used = 0;
-
- // Make sure we are looking at a TS packet:
- while (Count > TS_SIZE) {
- if (Data[0] == 0x47 && Data[TS_SIZE] == 0x47)
- break;
- Data++;
- Count--;
- used++;
- }
- if (used)
- esyslog("ERROR: skipped %d byte to sync on TS packet", used);
-
- // Convert incoming TS data
- for (int i = 0; i < Count; i += TS_SIZE) {
- if (Count - i < TS_SIZE)
- break;
- if (Data[i] != 0x47)
- break;
- int pid = get_pid((uint8_t*)(Data + i + 1));
- if (Data[i + 3] & 0x10) // got payload
- PutTSPacket(pid, Data + i);
- /*if (pid == m_VPid) m_VRemux->ConvertTSPacket(Data + i);
- else if (pid == m_APid1) m_ARemux1->ConvertTSPacket(Data + i);
- else if (pid == m_APid2 && m_ARemux2) m_ARemux2->ConvertTSPacket(Data + i);
- else if (pid == m_DPid1 && m_DRemux1) m_DRemux1->ConvertTSPacket(Data + i);
- else if (pid == m_DPid2 && m_DRemux2) m_DRemux2->ConvertTSPacket(Data + i);*/
- used += TS_SIZE;
- if (m_ResultCount > (int)sizeof(m_ResultBuffer) / 2)
- break;
- }
- Count = used;
-
- // When we don't need to sync, we don't need to sync :-)
- if (!m_Sync) {
- Result = m_ResultDelivered = m_ResultCount;
- return Result ? m_ResultBuffer : NULL;
- }
-
- // Check if we're getting anywhere here:
-
- if (!m_Synced && m_Skipped >= 0) {
- if (m_Skipped > MAXNONUSEFULDATA) {
- esyslog("ERROR: no useful data seen within %d byte of video stream", m_Skipped);
- m_Skipped = -1;
- //if (exitOnFailure)
- //cThread::EmergencyExit(true);
- }
- else
- m_Skipped += Count;
- }
-
- // Check for frame borders:
-
- if (m_ResultCount >= MINVIDEODATA) {
- for (int i = 0; i < m_ResultCount; i++) {
- if (m_ResultBuffer[i] == 0 && m_ResultBuffer[i + 1] == 0 && m_ResultBuffer[i + 2] == 1) {
- switch (m_ResultBuffer[i + 3]) {
- case VIDEO_STREAM_S ... VIDEO_STREAM_E:
- {
- uchar pt = NO_PICTURE;
- int l = ScanVideoPacket(m_ResultBuffer, m_ResultCount, i, pt);
- if (l < 0)
- return NULL; // no useful data found, wait for more
- if (pt != NO_PICTURE) {
- if (pt < I_FRAME || B_FRAME < pt)
- esyslog("ERROR: unknown picture type '%d'", pt);
- else if (!m_Synced) {
- if (pt == I_FRAME) {
- m_ResultDelivered = i; // will drop everything before this position
- SetBrokenLink(m_ResultBuffer + i, l);
- m_Synced = true;
- }
- else {
- m_ResultDelivered = i + l; // will drop everything before and including this packet
- return NULL;
- }
- }
- }
- if (m_Synced) {
- Result = l;
- uchar *p = m_ResultBuffer + m_ResultDelivered;
- m_ResultDelivered += l;
- return p;
- }
- else {
- m_ResultDelivered = i + l; // will drop everything before and including this packet
- return NULL;
- }
- }
- break;
- case PRIVATE_STREAM1:
- case AUDIO_STREAM_S ... AUDIO_STREAM_E:
- {
- int l = GetPacketLength(m_ResultBuffer, m_ResultCount, i);
- if (l < 0)
- return NULL; // no useful data found, wait for more
- if (m_Synced) {
- Result = l;
- uchar *p = m_ResultBuffer + m_ResultDelivered;
- m_ResultDelivered += l;
- return p;
- }
- else {
- m_ResultDelivered = i + l; // will drop everything before and including this packet
- return NULL;
- }
- }
- break;
- }
- }
- }
- }
- return NULL; // no useful data found, wait for more
-}
-
-int cTSRemux::ScanVideoPacket(const uchar *Data, int Count, int Offset, uchar &PictureType) {
- // Scans the video packet starting at Offset and returns its length.
- // If the return value is -1 the packet was not completely in the buffer.
-
- int Length = GetPacketLength(Data, Count, Offset);
- if (Length > 0 && Offset + Length <= Count) {
- int i = Offset + 8; // the minimum length of the video packet header
- i += Data[i] + 1; // possible additional header bytes
- for (; i < Offset + Length; i++) {
- if (Data[i] == 0 && Data[i + 1] == 0 && Data[i + 2] == 1) {
- switch (Data[i + 3]) {
- case SC_PICTURE: PictureType = (Data[i + 5] >> 3) & 0x07;
- return Length;
- }
- }
- }
- PictureType = NO_PICTURE;
- return Length;
- }
- return -1;
-}
-
-int cTSRemux::GetPacketLength(const uchar *Data, int Count, int Offset) {
- // Returns the entire length of the packet starting at offset, or -1 in case of error.
- return (Offset + 5 < Count) ? (Data[Offset + 4] << 8) + Data[Offset + 5] + 6 : -1;
-}
-
-void cTSRemux::SetBrokenLink(uchar *Data, int Length) {
- if (Length > 9 && Data[0] == 0 && Data[1] == 0 && Data[2] == 1 && (Data[3] & VIDEO_STREAM_S) == VIDEO_STREAM_S) {
- for (int i = Data[8] + 9; i < Length - 7; i++) { // +9 to skip video packet header
- if (Data[i] == 0 && Data[i + 1] == 0 && Data[i + 2] == 1 && Data[i + 3] == 0xB8) {
- if (!(Data[i + 7] & 0x40)) // set flag only if GOP is not closed
- Data[i + 7] |= 0x20;
- return;
- }
- }
- dsyslog("SetBrokenLink: no GOP header found in video packet");
- }
- else
- dsyslog("SetBrokenLink: no video packet in frame");
-}
diff --git a/remux/tsremux.h b/remux/tsremux.h
deleted file mode 100644
index 3e83c73..0000000
--- a/remux/tsremux.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef VDR_STREAMDEV_TSREMUX_H
-#define VDR_STREAMDEV_TSREMUX_H
-
-#include "libdvbmpeg/transform.h"
-#include <vdr/remux.h>
-
-class cTSRemux {
-protected:
- uchar m_ResultBuffer[RESULTBUFFERSIZE];
- int m_ResultCount;
- int m_ResultDelivered;
- int m_Synced;
- int m_Skipped;
- int m_Sync;
-
- int GetPacketLength(const uchar *Data, int Count, int Offset);
- int ScanVideoPacket(const uchar *Data, int Count, int Offset, uchar &PictureType);
-
- virtual void PutTSPacket(int Pid, const uint8_t *Data) = 0;
-
-public:
- cTSRemux(bool Sync = true);
- virtual ~cTSRemux();
-
- virtual uchar *Process(const uchar *Data, int &Count, int &Result);
-
- static void SetBrokenLink(uchar *Data, int Length);
-};
-
-#endif // VDR_STREAMDEV_TSREMUX_H