mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 00:11:14 +02:00
eitd: move freesatHuffmanDecode to SIutils
This commit is contained in:
@@ -95,6 +95,7 @@ struct descr_linkage_header {
|
||||
} __attribute__ ((packed)) ;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
struct descr_pdc_header {
|
||||
unsigned descriptor_tag : 8;
|
||||
unsigned descriptor_length : 8;
|
||||
@@ -102,6 +103,7 @@ struct descr_pdc_header {
|
||||
unsigned pil1 : 8;
|
||||
unsigned pil2 : 8;
|
||||
} __attribute__ ((packed)) ;
|
||||
#endif
|
||||
|
||||
class SIlinkage {
|
||||
public:
|
||||
@@ -393,7 +395,6 @@ class SIevent
|
||||
std::string getText() const;
|
||||
void setText(const std::string &lang, const std::string &text);
|
||||
|
||||
|
||||
// Aus dem Extended Descriptor
|
||||
std::string getExtendedText() const;
|
||||
void appendExtendedText(const std::string &lang, const std::string &text);
|
||||
|
@@ -40,7 +40,7 @@
|
||||
#include <zapit/dvbstring.h>
|
||||
#include <edvbstring.h>
|
||||
#ifdef ENABLE_FREESATEPG
|
||||
#include "FreesatTables.hpp"
|
||||
//#include "FreesatTables.hpp"
|
||||
#endif
|
||||
|
||||
#include <dvbsi++/descriptor_tag.h>
|
||||
@@ -398,10 +398,6 @@ void SIsectionSDT::parseServiceDescriptor(const char *buf, SIservice &s)
|
||||
s.serviceTyp=sv->service_typ;
|
||||
is_blacklisted = check_blacklisted(s.original_network_id, s.transport_stream_id);
|
||||
if(sv->service_provider_name_length) {
|
||||
//if(*buf < 0x06) // other code table
|
||||
// s.providerName=std::string(buf+1, sv->service_provider_name_length-1);
|
||||
// else
|
||||
// s.providerName=std::string(buf, sv->service_provider_name_length);
|
||||
if ((*buf > 0x05) && (is_blacklisted))
|
||||
s.providerName = CDVBString(("\x05" + std::string((const char *)(buf))).c_str(), sv->service_provider_name_length+1).getContent();
|
||||
else
|
||||
@@ -489,7 +485,7 @@ void SIsectionSDT::parse(void)
|
||||
parsed = 1;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FREESATEPG
|
||||
#if 0 //def ENABLE_FREESATEPG
|
||||
std::string SIsectionEIT::freesatHuffmanDecode(std::string input)
|
||||
{
|
||||
const char *src = input.c_str();
|
||||
|
@@ -158,6 +158,10 @@ protected:
|
||||
|
||||
class SIsectionEIT : /*public SIsection,*/ public EventInformationSection
|
||||
{
|
||||
protected:
|
||||
SIevents evts;
|
||||
int parsed;
|
||||
void parse(void);
|
||||
public:
|
||||
SIsectionEIT(uint8_t *buf) : /*SIsection(buf),*/ EventInformationSection(buf)
|
||||
{
|
||||
@@ -192,10 +196,6 @@ public:
|
||||
return parsed;
|
||||
}
|
||||
|
||||
protected:
|
||||
SIevents evts;
|
||||
int parsed;
|
||||
void parse(void);
|
||||
#if 0
|
||||
void parseDescriptors(const uint8_t *desc, unsigned len, SIevent &e);
|
||||
void parseShortEventDescriptor(const char *buf, SIevent &e, unsigned maxlen);
|
||||
@@ -205,10 +205,10 @@ protected:
|
||||
void parseParentalRatingDescriptor(const char *buf, SIevent &e, unsigned maxlen);
|
||||
void parseLinkageDescriptor(const char *buf, SIevent &e, unsigned maxlen);
|
||||
void parsePDCDescriptor(const char *buf, SIevent &e, unsigned maxlen);
|
||||
#endif
|
||||
#ifdef ENABLE_FREESATEPG
|
||||
std::string freesatHuffmanDecode(std::string input);
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
@@ -81,6 +81,8 @@
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
@@ -240,3 +242,111 @@ void removeControlCodes(char *string)
|
||||
return ;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FREESATEPG
|
||||
#include "FreesatTables.hpp"
|
||||
std::string freesatHuffmanDecode(std::string input)
|
||||
{
|
||||
const char *src = input.c_str();
|
||||
uint size = input.length();
|
||||
|
||||
if (src[1] == 1 || src[1] == 2)
|
||||
{
|
||||
std::string uncompressed(size * 3, ' ');
|
||||
uint p = 0;
|
||||
struct hufftab *table;
|
||||
unsigned table_length;
|
||||
if (src[1] == 1)
|
||||
{
|
||||
table = fsat_huffman1;
|
||||
table_length = sizeof(fsat_huffman1) / sizeof(fsat_huffman1[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
table = fsat_huffman2;
|
||||
table_length = sizeof(fsat_huffman2) / sizeof(fsat_huffman2[0]);
|
||||
}
|
||||
unsigned value = 0, byte = 2, bit = 0;
|
||||
while (byte < 6 && byte < size)
|
||||
{
|
||||
value |= src[byte] << ((5-byte) * 8);
|
||||
byte++;
|
||||
}
|
||||
char lastch = START;
|
||||
|
||||
do
|
||||
{
|
||||
bool found = false;
|
||||
unsigned bitShift = 0;
|
||||
if (lastch == ESCAPE)
|
||||
{
|
||||
found = true;
|
||||
// Encoded in the next 8 bits.
|
||||
// Terminated by the first ASCII character.
|
||||
char nextCh = (value >> 24) & 0xff;
|
||||
bitShift = 8;
|
||||
if ((nextCh & 0x80) == 0)
|
||||
lastch = nextCh;
|
||||
if (p >= uncompressed.length())
|
||||
uncompressed.resize(p+10);
|
||||
uncompressed[p++] = nextCh;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned j = 0; j < table_length; j++)
|
||||
{
|
||||
if (table[j].last == lastch)
|
||||
{
|
||||
unsigned mask = 0, maskbit = 0x80000000;
|
||||
for (short kk = 0; kk < table[j].bits; kk++)
|
||||
{
|
||||
mask |= maskbit;
|
||||
maskbit >>= 1;
|
||||
}
|
||||
if ((value & mask) == table[j].value)
|
||||
{
|
||||
char nextCh = table[j].next;
|
||||
bitShift = table[j].bits;
|
||||
if (nextCh != STOP && nextCh != ESCAPE)
|
||||
{
|
||||
if (p >= uncompressed.length())
|
||||
uncompressed.resize(p+10);
|
||||
uncompressed[p++] = nextCh;
|
||||
}
|
||||
found = true;
|
||||
lastch = nextCh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
// Shift up by the number of bits.
|
||||
for (unsigned b = 0; b < bitShift; b++)
|
||||
{
|
||||
value = (value << 1) & 0xfffffffe;
|
||||
if (byte < size)
|
||||
value |= (src[byte] >> (7-bit)) & 1;
|
||||
if (bit == 7)
|
||||
{
|
||||
bit = 0;
|
||||
byte++;
|
||||
}
|
||||
else bit++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Entry missing in table.
|
||||
uncompressed.resize(p);
|
||||
uncompressed.append("...");
|
||||
return uncompressed;
|
||||
}
|
||||
} while (lastch != STOP && value != 0);
|
||||
|
||||
uncompressed.resize(p);
|
||||
return uncompressed;
|
||||
}
|
||||
else return input;
|
||||
}
|
||||
#endif
|
||||
|
@@ -44,7 +44,11 @@
|
||||
// Alles neu macht der Mai.
|
||||
//
|
||||
//
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#define ENABLE_FREESATEPG //FIXME
|
||||
|
||||
time_t changeUTCtoCtime(const unsigned char *buffer, int local_time=1);
|
||||
time_t parseDVBtime(uint16_t mjd, uint32_t bcd);
|
||||
@@ -57,4 +61,8 @@ int saveStringToXMLfile(FILE *out, const char *string, int withControlCodes=0);
|
||||
// Entfernt die ControlCodes aus dem String (-> String wird evtl. kuerzer)
|
||||
void removeControlCodes(char *string);
|
||||
|
||||
#ifdef ENABLE_FREESATEPG
|
||||
std::string freesatHuffmanDecode(std::string input);
|
||||
#endif
|
||||
|
||||
#endif // SIUTILS_HPP
|
||||
|
@@ -5,6 +5,8 @@
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include <SIutils.hpp>
|
||||
|
||||
std::map<std::string, int> CountryCodeDefaultMapping;
|
||||
std::map<int, int> TransponderDefaultMapping;
|
||||
std::set<int> TransponderUseTwoCharMapping;
|
||||
@@ -666,9 +668,18 @@ std::string convertDVBUTF8(const char *data, int len, int table, int tsidonid)
|
||||
++i;
|
||||
{} //eDebug("unsup. Big5 subset of ISO/IEC 10646-1 enc.");
|
||||
break;
|
||||
case 0x1F:
|
||||
{
|
||||
#ifdef ENABLE_FREESATEPG
|
||||
std::string decoded_string = freesatHuffmanDecode(std::string(data, len));
|
||||
if (!decoded_string.empty()) return decoded_string;
|
||||
#endif
|
||||
}
|
||||
++i;
|
||||
break;
|
||||
case 0x0:
|
||||
case 0xD ... 0xF:
|
||||
case 0x15 ... 0x1F:
|
||||
case 0x15 ... 0x1E:
|
||||
{} //eDebug("reserved %d", data[0]);
|
||||
++i;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user