1 Star 0 Fork 0

hankersyan/nginx-rtmp-module

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ngx_rtmp_bitop.c 1.04 KB
一键复制 编辑 原始数据 按行查看 历史
/*
* Copyright (C) Roman Arutyunyan
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include "ngx_rtmp_bitop.h"
void
ngx_rtmp_bit_init_reader(ngx_rtmp_bit_reader_t *br, u_char *pos, u_char *last)
{
ngx_memzero(br, sizeof(ngx_rtmp_bit_reader_t));
br->pos = pos;
br->last = last;
}
uint64_t
ngx_rtmp_bit_read(ngx_rtmp_bit_reader_t *br, ngx_uint_t n)
{
uint64_t v;
ngx_uint_t d;
v = 0;
while (n) {
if (br->pos >= br->last) {
br->err = 1;
return 0;
}
d = (br->offs + n > 8 ? (ngx_uint_t) (8 - br->offs) : n);
v <<= d;
v += (*br->pos >> (8 - br->offs - d)) & ((u_char) 0xff >> (8 - d));
br->offs += d;
n -= d;
if (br->offs == 8) {
br->pos++;
br->offs = 0;
}
}
return v;
}
uint64_t
ngx_rtmp_bit_read_golomb(ngx_rtmp_bit_reader_t *br)
{
ngx_uint_t n;
for (n = 0; ngx_rtmp_bit_read(br, 1) == 0 && !br->err; n++);
return ((uint64_t) 1 << n) + ngx_rtmp_bit_read(br, n) - 1;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hankersyan/nginx-rtmp-module.git
git@gitee.com:hankersyan/nginx-rtmp-module.git
hankersyan
nginx-rtmp-module
nginx-rtmp-module
master

搜索帮助