2024-10-08 02:29:00 +00:00
|
|
|
#ifndef DECODER_H
|
|
|
|
#define DECODER_H
|
|
|
|
|
2024-11-02 02:19:01 +00:00
|
|
|
#include <filesystem>
|
|
|
|
|
2024-10-10 07:23:13 +00:00
|
|
|
extern "C" {
|
2024-10-08 02:29:00 +00:00
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libavformat/avformat.h>
|
2024-10-10 07:23:13 +00:00
|
|
|
}
|
2024-10-08 02:29:00 +00:00
|
|
|
|
2024-11-17 00:00:00 +00:00
|
|
|
class Decoder {
|
|
|
|
public:
|
|
|
|
Decoder();
|
|
|
|
~Decoder();
|
|
|
|
|
|
|
|
int init(AVHWDeviceType hw_type, AVBufferRef *hw_ctx, const std::filesystem::path &in_fpath);
|
|
|
|
|
|
|
|
AVFormatContext *get_format_context() const;
|
|
|
|
AVCodecContext *get_codec_context() const;
|
|
|
|
int get_video_stream_index() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static enum AVPixelFormat hw_pix_fmt_;
|
|
|
|
static enum AVPixelFormat
|
|
|
|
get_hw_format(AVCodecContext *ctx, const enum AVPixelFormat *pix_fmts);
|
|
|
|
|
|
|
|
AVFormatContext *fmt_ctx_;
|
|
|
|
AVCodecContext *dec_ctx_;
|
|
|
|
int in_vstream_idx_;
|
|
|
|
};
|
2024-10-08 02:29:00 +00:00
|
|
|
|
|
|
|
#endif // DECODER_H
|