sws_helper.h 502 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(
  11. AVPixelFormat src_fmt,int src_width,int src_height,
  12. AVPixelFormat dst_fmt,int dst_width,int dst_height
  13. );
  14. int convert(const AVFrame *frame, uint8_t ** out_data, int *len);
  15. private:
  16. void cleanup();
  17. private:
  18. std::atomic_bool _inited;
  19. AVFrame *_frame;
  20. uint8_t *_buffer;
  21. int _buffer_size;
  22. struct SwsContext *_ctx;
  23. };
  24. }