vdr/libsi/util.h
Klaus Schmidinger 5619c0602b Version 1.7.17
- Updated the Estonian OSD texts (thanks to Arthur Konovalov).
- Fixed following symbolic links in RemoveFileOrDir() (cont'd) (thanks to
  Steffen Barszus).
- Changed the description of cDevice::GetSTC() to make it mandatory for devices
  that can replay.
- Removed the check for positive STC values from cDvbSubtitleConverter::Action().
- Added cString::operator=(const char *String) (suggested by Antti Seppälä).
- Some spelling fixes (thanks to Ville Skyttä).
- Passing package name and version to xgettext (thanks to Ville Skyttä).
- Made 'dist' target dependent on up to date *.po (thanks to Ville Skyttä).
- Added Language and fixed Language-Team header of *.po (thanks to Ville Skyttä).
- Updated the Lithuanian OSD texts (thanks to Valdemaras Pipiras).
- Fixed detecting frames on channels that broadcast with 50 or 60 fps.
  This avoids artifacts during fast forward/rewind when replaying recordings from such
  channels. To fix the index of existing recordings from such channels, just delete the
  'index' file of the recording and VDR will generate a new one the next time you play it.
  You should also change the line "F 25" to "F 50" in the 'info' file of that recording.
- Added support for "registration descriptor" to 'libsi' and using it in pat.c (thanks
  to Rolf Ahrenberg).
- Fixed unjustified log entries about changed channel pids (reported by Derek Kelly).
- Added an include of VDR's 'Make.global' to libsi's Makefile (thanks to Rolf
  Ahrenberg).
- Removed displaying the "contents" information from the "Classic VDR" and
  "ST:TNG Panels" skins, because it is often wrong and nothing but irritating.
- Added typecasts to avoid gcc 4.5 warnings in switch statements on eKeys
  variables where additional 'k_...' flags are used.
- Fixed inclusion of <stdarg.h> (thanks to Henning Heinold).
- Changed "frame duration" to "frame rate" in vdr.5 (reported by Tobias Grimm).
- Removing a cRemote from the Remotes list in case its initialization failed (thanks
  to Dominik Strasser).
- Added LDFLAGS to the linker calls in the Makefiles (thanks to Joerg Bornkessel and
  Paul Menzel).
- Now updating the 'frames per second' data in the list of recordings when a new
  recording is started that has a frame rate other than the default.
- The include path to the freetype2 header files is now retrieved via a call to
  'pkg-config --cflags freetype2' (suggested by Andreas Oberritter).
- The OSD now has full TrueColor support. There can be several "pixmaps" that can
  be overlayed with alpha blending. All existing skins should work out of the box
  with the TrueColor OSD - the only exception being cOsd::GetBitmap(). Since the
  TrueColor OSD doesn't use bitmaps, this function will return a dummy bitmap, which
  may not be what the plugin expects. As long as this bitmap is only used for setting
  the palette, there is no problem. However, any other operations on this bitmap will
  have no effect. See the description of the cPixmap functions in osd.h for details
  about the new functionalities.
  The "ST:TNG Panels" skin has been enhanced to automatically use the TrueColor OSD
  if available.
  The "osddemo" plugin has been extended to show some of the possibilities of the
  TrueColor OSD if it is run on a system that actually provides TrueColor support.
  Thanks to Reinhard Nissl for some valuable input, help with debugging, and an
  implementation of the AlphaBlend() function.
- Updated the Slovakian language texts (thanks to Milan Hrala).
- Added Serbian language texts (thanks to Milan Cvijanovic).
- Fixed reallocating memory in the "pictures" plugin (reported by Paul Menzel, with
  input from Oliver Endriss).
- Fixed reallocating memory in cTsToPes::PutTs() (suggested by Oliver Endriss).
- Now checking the result of all realloc() calls.
- Fixed setting up the 'Recordings' menu in case there are several recordings
  with exactly the same name (reported by Marcus Hilbrich).
- Setting the audio type of language descriptors to 0x00 in the PAT/PMT generator
  (thanks to Anssi Hannula).
- Changed the compiler optimization flag to -O3, which gives quite a performance
  boost in the AlphaBlend() function.
- While replaying, the editing marks are now updated every 10 seconds (based on a
  patch from Manuel Reimer).
- Now reducing the thread and I/O priority cCuttingThread::Action() to make the
  foreground process more responsive (suggested by Frank Neumann).
- Removed checking for minimum line length of 21 characters in the LIRC receiver code
  (reported by Gerald Dachs).
- Updated the Romanian OSD texts (thanks to Lucian Muresan).
- Now storing the original display size when handling DVB subtitles (thanks to
  Reinhard Nissl).
- The original display size of subtitles is now used to scale them properly when
  displaying them on an HD OSD.
2011-03-19 19:02:09 +01:00

164 lines
5.7 KiB
C++

