Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
annexb_filler.h File Reference

Removing filler data units from an Annex B H.264 or HEVC frame. More...

#include <cstddef>
#include <cstdint>
#include <cstring>
Include dependency graph for annexb_filler.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum class  video::annexb::codec_e { h264 , hevc }
 Which bitstream syntax a frame uses. More...

Functions

std::size_t video::annexb::detail::find_start_code (const std::uint8_t *data, std::size_t from, std::size_t size)
 Offset of the next 00 00 01 start code at or after from, or size.
bool video::annexb::detail::is_filler (std::uint8_t header, codec_e codec)
 Filler data: H.264 nal_unit_type 12, HEVC nal_unit_type 38 (FD_NUT).
std::size_t video::annexb::strip_filler_data (std::uint8_t *data, std::size_t size, codec_e codec)

Detailed Description

Removing filler data units from an Annex B H.264 or HEVC frame.

Definition in file annexb_filler.h.

Enumeration Type Documentation

◆ codec_e

enum class video::annexb::codec_e
strong

Which bitstream syntax a frame uses.

Definition at line 14 of file annexb_filler.h.

Function Documentation

◆ find_start_code()

std::size_t video::annexb::detail::find_start_code ( const std::uint8_t * data,
std::size_t from,
std::size_t size )
inline

Offset of the next 00 00 01 start code at or after from, or size.

Definition at line 21 of file annexb_filler.h.

◆ is_filler()

bool video::annexb::detail::is_filler ( std::uint8_t header,
codec_e codec )
inline

Filler data: H.264 nal_unit_type 12, HEVC nal_unit_type 38 (FD_NUT).

Definition at line 37 of file annexb_filler.h.

◆ strip_filler_data()

std::size_t video::annexb::strip_filler_data ( std::uint8_t * data,
std::size_t size,
codec_e codec )
inline

Remove the filler data units from an Annex B frame, in place.

In CBR, radeonsi pads H.264 and HEVC frames with filler data up to the target bitrate, and FFmpeg has no option to turn that off: a still screen streams at the full bitrate, nearly all of it filler. A decoder discards filler data, so the client has no use for it.

A unit runs from the zero bytes before its start code to the zero bytes before the next one. A unit never ends in a zero byte, so those zeros are framing, and removing a unit with them leaves its neighbours exactly as they were. The payload is escaped, so a start code only ever marks a unit. Kept units move only when something before them was removed.

Returns
The frame's size without filler. A frame with no filler, or with nothing but filler, is left whole and size is returned.

Definition at line 59 of file annexb_filler.h.