blob: a420ac0fdd4247f34f3be97199bdf97a84ec8639 [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
Elad Alon38ac7bf2019-04-23 13:03:18 +020050 bool IntraFrame() const {
51 // Intra frames do not reference any buffers, and update all buffers.
52 return last_buffer_flags == kUpdate && golden_buffer_flags == kUpdate &&
53 arf_buffer_flags == kUpdate;
54 }
55
Elad Alon411b49b2019-01-29 14:05:55 +010056 bool drop_frame;
57 BufferFlags last_buffer_flags;
58 BufferFlags golden_buffer_flags;
59 BufferFlags arf_buffer_flags;
60
61 // The encoder layer ID is used to utilize the correct bitrate allocator
62 // inside the encoder. It does not control references nor determine which
63 // "actual" temporal layer this is. The packetizer temporal index determines
64 // which layer the encoded frame should be packetized into.
65 // Normally these are the same, but current temporal-layer strategies for
66 // screenshare use one bitrate allocator for all layers, but attempt to
67 // packetize / utilize references to split a stream into multiple layers,
68 // with different quantizer settings, to hit target bitrate.
69 // TODO(sprang): Screenshare layers are being reconsidered at the time of
70 // writing, we might be able to remove this distinction, and have a temporal
71 // layer imply both (the normal case).
72 int encoder_layer_id;
73 // TODO(eladalon/sprang): Move out of this class.
74 int packetizer_temporal_idx;
75
76 // TODO(eladalon/sprang): Move out of this class.
77 bool layer_sync;
78
79 bool freeze_entropy;
80
81 // Indicates in which order the encoder should search the reference buffers
82 // when doing motion prediction. Set to kNone to use unspecified order. Any
83 // buffer indicated here must not have the corresponding no_ref bit set.
84 // If all three buffers can be reference, the one not listed here should be
85 // searched last.
86 Vp8BufferReference first_reference;
87 Vp8BufferReference second_reference;
88
89 private:
90 Vp8FrameConfig(BufferFlags last,
91 BufferFlags golden,
92 BufferFlags arf,
93 bool freeze_entropy);
94};
95
96} // namespace webrtc
97
98#endif // API_VIDEO_CODECS_VP8_FRAME_CONFIG_H_