blob: b70eddfc534637dcc59255b6106486f9bd78b62a [file] [log] [blame]
Danil Chapovalov02b17a52020-02-05 15:06:17 +01001/*
2 * Copyright (c) 2020 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 MODULES_VIDEO_CODING_FRAME_DEPENDENCIES_CALCULATOR_H_
12#define MODULES_VIDEO_CODING_FRAME_DEPENDENCIES_CALCULATOR_H_
13
14#include <stdint.h>
15
16#include <vector>
17
18#include "absl/container/inlined_vector.h"
19#include "absl/types/optional.h"
20#include "api/array_view.h"
21#include "api/video/video_frame_type.h"
22#include "common_video/generic_frame_descriptor/generic_frame_info.h"
Danil Chapovalov02b17a52020-02-05 15:06:17 +010023
24namespace webrtc {
25
Danil Chapovalov02d71fb2020-02-10 16:22:57 +010026// This class is thread compatible.
Danil Chapovalov02b17a52020-02-05 15:06:17 +010027class FrameDependenciesCalculator {
28 public:
29 FrameDependenciesCalculator() = default;
Danil Chapovalov02d71fb2020-02-10 16:22:57 +010030 FrameDependenciesCalculator(const FrameDependenciesCalculator&) = default;
31 FrameDependenciesCalculator& operator=(const FrameDependenciesCalculator&) =
Danil Chapovalov02b17a52020-02-05 15:06:17 +010032 default;
33
34 // Calculates frame dependencies based on previous encoder buffer usage.
35 absl::InlinedVector<int64_t, 5> FromBuffersUsage(
36 VideoFrameType frame_type,
37 int64_t frame_id,
38 rtc::ArrayView<const CodecBufferUsage> buffers_usage);
39
40 private:
41 struct BufferUsage {
42 absl::optional<int64_t> frame_id;
43 absl::InlinedVector<int64_t, 4> dependencies;
44 };
45
Danil Chapovalov02d71fb2020-02-10 16:22:57 +010046 absl::InlinedVector<BufferUsage, 4> buffers_;
Danil Chapovalov02b17a52020-02-05 15:06:17 +010047};
48
49} // namespace webrtc
50
51#endif // MODULES_VIDEO_CODING_FRAME_DEPENDENCIES_CALCULATOR_H_