资源简介
写的不太好,有需要的参考吧
代码片段和文件信息
// NALDecoder.cpp : Defines the entry point for the console application.
//
#include
#include
#include
#include
#include “rtp1.h“
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “writer.h“
#include “../demo.h“
static int FindStartCode2 (unsigned char *Buf);//查找开始字符0x000001
static int FindStartCode3 (unsigned char *Buf);//查找开始字符0x00000001
static int info2=0 info3=0;
//为NALU_t结构体分配内存空间
NALU_t *AllocNALU(int buffersize)
{
NALU_t *n;
if ((n = (NALU_t*)calloc (1 sizeof (NALU_t))) == NULL)
{
printf(“AllocNALU: n“);
exit(0);
}
n->max_size=buffersize;
if ((n->buf = (char*)calloc (buffersize sizeof (char))) == NULL)
{
free (n);
printf (“AllocNALU: n->buf“);
exit(0);
}
return n;
}
//释放
void FreeNALU(NALU_t *n)
{
if (n)
{
if (n->buf)
{
free(n->buf);
n->buf=NULL;
}
free (n);
}
}
//这个函数输入为一个NAL结构体,主要功能为得到一个完整的NALU并保存在NALU_t的buf中,获取他的长度,填充FIDCTYPE位。
//并且返回两个开始字符之间间隔的字节数,即包含有前缀的NALU的长度
int GetAnnexbNALU (NALU_t *naluInt8* bitsInt32 NumBytesint pos_m)
{
int pos = 0;
int StartCodeFound rewind;
unsigned char *Buf;
if ((Buf = (unsigned char*)calloc (nalu->max_size sizeof(char))) == NULL)
printf (“GetAnnexbNALU: Could not allocate Buf memory\n“);
nalu->startcodeprefix_len=3;//初始化码流序列的开始字符为3个字节
memcpy (Bufbits+pos_m 3);
info2 = FindStartCode2 (Buf);//判断是否为0x000001
if(info2 != 1)
{
//如果不是,再读一个字节
memcpy (Buf+3 bits+pos_m+3 1);
info3 = FindStartCode3 (Buf);//判断是否为0x00000001
if (info3 != 1)//如果不是,返回-1
{
free(Buf);
return -1;
}
else
{
//如果是0x00000001得到开始前缀为4个字节
pos = 4;
nalu->startcodeprefix_len = 4;
}
}
else
{
//如果是0x000001得到开始前缀为3个字节
nalu->startcodeprefix_len = 3;
pos = 3;
}
//查找下一个开始字符的标志位
StartCodeFound = 0;
info2 = 0;
info3 = 0;
while (!StartCodeFound)
{
if ((pos_m+pos)>NumBytes)//判断是否到了文件尾
{
nalu->len = (pos-1)-nalu->startcodeprefix_len;
memcpy (nalu->buf &Buf[nalu->startcodeprefix_len] nalu->len);
nalu->forbidden_bit = nalu->buf[0] & 0x80; //1 bit
nalu->nal_reference_idc = nalu->buf[0] & 0x60; // 2 bit
nalu->nal_unit_type = (nalu->buf[0]) & 0x1f;// 5 bit
free(Buf);
return pos_m+pos-1;
}
Buf[pos] = bits[pos_m+pos];//读一个字节到BUF中
pos++;
info3 = FindStartCode3(&Buf[pos-4]);//判断是否为0x00000001
if(info3 != 1)
info2 = FindStartCode2(&Buf[pos-3]);//判断是否为0x000001
StartCodeFound = (info2 == 1 || info3 == 1);
}
// Here we have found another start code (and read length of startcode bytes more than we should
// have. Hence go back in the file
rewind = (info3 == 1)? -4 : -3;
pos_m=pos_m
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4868 2013-09-12 10:44 rtp1.c
文件 2453 2013-10-26 11:32 rtp1.h
文件 18263 2015-09-20 10:38 writer.c
文件 2577 2013-11-17 20:56 writer.h
----------- --------- ---------- ----- ----
28161 4
- 上一篇:linuxRTP打包发送
- 下一篇:AD9851频率、相位控制字
相关资源
- CPLEX求解VRPTW
- 蜂群算法求解VRPTW
- 最后一公里EC配送程序源代码
- RTP实时传输H.264
- vrptw问题代码
- linux下的实时语音聊天程序源码adpcm编
- TEKLA -构件清单(净重).rpt
- rtsp解析实现音视频实时传输
- 用WindowsSocket实现局域网上的语音实时
- 论文研究 - 内源性大麻素Anandamide诱导
- Selective adsorption property of collagen fibr
- The theoretical study of the adsorption of 4-t
-
Size Effects for the Adsorption of Alkali me
- TEM/EDX investigation on adsorption of Pb on s
- Effect of tribocorrosion processes on adsorpti
- First principles study of the adsorption of Ti
- Influence of Hydrophobicity of Substrates on t
- The first principle study of adsorption for tw
- Adsorption of Pb2+ and Zn2+ from aqueous solut
- Isotherm kinetics and thermodynamic studies of
- Application of orange peel xanthate for the ad
- Adsorption behavior of Cr (VI) from aqueou
- Adsorption of Nickel on Chinese Loess in Aqueo
- Adsorption of copper and cadmium ions from aqu
- IRPTrace2.0+注册机
- opencv UDP协议的摄像头视频实时传输
- 解VRPTW问题的模拟退火程序
- solomon.zip
- jstat js正态分布函数库
评论
共有 条评论