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

Side by Side Diff: media/formats/mp4/avc.h

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years 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
OLDNEW
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"
11 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
12 #include "media/base/media_export.h" 11 #include "media/base/media_export.h"
13 #include "media/formats/mp4/bitstream_converter.h" 12 #include "media/formats/mp4/bitstream_converter.h"
14 13
15 namespace media { 14 namespace media {
16 15
17 struct SubsampleEntry; 16 struct SubsampleEntry;
18 17
19 namespace mp4 { 18 namespace mp4 {
20 19
21 struct AVCDecoderConfigurationRecord; 20 struct AVCDecoderConfigurationRecord;
22 21
23 class MEDIA_EXPORT AVC { 22 class MEDIA_EXPORT AVC {
24 public: 23 public:
25 static bool ConvertFrameToAnnexB(int length_size, 24 static bool ConvertFrameToAnnexB(int length_size,
26 std::vector<uint8>* buffer, 25 std::vector<uint8_t>* buffer,
27 std::vector<SubsampleEntry>* subsamples); 26 std::vector<SubsampleEntry>* subsamples);
28 27
29 // Inserts the SPS & PPS data from |avc_config| into |buffer|. 28 // Inserts the SPS & PPS data from |avc_config| into |buffer|.
30 // |buffer| is expected to contain AnnexB conformant data. 29 // |buffer| is expected to contain AnnexB conformant data.
31 // |subsamples| contains the SubsampleEntry info if |buffer| contains 30 // |subsamples| contains the SubsampleEntry info if |buffer| contains
32 // encrypted data. 31 // encrypted data.
33 // Returns true if the param sets were successfully inserted. 32 // Returns true if the param sets were successfully inserted.
34 static bool InsertParamSetsAnnexB( 33 static bool InsertParamSetsAnnexB(
35 const AVCDecoderConfigurationRecord& avc_config, 34 const AVCDecoderConfigurationRecord& avc_config,
36 std::vector<uint8>* buffer, 35 std::vector<uint8_t>* buffer,
37 std::vector<SubsampleEntry>* subsamples); 36 std::vector<SubsampleEntry>* subsamples);
38 37
39 static bool ConvertConfigToAnnexB( 38 static bool ConvertConfigToAnnexB(
40 const AVCDecoderConfigurationRecord& avc_config, 39 const AVCDecoderConfigurationRecord& avc_config,
41 std::vector<uint8>* buffer); 40 std::vector<uint8_t>* buffer);
42 41
43 // Verifies that the contents of |buffer| conform to 42 // Verifies that the contents of |buffer| conform to
44 // Section 7.4.1.2.3 of ISO/IEC 14496-10. 43 // Section 7.4.1.2.3 of ISO/IEC 14496-10.
45 // |subsamples| contains the information about what parts of the buffer are 44 // |subsamples| contains the information about what parts of the buffer are
46 // encrypted and which parts are clear. 45 // encrypted and which parts are clear.
47 // Returns true if |buffer| contains conformant Annex B data 46 // Returns true if |buffer| contains conformant Annex B data
48 // TODO(acolwell): Remove the std::vector version when we can use, 47 // TODO(acolwell): Remove the std::vector version when we can use,
49 // C++11's std::vector<T>::data() method. 48 // C++11's std::vector<T>::data() method.
50 static bool IsValidAnnexB(const std::vector<uint8>& buffer, 49 static bool IsValidAnnexB(const std::vector<uint8_t>& buffer,
51 const std::vector<SubsampleEntry>& subsamples); 50 const std::vector<SubsampleEntry>& subsamples);
52 static bool IsValidAnnexB(const uint8* buffer, size_t size, 51 static bool IsValidAnnexB(const uint8_t* buffer,
52 size_t size,
53 const std::vector<SubsampleEntry>& subsamples); 53 const std::vector<SubsampleEntry>& subsamples);
54 54
55 // Given a |buffer| and |subsamples| information and |pts| pointer into the 55 // Given a |buffer| and |subsamples| information and |pts| pointer into the
56 // |buffer| finds the index of the subsample |ptr| is pointing into. 56 // |buffer| finds the index of the subsample |ptr| is pointing into.
57 static int FindSubsampleIndex(const std::vector<uint8>& buffer, 57 static int FindSubsampleIndex(const std::vector<uint8_t>& buffer,
58 const std::vector<SubsampleEntry>* subsamples, 58 const std::vector<SubsampleEntry>* subsamples,
59 const uint8* ptr); 59 const uint8_t* ptr);
60 }; 60 };
61 61
62 // AVCBitstreamConverter converts AVC/H.264 bitstream from MP4 container format 62 // AVCBitstreamConverter converts AVC/H.264 bitstream from MP4 container format
63 // with embedded NALU lengths into AnnexB bitstream format (described in ISO/IEC 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 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. 65 // streams and adjusts subsample data for those streams while converting.
66 class AVCBitstreamConverter : public BitstreamConverter { 66 class AVCBitstreamConverter : public BitstreamConverter {
67 public: 67 public:
68 explicit AVCBitstreamConverter( 68 explicit AVCBitstreamConverter(
69 scoped_ptr<AVCDecoderConfigurationRecord> avc_config); 69 scoped_ptr<AVCDecoderConfigurationRecord> avc_config);
70 70
71 // BitstreamConverter interface 71 // BitstreamConverter interface
72 bool ConvertFrame(std::vector<uint8>* frame_buf, 72 bool ConvertFrame(std::vector<uint8_t>* frame_buf,
73 bool is_keyframe, 73 bool is_keyframe,
74 std::vector<SubsampleEntry>* subsamples) const override; 74 std::vector<SubsampleEntry>* subsamples) const override;
75
75 private: 76 private:
76 ~AVCBitstreamConverter() override; 77 ~AVCBitstreamConverter() override;
77 scoped_ptr<AVCDecoderConfigurationRecord> avc_config_; 78 scoped_ptr<AVCDecoderConfigurationRecord> avc_config_;
78 }; 79 };
79 80
80 } // namespace mp4 81 } // namespace mp4
81 } // namespace media 82 } // namespace media
82 83
83 #endif // MEDIA_FORMATS_MP4_AVC_H_ 84 #endif // MEDIA_FORMATS_MP4_AVC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698