summaryrefslogtreecommitdiffstats
path: root/xbmc/cores/VideoPlayer/DVDDemuxSPU.h
blob: 8f1bcc117a2a4929c5b03cb7c9b283348a6e6e3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 *  Copyright (C) 2005-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include <stdint.h>

struct AVFrame;
class CDVDOverlaySpu;

typedef struct SPUData
{
  uint8_t* data;
  unsigned int iSize; // current data size
  unsigned int iNeededSize; // wanted packet size
  unsigned int iAllocatedSize;
  double pts;
}
SPUData;

// upto 32 streams can exist
#define DVD_MAX_SPUSTREAMS 32

class CDVDDemuxSPU final
{
public:
  CDVDDemuxSPU();
  ~CDVDDemuxSPU();

  CDVDOverlaySpu* AddData(uint8_t* data, int iSize, double pts); // returns a packet from ParsePacket if possible

  CDVDOverlaySpu* ParseRLE(CDVDOverlaySpu* pSPU, uint8_t* pUnparsedData);
  static void FindSubtitleColor(int last_color, int stats[4], CDVDOverlaySpu* pSPU);
  static bool CanDisplayWithAlphas(const int a[4], const int stats[4]);

  void Reset();
  void FlushCurrentPacket(); // flushes current unparsed data

  // m_clut set by libdvdnav once in a time
  // color lookup table is representing 16 different yuv colors
  // [][0] = Y, [][1] = Cr, [][2] = Cb
  uint8_t m_clut[16][3];
  bool m_bHasClut;

protected:
  CDVDOverlaySpu* ParsePacket(SPUData* pSPUData);

  SPUData m_spuData;
};