webrtc支持的最小宽度和高度

代码在:h264/sps_parser.cc

cpp 复制代码
//
// IMPORTANT ONES! Now we're getting to resolution. First we read the pic
// width/height in macroblocks (16x16), which gives us the base resolution,
// and then we continue on until we hit the frame crop offsets, which are used
// to signify resolutions that aren't multiples of 16.
//
// pic_width_in_mbs_minus1: ue(v)
sps.width = 16 * (reader.ReadExponentialGolomb() + 1);
cpp 复制代码
// Figure out the crop units in pixels. That's based on the chroma format's
// sampling, which is indicated by chroma_format_idc.
if (sps.separate_colour_plane_flag || chroma_format_idc == 0) {
  frame_crop_bottom_offset *= (2 - sps.frame_mbs_only_flag);
  frame_crop_top_offset *= (2 - sps.frame_mbs_only_flag);
} else if (!sps.separate_colour_plane_flag && chroma_format_idc > 0) {
  // Width multipliers for formats 1 (4:2:0) and 2 (4:2:2).
  if (chroma_format_idc == 1 || chroma_format_idc == 2) {
    frame_crop_left_offset *= 2;
    frame_crop_right_offset *= 2;
  }
  // Height multipliers for format 1 (4:2:0).
  if (chroma_format_idc == 1) {
    frame_crop_top_offset *= 2;
    frame_crop_bottom_offset *= 2;
  }
}
// Subtract the crop for each dimension.
sps.width -= (frame_crop_left_offset + frame_crop_right_offset);
sps.height -= (frame_crop_top_offset + frame_crop_bottom_offset);

读取图像的宽度和高度,以宏块(16x16)为单位,这给出了基本分辨率。然后,继续读取直到遇到帧裁剪偏移量,这些偏移量用于表示不是16的倍数的分辨率。

在这段代码中,"pic_width_in_mbs_minus1" 是一个无符号指数哥伦布编码(ue(v)),用于计算图像的宽度。最后一行代码则将图像的宽度设置为16乘以读取的值加1。

根据色度格式和色度平面标志来调整帧的裁剪偏移量,然后根据计算得到的偏移量来调整图像的宽度和高度,以实现正确的裁剪。

即支持16x16的块,然后按2的倍数做裁减。

相关推荐
福大大架构师每日一题16 小时前
mediamtx v1.21.0 发布:Media-over-QUIC、RTSP、HLS、WebRTC 与安全能力全面升级
安全·webrtc
脏脏a2 天前
Neko 自托管实战:WebRTC 远程浏览器、多用户权限与公网访问
webrtc
cuijiecheng20183 天前
从 6.49 秒到约 1.9 秒:RK3588上的WebRTC 实时流启动速度优化记录
webrtc
SendTomo4 天前
SendTomo 与 send.wang 全景对比评测与实战指南
网络·网络协议·tcp/ip·webrtc·p2p
java_logo4 天前
Docker 部署 SRS:轻松搭建实时音视频流媒体平台
docker·容器·webrtc·实时音视频·rtmp·http-flv·轩辕镜像
wjcroom5 天前
一个可以在线多人玩的五子棋开发与布署方法-WebRTC和WebSocket的测试方法
websocket·网络协议·webrtc
cuijiecheng20188 天前
RK3588 WebRTC 实时流卡顿优化:从视频桥接到 H.264 PTS 回退
音视频·webrtc·h.264
SendTomo10 天前
send.wang:基于浏览器WebRTC实现无客户端文件互传
网络·python·网络协议·webrtc·p2p
应用市场16 天前
无线控制与图传协议全景:从 S.BUS 到 WebRTC,一篇讲透遥控、数传与视频链路
音视频·webrtc
福大大架构师每日一题16 天前
webrtc-rs/webrtc v0.20.3更新:Android 网络切换后 ICE Restart 卡死约 10 秒的问题终于解决
android·网络·webrtc