Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to v0.10.0 #56

Merged
merged 7 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Membrane H264 Plugin
# Membrane H26x Plugin

[![Hex.pm](https://img.shields.io/hexpm/v/membrane_h264_plugin.svg)](https://hex.pm/packages/membrane_h264_plugin)
[![API Docs](https://img.shields.io/badge/api-docs-yellow.svg?style=flat)](https://hexdocs.pm/membrane_h264_plugin)
[![CircleCI](https://circleci.com/gh/membraneframework/membrane_h264_plugin.svg?style=svg)](https://circleci.com/gh/membraneframework/membrane_h264_plugin)

Membrane H264 parser.
It is the Membrane element responsible for parsing the incoming H264 stream. The parsing is done as a sequence of the following steps:
* splitting the H264 stream into stream NAL units, based on the "Annex B" of the "ITU-T Rec. H.264 (01/2012)" or length prefix defined in "ISO/IEC 14496-10"
Membrane H.264 and H.265 parsers.
It is a pair of Membrane elements responsible for parsing the incoming H.264 and H.265 streams. The parsing is done as a sequence of the following steps:
* splitting the stream into stream NAL units
* Parsing the NAL unit headers, so that to read the type of the NAL unit
* Parsing the NAL unit body with the appropriate scheme, based on the NAL unit type read in the step before
* Aggregating the NAL units into a stream of *access units*
Expand All @@ -17,12 +17,12 @@ It is part of [Membrane Multimedia Framework](https://membraneframework.org).

## Installation

The package can be installed by adding `membrane_h264_plugin` to your list of dependencies in `mix.exs`:
The package can be installed by adding `membrane_h26x_plugin` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:membrane_h264_plugin, "~> 0.9.1"}
{:membrane_h26x_plugin, "~> 0.10.0"}
]
end
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defmodule Membrane.H264.DecoderConfigurationRecord do
@doc """
Generates a DCR based on given PPSs and SPSs.
"""
@spec generate([binary()], [binary()], Membrane.H26x.Parser.stream_structure()) ::
@spec generate([binary()], [binary()], Membrane.H264.Parser.stream_structure()) ::
binary() | nil
def generate([], _ppss, _stream_structure) do
nil
Expand Down
8 changes: 8 additions & 0 deletions lib/membrane_h264_plugin/h264_parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ defmodule Membrane.H264.Parser do
"""
]

@typedoc """
Format of the H264 stream, if set to `:annexb` NALUs will be separated by
a start code (0x(00)000001) or if set to `:avc3` or `:avc1` they will
be prefixed by their size.
"""
@type stream_structure ::
:annexb | {codec_tag :: :avc1 | :avc3, nalu_length_size :: pos_integer()}

@impl true
def handle_init(ctx, opts) do
output_stream_structure =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ defmodule Membrane.H265.DecoderConfigurationRecord do
@doc """
Generates a DCR based on given PPSs, SPSs and VPSs.
"""
@spec generate([NALu.t()], [NALu.t()], [NALu.t()], Membrane.H26x.Parser.stream_structure()) ::
@spec generate([NALu.t()], [NALu.t()], [NALu.t()], Membrane.H265.Parser.stream_structure()) ::
binary() | nil
def generate(_vpss, [], _ppss, _stream_structure) do
nil
Expand Down
8 changes: 8 additions & 0 deletions lib/membrane_h264_plugin/h265_parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ defmodule Membrane.H265.Parser do
"""
]

@typedoc """
Format of the H265 stream, if set to `:annexb` NALUs will be separated by
a start code (0x(00)000001) or if set to `:hvc1` or `:hev1` they will be
prefixed by their size.
"""
@type stream_structure ::
:annexb | {codec_tag :: :hvc1 | :hev1, nalu_length_size :: pos_integer()}
Comment on lines +162 to +163
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be used by the spec for the output_stream_structure option?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done here H.264 and H.265


@impl true
def handle_init(ctx, opts) do
output_stream_structure =
Expand Down
3 changes: 2 additions & 1 deletion lib/membrane_h264_plugin/h26x_parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ defmodule Membrane.H26x.Parser do
Stream structure of the NALUs. In case it's not `:annexb` format, it contains an information
about the size of each NALU's prefix describing their length.
"""
@type stream_structure :: :annexb | {codec_tag :: atom(), nalu_length_size :: pos_integer()}
@type stream_structure ::
Membrane.H264.Parser.stream_structure() | Membrane.H265.Parser.stream_structure()

@type callback_context :: Membrane.Element.CallbackContext.t()
@type action :: Membrane.Element.Action.t()
Expand Down
16 changes: 8 additions & 8 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
defmodule Membrane.H264.Plugin.Mixfile do
defmodule Membrane.H26x.Plugin.Mixfile do
use Mix.Project

@version "0.9.1"
@github_url "https://github.com/membraneframework/membrane_h264_plugin"
@version "0.10.0"
@github_url "https://github.com/membraneframework/membrane_h26x_plugin"

def project do
[
app: :membrane_h264_plugin,
app: :membrane_h26x_plugin,
version: @version,
elixir: "~> 1.13",
elixirc_paths: elixirc_paths(Mix.env()),
Expand All @@ -15,11 +15,11 @@ defmodule Membrane.H264.Plugin.Mixfile do
dialyzer: dialyzer(),

# hex
description: "Membrane H264 parser",
description: "Membrane H.264 and H.265 parser",
package: package(),

# docs
name: "Membrane H264 plugin",
name: "Membrane H.264 and H.265 plugin",
source_url: @github_url,
homepage_url: "https://membrane.stream",
docs: docs()
Expand Down Expand Up @@ -79,8 +79,8 @@ defmodule Membrane.H264.Plugin.Mixfile do
extras: ["README.md", "LICENSE"],
formatters: ["html"],
source_ref: "v#{@version}",
filter_modules: "Membrane\.H264\.Parser",
nest_modules_by_prefix: [Membrane.H264.Parser]
filter_modules: "Membrane\.H26(4|5)",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

nest_modules_by_prefix: [Membrane.H264, Membrane.H265, Membrane.H26x]
]
end
end
6 changes: 2 additions & 4 deletions test/parser/h264/au_splitter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ defmodule Membrane.H264.AUSplitterTest do

@test_files_names ["10-720a", "10-720p"]

# These values were obtained with the use of H264.FFmpeg.Parser, available
# in the membrane_h264_ffmpeg_plugin repository.
@au_lengths_ffmpeg %{
@au_lengths_snapshot %{
"10-720a" => [777, 146, 93, 136],
"10-720p" => [25_699, 19_043, 14_379, 14_281, 14_761, 18_702, 14_735, 13_602, 12_094, 17_228]
}
Expand Down Expand Up @@ -40,7 +38,7 @@ defmodule Membrane.H264.AUSplitterTest do
byte_size(payload) + byte_size(prefix) + acc
end)

assert au_lengths == @au_lengths_ffmpeg[name]
assert au_lengths == @au_lengths_snapshot[name]
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/parser/h265/process_all_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ defmodule Membrane.H265.ProcessAllTest do
import Membrane.ChildrenSpec
import Membrane.Testing.Assertions

alias Membrane.H26x.NALuSplitter
alias Membrane.H265
alias Membrane.H26x.NALuSplitter
alias Membrane.Testing.Pipeline

defp make_pipeline(in_path, out_path, parameter_sets) do
Expand Down
8 changes: 4 additions & 4 deletions test/parser/h265/repeat_parameter_sets_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ defmodule Membrane.H265.RepeatParameterSetsTest do
parser_input_stream_structure \\ :annexb,
parser_output_stream_structure \\ :annexb
) do
buffers = prepare_h264_buffers(data, mode, parser_input_stream_structure)
buffers = prepare_h265_buffers(data, mode, parser_input_stream_structure)

assert_sink_playing(pipeline_pid, :sink)
actions = for buffer <- buffers, do: {:buffer, {:output, buffer}}
Pipeline.message_child(pipeline_pid, :source, actions ++ [end_of_stream: :output])

output_buffers =
prepare_h264_buffers(
prepare_h265_buffers(
File.read!(@ref_path),
:au_aligned,
parser_output_stream_structure
Expand Down Expand Up @@ -112,14 +112,14 @@ defmodule Membrane.H265.RepeatParameterSetsTest do
source = %H26x.Support.TestSource{mode: :bytestream}
pid = make_pipeline(source)

buffers = prepare_h264_buffers(File.read!(in_path), :bytestream)
buffers = prepare_h265_buffers(File.read!(in_path), :bytestream)

assert_sink_playing(pid, :sink)
actions = for buffer <- buffers, do: {:buffer, {:output, buffer}}
Pipeline.message_child(pid, :source, actions ++ [end_of_stream: :output])

File.read!(ref_path)
|> prepare_h264_buffers(:au_aligned)
|> prepare_h265_buffers(:au_aligned)
|> Enum.each(fn output_buffer ->
assert_sink_buffer(pid, :sink, buffer)
assert split_access_unit(output_buffer.payload) == split_access_unit(buffer.payload)
Expand Down