91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

寫的不太好,有需要的參考吧

資源截圖

代碼片段和文件信息

//?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


評論

共有 條評論