This repository has been archived by the owner on Mar 12, 2024. It is now read-only.
generated from membraneframework/membrane_template_plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Repeat parameter sets on each IRAP picture (#6)
- Loading branch information
Showing
9 changed files
with
183 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
defmodule Membrane.H265.RepeatParameterSetsTest do | ||
@moduledoc false | ||
|
||
use ExUnit.Case, async: true | ||
|
||
import Membrane.ChildrenSpec | ||
import Membrane.Testing.Assertions | ||
import Membrane.H265.Support.Common | ||
|
||
alias Membrane.H265 | ||
alias Membrane.H265.Parser.NALuSplitter | ||
alias Membrane.Testing.{Pipeline, Sink} | ||
|
||
@in_path "../fixtures/input-60-640x480-no-parameter-sets.h265" |> Path.expand(__DIR__) | ||
@ref_path "../fixtures/reference-60-640x480-with-parameter-sets.h265" |> Path.expand(__DIR__) | ||
|
||
@vps <<64, 1, 12, 1, 255, 255, 33, 96, 0, 0, 3, 0, 144, 0, 0, 3, 0, 0, 3, 0, 153, 149, 152, 9>> | ||
@sps <<66, 1, 1, 33, 96, 0, 0, 3, 0, 144, 0, 0, 3, 0, 0, 3, 0, 153, 160, 5, 2, 1, 225, 101, 149, | ||
154, 73, 50, 188, 57, 160, 32, 0, 0, 3, 0, 32, 0, 0, 3, 3, 193>> | ||
@pps <<68, 1, 193, 114, 180, 98, 64>> | ||
@dcr <<1, 33, 96, 0, 0, 0, 144, 0, 0, 0, 0, 0, 153, 240, 0, 252, 253, 248, 248, 0, 0, 15, 3, | ||
160, 0, 1, 0, 24, 64, 1, 12, 1, 255, 255, 33, 96, 0, 0, 3, 0, 144, 0, 0, 3, 0, 0, 3, 0, | ||
153, 149, 152, 9, 161, 0, 1, 0, 42, 66, 1, 1, 33, 96, 0, 0, 3, 0, 144, 0, 0, 3, 0, 0, 3, | ||
0, 153, 160, 5, 2, 1, 225, 101, 149, 154, 73, 50, 188, 57, 160, 32, 0, 0, 3, 0, 32, 0, 0, | ||
3, 3, 193, 162, 0, 1, 0, 7, 68, 1, 193, 114, 180, 98, 64>> | ||
|
||
defp make_pipeline( | ||
source, | ||
vpss \\ [], | ||
spss \\ [], | ||
ppss \\ [], | ||
output_stream_structure \\ :annexb | ||
) do | ||
structure = | ||
child(:source, source) | ||
|> child(:parser, %H265.Parser{ | ||
vpss: vpss, | ||
spss: spss, | ||
ppss: ppss, | ||
repeat_parameter_sets: true, | ||
output_stream_structure: output_stream_structure | ||
}) | ||
|> child(:sink, Sink) | ||
|
||
Pipeline.start_link_supervised!(structure: structure) | ||
end | ||
|
||
defp perform_test( | ||
pipeline_pid, | ||
data, | ||
mode \\ :bytestream, | ||
parser_input_stream_structure \\ :annexb, | ||
parser_output_stream_structure \\ :annexb | ||
) do | ||
buffers = prepare_buffers(data, mode, parser_input_stream_structure) | ||
|
||
assert_pipeline_play(pipeline_pid) | ||
actions = for buffer <- buffers, do: {:buffer, {:output, buffer}} | ||
Pipeline.message_child(pipeline_pid, :source, actions ++ [end_of_stream: :output]) | ||
|
||
output_buffers = | ||
prepare_buffers( | ||
File.read!(@ref_path), | ||
:au_aligned, | ||
parser_output_stream_structure | ||
) | ||
|
||
Enum.each(output_buffers, fn output_buffer -> | ||
assert_sink_buffer(pipeline_pid, :sink, buffer) | ||
assert buffer.payload == output_buffer.payload | ||
end) | ||
|
||
assert_end_of_stream(pipeline_pid, :sink, :input, 3_000) | ||
Pipeline.terminate(pipeline_pid, blocking?: true) | ||
end | ||
|
||
defp split_access_unit(access_unit) do | ||
{nalus, _splitter} = NALuSplitter.split(access_unit, true, NALuSplitter.new()) | ||
Enum.sort(nalus) | ||
end | ||
|
||
describe "Parameter sets should be reapeated on each IRAP access unit" do | ||
test "when provided by parser options" do | ||
source = %H265.Support.TestSource{mode: :bytestream} | ||
pid = make_pipeline(source, [@vps], [@sps], [@pps]) | ||
perform_test(pid, File.read!(@in_path)) | ||
end | ||
|
||
test "when retrieved from the bytestream" do | ||
source = %H265.Support.TestSource{mode: :bytestream} | ||
pid = make_pipeline(source) | ||
|
||
data = Enum.join([<<>>, @vps, @sps, @pps], <<0, 0, 0, 1>>) <> File.read!(@in_path) | ||
perform_test(pid, data) | ||
end | ||
|
||
test "when provided via DCR" do | ||
source = %H265.Support.TestSource{ | ||
mode: :au_aligned, | ||
output_raw_stream_structure: {:hev1, @dcr} | ||
} | ||
|
||
pid = make_pipeline(source, [], [], [], {:hev1, 4}) | ||
perform_test(pid, File.read!(@in_path), :au_aligned, {:hev1, 4}, {:hev1, 4}) | ||
end | ||
|
||
test "when bytestream has variable parameter sets" do | ||
in_path = "./test/fixtures/input-60-640x480-variable-parameters.h265" | ||
ref_path = "./test/fixtures/reference-60-640x480-variable-parameters.h265" | ||
|
||
source = %H265.Support.TestSource{mode: :bytestream} | ||
pid = make_pipeline(source) | ||
|
||
buffers = prepare_buffers(File.read!(in_path), :bytestream) | ||
|
||
assert_pipeline_play(pid) | ||
actions = for buffer <- buffers, do: {:buffer, {:output, buffer}} | ||
Pipeline.message_child(pid, :source, actions ++ [end_of_stream: :output]) | ||
|
||
File.read!(ref_path) | ||
|> prepare_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) | ||
end) | ||
|
||
assert_end_of_stream(pid, :sink, :input, 3_000) | ||
Pipeline.terminate(pid, blocking?: true) | ||
end | ||
end | ||
end |