fm.liveswitch.h264.Nalu Class Reference

An H264 Network Abstraction Layer Unit. More...

Public Member Functions

fm.liveswitch.DataBuffer getBuffer ()
 Gets the backing DataBuffer. More...
 
fm.liveswitch.DataBuffer getBytes ()
 Gets the NAL Unit as a byte array that can be passed to an encoder (includes Start Code). More...
 
boolean getFBit ()
 Gets the forbidden Zero Bit. More...
 
int getHeader ()
 Gets the NAL header. More...
 
int getNalRefIdc ()
 Gets the NRI: 2bits otherwise known as nal_ref_idc. More...
 
fm.liveswitch.DataBuffer getPayload ()
 Gets the NAL payload. More...
 
fm.liveswitch.DataBuffer getShortLength ()
 Gets the size of the NAL Unit (including NAL header) in two octets stored in the returned byte array. More...
 
int getType ()
 Gets the NAL Unit Type. More...
 
 Nalu ()
 Creates an empty NAL Unit. More...
 
 Nalu (fm.liveswitch.DataBuffer naluBytes)
 Creates a NAL Unit from a byte array. More...
 

Static Public Member Functions

static int findNalu (fm.liveswitch.DataBuffer encodedData)
 Scans for the index of the first NAL Unit after start. More...
 
static int findNextNalu (fm.liveswitch.DataBuffer encodedData, int start)
 Scans for the index of the first NAL Unit after start. More...
 
static int getFBitMask ()
 Gets the forbidden zero bit mask. More...
 
static fm.liveswitch.h264.Nalu getNalu (fm.liveswitch.DataBuffer encodedData)
 Returns the first NAL unit after nalStart. More...
 
static fm.liveswitch.h264.Nalu getNalu (fm.liveswitch.DataBuffer encodedData, int nalStart, fm.liveswitch.IntegerHolder nextStartCodeLength)
 Returns the first NAL unit after nalStart. More...
 
static int getNriMask ()
 Gets the nal_ref_idc mask. More...
 
static fm.liveswitch.DataBuffer getStartCode ()
 Gets the 4-byte NALU start code. More...
 
static int getTypeMask ()
 Gets the NAL Unit Type mask. More...
 

Protected Member Functions

int getBottomFieldFlag ()
 Gets the bottom_field_flag. More...
 
int[] getDeltaPicOrderCnt ()
 Gets the pic_order_cnt_lsb. More...
 
int getFieldPicFlag ()
 Gets the field_pic_flag. More...
 
int getFirstMbInSlice ()
 Gets the first_mb_in_slice specifies the address of the first macroblock in the slice. More...
 
int getFrameNum ()
 Gets the frame_num: The Frame Number is used as an identifier for pictures and shall be represented by log2_max_frame_num_minus4 + 4 bits in the bitstream. More...
 
int getIdrPicFlag ()
 Gets the idr_pic_flag. More...
 
int getIdrPicId ()
 Gets the idr_pic_id: The values of idr_pic_id in all the slices of an IDR picture shall remain unchanged. More...
 
int getPicOrderCntLsb ()
 Gets the pic_order_cnt_lsb. More...
 
int getPicOrderCntType ()
 Gets the pic_order_cnt_type. More...
 
int getPpsId ()
 Gets the Picture Parameter Set specifies the picture parameter set in use. More...
 
int getSliceType ()
 Gets the type of Slice contained in this NAL. More...
 
int getSpsId ()
 Gets the Sequence Parameter Set this NAL references. More...
 

Detailed Description

An H264 Network Abstraction Layer Unit.

Constructor & Destructor Documentation

◆ Nalu() [1/2]

fm.liveswitch.h264.Nalu.Nalu ( )

Creates an empty NAL Unit.

◆ Nalu() [2/2]

fm.liveswitch.h264.Nalu.Nalu ( fm.liveswitch.DataBuffer  naluBytes)

Creates a NAL Unit from a byte array.

Parameters
naluBytesThe NALU bytes.

Member Function Documentation

◆ findNalu()

static int fm.liveswitch.h264.Nalu.findNalu ( fm.liveswitch.DataBuffer  encodedData)
static

Scans for the index of the first NAL Unit after start.

Parameters
encodedDataThe stream to search.

◆ findNextNalu()

static int fm.liveswitch.h264.Nalu.findNextNalu ( fm.liveswitch.DataBuffer  encodedData,
int  start 
)
static

Scans for the index of the first NAL Unit after start.

Parameters
encodedDataThe stream to search.
startThe index to start searching from.

◆ getBottomFieldFlag()

int fm.liveswitch.h264.Nalu.getBottomFieldFlag ( )
protected

Gets the bottom_field_flag.

◆ getBuffer()

fm.liveswitch.DataBuffer fm.liveswitch.h264.Nalu.getBuffer ( )

Gets the backing DataBuffer.

◆ getBytes()

fm.liveswitch.DataBuffer fm.liveswitch.h264.Nalu.getBytes ( )

Gets the NAL Unit as a byte array that can be passed to an encoder (includes Start Code).

◆ getDeltaPicOrderCnt()

