1// Copyright 2013 Google Inc. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// This class models a sequence of literals and a backward reference copy.
16
17#ifndef BROTLI_ENC_COMMAND_H_
18#define BROTLI_ENC_COMMAND_H_
19
20#include <stdint.h>
21
22namespace brotli {
23
24// Command holds a sequence of literals and a backward reference copy.
25class Command {
26 public:
27  // distance_code_ is initialized to 17 because it refers to the distance
28  // code of a backward distance of 1, this way the last insert-only command
29  // won't use the last-distance short code, and accordingly distance_prefix_ is
30  // set to 16
31  Command() : insert_length_(0), copy_length_(0), copy_length_code_(0),
32              copy_distance_(0), distance_code_(17),
33              distance_prefix_(16), command_prefix_(0),
34              distance_extra_bits_(0), distance_extra_bits_value_(0) {}
35
36  uint32_t insert_length_;
37  uint32_t copy_length_;
38  uint32_t copy_length_code_;
39  uint32_t copy_distance_;
40  // Values <= 16 are short codes, values > 16 are distances shifted by 16.
41  uint32_t distance_code_;
42  uint16_t distance_prefix_;
43  uint16_t command_prefix_;
44  int distance_extra_bits_;
45  uint32_t distance_extra_bits_value_;
46};
47
48}  // namespace brotli
49
50#endif  // BROTLI_ENC_COMMAND_H_
51