Merge some MPC-HC Rev.3895 code to get HdmvSub and DVBSub support.
[xy_vsfilter.git] / src / dsutil / H264Nalu.h
blob429a45af307316cef268236600b9de9cea9e71e7
1 /*
2 * $Id: H264Nalu.h 3581 2011-08-05 16:26:10Z underground78 $
4 * (C) 2006-2011 see AUTHORS
6 * This file is part of mplayerc.
8 * Mplayerc is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * Mplayerc is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #pragma once
26 typedef enum {
27 NALU_TYPE_SLICE = 1,
28 NALU_TYPE_DPA = 2,
29 NALU_TYPE_DPB = 3,
30 NALU_TYPE_DPC = 4,
31 NALU_TYPE_IDR = 5,
32 NALU_TYPE_SEI = 6,
33 NALU_TYPE_SPS = 7,
34 NALU_TYPE_PPS = 8,
35 NALU_TYPE_AUD = 9,
36 NALU_TYPE_EOSEQ = 10,
37 NALU_TYPE_EOSTREAM = 11,
38 NALU_TYPE_FILL = 12
39 } NALU_TYPE;
41 class CH264Nalu
43 private :
44 int forbidden_bit; //! should be always FALSE
45 int nal_reference_idc; //! NALU_PRIORITY_xxxx
46 NALU_TYPE nal_unit_type; //! NALU_TYPE_xxxx
48 int m_nNALStartPos; //! NALU start (including startcode / size)
49 int m_nNALDataPos; //! Useful part
50 unsigned m_nDataLen; //! Length of the NAL unit (Excluding the start code, which does not belong to the NALU)
52 BYTE* m_pBuffer;
53 int m_nCurPos;
54 int m_nNextRTP;
55 int m_nSize;
56 int m_nNALSize;
58 bool MoveToNextAnnexBStartcode();
59 bool MoveToNextRTPStartcode();
61 public :
62 CH264Nalu();
64 NALU_TYPE GetType() const {
65 return nal_unit_type;
67 bool IsRefFrame() const {
68 return (nal_reference_idc != 0);
71 int GetDataLength() const {
72 return m_nCurPos - m_nNALDataPos;
74 BYTE* GetDataBuffer() {
75 return m_pBuffer + m_nNALDataPos;
77 int GetRoundedDataLength() const {
78 int nSize = m_nCurPos - m_nNALDataPos;
79 return nSize + 128 - (nSize %128);
82 int GetLength() const {
83 return m_nCurPos - m_nNALStartPos;
85 BYTE* GetNALBuffer() {
86 return m_pBuffer + m_nNALStartPos;
88 bool IsEOF() const {
89 return m_nCurPos >= m_nSize;
92 void SetBuffer (BYTE* pBuffer, int nSize, int nNALSize);
93 bool ReadNext();