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的倍数做裁减。

相关推荐
简离4 天前
前端调试实战:基于 chrome://webrtc-internals/ 高效排查WebRTC问题
前端·chrome·webrtc
YYDataV数据可视化5 天前
【P2P音视频通信系统】之 WebRTC Android平台 aar 下载
webrtc·实时音视频
dazhong20126 天前
WebRTC信令简介
webrtc
YYDataV数据可视化6 天前
【P2P音视频通信系统】之TURN 服务详解
音视频·webrtc·实时音视频·ai编程
YYDataV数据可视化6 天前
【P2P音视频通信系统】WebRTC 之 ICE 详解
网络协议·音视频·webrtc·p2p·ice·candidate
YYDataV数据可视化6 天前
【P2P音视频通信系统】webrtc 之 SDP 详解
音视频·webrtc·sdp
YYDataV数据可视化7 天前
【P2P音视频通信系统】之STUN服务详解
webrtc·p2p·stun·音视频通信
YYDataV数据可视化7 天前
WebRTC ICE 候选类型详解:对等反射候选者(Peer Reflexive Candidate)
webrtc·实时音视频·ai编程
YYDataV数据可视化7 天前
【音视频通话系统】架构详解
音视频·webrtc·实时音视频
REDcker8 天前
RTP、RTCP 与 SRTP 协议详解
网络·音视频·webrtc·实时音视频·rtp·rtcp