int [] fm.liveswitch.h264.Nalu.getDeltaPicOrderCnt ( )
protected

Gets the pic_order_cnt_lsb.

◆ getFBit()

boolean fm.liveswitch.h264.Nalu.getFBit ( )

Gets the forbidden Zero Bit.

The H.264 specification declares a value of 1 as a syntax violation.

◆ getFBitMask()

static int fm.liveswitch.h264.Nalu.getFBitMask ( )
static

Gets the forbidden zero bit mask.

◆ getFieldPicFlag()

int fm.liveswitch.h264.Nalu.getFieldPicFlag ( )
protected

Gets the field_pic_flag.

◆ getFirstMbInSlice()

int fm.liveswitch.h264.Nalu.getFirstMbInSlice ( )
protected

Gets the first_mb_in_slice specifies the address of the first macroblock in the slice.

When arbitrary slice order is not allowed as specified in Annex A, the value of first_mb_in_slice is constrained as follows: – If separate_colour_plane_flag is equal to 0, the value of first_mb_in_slice shall not be less than the value of first_mb_in_slice for any other slice of the current picture that precedes the current slice in decoding order. – Otherwise (separate_colour_plane_flag is equal to 1), the value of first_mb_in_slice shall not be less than the value of first_mb_in_slice for any other slice of the current picture that precedes the current slice in decoding order and has the same value of colour_plane_id.

◆ getFrameNum()

int fm.liveswitch.h264.Nalu.getFrameNum ( )
protected

Gets the frame_num: The Frame Number is used as an identifier for pictures and shall be represented by log2_max_frame_num_minus4 + 4 bits in the bitstream.

◆ getHeader()

int fm.liveswitch.h264.Nalu.getHeader ( )

Gets the NAL header.

◆ getIdrPicFlag()

int fm.liveswitch.h264.Nalu.getIdrPicFlag ( )
protected

Gets the idr_pic_flag.

◆ getIdrPicId()

int fm.liveswitch.h264.Nalu.getIdrPicId ( )
protected

Gets the idr_pic_id: The values of idr_pic_id in all the slices of an IDR picture shall remain unchanged.

When two consecutive access units in decoding order are both IDR access units, the value of idr_pic_id in the slices of the first such IDR access unit shall differ from the idr_pic_id in the second such IDR access unit. The value of idr_pic_id shall be in the range of 0 to 65535, inclusive.

◆ getNalRefIdc()

int fm.liveswitch.h264.Nalu.getNalRefIdc ( )

Gets the NRI: 2bits otherwise known as nal_ref_idc.

◆ getNalu() [1/2]

static fm.liveswitch.h264.Nalu fm.liveswitch.h264.Nalu.getNalu ( fm.liveswitch.DataBuffer  encodedData)
static

Returns the first NAL unit after nalStart.

Parameters
encodedDataThe byte array to search.

◆ getNalu() [2/2]

static fm.liveswitch.h264.Nalu fm.liveswitch.h264.Nalu.getNalu ( fm.liveswitch.DataBuffer  encodedData,
int  nalStart,
fm.liveswitch.IntegerHolder  nextStartCodeLength 
)
static

Returns the first NAL unit after nalStart.

Parameters
encodedDataThe byte array to search.
nalStartThe start index of the NAL.
nextStartCodeLengthOUT The length of the next the NAL startcode.

◆ getNriMask()

static int fm.liveswitch.h264.Nalu.getNriMask ( )
static

Gets the nal_ref_idc mask.

◆ getPayload()

fm.liveswitch.DataBuffer fm.liveswitch.h264.Nalu.getPayload ( )

Gets the NAL payload.

◆ getPicOrderCntLsb()

int fm.liveswitch.h264.Nalu.getPicOrderCntLsb ( )
protected

Gets the pic_order_cnt_lsb.

◆ getPicOrderCntType()

int fm.liveswitch.h264.Nalu.getPicOrderCntType ( )
protected

Gets the pic_order_cnt_type.

◆ getPpsId()

int fm.liveswitch.h264.Nalu.getPpsId ( )
protected

Gets the Picture Parameter Set specifies the picture parameter set in use.

The value of pic_parameter_set_id shall be in the range of 0 to 255, inclusive.

◆ getShortLength()

fm.liveswitch.DataBuffer fm.liveswitch.h264.Nalu.getShortLength ( )

Gets the size of the NAL Unit (including NAL header) in two octets stored in the returned byte array.

Useful for creating certain types of H264 such as STAP.

◆ getSliceType()

int fm.liveswitch.h264.Nalu.getSliceType ( )
protected

Gets the type of Slice contained in this NAL.

◆ getSpsId()

int fm.liveswitch.h264.Nalu.getSpsId ( )
protected

Gets the Sequence Parameter Set this NAL references.

◆ getStartCode()

static fm.liveswitch.DataBuffer fm.liveswitch.h264.Nalu.getStartCode ( )
static

Gets the 4-byte NALU start code.

◆ getType()

int fm.liveswitch.h264.Nalu.getType ( )

Gets the NAL Unit Type.

◆ getTypeMask()

static int fm.liveswitch.h264.Nalu.getTypeMask ( )
static

Gets the NAL Unit Type mask.