File: ES_hevc.h

package info (click to toggle)
kodi-inputstream-adaptive 2.6.14%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,036 kB
  • sloc: cpp: 53,019; ansic: 492; makefile: 10
file content (123 lines) | stat: -rw-r--r-- 3,853 bytes parent folder | download
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 *      Copyright (C) 2005-2012 Team XBMC
 *      Copyright (C) 2015 Team KODI
 *
 *      http://kodi.tv
 *
 *  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, or (at your option)
 *  any later version.
 *
 *  This Program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with KODI; see the file COPYING.  If not, see
 *  <http://www.gnu.org/licenses/>.
 *
 */

#ifndef ES_HEVC_H
#define ES_HEVC_H

#include "elementaryStream.h"

namespace TSDemux
{
  class ES_hevc : public ElementaryStream
  {
  private:
    typedef struct hevc_private
    {
      struct PPS
      {
        int sps;
        int dependent_slice_segments_enabled_flag;
      } pps[64];

      struct VCL_NAL
      {
        int pic_parameter_set_id; // slice
        unsigned int first_slice_segment_in_pic_flag;
        unsigned int nal_unit_type;
      } vcl_nal;

    } hevc_private_t;

    typedef struct HDR_NAL_t
    {
       unsigned nal_unit_type;
       unsigned nuh_layer_id;
       unsigned nuh_temporal_id;
    } HDR_NAL;

    typedef struct mpeg_rational_s {
      int num;
      int den;
    } mpeg_rational_t;

    enum
    {
      NAL_TRAIL_N  = 0x00, // Coded slice segment of trailing picture
      NAL_TRAIL_R  = 0x01, // Coded slice segment of trailing picture
      NAL_TSA_N    = 0x02, // Coded slice segment of TSA picture
      NAL_TSA_R    = 0x03, // Coded slice segment of TSA picture
      NAL_STSA_N   = 0x04, // Coded slice segment of STSA picture
      NAL_STSA_R   = 0x05, // Coded slice segment of STSA picture
      NAL_RADL_N   = 0x06, // Coded slice segment of RADL picture
      NAL_RADL_R   = 0x07, // Coded slice segment of RADL picture
      NAL_RASL_N   = 0x08, // Coded slice segment of RASL picture
      NAL_RASL_R   = 0x09, // Coded slice segment of RASL picture

      NAL_BLA_W_LP = 0x10, // Coded slice segment of a BLA picture
      NAL_CRA_NUT  = 0x15, // Coded slice segment of a CRA picture
      NAL_RSV_IRAP_VCL22 = 0x16, // Reserved IRAP VCL NAL unit types
      NAL_RSV_IRAP_VCL23 = 0x17, // Reserved IRAP VCL NAL unit types

      NAL_VPS_NUT  = 0x20, // Video Parameter SET
      NAL_SPS_NUT  = 0x21, // Sequence Parameter Set
      NAL_PPS_NUT  = 0x22, // Picture Parameter Set
      NAL_AUD_NUT  = 0x23, // Access Unit Delimiter
      NAL_EOS_NUT  = 0x24, // End of Sequence
      NAL_EOB_NUT  = 0x25, // End of Bitstream
      NAL_FD_NUT   = 0x26, // Filler Data
      NAL_PFX_SEI_NUT  = 0x27, // Supplemental Enhancement Information
      NAL_SFX_SEI_NUT  = 0x28, // Supplemental Enhancement Information

    };

    uint32_t        m_StartCode;
    int             m_LastStartPos;
    bool            m_NeedVPS;
    bool            m_NeedSPS;
    bool            m_NeedPPS;
    int             m_Width;
    int             m_Height;
    int             m_FpsScale;
    mpeg_rational_t m_PixelAspect;
    hevc_private_t  m_streamData;
    int64_t         m_DTS;
    int64_t         m_PTS;
    bool            m_Interlaced;

    void Parse_HEVC(int buf_ptr, unsigned int NumBytesInNalUnit, bool &complete);
    void Parse_PPS(uint8_t *buf, int len);
    void Parse_SLH(uint8_t *buf, int len, HDR_NAL hdr, hevc_private::VCL_NAL &vcl);
    void Parse_SPS(uint8_t *buf, int len, HDR_NAL hdr);
    bool IsFirstVclNal(hevc_private::VCL_NAL &vcl);

  public:
    ES_hevc(uint16_t pes_pid);
    virtual ~ES_hevc();

    virtual void Parse(STREAM_PKT* pkt);
    virtual void Reset();
  };

}

#endif /* ES_HEVC_H */