frame_dropper.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef MODULES_VIDEO_CODING_UTILITY_FRAME_DROPPER_H_
  2. #define MODULES_VIDEO_CODING_UTILITY_FRAME_DROPPER_H_
  3. #include <stddef.h>
  4. #include <stdint.h>
  5. #include <string.h>
  6. namespace video_coding {
  7. // The Frame Dropper implements a variant of the leaky bucket algorithm
  8. // for keeping track of when to drop frames to avoid bit rate
  9. // over use when the encoder can't keep its bit rate.
  10. typedef struct _FrameDropper FrameDropper;
  11. FrameDropper *frame_dropper_new();
  12. void frame_dropper_destroy(FrameDropper *obj);
  13. // Resets the FrameDropper to its initial state.
  14. void frame_dropper_reset(FrameDropper *obj);
  15. void frame_dropper_enable(FrameDropper *obj, bool enable);
  16. // Answers the question if it's time to drop a frame if we want to reach a
  17. // given frame rate. Must be called for every frame.
  18. //
  19. // Return value : True if we should drop the current frame.
  20. bool frame_dropper_drop_frame(FrameDropper *obj);
  21. // Updates the FrameDropper with the size of the latest encoded frame.
  22. // The FrameDropper calculates a new drop ratio (can be seen as the
  23. // probability to drop a frame) and updates its internal statistics.
  24. //
  25. // Input:
  26. // - framesize_bytes : The size of the latest frame returned
  27. // from the encoder.
  28. // - delta_frame : True if the encoder returned a key frame.
  29. void frame_dropper_fill(FrameDropper *obj, size_t framesize_bytes, bool delta_frame);
  30. void frame_dropper_leak(FrameDropper *obj, uint32_t input_framerate);
  31. // Sets the target bit rate and the frame rate produced by the camera.
  32. //
  33. // Input:
  34. // - bitrate : The target bit rate. µ¥Î»:kbps
  35. void frame_dropper_set_rates(FrameDropper *obj, float bitrate, float incoming_frame_rate);
  36. }
  37. #endif // MODULES_VIDEO_CODING_UTILITY_FRAME_DROPPER_H_