OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file contains an implementation of an H264 Annex-B video stream parser. | 5 // This file contains an implementation of an H264 Annex-B video stream parser. |
6 | 6 |
7 #ifndef MEDIA_FILTERS_H264_PARSER_H_ | 7 #ifndef MEDIA_FILTERS_H264_PARSER_H_ |
8 #define MEDIA_FILTERS_H264_PARSER_H_ | 8 #define MEDIA_FILTERS_H264_PARSER_H_ |
9 | 9 |
10 #include <stddef.h> | 10 #include <stddef.h> |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 #include <sys/types.h> | 12 #include <sys/types.h> |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "media/base/media_export.h" | 18 #include "media/base/media_export.h" |
19 #include "media/base/ranges.h" | 19 #include "media/base/ranges.h" |
| 20 #include "media/base/video_codecs.h" |
20 #include "media/filters/h264_bit_reader.h" | 21 #include "media/filters/h264_bit_reader.h" |
21 | 22 |
22 namespace media { | 23 namespace media { |
23 | 24 |
24 struct SubsampleEntry; | 25 struct SubsampleEntry; |
25 | 26 |
26 // For explanations of each struct and its members, see H.264 specification | 27 // For explanations of each struct and its members, see H.264 specification |
27 // at http://www.itu.int/rec/T-REC-H.264. | 28 // at http://www.itu.int/rec/T-REC-H.264. |
28 struct MEDIA_EXPORT H264NALU { | 29 struct MEDIA_EXPORT H264NALU { |
29 H264NALU(); | 30 H264NALU(); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 off_t* start_code_size); | 354 off_t* start_code_size); |
354 | 355 |
355 // Wrapper for FindStartCode() that skips over start codes that | 356 // Wrapper for FindStartCode() that skips over start codes that |
356 // may appear inside of |encrypted_ranges_|. | 357 // may appear inside of |encrypted_ranges_|. |
357 // Returns true if a start code was found. Otherwise returns false. | 358 // Returns true if a start code was found. Otherwise returns false. |
358 static bool FindStartCodeInClearRanges(const uint8_t* data, | 359 static bool FindStartCodeInClearRanges(const uint8_t* data, |
359 off_t data_size, | 360 off_t data_size, |
360 const Ranges<const uint8_t*>& ranges, | 361 const Ranges<const uint8_t*>& ranges, |
361 off_t* offset, | 362 off_t* offset, |
362 off_t* start_code_size); | 363 off_t* start_code_size); |
| 364 |
| 365 static VideoCodecProfile ProfileIDCToVideoCodecProfile(int profile_idc); |
| 366 |
363 H264Parser(); | 367 H264Parser(); |
364 ~H264Parser(); | 368 ~H264Parser(); |
365 | 369 |
366 void Reset(); | 370 void Reset(); |
367 // Set current stream pointer to |stream| of |stream_size| in bytes, | 371 // Set current stream pointer to |stream| of |stream_size| in bytes, |
368 // |stream| owned by caller. | 372 // |stream| owned by caller. |
369 // |subsamples| contains information about what parts of |stream| are | 373 // |subsamples| contains information about what parts of |stream| are |
370 // encrypted. | 374 // encrypted. |
371 void SetStream(const uint8_t* stream, off_t stream_size); | 375 void SetStream(const uint8_t* stream, off_t stream_size); |
372 void SetEncryptedStream(const uint8_t* stream, | 376 void SetEncryptedStream(const uint8_t* stream, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 // Ranges of encrypted bytes in the buffer passed to | 482 // Ranges of encrypted bytes in the buffer passed to |
479 // SetEncryptedStream(). | 483 // SetEncryptedStream(). |
480 Ranges<const uint8_t*> encrypted_ranges_; | 484 Ranges<const uint8_t*> encrypted_ranges_; |
481 | 485 |
482 DISALLOW_COPY_AND_ASSIGN(H264Parser); | 486 DISALLOW_COPY_AND_ASSIGN(H264Parser); |
483 }; | 487 }; |
484 | 488 |
485 } // namespace media | 489 } // namespace media |
486 | 490 |
487 #endif // MEDIA_FILTERS_H264_PARSER_H_ | 491 #endif // MEDIA_FILTERS_H264_PARSER_H_ |
OLD | NEW |