vp8_frame_config.h 3.6 KB

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