format_converter.cpp 597 B

12345678910111213141516171819202122
  1. #include "format_converter.h"
  2. FormatConverter::FormatConverter(
  3. size_t width, size_t height,
  4. AVPixelFormat input_pixel_format, AVPixelFormat output_pixel_format) :
  5. width_{width}, height_{height}, conversion_context_{sws_getContext(
  6. // Source
  7. width, height, input_pixel_format,
  8. // Destination
  9. width, height, output_pixel_format,
  10. // Filters
  11. SWS_BICUBIC, nullptr, nullptr, nullptr)} {
  12. }
  13. void FormatConverter::operator()(AVFrame* src, AVFrame* dst) {
  14. sws_scale(conversion_context_,
  15. // Source
  16. src->data, src->linesize, 0, height_,
  17. // Destination
  18. dst->data, dst->linesize);
  19. }