mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-21 05:53:12 -07:00
Move FFMPEG Decoder to lib
This commit is contained in:
parent
aba17d48a3
commit
673a2de9c1
24 changed files with 566 additions and 350 deletions
|
@ -100,6 +100,8 @@ static inline bool chiaki_codec_is_hdr(ChiakiCodec codec)
|
|||
return codec == CHIAKI_CODEC_H265_HDR;
|
||||
}
|
||||
|
||||
CHIAKI_EXPORT const char *chiaki_codec_name(ChiakiCodec codec);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
43
lib/include/chiaki/ffmpegdecoder.h
Normal file
43
lib/include/chiaki/ffmpegdecoder.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
#ifndef CHIAKI_FFMPEG_DECODER_H
|
||||
#define CHIAKI_FFMPEG_DECODER_H
|
||||
|
||||
#include <chiaki/config.h>
|
||||
#include <chiaki/log.h>
|
||||
#include <chiaki/thread.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
||||
typedef struct chiaki_ffmpeg_decoder_t ChiakiFfmpegDecoder;
|
||||
|
||||
typedef void (*ChiakiFfmpegFrameAvailable)(ChiakiFfmpegDecoder *decover, void *user);
|
||||
|
||||
struct chiaki_ffmpeg_decoder_t
|
||||
{
|
||||
ChiakiLog *log;
|
||||
ChiakiMutex mutex;
|
||||
AVCodec *av_codec;
|
||||
AVCodecContext *codec_context;
|
||||
enum AVPixelFormat hw_pix_fmt;
|
||||
AVBufferRef *hw_device_ctx;
|
||||
ChiakiMutex cb_mutex;
|
||||
ChiakiFfmpegFrameAvailable frame_available_cb;
|
||||
void *frame_available_cb_user;
|
||||
};
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_ffmpeg_decoder_init(ChiakiFfmpegDecoder *decoder, ChiakiLog *log,
|
||||
ChiakiCodec codec, const char *hw_decoder_name,
|
||||
ChiakiFfmpegFrameAvailable frame_available_cb, void *frame_available_cb_user);
|
||||
CHIAKI_EXPORT void chiaki_ffmpeg_decoder_fini(ChiakiFfmpegDecoder *decoder);
|
||||
CHIAKI_EXPORT bool chiaki_ffmpeg_decoder_video_sample_cb(uint8_t *buf, size_t buf_size, void *user);
|
||||
CHIAKI_EXPORT AVFrame *chiaki_ffmpeg_decoder_pull_frame(ChiakiFfmpegDecoder *decoder);
|
||||
CHIAKI_EXPORT enum AVPixelFormat chiaki_ffmpeg_decoder_get_pixel_format(ChiakiFfmpegDecoder *decoder);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CHIAKI_FFMPEG_DECODER_H
|
|
@ -50,6 +50,20 @@ CHIAKI_EXPORT void chiaki_log_hexdump_raw(ChiakiLog *log, ChiakiLogLevel level,
|
|||
#define CHIAKI_LOGW(log, ...) do { chiaki_log((log), CHIAKI_LOG_WARNING, __VA_ARGS__); } while(0)
|
||||
#define CHIAKI_LOGE(log, ...) do { chiaki_log((log), CHIAKI_LOG_ERROR, __VA_ARGS__); } while(0)
|
||||
|
||||
typedef struct chiaki_log_sniffer_t
|
||||
{
|
||||
ChiakiLog *forward_log; // The original log, where everything is forwarded
|
||||
ChiakiLog sniff_log; // The log where others will log into
|
||||
uint32_t sniff_level_mask;
|
||||
char *buf; // always null-terminated
|
||||
size_t buf_len; // strlen(buf)
|
||||
} ChiakiLogSniffer;
|
||||
|
||||
CHIAKI_EXPORT void chiaki_log_sniffer_init(ChiakiLogSniffer *sniffer, uint32_t level_mask, ChiakiLog *forward_log);
|
||||
CHIAKI_EXPORT void chiaki_log_sniffer_fini(ChiakiLogSniffer *sniffer);
|
||||
static inline ChiakiLog *chiaki_log_sniffer_get_log(ChiakiLogSniffer *sniffer) { return &sniffer->sniff_log; }
|
||||
static inline const char *chiaki_log_sniffer_get_buffer(ChiakiLogSniffer *sniffer) { return sniffer->buf; }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue