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
3 // found in the LICENSE file.
5 #ifndef MEDIA_FORMATS_MP4_AVC_H_
6 #define MEDIA_FORMATS_MP4_AVC_H_
10 #include "base/basictypes.h"
11 #include "media/base/media_export.h"
15 struct SubsampleEntry;
19 struct AVCDecoderConfigurationRecord;
21 class MEDIA_EXPORT AVC {
23 static bool ConvertFrameToAnnexB(int length_size, std::vector<uint8>* buffer);
25 // Inserts the SPS & PPS data from |avc_config| into |buffer|.
26 // |buffer| is expected to contain AnnexB conformant data.
27 // |subsamples| contains the SubsampleEntry info if |buffer| contains
29 // Returns true if the param sets were successfully inserted.
30 static bool InsertParamSetsAnnexB(
31 const AVCDecoderConfigurationRecord& avc_config,
32 std::vector<uint8>* buffer,
33 std::vector<SubsampleEntry>* subsamples);
35 static bool ConvertConfigToAnnexB(
36 const AVCDecoderConfigurationRecord& avc_config,
37 std::vector<uint8>* buffer,
38 std::vector<SubsampleEntry>* subsamples);
40 // Verifies that the contents of |buffer| conform to
41 // Section 7.4.1.2.3 of ISO/IEC 14496-10.
42 // Returns true if |buffer| contains conformant Annex B data
43 // TODO(acolwell): Remove the std::vector version when we can use,
44 // C++11's std::vector<T>::data() method.
45 static bool IsValidAnnexB(const std::vector<uint8>& buffer);
46 static bool IsValidAnnexB(const uint8* buffer, size_t size);
52 #endif // MEDIA_FORMATS_MP4_AVC_H_