perf: 降低串流延迟(软编降档、编码器实时参数、NV12 转换与绘制优化)
- VideoEncoder 按实时流配置编码器:实时优先、不攒帧(KEY_LATENCY)、 禁 B 帧、CBR;个别 ROM 拒绝这些参数时自动退回默认配置 - 新增 VideoEncoder.isSoftwareEncoder:全部候选编码器都是 c2.android./OMX.google. 时判定为软编,ReceiverSession 把长边上限从 1920 降到 1280 (模拟器实测 864x1920 → 576x1280,滑动时帧率明显回升) - ConvertNv12 改为每 2 个像素复用一次 U/V 计算,裁剪改成无分支写法 - 串流窗口画面铺满客户区时跳过整屏刷黑,省一次全屏填充 - README 3.4 补充编码器实时配置与软编降档说明
This commit is contained in:
1 parent
04f2b800b2
commit
cbbc2a642d
5 files changed
+135
-30
No files matched your search
@@ -307,7 +307,6 @@ void VideoWindow::Paint() {
|
||||
target = back_dc_;
|
||||
}
|
||||
}
|
||||
FillRect(target, &client, static_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)));
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
@@ -333,6 +332,13 @@ void VideoWindow::Paint() {
|
||||
const int offset_x = client.left + (client_width - draw_width) / 2;
|
||||
const int offset_y = client.top + (client_height - draw_height) / 2;
|
||||
|
||||
// 画面正好铺满客户区时不用先刷黑:StretchDIBits 会把整块覆盖掉,
|
||||
// 省掉每秒几十次的全屏填充(1080p 一帧就是 8MB 内存带宽)。
|
||||
if (draw_width < client_width || draw_height < client_height) {
|
||||
FillRect(target, &client,
|
||||
static_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)));
|
||||
}
|
||||
|
||||
// 记住这一帧的尺寸和实际绘制矩形,鼠标点击时据此换算成画面像素。
|
||||
frame_width_ = width;
|
||||
frame_height_ = height;
|
||||
@@ -352,6 +358,8 @@ void VideoWindow::Paint() {
|
||||
StretchDIBits(target, offset_x, offset_y, draw_width, draw_height, 0, 0,
|
||||
width, height, frame->data(), &info, DIB_RGB_COLORS, SRCCOPY);
|
||||
} else {
|
||||
FillRect(target, &client,
|
||||
static_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)));
|
||||
// 还没有画面:清掉坐标映射,避免拿上一路的尺寸误点。
|
||||
frame_width_ = 0;
|
||||
frame_height_ = 0;
|
||||
|
||||
Reference in new issue
Block a user