blob: e610a87672d361873fd6dd17b53c6d017ec8d669 [file] [log] [blame]
Elad Alon411b49b2019-01-29 14:05:55 +01001/*
2 * Copyright (c) 2019 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#ifndef API_VIDEO_CODECS_VP8_FRAME_CONFIG_H_
12#define API_VIDEO_CODECS_VP8_FRAME_CONFIG_H_
13
14#include <stdint.h>
15
16namespace webrtc {
17
18struct Vp8FrameConfig {
19 enum BufferFlags : int {
20 kNone = 0,
21 kReference = 1,
22 kUpdate = 2,
23 kReferenceAndUpdate = kReference | kUpdate,
24 };
25
26 enum FreezeEntropy { kFreezeEntropy };
27
28 // Defined bit-maskable reference to the three buffers available in VP8.
29 enum class Vp8BufferReference : uint8_t {
30 kNone = 0,
31 kLast = 1,
32 kGolden = 2,
33 kAltref = 4
34 };
35
36 Vp8FrameConfig();
37
38 Vp8FrameConfig(BufferFlags last, BufferFlags golden, BufferFlags arf);
39 Vp8FrameConfig(BufferFlags last,
40 BufferFlags golden,
41 BufferFlags arf,
42 FreezeEntropy);
43
44 enum class Buffer : int { kLast = 0, kGolden = 1, kArf = 2, kCount };
45
46 bool References(Buffer buffer) const;
47
48 bool Updates(Buffer buffer) const;
49
50 bool drop_frame;
51 BufferFlags last_buffer_flags;
52 BufferFlags golden_buffer_flags;
53 BufferFlags arf_buffer_flags;
54
55 // The encoder layer ID is used to utilize the correct bitrate allocator
56 // inside the encoder. It does not control references nor determine which
57 // "actual" temporal layer this is. The packetizer temporal index determines
58 // which layer the encoded frame should be packetized into.
59 // Normally these are the same, but current temporal-layer strategies for
60 // screenshare use one bitrate allocator for all layers, but attempt to
61 // packetize / utilize references to split a stream into multiple layers,
62 // with different quantizer settings, to hit target bitrate.
63 // TODO(sprang): Screenshare layers are being reconsidered at the time of
64 // writing, we might be able to remove this distinction, and have a temporal
65 // layer imply both (the normal case).
66 int encoder_layer_id;
67 // TODO(eladalon/sprang): Move out of this class.
68 int packetizer_temporal_idx;
69
70 // TODO(eladalon/sprang): Move out of this class.
71 bool layer_sync;
72
73 bool freeze_entropy;
74
75 // Indicates in which order the encoder should search the reference buffers
76 // when doing motion prediction. Set to kNone to use unspecified order. Any
77 // buffer indicated here must not have the corresponding no_ref bit set.
78 // If all three buffers can be reference, the one not listed here should be
79 // searched last.
80 Vp8BufferReference first_reference;
81 Vp8BufferReference second_reference;
82
83 private:
84 Vp8FrameConfig(BufferFlags last,
85 BufferFlags golden,
86 BufferFlags arf,
87 bool freeze_entropy);
88};
89
90} // namespace webrtc
91
92#endif // API_VIDEO_CODECS_VP8_FRAME_CONFIG_H_