OLD | NEW |
---|---|
(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 | |
12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_H264_BITSTREAM_REWRITER_H_ | |
13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_H264_BITSTREAM_REWRITER_H_ | |
14 | |
15 #include "webrtc/base/optional.h" | |
16 #include "webrtc/modules/rtp_rtcp/source/h264/sps_parser.h" | |
17 | |
18 namespace rtc { | |
19 class BitBuffer; | |
20 class BitBufferWriter; | |
21 class ByteBufferWriter; | |
22 } | |
23 | |
24 namespace webrtc { | |
25 | |
26 // A class that copies H264 data from a source to a destination and rewrites | |
noahric
2016/05/18 01:35:06
Since this version only rewrites SPS and only in a
sprang_webrtc
2016/05/20 16:10:59
I'd rather keep it out of SpsParser, since this is
| |
27 // the bitstream in the process to allow for faster decoding for streams that | |
28 // use picture order count type 0. Streams in that format incur additional delay | |
29 // because it allows decode order to differ from render order. | |
30 // The mechanism used is to rewrite (edit or add) the SPS's VUI to contain | |
31 // restrictions on the maximum number of reordered pictures. This reduces | |
32 // latency significantly, though it still adds about a frame of latency to | |
33 // decoding. | |
34 class H264BitstreamRewriter { | |
35 public: | |
36 H264BitstreamRewriter() {} | |
37 // Parses an SPS NALU and if necessary copies it and rewrites the VUI. | |
38 // Returns true on success, and if so sets output_buffer_ to the processed | |
39 // payload. Otherwise return false and leaves output_buffer_ unchanged. | |
40 // Buffer assumes NALU header (first 4 bytes) has already been parsed and is | |
41 // NOT part of this buffer. | |
42 bool ParseAndRewriteSps(const uint8_t* buffer, size_t length); | |
noahric
2016/05/18 01:35:06
Make output_buffer an out param; there's no reason
sprang_webrtc
2016/05/20 16:10:59
I quite dislike output params, but fine :P
I went
| |
43 | |
44 rtc::Optional<SpsParser::SpsState> sps_state_; | |
45 std::unique_ptr<rtc::ByteBufferWriter> output_buffer_; | |
46 | |
47 private: | |
48 bool CopyHrdParameters(rtc::BitBuffer* source, | |
noahric
2016/05/18 01:35:06
These don't need to be on the class (they weren't
sprang_webrtc
2016/05/20 16:10:59
Done.
| |
49 rtc::BitBufferWriter* destination); | |
50 bool AddBitstreamRestriction(rtc::BitBufferWriter* destination, | |
51 uint32_t max_num_ref_frames); | |
52 bool CopyRemainingBits(rtc::BitBuffer* source, | |
53 rtc::BitBufferWriter* destination); | |
54 bool CopyAndRewriteVui(rtc::BitBuffer* source, | |
55 rtc::BitBufferWriter* destination, | |
56 bool* out_vui_rewritten); | |
57 }; | |
58 | |
59 } // namespace webrtc | |
60 | |
61 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_H264_BITSTREAM_REWRITER_H_ | |
OLD | NEW |