frame_dependencies_calculator.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #ifndef MODULES_VIDEO_CODING_FRAME_DEPENDENCIES_CALCULATOR_H_
  11. #define MODULES_VIDEO_CODING_FRAME_DEPENDENCIES_CALCULATOR_H_
  12. #include <stdint.h>
  13. #include <vector>
  14. #include "absl/container/inlined_vector.h"
  15. #include "absl/types/optional.h"
  16. #include "api/array_view.h"
  17. #include "api/video/video_frame_type.h"
  18. #include "common_video/generic_frame_descriptor/generic_frame_info.h"
  19. namespace webrtc {
  20. // This class is thread compatible.
  21. class FrameDependenciesCalculator {
  22. public:
  23. FrameDependenciesCalculator() = default;
  24. FrameDependenciesCalculator(const FrameDependenciesCalculator&) = default;
  25. FrameDependenciesCalculator& operator=(const FrameDependenciesCalculator&) =
  26. default;
  27. // Calculates frame dependencies based on previous encoder buffer usage.
  28. absl::InlinedVector<int64_t, 5> FromBuffersUsage(
  29. VideoFrameType frame_type,
  30. int64_t frame_id,
  31. rtc::ArrayView<const CodecBufferUsage> buffers_usage);
  32. private:
  33. struct BufferUsage {
  34. absl::optional<int64_t> frame_id;
  35. absl::InlinedVector<int64_t, 4> dependencies;
  36. };
  37. absl::InlinedVector<BufferUsage, 4> buffers_;
  38. };
  39. } // namespace webrtc
  40. #endif // MODULES_VIDEO_CODING_FRAME_DEPENDENCIES_CALCULATOR_H_