webrtc支持的最小宽度和高度

代码在:h264/sps_parser.cc

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

最近更新

  1. TCP协议是安全的吗?

    2023-12-21 06:50:04       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-21 06:50:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-21 06:50:04       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-21 06:50:04       20 阅读

热门阅读

  1. 副显示器显示不清晰问题

    2023-12-21 06:50:04       41 阅读
  2. 爬虫scrapy中间件的使用

    2023-12-21 06:50:04       27 阅读
  3. linux 安装 npm pnpm

    2023-12-21 06:50:04       30 阅读
  4. 什么是深度学习,多模态学习,迁移学习,LLM

    2023-12-21 06:50:04       41 阅读
  5. 机器学习之迁移学习(Transfer Learning)附代码

    2023-12-21 06:50:04       28 阅读
  6. 微信小程序实现一个简单的登录功能

    2023-12-21 06:50:04       39 阅读
  7. Haproxy负载均衡

    2023-12-21 06:50:04       45 阅读
  8. KNN算法详解与Python实现

    2023-12-21 06:50:04       37 阅读
  9. Hadoop伪分布式集群安装

    2023-12-21 06:50:04       39 阅读
  10. 定制@ResponseBody

    2023-12-21 06:50:04       30 阅读
  11. 【GIT】新建分支

    2023-12-21 06:50:04       41 阅读