View Source Membrane.H264.Parser.AUSplitter (Membrane H264 plugin v0.9.2)
Module providing functionalities to divide the binary h264 stream into access units.
The access unit splitter's behaviour is based on "22.214.171.124.3 Order of NAL units and coded pictures and association to access units" of the "ITU-T Rec. H.264 (01/2012)" specification. The most crucial part of the access unit splitter is the mechanism to detect new primary coded video picture.
WARNING: Our implementation of that mechanism is based on: "126.96.36.199.4 Detection of the first VCL NAL unit of a primary coded picture" of the "ITU-T Rec. H.264 (01/2012)", however it adds one more additional condition which, when satisfied, says that the given VCL NALu is a new primary coded picture. That condition is whether the picture is a keyframe or not.
A type representing an access unit - a list of logically associated NAL units.
A structure holding a state of the access unit splitter.
@spec new() :: t()
Returns a structure holding a clear state of the access unit splitter.
Splits the given list of NAL units into the access units.
It can be used for a stream which is not completely available at the time of function invocation,
as the function updates the state of the access unit splitter - the function can
be invoked once more, with new NAL units and the updated state.
Under the hood,
split/2 defines a finite state machine
with two states:
:second. The state
:first describes the state before
reaching the primary coded picture NALu of a given access unit. The state
describes the state after processing the primary coded picture NALu of a given
assume_au_aligned flag is set to
true, input is assumed to form a complete set
of access units and therefore all of them are returned. Otherwise, the last access unit
is not returned until another access unit starts, as it's the only way to prove that
the access unit is complete.