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 #ifndef MEDIA_FORMATS_MP4_AVC_H_ | 5 #ifndef MEDIA_FORMATS_MP4_AVC_H_ |
6 #define MEDIA_FORMATS_MP4_AVC_H_ | 6 #define MEDIA_FORMATS_MP4_AVC_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" |
11 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
| 13 #include "media/formats/mp4/bitstream_converter.h" |
12 | 14 |
13 namespace media { | 15 namespace media { |
14 | 16 |
15 struct SubsampleEntry; | 17 struct SubsampleEntry; |
16 | 18 |
17 namespace mp4 { | 19 namespace mp4 { |
18 | 20 |
19 struct AVCDecoderConfigurationRecord; | 21 struct AVCDecoderConfigurationRecord; |
20 | 22 |
21 class MEDIA_EXPORT AVC { | 23 class MEDIA_EXPORT AVC { |
(...skipping 28 matching lines...) Expand all Loading... |
50 static bool IsValidAnnexB(const uint8* buffer, size_t size, | 52 static bool IsValidAnnexB(const uint8* buffer, size_t size, |
51 const std::vector<SubsampleEntry>& subsamples); | 53 const std::vector<SubsampleEntry>& subsamples); |
52 | 54 |
53 // Given a |buffer| and |subsamples| information and |pts| pointer into the | 55 // Given a |buffer| and |subsamples| information and |pts| pointer into the |
54 // |buffer| finds the index of the subsample |ptr| is pointing into. | 56 // |buffer| finds the index of the subsample |ptr| is pointing into. |
55 static int FindSubsampleIndex(const std::vector<uint8>& buffer, | 57 static int FindSubsampleIndex(const std::vector<uint8>& buffer, |
56 const std::vector<SubsampleEntry>* subsamples, | 58 const std::vector<SubsampleEntry>* subsamples, |
57 const uint8* ptr); | 59 const uint8* ptr); |
58 }; | 60 }; |
59 | 61 |
| 62 // AVCBitstreamConverter converts AVC/H.264 bitstream from MP4 container format |
| 63 // with embedded NALU lengths into AnnexB bitstream format (described in ISO/IEC |
| 64 // 14496-10) with 4-byte start codes. It also knows how to handle CENC-encrypted |
| 65 // streams and adjusts subsample data for those streams while converting. |
| 66 class AVCBitstreamConverter : public BitstreamConverter { |
| 67 public: |
| 68 explicit AVCBitstreamConverter( |
| 69 scoped_ptr<AVCDecoderConfigurationRecord> avc_config); |
| 70 |
| 71 // BitstreamConverter interface |
| 72 bool ConvertFrame(std::vector<uint8>* frame_buf, |
| 73 bool is_keyframe, |
| 74 std::vector<SubsampleEntry>* subsamples) const override; |
| 75 private: |
| 76 ~AVCBitstreamConverter() override; |
| 77 scoped_ptr<AVCDecoderConfigurationRecord> avc_config_; |
| 78 }; |
| 79 |
60 } // namespace mp4 | 80 } // namespace mp4 |
61 } // namespace media | 81 } // namespace media |
62 | 82 |
63 #endif // MEDIA_FORMATS_MP4_AVC_H_ | 83 #endif // MEDIA_FORMATS_MP4_AVC_H_ |
OLD | NEW |