我想知道如何使用C编程来识别HEVC流中的NAL单元
I want to know how to recognize the NAL unit in a HEVC stream using C programing
我想知道如何使用C或C++编程来识别HEVC流中的NAL单元。该代码应当能够将HEVC流作为输入,并且应当产生关于NAL单元的信息,例如IDR帧。
#include <stdio.h>
int main(int argc, char *argv[])
{
FILE *inp = fopen("c:\test.hevc", "rb");
// parser state
bool start = true;
// current code word
unsigned long int code_word = 0;
// iterate through byte stream
while(true) {
// read next byte
int b = fgetc(inp);
// quit at end of byte stream
if (b == EOF) {
break;
}
// track 32-bit code word
code_word = (code_word | b) << 8;
// NALU start
if (code_word == 0x00000100) {
if (start) {
// read nalu type
int type = fgetc(inp);
// quit at end of byte stream
if (type == EOF) {
break;
}
// ignore reserved bit
type >>= 1;
if (type == 19 /* IDR */) {
printf("NALU type: IDRn");
}
else {
printf("NALU type: %dn", type);
}
code_word = 0;
}
start = !start;
}
}
fclose(inp);
return 0;
}
相关文章:
- 什么时候调用组成单元对象的析构函数
- 不同翻译单元中不可重载的非内联函数定义
- 有什么好的方法可以让系统调用代理允许在单元测试中进行模拟
- 在子目录中使用target_sources()命令时用于单元测试(qtest)的项目结构
- VC++本机单元测试,找不到调试符号
- 将QIcon添加到QTableView单元格
- 用于交叉编译和CMake的预处理器宏的单元测试
- 当用户在qtablewidget中输入单元格时,如何获得信号?C++
- 字节真的是最小可寻址单元吗
- C++ 用于单元测试的模板模板
- 为什么未命名的结构内联变量在每个翻译单元中没有相同的地址?
- 提升 1.64 单元测试编译失败
- boost::包含提升单元的元组的哈希值
- 单元测试欧拉到四元数实现失败
- 查找矩阵中单元格的相邻元素
- 运行 C++ 单元测试时LNK2005链接错误
- 禁用自动捕获 Googletest 单元测试中的C++异常
- 有没有办法在不使用 #ifdef 的情况下不编译发布版本中的单元测试函数体?
- 使用 Google Test 对自定义断言函数进行单元测试
- 我想知道如何使用C编程来识别HEVC流中的NAL单元