45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "VideoEncoderBase.h"
|
|
|
|
extern "C" {
|
|
#include <libyuv\libyuv.h>
|
|
#include <x264\x264.h>
|
|
}
|
|
|
|
#include "common/config.h"
|
|
|
|
class CX264Encoder : public VideoEncoderBase
|
|
{
|
|
private:
|
|
x264_t* m_pCodec; //编码器实例
|
|
x264_picture_t *m_pPicIn;
|
|
x264_picture_t *m_pPicOut;
|
|
x264_param_t m_Param;
|
|
bool m_forceIDR; // 下一次 encode 强制 IDR
|
|
public:
|
|
// 旧签名保留:被 ScreenCapture 临时直接调;新增 EncoderParams overload 走接口路径
|
|
bool open(int width, int height, int fps, int crf);
|
|
bool open(x264_param_t * param);
|
|
|
|
// VideoEncoderBase
|
|
bool open(const EncoderParams& params) override;
|
|
void close() override;
|
|
int encode(
|
|
uint8_t * rgb,
|
|
uint8_t bpp,
|
|
uint32_t stride,
|
|
uint32_t width,
|
|
uint32_t height,
|
|
uint8_t ** lppData,
|
|
uint32_t * lpSize,
|
|
int direction = 1
|
|
) override;
|
|
void forceIDR() override { m_forceIDR = true; }
|
|
VideoCodec codec() const override { return VideoCodec::H264; }
|
|
const char* backendName() const override { return "x264"; }
|
|
|
|
CX264Encoder();
|
|
~CX264Encoder() override;
|
|
};
|