日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

h.264 SODB RBSP EBSP的区别

發布時間:2023/12/10 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 h.264 SODB RBSP EBSP的区别 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
SODB 數據比特串-->最原始的編碼數據

RBSP 原始字節序列載荷-->在SODB的后面填加了結尾比特(RBSP trailing bits 一個bit“1”若干比特“0”,以便字節對齊。

EBSP 擴展字節序列載荷-->在RBSP基礎上填加了仿校驗字節(0X03)它的原因是: 在NALU加到Annexb上時,需要填加每組NALU之前的開始碼StartCodePrefix,如果該NALU對應的slice為一幀的開始則用4位字節表示,ox00000001,否則用3位字節表示ox000001.為了使NALU主體中不包括與開始碼相沖突的,在編碼時,每遇到兩個字節連續為0,就插入一個字節的0x03。解碼時將0x03去掉。也稱為脫殼操作。

網上查詢的區別:

在對整幀圖像的數據比特串(SODB)添加原始字節序列載荷(RBSP)結尾比特(RBSP trailing bits,添加一比特的“1”和若干比特“0”,以便字節對齊),再檢查RBSP 中是否存在連續的三字節“00000000 00000000 000000xx”;若存在這種連續的三字節碼,在第三字節前插入一字節的“0×03”,以免與起始碼競爭,形成EBSP碼流,這需要將近兩倍的整幀圖像碼流大小。為了減小存儲器需求,在每個宏塊編碼結束后即檢查該宏塊SODB中的起始碼競爭問題,并保留SODB最后兩字節的零字節個數,以便與下一宏塊的SODB的開始字節形成連續的起始碼競爭檢測;對一幀圖像的最后一個宏塊,先添加結尾停止比特,再檢測起始碼競爭。

程序:

typedef struct

{

int???????????? byte_pos;?????????? //!< current position in bitstream;

int???????????? bits_to_go;???????? //!< current bitcounter

byte??????????? byte_buf;?????????? //!< current buffer for last written byte

int???????????? stored_byte_pos;??? //!< storage for position in bitstream;

int???????????? stored_bits_to_go; //!< storage for bitcounter

byte??????????? stored_byte_buf;??? //!< storage for buffer of last written byte

byte??????????? byte_buf_skip;????? //!< current buffer for last written byte

int???????????? byte_pos_skip;????? //!< storage for position in bitstream;

int???????????? bits_to_go_skip;??? //!< storage for bitcounter

byte??????????? *streamBuffer;????? //!< actual buffer for written bytes

int???????????? write_flag;???????? //!< Bitstream contains data and needs to be written

} Bitstream; 定義比特流結構

static byte *NAL_Payload_buffer;

void SODBtoRBSP(Bitstream *currStream)
{
currStream->byte_buf <<= 1;  //左移1bit
currStream->byte_buf |= 1;   //在尾部填一個“1”占1bit
currStream->bits_to_go--;
currStream->byte_buf <<= currStream->bits_to_go;
currStream->streamBuffer[currStream->byte_pos++] = currStream->byte_buf;
currStream->bits_to_go = 8;
currStream->byte_buf = 0;
}

int RBSPtoEBSP(byte *streamBuffer, int begin_bytepos, int end_bytepos, int min_num_bytes)
{

int i, j, count;

for(i = begin_bytepos; i < end_bytepos; i++)
??? NAL_Payload_buffer[i] = streamBuffer[i];

count = 0;
j = begin_bytepos;
for(i = begin_bytepos; i < end_bytepos; i++)
{
??? if(count == ZEROBYTES_SHORTSTARTCODE && !(NAL_Payload_buffer[i] & 0xFC))
??? {
????? streamBuffer[j] = 0x03;
????? j++;
????? count = 0;??
??? }
??? streamBuffer[j] = NAL_Payload_buffer[i];
??? if(NAL_Payload_buffer[i] == 0x00)?????
????? count++;
??? else
????? count = 0;
??? j++;
}
while (j < begin_bytepos+min_num_bytes) {
??? streamBuffer[j] = 0x00; // cabac stuffing word
??? streamBuffer[j+1] = 0x00;
??? streamBuffer[j+2] = 0x03;
??? j += 3;
??? stat->bit_use_stuffingBits[img->type]+=16;
}
return j;
}


總結

以上是生活随笔為你收集整理的h.264 SODB RBSP EBSP的区别的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。