14
14
#include < vector>
15
15
16
16
#include " common_video/h264/h264_common.h"
17
- #include " rtc_base/bit_buffer .h"
17
+ #include " rtc_base/bitstream_reader .h"
18
18
19
19
namespace {
20
20
typedef absl::optional<webrtc::PrefixParser::PrefixState> OptionalPrefix;
@@ -38,46 +38,42 @@ PrefixParser::PrefixState::~PrefixState() = default;
38
38
// Unpack RBSP and parse SVC extension state from the supplied buffer.
39
39
absl::optional<PrefixParser::PrefixState> PrefixParser::ParsePrefix (
40
40
const uint8_t * data,
41
- size_t length) {
41
+ size_t length) {
42
42
std::vector<uint8_t > unpacked_buffer = H264::ParseRbsp (data, length);
43
- rtc::BitBuffer bit_buffer (unpacked_buffer. data (), unpacked_buffer. size () );
44
- return ParsePrefixUpToSvcExtension (&bit_buffer );
43
+ BitstreamReader reader (unpacked_buffer );
44
+ return ParsePrefixUpToSvcExtension (reader );
45
45
}
46
46
47
- absl::optional<PrefixParser::PrefixState> PrefixParser::ParsePrefixUpToSvcExtension (
48
- rtc::BitBuffer* buffer ) {
47
+ absl::optional<PrefixParser::PrefixState>
48
+ PrefixParser::ParsePrefixUpToSvcExtension (BitstreamReader& reader ) {
49
49
// Now, we need to use a bit buffer to parse through the actual SVC extension
50
50
// format. See Section 7.3.1 ("NAL unit syntax") and 7.3.1.1 ("NAL unit header
51
51
// SVC extension syntax") of the H.264 standard for a complete description.
52
-
53
52
PrefixState svc_extension;
54
53
55
- uint32_t svc_extension_flag = 0 ;
56
54
// Make sure the svc_extension_flag is on.
57
- RETURN_EMPTY_ON_FAIL (buffer-> ReadBits (& svc_extension_flag, 1 ) );
55
+ bool svc_extension_flag = reader. ReadBit ( );
58
56
if (!svc_extension_flag)
59
57
return OptionalPrefix ();
60
58
61
59
// idr_flag: u(1)
62
- RETURN_EMPTY_ON_FAIL (buffer-> ReadBits (& svc_extension.idr_flag , 1 ) );
60
+ svc_extension.idr_flag = reader. Read < bool >( );
63
61
// priority_id: u(6)
64
- RETURN_EMPTY_ON_FAIL (buffer-> ReadBits (& svc_extension.priority_id , 6 ) );
62
+ svc_extension.priority_id = reader. ReadBits ( 6 );
65
63
// no_inter_layer_pred_flag: u(1)
66
- RETURN_EMPTY_ON_FAIL (
67
- buffer->ReadBits (&svc_extension.no_inter_layer_pred_flag , 1 ));
64
+ svc_extension.no_inter_layer_pred_flag = reader.Read <bool >();
68
65
// dependency_id: u(3)
69
- RETURN_EMPTY_ON_FAIL (buffer-> ReadBits (& svc_extension.dependency_id , 3 ) );
66
+ svc_extension.dependency_id = reader. ReadBits ( 3 );
70
67
// quality_id: u(4)
71
- RETURN_EMPTY_ON_FAIL (buffer-> ReadBits (& svc_extension.quality_id , 4 ) );
68
+ svc_extension.quality_id = reader. ReadBits ( 4 );
72
69
// temporal_id: u(3)
73
- RETURN_EMPTY_ON_FAIL (buffer-> ReadBits (& svc_extension.temporal_id , 3 ) );
70
+ svc_extension.temporal_id = reader. ReadBits ( 3 );
74
71
// use_ref_base_pic_flag: u(1)
75
- RETURN_EMPTY_ON_FAIL (
76
- buffer->ReadBits (&svc_extension.use_ref_base_pic_flag , 1 ));
72
+ svc_extension.use_ref_base_pic_flag = reader.Read <bool >();
77
73
// discardable_flag: u(1)
78
- RETURN_EMPTY_ON_FAIL (buffer-> ReadBits (& svc_extension.discardable_flag , 1 ) );
74
+ svc_extension.discardable_flag = reader. Read < bool >( );
79
75
// output_flag: u(1)
80
- RETURN_EMPTY_ON_FAIL (buffer-> ReadBits (& svc_extension.output_flag , 1 ) );
76
+ svc_extension.output_flag = reader. Read < bool >( );
81
77
82
78
return OptionalPrefix (svc_extension);
83
79
}
0 commit comments