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

Side by Side Diff: media/filters/vp9_bool_decoder.h

Issue 2133993002: Parse VP9 compressed header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reset curr_frame_info_ when Reset Created 4 years, 4 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
« no previous file with comments | « media/BUILD.gn ('k') | media/filters/vp9_bool_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #ifndef MEDIA_FILTERS_VP9_BOOL_DECODER_H_
6 #define MEDIA_FILTERS_VP9_BOOL_DECODER_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <memory>
12
13 #include "base/macros.h"
14 #include "media/base/media_export.h"
15
16 namespace media {
17
18 class BitReader;
19
20 class MEDIA_EXPORT Vp9BoolDecoder {
21 public:
22 Vp9BoolDecoder();
23 ~Vp9BoolDecoder();
24
25 // |data| is the input buffer with |size| bytes.
26 // Returns true if read first marker bit successfully.
27 bool Initialize(const uint8_t* data, size_t size);
28
29 // Returns true if none of the reads since the last Initialize() call has
30 // gone beyond the end of available data.
31 bool IsValid() const { return valid_; }
32
33 // Reads one bit. B(p).
34 // If the read goes beyond the end of buffer, the return value is undefined.
35 bool ReadBool(int prob);
36
37 // Reads a literal. L(n).
38 // If the read goes beyond the end of buffer, the return value is undefined.
39 uint8_t ReadLiteral(int bits);
40
41 // Consumes padding bits up to end of data. Returns true if no
42 // padding bits or they are all zero.
43 bool ConsumePaddingBits();
44
45 private:
46 // The highest 8 bits of BigBool is actual "bool value". The remain bits
47 // are optimization of prefill buffer.
48 using BigBool = size_t;
49 // The size of "bool value" used for boolean decoding defined in spec.
50 const int kBoolSize = 8;
51 const int kBigBoolBitSize = sizeof(BigBool) * 8;
52
53 bool Fill();
54
55 std::unique_ptr<BitReader> reader_;
56
57 // Indicates if none of the reads since the last Initialize() call has gone
58 // beyond the end of available data.
59 bool valid_ = true;
60
61 BigBool bool_value_ = 0;
62
63 // Need to fill at least |count_to_fill_| bits. Negative value means extra
64 // bits pre-filled.
65 int count_to_fill_ = 0;
66 unsigned int bool_range_ = 0;
67
68 DISALLOW_COPY_AND_ASSIGN(Vp9BoolDecoder);
69 };
70
71 } // namespace media
72
73 #endif // MEDIA_FILTERS_VP9_BOOL_DECODER_H_
OLDNEW
« no previous file with comments | « media/BUILD.gn ('k') | media/filters/vp9_bool_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698