@@ -34,9 +34,16 @@ defmodule Membrane.Transcoder.IntegrationTest do
3434 output <- @ audio_outputs ,
3535 do: Map . put ( input , :output_format , output )
3636
37+ # Only H264 outputs exercise the Vulkan-accelerated encode path. Each case
38+ # has a committed fixture under test/fixtures/vk_outputs/ that pins the
39+ # expected bitstream produced on a Vulkan-capable machine. To (re)generate
40+ # the fixtures, run `REGEN_VK_FIXTURES=1 mix test --include vulkan` once on
41+ # such a machine and commit the resulting files.
3742 @ vk_video_cases for input <- @ video_inputs ,
3843 do: Map . put ( input , :output_format , H264 )
3944
45+ @ vk_fixtures_dir "./test/fixtures/vk_outputs"
46+
4047 @ test_cases @ video_cases ++ @ audio_cases
4148
4249 Enum . map ( @ test_cases , fn test_case ->
@@ -79,12 +86,14 @@ defmodule Membrane.Transcoder.IntegrationTest do
7986
8087 Enum . map ( @ vk_video_cases , fn test_case ->
8188 @ tag :vulkan
82- test "transcoder produces identical output for #{ inspect ( test_case . input_format ) } -> H264 with and without native acceleration" do
83- sw_output = run_transcoder_to_file ( unquote ( Macro . escape ( test_case ) ) , :never )
84- vk_output = run_transcoder_to_file ( unquote ( Macro . escape ( test_case ) ) , :if_available )
89+ test "transcoder produces stable output for #{ inspect ( test_case . input_format ) } -> H264 with native acceleration" do
90+ fixture_path =
91+ Path . join ( @ vk_fixtures_dir , "#{ unquote ( test_case . input_format ) |> Module . split ( ) |> List . last ( ) |> String . downcase ( ) } _to_h264.bin" )
92+
93+ actual = run_transcoder_to_file ( unquote ( Macro . escape ( test_case ) ) , :if_available )
8594
86- assert byte_size ( sw_output ) > 0
87- assert :crypto . hash ( :sha256 , sw_output ) == :crypto . hash ( :sha256 , vk_output )
95+ assert byte_size ( actual ) > 0 , "transcoder produced empty output"
96+ assert_or_regenerate_fixture! ( actual , fixture_path )
8897 end
8998 end )
9099
@@ -114,6 +123,27 @@ defmodule Membrane.Transcoder.IntegrationTest do
114123 bytes
115124 end
116125
126+ defp assert_or_regenerate_fixture! ( actual , fixture_path ) do
127+ if System . get_env ( "REGEN_VK_FIXTURES" ) == "1" do
128+ File . mkdir_p! ( Path . dirname ( fixture_path ) )
129+ File . write! ( fixture_path , actual )
130+ IO . puts ( "Regenerated fixture: #{ fixture_path } " )
131+ else
132+ case File . read ( fixture_path ) do
133+ { :ok , expected } ->
134+ assert :crypto . hash ( :sha256 , actual ) == :crypto . hash ( :sha256 , expected ) ,
135+ "output does not match fixture #{ fixture_path } "
136+
137+ { :error , :enoent } ->
138+ flunk ( """
139+ Missing fixture #{ fixture_path } .
140+ Run `REGEN_VK_FIXTURES=1 mix test --include vulkan` on a Vulkan-capable \
141+ machine to generate it, then commit the resulting file.
142+ """ )
143+ end
144+ end
145+ end
146+
117147 defmodule FormatSource do
118148 use Membrane.Source
119149
0 commit comments