/***************************************************************************
* Copyright (c) 2003 by Marcel Wiesweg *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* $Id: util.h 2.2 2010/11/01 15:24:32 kls Exp $
* *
***************************************************************************/
#ifndef LIBSI_UTIL_H
#define LIBSI_UTIL_H
#include <stdint.h>
#include <sys/types.h>
#include <pthread.h>
#include <time.h>
#define HILO(x) (x##_hi << 8 | x##_lo)
#define HILOHILO(x) (x##_hi_hi << 24 | x##_hi_lo << 16 | x##_lo_hi << 8 | x##_lo_lo)
#define BCD_TIME_TO_SECONDS(x) ((3600 * ((10*((x##_h & 0xF0)>>4)) + (x##_h & 0xF))) + \
(60 * ((10*((x##_m & 0xF0)>>4)) + (x##_m & 0xF))) + \
((10*((x##_s & 0xF0)>>4)) + (x##_s & 0xF)))
namespace SI {
//Holds an array of unsigned char which is deleted
//when the last object pointing to it is deleted.
//Optimized for use in libsi.
class CharArray {
public:
CharArray();
CharArray(const CharArray &source);
CharArray& operator=(const CharArray &source);
~CharArray();
//can be called exactly once
void assign(const unsigned char*data, int size, bool doCopy=true);
//compares to a null-terminated string
bool operator==(const char *string) const;
//compares to another CharArray (data not necessarily null-terminated)
bool operator==(const CharArray &other) const;
//returns another CharArray with its offset incremented by offset
CharArray operator+(const int offset) const;
//access and convenience methods
const unsigned char* getData() const { return data_->data+off; }
const unsigned char* getData(int offset) const { return data_->data+offset+off; }
template <typename T> const T* getData() const { return (T*)(data_->data+off); }
template <typename T> const T* getData(int offset) const { return (T*)(data_->data+offset+off); }
//sets p to point to data+offset, increments offset
template <typename T> void setPointerAndOffset(const T* &p, int &offset) const { p=(T*)getData(offset); offset+=sizeof(T); }
unsigned char operator[](const int index) const { return data_->data ? data_->data[off+index] : 0; }
int getLength() const { return data_->size; }
u_int16_t TwoBytes(const int index) const { return data_->data ? data_->TwoBytes(off+index) : 0; }
u_int32_t FourBytes(const int index) const { return data_->data ? data_->FourBytes(off+index) : 0; }
bool isValid() const { return data_->valid; }
bool checkSize(int offset) { return (data_->valid && (data_->valid=(offset>=0 && off+offset < data_->size))); }
void addOffset(int offset) { off+=offset; }
private:
class Data {
public:
Data();
virtual ~Data();
virtual void assign(const unsigned char*data, int size) = 0;
virtual void Delete() = 0;
u_int16_t TwoBytes(const int index) const
{ return (data[index] << 8) | data[index+1]; }
u_int32_t FourBytes(const int index) const
{ return (data[index] << 24) | (data[index+1] << 16) | (data[index+2] << 8) | data[index+3]; }
/*#ifdef CHARARRAY_THREADSAFE
void Lock();
void Unlock();
#else
void Lock() {}
void Unlock() {}
#endif
Data(const Data& d);
void assign(int size);
*/
const unsigned char*data;
int size;
// count_ is the number of CharArray objects that point at this
// count_ must be initialized to 1 by all constructors
// (it starts as 1 since it is pointed to by the CharArray object that created it)
unsigned count_;
bool valid;
/*
pthread_mutex_t mutex;
pid_t lockingPid;
pthread_t locked;
*/
};
class DataOwnData : public Data {
public:
DataOwnData() {}
virtual ~DataOwnData();
virtual void assign(const unsigned char*data, int size);
virtual void Delete();
};
class DataForeignData : public Data {
public:
DataForeignData() {}
virtual ~DataForeignData();
virtual void assign(const unsigned char*data, int size);
virtual void Delete();
};
Data* data_;
int off;
};
//abstract base class
class Parsable {
public:
void CheckParse();
protected:
Parsable();
virtual ~Parsable() {}
//actually parses given data.
virtual void Parse() = 0;
private:
bool parsed;
};
//taken and adapted from libdtv, (c) Rolf Hakenes and VDR, (c) Klaus Schmidinger
namespace DVBTime {
time_t getTime(unsigned char date_hi, unsigned char date_lo, unsigned char timehr, unsigned char timemi, unsigned char timese);
time_t getDuration(unsigned char timehr, unsigned char timemi, unsigned char timese);
inline unsigned char bcdToDec(unsigned char b) { return ((b >> 4) & 0x0F) * 10 + (b & 0x0F); }
}
//taken and adapted from libdtv, (c) Rolf Hakenes
class CRC32 {
public:
CRC32(const char *d, int len, u_int32_t CRCvalue=0xFFFFFFFF);
bool isValid() { return crc32(data, length, value) == 0; }
static bool isValid(const char *d, int len, u_int32_t CRCvalue=0xFFFFFFFF) { return crc32(d, len, CRCvalue) == 0; }
static u_int32_t crc32(const char *d, int len, u_int32_t CRCvalue);
protected:
static u_int32_t crc_table[256];
const char *data;
int length;
u_int32_t value;
};
} //end of namespace
#endif