简体   繁体   English

h265:从位流文件中解析切片头

[英]h265: parsing slice header from bitstream file

I need to read the POC number from the HEVC bitstream using python BitStream. 我需要使用Python BitStream从HEVC比特流中读取POC编号。 Currently I read the nal unit header. 目前,我阅读了最终单位标题。 Is there an easy way to get it? 有一种简单的方法可以得到它吗?

I have trace enabled HM14.0 but the EncTrace.txt does not include all my packets. 我已启用跟踪HM14.0,但EncTrace.txt并未包括我的所有数据包。

Any idea? 任何想法?

Edit: I attach my python code. 编辑:我附上我的python代码。 This is my bitstream file . 这是我的比特流文件

import re

import collections
import bitstring
from bitstring import BitStream, BitArray, ConstBitStream, pack
from bitstring import ByteStore, offsetcopy
import unicodedata


text_file = open("nal_Output.txt", "wb")

s = BitStream(filename='new.str')

#Find number of packets
pcks = list(s.findall('0x000001', bytealigned=True))


s.pos=0
num_of_pcks = len(pcks)
num_of_POC_pcks =0
for x in range(0, num_of_pcks):
    s.pos =pcks[x]+24
    #print x
    if x < num_of_pcks-1:
        no_p = pcks[x+1]-pcks[x]-24
    else:
        no_p = 0

    forbidden_zero_bit  = s.read('uint:1')
    nal_unit_type = s.read('uint:6')
    nuh_layer_id = s.read('uint:6')
    nuh_temporal_id_plus1 = s.read('uint:3')

    #nal unit type 39 is for SEI messages: one byte message
    if int(nal_unit_type) >31 :
        #print 'nal=39'
        #size_of_pck = (no_p+24+8)/8
        packet = 0
    elif int(nal_unit_type) <32:
        #print int(nal_unit_type)
        num_of_POC_pcks = num_of_POC_pcks+1
        size_of_pck = (no_p+24)/8
        text_file.write("NumBytesInNALunit: {0}\n".format(str(size_of_pck)))
    s.read(no_p)

print num_of_POC_pcks 

text_file.close()

Chapter 8.3.1 in the standard tells you how the PicOrderCntVal is deriverad. 标准中的第8.3.1章告诉您PicOrderCntVal是如何派生的。 In python, this is non-trivial to extract... 在python中,这并非易事……

Using the reference SW , the slice header is parsed in function TDecCavlc::parseSliceHeader in source/Lib/TLibDecoder/TDecCAVLC.cpp that is also where the POC-value is read. 使用引用SW ,在source/Lib/TLibDecoder/TDecCAVLC.cpp中的函数TDecCavlc::parseSliceHeader中解析切片标头,这也是读取POC值的位置。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM