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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 class MEDIA_EXPORT AVC { | 25 class MEDIA_EXPORT AVC { |
26 public: | 26 public: |
27 static bool ConvertFrameToAnnexB(int length_size, | 27 static bool ConvertFrameToAnnexB(int length_size, |
28 std::vector<uint8_t>* buffer, | 28 std::vector<uint8_t>* buffer, |
29 std::vector<SubsampleEntry>* subsamples); | 29 std::vector<SubsampleEntry>* subsamples); |
30 | 30 |
31 // Inserts the SPS & PPS data from |avc_config| into |buffer|. | 31 // Inserts the SPS & PPS data from |avc_config| into |buffer|. |
32 // |buffer| is expected to contain AnnexB conformant data. | 32 // |buffer| is expected to contain AnnexB conformant data. |
33 // |subsamples| contains the SubsampleEntry info if |buffer| contains | 33 // |subsamples| contains the SubsampleEntry info if |buffer| contains |
34 // encrypted data. | 34 // encrypted data. |
| 35 // |annexb_validation| indicates if it should perform Annex B validation after |
| 36 // the operation. |
35 // Returns true if the param sets were successfully inserted. | 37 // Returns true if the param sets were successfully inserted. |
36 static bool InsertParamSetsAnnexB( | 38 static bool InsertParamSetsAnnexB( |
37 const AVCDecoderConfigurationRecord& avc_config, | 39 const AVCDecoderConfigurationRecord& avc_config, |
38 std::vector<uint8_t>* buffer, | 40 std::vector<uint8_t>* buffer, |
39 std::vector<SubsampleEntry>* subsamples); | 41 std::vector<SubsampleEntry>* subsamples, |
| 42 bool annexb_validation); |
40 | 43 |
41 static bool ConvertConfigToAnnexB( | 44 static bool ConvertConfigToAnnexB( |
42 const AVCDecoderConfigurationRecord& avc_config, | 45 const AVCDecoderConfigurationRecord& avc_config, |
43 std::vector<uint8_t>* buffer); | 46 std::vector<uint8_t>* buffer); |
44 | 47 |
45 // Verifies that the contents of |buffer| conform to | 48 // Verifies that the contents of |buffer| conform to |
46 // Section 7.4.1.2.3 of ISO/IEC 14496-10. | 49 // Section 7.4.1.2.3 of ISO/IEC 14496-10. |
47 // |subsamples| contains the information about what parts of the buffer are | 50 // |subsamples| contains the information about what parts of the buffer are |
48 // encrypted and which parts are clear. | 51 // encrypted and which parts are clear. |
49 // Returns true if |buffer| contains conformant Annex B data | 52 // Returns true if |buffer| contains conformant Annex B data |
(...skipping 13 matching lines...) Expand all Loading... |
63 }; | 66 }; |
64 | 67 |
65 // AVCBitstreamConverter converts AVC/H.264 bitstream from MP4 container format | 68 // AVCBitstreamConverter converts AVC/H.264 bitstream from MP4 container format |
66 // with embedded NALU lengths into AnnexB bitstream format (described in ISO/IEC | 69 // with embedded NALU lengths into AnnexB bitstream format (described in ISO/IEC |
67 // 14496-10) with 4-byte start codes. It also knows how to handle CENC-encrypted | 70 // 14496-10) with 4-byte start codes. It also knows how to handle CENC-encrypted |
68 // streams and adjusts subsample data for those streams while converting. | 71 // streams and adjusts subsample data for those streams while converting. |
69 class AVCBitstreamConverter : public BitstreamConverter { | 72 class AVCBitstreamConverter : public BitstreamConverter { |
70 public: | 73 public: |
71 explicit AVCBitstreamConverter( | 74 explicit AVCBitstreamConverter( |
72 std::unique_ptr<AVCDecoderConfigurationRecord> avc_config); | 75 std::unique_ptr<AVCDecoderConfigurationRecord> avc_config); |
| 76 // Overrides |post_annexb_validation_| to disable Annex B validation |
| 77 void DisablePostAnnexbValidation() { post_annexb_validation_ = false; } |
73 | 78 |
74 // BitstreamConverter interface | 79 // BitstreamConverter interface |
75 bool ConvertFrame(std::vector<uint8_t>* frame_buf, | 80 bool ConvertFrame(std::vector<uint8_t>* frame_buf, |
76 bool is_keyframe, | 81 bool is_keyframe, |
77 std::vector<SubsampleEntry>* subsamples) const override; | 82 std::vector<SubsampleEntry>* subsamples) const override; |
78 | 83 |
79 private: | 84 private: |
80 ~AVCBitstreamConverter() override; | 85 ~AVCBitstreamConverter() override; |
81 std::unique_ptr<AVCDecoderConfigurationRecord> avc_config_; | 86 std::unique_ptr<AVCDecoderConfigurationRecord> avc_config_; |
| 87 // Indicates if it needs to do AnnexB validation on bitstream after performing |
| 88 // ConvertFrame() operation. |
| 89 bool post_annexb_validation_; |
82 }; | 90 }; |
83 | 91 |
84 } // namespace mp4 | 92 } // namespace mp4 |
85 } // namespace media | 93 } // namespace media |
86 | 94 |
87 #endif // MEDIA_FORMATS_MP4_AVC_H_ | 95 #endif // MEDIA_FORMATS_MP4_AVC_H_ |
OLD | NEW |