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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/h264/h264_common.h

Issue 1979443004: Add H264 bitstream rewriting to limit frame reordering marker in header (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed compiler warning on win Created 4 years, 7 months 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
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_H264_H264_COMMON_H_
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_H264_H264_COMMON_H_
13
14 #include <memory>
15 #include <vector>
16
17 #include "webrtc/base/common.h"
18 #include "webrtc/base/buffer.h"
19
20 namespace webrtc {
21
22 class H264Common {
stefan-webrtc 2016/05/22 23:11:50 Should this be a namespace instead, maybe?
sprang_webrtc 2016/05/25 09:06:02 Done.
23 public:
24 // The size of a full NALU start sequence {0 0 0 1}, used for the first NALU
25 // of an access unit, and for SPS and PPS blocks.
26 static const size_t kNaluLongStartSequenceSize;
27
28 // The size of a shortened NALU start sequence {0 0 1}, that may be used if
29 // not the first NALU of an access unit or an SPS or PPS block.
30 static const size_t kNaluShortStartSequenceSize;
31
32 // The size of the NALU type byte (1).
33 static const size_t kNaluTypeSize;
34
35 enum NaluType : uint8_t {
36 kIdr = 5,
37 kSei = 6,
38 kSps = 7,
39 kPps = 8,
40 kAud = 9,
41 kEndOfSequence = 10,
42 kEndOfStream = 11,
43 kFiller = 12
44 };
45 enum SliceType : uint8_t { P = 0, B = 1, I = 2, Sp = 3, Si = 4 };
stefan-webrtc 2016/05/22 23:11:50 Empty line above. You should probably add k befor
sprang_webrtc 2016/05/25 09:06:02 Done.
46
47 struct NaluIndex {
48 // Start index of NALU, including start sequence.
49 size_t start_offset;
50 // Start index of NALU payload, typically type header.
51 size_t payload_start_offset;
52 // Length of NALU payload, in bytes, counting from payload_start_offset.
53 size_t payload_size;
54 };
55
56 // Returns a vector of the NALU indices in the given buffer.
57 static std::vector<NaluIndex> FindNaluIndices(const uint8_t* buffer,
58 size_t buffer_size);
59
60 // Get the NAL type from the header byte immediately following start sequence.
61 static NaluType ParseNaluType(uint8_t data);
62
63 // Parse the given data and remove any emulation byte escaping.
64 static std::unique_ptr<rtc::Buffer> ParseRbsp(const uint8_t* data,
65 size_t length);
66
67 // Write the given data to the destination buffer, inserting and emulation
68 // bytes in order to escape any data the could be interpreted as a start
69 // sequence.
70 static void WriteRbsp(const uint8_t* bytes,
71 size_t length,
72 rtc::Buffer* destination);
73 };
74
75 } // namespace webrtc
76
77 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_H264_H264_COMMON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698