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