sws_helper.h 587 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include <atomic>
  3. #include "headers_ffmpeg.h"
  4. namespace am {
  5. class sws_helper
  6. {
  7. public:
  8. sws_helper();
  9. ~sws_helper();
  10. int init(AVPixelFormat src_fmt,
  11. int src_width,
  12. int src_height,
  13. AVPixelFormat dst_fmt,
  14. int dst_width,
  15. int dst_height);
  16. int convert(const AVFrame *frame, uint8_t **out_data, int *len);
  17. private:
  18. void cleanup();
  19. private:
  20. std::atomic_bool _inited;
  21. AVFrame *_frame;
  22. uint8_t *_buffer;
  23. int _buffer_size;
  24. struct SwsContext *_ctx;
  25. };
  26. } // namespace am