1 // Copyright 2016 The Chromium Authors
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_FILTERS_VP9_COMPRESSED_HEADER_PARSER_H_
6 #define MEDIA_FILTERS_VP9_COMPRESSED_HEADER_PARSER_H_
8 #include "media/filters/vp9_bool_decoder.h"
9 #include "media/filters/vp9_parser.h"
13 class Vp9CompressedHeaderParser {
15 Vp9CompressedHeaderParser();
17 Vp9CompressedHeaderParser(const Vp9CompressedHeaderParser&) = delete;
18 Vp9CompressedHeaderParser& operator=(const Vp9CompressedHeaderParser&) =
21 // Parses VP9 compressed header in |stream| with |frame_size| into |fhdr|.
22 // Returns true if no error.
23 bool Parse(const uint8_t* stream, off_t frame_size, Vp9FrameHeader* fhdr);
24 // Similar to Parse() but will store the deltaProb in the context instead of
25 // updating existing probabilities. (see 6.3.3 Diff update prob syntax)
26 bool ParseNoContext(const uint8_t* stream,
28 Vp9FrameHeader* fhdr);
31 bool ParseInternal(const uint8_t* stream,
33 Vp9FrameHeader* fhdr);
35 void ReadTxMode(Vp9FrameHeader* fhdr);
36 uint8_t DecodeTermSubexp();
37 void DiffUpdateProb(Vp9Prob* prob);
39 void DiffUpdateProbArray(Vp9Prob (&prob_array)[N]);
40 void ReadTxModeProbs(Vp9FrameContext* frame_context);
41 void ReadCoefProbs(Vp9FrameHeader* fhdr);
42 void ReadSkipProb(Vp9FrameContext* frame_context);
43 void ReadInterModeProbs(Vp9FrameContext* frame_context);
44 void ReadInterpFilterProbs(Vp9FrameContext* frame_context);
45 void ReadIsInterProbs(Vp9FrameContext* frame_context);
46 void ReadFrameReferenceMode(Vp9FrameHeader* fhdr);
47 void ReadFrameReferenceModeProbs(Vp9FrameHeader* fhdr);
48 void ReadYModeProbs(Vp9FrameContext* frame_context);
49 void ReadPartitionProbs(Vp9FrameContext* frame_context);
50 void ReadMvProbs(bool allow_high_precision_mv,
51 Vp9FrameContext* frame_context);
52 void UpdateMvProb(Vp9Prob* prob);
54 void UpdateMvProbArray(Vp9Prob (&prob_array)[N]);
56 // Bool decoder for compressed frame header.
57 Vp9BoolDecoder reader_;
59 // Used to change behaviour when parsing without previous frame context. Set
60 // by Parse()/ParseNoContext()
61 bool have_frame_context_ = true;
66 #endif // MEDIA_FILTERS_VP9_COMPRESSED_HEADER_PARSER_H_