2024-06-26 11:51:59 +00:00
|
|
|
#ifndef AVVIDEODECODER_HPP
|
|
|
|
#define AVVIDEODECODER_HPP
|
|
|
|
|
2024-09-27 18:00:31 +00:00
|
|
|
#include "Printer/BambuTunnel.h"
|
2024-06-26 11:51:59 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libswscale/swscale.h>
|
|
|
|
}
|
2024-10-16 20:59:30 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <wx/bitmap.h>
|
|
|
|
#include <wx/gdicmn.h>
|
|
|
|
#include <wx/image.h>
|
|
|
|
|
2024-06-26 11:51:59 +00:00
|
|
|
class wxBitmap;
|
|
|
|
|
|
|
|
class AVVideoDecoder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AVVideoDecoder();
|
|
|
|
|
|
|
|
~AVVideoDecoder();
|
|
|
|
|
|
|
|
public:
|
|
|
|
int open(Bambu_StreamInfo const &info);
|
|
|
|
|
|
|
|
int decode(Bambu_Sample const &sample);
|
|
|
|
|
|
|
|
int flush();
|
|
|
|
|
|
|
|
void close();
|
|
|
|
|
|
|
|
bool toWxImage(wxImage &image, wxSize const &size);
|
|
|
|
|
|
|
|
bool toWxBitmap(wxBitmap &bitmap, wxSize const & size);
|
|
|
|
|
|
|
|
private:
|
|
|
|
AVCodecContext *codec_ctx_ = nullptr;
|
|
|
|
AVFrame * frame_ = nullptr;
|
|
|
|
SwsContext * sws_ctx_ = nullptr;
|
|
|
|
bool got_frame_ = false;
|
2024-10-12 03:33:52 +00:00
|
|
|
int width_ { 0 }; // scale result width
|
2024-07-12 09:00:24 +00:00
|
|
|
std::vector<uint8_t> bits_;
|
2024-06-26 11:51:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // AVVIDEODECODER_HPP
|