2 Copyright 2008 Mark Calderbank
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
20 #ifndef DVBSUBTITLES_H
21 #define DVBSUBTITLES_H
30 #include <condition_variable>
34 typedef unsigned long long uint64_t;
48 void setEntry(int bpp, UINT index, UCHAR Y, UCHAR Cr, UCHAR Cb, UCHAR T);
49 const Palette& getPalette(int bpp) const;
54 const static ULONG defaultPalette2[4];
55 const static ULONG defaultPalette4[16];
56 const static ULONG defaultPalette8[256];
59 class DVBSubtitleRegion : public Bitmap
70 UINT horizontalPosition;
71 UINT verticalPosition;
73 typedef std::vector<struct ObjectRef> ObjectList;
87 typedef std::map<UCHAR, DVBSubtitleCLUT> CLUTMap;
89 typedef std::map<UCHAR, DVBSubtitleRegion> RegionMap;
91 struct Coords { UINT x; UINT y; };
92 typedef std::map<UCHAR, Coords> DisplayMap;
93 DisplayMap currentDisplay;
94 DisplayMap pendingDisplay;
96 void setState(UCHAR s);
97 void updateRegionPalettes(const DVBSubtitleCLUT&);
100 class DVBSubtitleDisplayDefinition: public DisplayRegion
103 DVBSubtitleDisplayDefinition();
113 DVBSubtitles(OSDReceiver* tosd = NULL);
114 virtual ~DVBSubtitles() {}
115 void put(const PESPacket& packet);
122 void setOSDMenuVisibility(bool visible);
123 bool isShowing() { return showing; }
127 std::deque<PESPacket> worklist;
128 typedef std::map<UINT, DVBSubtitlePage> PageMap;
131 bool decodePacket(const PESPacket&);
132 void finishPage(const DVBSubtitlePage&);
133 void clearDisplayedPages();
134 DVBSubtitleDisplayDefinition dds;
139 std::chrono::time_point<std::chrono::system_clock> subtitleTimeoutPoint;
140 bool subtitleTimeoutPointActive{};
143 std::mutex input_mutex; // Also use as thread/cond/signal mutex, master loop etc.
144 std::mutex output_mutex;
146 std::thread dvbsThread;
147 std::condition_variable dvbsCond;
149 bool signalRecalcWLTO{};