Danil Chapovalov | 02b17a5 | 2020-02-05 14:06:17 | [diff] [blame] | 1 | /* |
| 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" |
Danil Chapovalov | 02b17a5 | 2020-02-05 14:06:17 | [diff] [blame] | 21 | #include "common_video/generic_frame_descriptor/generic_frame_info.h" |
Danil Chapovalov | 02b17a5 | 2020-02-05 14:06:17 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
| 24 | |
Danil Chapovalov | 02d71fb | 2020-02-10 15:22:57 | [diff] [blame] | 25 | // This class is thread compatible. |
Danil Chapovalov | 02b17a5 | 2020-02-05 14:06:17 | [diff] [blame] | 26 | class FrameDependenciesCalculator { |
| 27 | public: |
| 28 | FrameDependenciesCalculator() = default; |
Danil Chapovalov | 02d71fb | 2020-02-10 15:22:57 | [diff] [blame] | 29 | FrameDependenciesCalculator(const FrameDependenciesCalculator&) = default; |
| 30 | FrameDependenciesCalculator& operator=(const FrameDependenciesCalculator&) = |
Danil Chapovalov | 02b17a5 | 2020-02-05 14:06:17 | [diff] [blame] | 31 | default; |
| 32 | |
| 33 | // Calculates frame dependencies based on previous encoder buffer usage. |
| 34 | absl::InlinedVector<int64_t, 5> FromBuffersUsage( |
Danil Chapovalov | 02b17a5 | 2020-02-05 14:06:17 | [diff] [blame] | 35 | int64_t frame_id, |
| 36 | rtc::ArrayView<const CodecBufferUsage> buffers_usage); |
| 37 | |
| 38 | private: |
| 39 | struct BufferUsage { |
| 40 | absl::optional<int64_t> frame_id; |
| 41 | absl::InlinedVector<int64_t, 4> dependencies; |
| 42 | }; |
| 43 | |
Danil Chapovalov | 02d71fb | 2020-02-10 15:22:57 | [diff] [blame] | 44 | absl::InlinedVector<BufferUsage, 4> buffers_; |
Danil Chapovalov | 02b17a5 | 2020-02-05 14:06:17 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | } // namespace webrtc |
| 48 | |
| 49 | #endif // MODULES_VIDEO_CODING_FRAME_DEPENDENCIES_CALCULATOR_H_ |