Feature: Implement H.264 and AV1 hardware encoding for remote control

Remark: Need to update FFmpeg static libraries to take effort
This commit is contained in:
yuanyuanxiang
2026-05-28 11:41:33 +02:00
parent d1aa7a2c02
commit 8c7f612449
30 changed files with 2113 additions and 68 deletions

View File

@@ -1,5 +1,7 @@
#pragma once
#include "VideoEncoderBase.h"
extern "C" {
#include <libyuv\libyuv.h>
#include <x264\x264.h>
@@ -7,19 +9,22 @@ extern "C" {
#include "common/config.h"
class CX264Encoder
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);
void close();
// VideoEncoderBase
bool open(const EncoderParams& params) override;
void close() override;
int encode(
uint8_t * rgb,
uint8_t bpp,
@@ -29,9 +34,11 @@ public:
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();
~CX264Encoder() override;
};