Compy 0.2.0
A lightweight RTSP 1.0 server library for embedded systems
Loading...
Searching...
No Matches
nal.h File Reference

A generic NAL (Network Abstraction Layer) representation. More...

#include <compy/nal/h264.h>
#include <compy/nal/h265.h>
#include <stdbool.h>
#include <stdint.h>
#include <datatype99.h>
#include <slice99.h>
#include <compy/priv/compiler_attrs.h>
Include dependency graph for nal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Compy_NalUnit
 A generic NAL unit (either H.264 or H.265). More...
 

Typedefs

typedef size_t(* Compy_NalStartCodeTester) (U8Slice99 data)
 A function that tests whether data starts with some start code.
 

Functions

 datatype99 (Compy_NalHeader,(Compy_NalHeader_H264, Compy_H264NalHeader),(Compy_NalHeader_H265, Compy_H265NalHeader))
 A generic NAL header (either H.264 or H.265).
 
uint8_t Compy_NalHeader_unit_type (Compy_NalHeader self) COMPY_PRIV_MUST_USE
 Returns the NAL unit type of self.
 
size_t Compy_NalHeader_size (Compy_NalHeader self) COMPY_PRIV_MUST_USE
 Computes the size of self in bytes.
 
size_t Compy_NalHeader_fu_size (Compy_NalHeader self) COMPY_PRIV_MUST_USE
 Computes the size of a fragmentation unit (FU) header self.
 
bool Compy_NalHeader_is_vps (Compy_NalHeader self) COMPY_PRIV_MUST_USE
 Checks whether self is VPS.
 
bool Compy_NalHeader_is_sps (Compy_NalHeader self) COMPY_PRIV_MUST_USE
 Checks whether self is SPS.
 
bool Compy_NalHeader_is_pps (Compy_NalHeader self) COMPY_PRIV_MUST_USE
 Checks whether self is PPS.
 
bool Compy_NalHeader_is_coded_slice_idr (Compy_NalHeader self) COMPY_PRIV_MUST_USE
 Checks whether self is a coded slice IDR.
 
bool Compy_NalHeader_is_coded_slice_non_idr (Compy_NalHeader self) COMPY_PRIV_MUST_USE
 Checks whether self is a coded slice non-IDR.
 
void Compy_NalHeader_serialize (Compy_NalHeader self, uint8_t buffer[restrict])
 Writes the binary representation of self into buffer.
 
void Compy_NalHeader_write_fu_header (Compy_NalHeader self, uint8_t buffer[restrict], bool is_first_fragment, bool is_last_fragment)
 Writes a FU header of self to buffer.
 
uint8_t compy_nal_fu_header (bool is_first_fragment, bool is_last_fragment, uint8_t unit_type) COMPY_PRIV_MUST_USE
 Creates a generic NAL FU header.
 
Compy_NalStartCodeTester compy_determine_start_code (U8Slice99 data) COMPY_PRIV_MUST_USE
 Returns a start code tester for data.
 
size_t compy_test_start_code_3b (U8Slice99 data)
 The 3-byte start code tester (0x000001).
 
size_t compy_test_start_code_4b (U8Slice99 data)
 The 3-byte start code tester (0x00000001).
 

Detailed Description

A generic NAL (Network Abstraction Layer) representation.

Typedef Documentation

◆ Compy_NalStartCodeTester

typedef size_t(* Compy_NalStartCodeTester) (U8Slice99 data)

A function that tests whether data starts with some start code.

Returns
The number of start code bytes. If there is no start code in the beginning of data, returns 0.
See also
compy_test_start_code_3b
compy_test_start_code_4b

Function Documentation

◆ compy_determine_start_code()

Compy_NalStartCodeTester compy_determine_start_code ( U8Slice99  data)

Returns a start code tester for data.

If data does not begin with a start code (either 0x000001 or 0x00000001), returns NULL.

This function is useful when you have some *.h264 bitstream file and you want to determine what start code it uses – just pass the beginning of this file to compy_determine_start_code and invoke the returned tester multiple times afterwards.

◆ Compy_NalHeader_fu_size()

size_t Compy_NalHeader_fu_size ( Compy_NalHeader  self)

Computes the size of a fragmentation unit (FU) header self.

See also
H.264 Fragmentation Units (FUs): https://datatracker.ietf.org/doc/html/rfc6184#section-5.8
H.265 Fragmentation Units (FUs): https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.3

◆ Compy_NalHeader_serialize()

void Compy_NalHeader_serialize ( Compy_NalHeader  self,
uint8_t  buffer[restrict] 
)

Writes the binary representation of self into buffer.

Parameters
[in]selfThe header to write.
[out]bufferThe memory area capable of storing Compy_NalHeader_size(self) bytes.

◆ Compy_NalHeader_write_fu_header()

void Compy_NalHeader_write_fu_header ( Compy_NalHeader  self,
uint8_t  buffer[restrict],
bool  is_first_fragment,
bool  is_last_fragment 
)

Writes a FU header of self to buffer.

Parameters
[in]selfThe header to write.
[out]bufferThe memory area capable of storing Compy_NalHeader_fu_size(self) bytes.
[in]is_first_fragmentThe indication of a start of the FU.
[in]is_last_fragmentThe indication of an end of the FU.
See also
H.264 Fragmentation Units (FUs): https://datatracker.ietf.org/doc/html/rfc6184#section-5.8
H.265 Fragmentation Units (FUs): https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.3

◆ datatype99()

datatype99 ( Compy_NalHeader  ,
(Compy_NalHeader_H264, Compy_H264NalHeader ,
(Compy_NalHeader_H265, Compy_H265NalHeader  
)

A generic NAL header (either H.264 or H.265).

See Datatype99 for the macro usage.