Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(675)

Side by Side Diff: media/filters/h265_parser.h

Issue 816353010: Implemented HEVC video demuxing and parsing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved back h265_parser_unittest.cc in media/BUILD.gn Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/filters/h264_parser.cc ('k') | media/filters/h265_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // This file contains an implementation of an H265 Annex-B video stream parser.
6
7 #ifndef MEDIA_FILTERS_H265_PARSER_H_
8 #define MEDIA_FILTERS_H265_PARSER_H_
9
10 #include <sys/types.h>
11
12 #include <map>
13 #include <vector>
14
15 #include "base/basictypes.h"
16 #include "base/macros.h"
17 #include "media/base/media_export.h"
18 #include "media/base/ranges.h"
19 #include "media/filters/h264_bit_reader.h"
20 #include "media/filters/h264_parser.h"
21
22 namespace media {
23
24 struct SubsampleEntry;
25
26 // For explanations of each struct and its members, see H.265 specification
27 // at http://www.itu.int/rec/T-REC-H.265.
28 struct MEDIA_EXPORT H265NALU {
29 H265NALU();
30
31 // NAL Unit types are taken from Table 7-1 of HEVC/H265 standard
32 // http://www.itu.int/rec/T-REC-H.265-201410-I/en
33 enum Type {
34 TRAIL_N = 0,
35 TRAIL_R = 1,
36 TSA_N = 2,
37 TSA_R = 3,
38 STSA_N = 4,
39 STSA_R = 5,
40 RADL_N = 6,
41 RADL_R = 7,
42 RASL_N = 8,
43 RASL_R = 9,
44 RSV_VCL_N10 = 10,
45 RSV_VCL_R11 = 11,
46 RSV_VCL_N12 = 12,
47 RSV_VCL_R13 = 13,
48 RSV_VCL_N14 = 14,
49 RSV_VCL_R15 = 15,
50 BLA_W_LP = 16,
51 BLA_W_RADL = 17,
52 BLA_N_LP = 18,
53 IDR_W_RADL = 19,
54 IDR_N_LP = 20,
55 CRA_NUT = 21,
56 RSV_IRAP_VCL22 = 22,
57 RSV_IRAP_VCL23 = 23,
58 RSV_VCL24 = 24,
59 RSV_VCL25 = 25,
60 RSV_VCL26 = 26,
61 RSV_VCL27 = 27,
62 RSV_VCL28 = 28,
63 RSV_VCL29 = 29,
64 RSV_VCL30 = 30,
65 RSV_VCL31 = 31,
66 VPS_NUT = 32,
67 SPS_NUT = 33,
68 PPS_NUT = 34,
69 AUD_NUT = 35,
70 EOS_NUT = 36,
71 EOB_NUT = 37,
72 FD_NUT = 38,
73 PREFIX_SEI_NUT = 39,
74 SUFFIX_SEI_NUT = 40,
75 RSV_NVCL41 = 41,
76 RSV_NVCL42 = 42,
77 RSV_NVCL43 = 43,
78 RSV_NVCL44 = 44,
79 RSV_NVCL45 = 45,
80 RSV_NVCL46 = 46,
81 RSV_NVCL47 = 47,
82 };
83
84 // After (without) start code; we don't own the underlying memory
85 // and a shallow copy should be made when copying this struct.
86 const uint8* data;
87 off_t size; // From after start code to start code of next NALU (or EOS).
88
89 int nal_unit_type;
90 int nuh_layer_id;
91 int nuh_temporal_id_plus1;
92 };
93
94 // Class to parse an Annex-B H.265 stream.
95 class MEDIA_EXPORT H265Parser {
96 public:
97 enum Result {
98 kOk,
99 kInvalidStream, // error in stream
100 kUnsupportedStream, // stream not supported by the parser
101 kEOStream, // end of stream
102 };
103
104 H265Parser();
105 ~H265Parser();
106
107 void Reset();
108 // Set current stream pointer to |stream| of |stream_size| in bytes,
109 // |stream| owned by caller.
110 // |subsamples| contains information about what parts of |stream| are
111 // encrypted.
112 void SetStream(const uint8* stream, off_t stream_size);
113 void SetEncryptedStream(const uint8* stream, off_t stream_size,
114 const std::vector<SubsampleEntry>& subsamples);
115
116 // Read the stream to find the next NALU, identify it and return
117 // that information in |*nalu|. This advances the stream to the beginning
118 // of this NALU, but not past it, so subsequent calls to NALU-specific
119 // parsing functions (ParseSPS, etc.) will parse this NALU.
120 // If the caller wishes to skip the current NALU, it can call this function
121 // again, instead of any NALU-type specific parse functions below.
122 Result AdvanceToNextNALU(H265NALU* nalu);
123
124 private:
125 // Move the stream pointer to the beginning of the next NALU,
126 // i.e. pointing at the next start code.
127 // Return true if a NALU has been found.
128 // If a NALU is found:
129 // - its size in bytes is returned in |*nalu_size| and includes
130 // the start code as well as the trailing zero bits.
131 // - the size in bytes of the start code is returned in |*start_code_size|.
132 bool LocateNALU(off_t* nalu_size, off_t* start_code_size);
133
134 // Pointer to the current NALU in the stream.
135 const uint8* stream_;
136
137 // Bytes left in the stream after the current NALU.
138 off_t bytes_left_;
139
140 H264BitReader br_;
141
142 // Ranges of encrypted bytes in the buffer passed to
143 // SetEncryptedStream().
144 Ranges<const uint8*> encrypted_ranges_;
145
146 DISALLOW_COPY_AND_ASSIGN(H265Parser);
147 };
148
149 } // namespace media
150
151 #endif // MEDIA_FILTERS_H265_PARSER_H_
OLDNEW
« no previous file with comments | « media/filters/h264_parser.cc ('k') | media/filters/h265_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698