Add output resolution support via output format struct width/height#23
Add output resolution support via output format struct width/height#23khamilowicz wants to merge 1 commit into
Conversation
c4d8f03 to
9a2754b
Compare
Resolution is specified directly on the output format struct (e.g.
`%H264{width: 160, height: 90}`) rather than as a separate option.
SWScale.Converter handles scaling when non-nil dimensions are present.
Parser-only shortcuts for H264→H264 and H265→H265 are blocked when
output has non-nil dimensions, since scaling requires full decode+encode.
Vulkan path uses the same SWScale-based scaling approach. Converter
no-op detection is consolidated into named defguardp helpers:
is_nv12_native/1, raw_video_passthrough/2, h26x_compatible_input/1.
Scaling integration tests added with reference fixtures (160x90, half
of the 320x180 source) for software path (H264↔H264, H264↔RawVideo).
Fixture filenames include resolution and proper format extension.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
9a2754b to
7591111
Compare
| end) | ||
|
|
||
| defp assert_or_regenerate_scaled_fixture!(actual, fixture_path) do | ||
| if System.get_env("REGEN_SCALED_FIXTURES") == "1" do |
There was a problem hiding this comment.
Do we need a separate env for that? I think it would be enough to have a single env telling whether or not to regenerate fixtures
| defp assert_or_regenerate_scaled_fixture!(actual, fixture_path) do | ||
| if System.get_env("REGEN_SCALED_FIXTURES") == "1" do | ||
| File.mkdir_p!(Path.dirname(fixture_path)) | ||
| File.write!(fixture_path, actual) |
There was a problem hiding this comment.
[NIT] we silently ignore failures here
| resolution: [ | ||
| spec: {pos_integer(), pos_integer()} | nil, | ||
| default: nil, | ||
| description: """ | ||
| Desired output video resolution `{width, height}` applied to all outputs. | ||
|
|
||
| When set, overrides `width` and `height` on the resolved output stream format. | ||
| Individual outputs can override this via the per-output `resolution` pad option. | ||
| """ |
There was a problem hiding this comment.
I am not 100% convinced we should duplicate these options both here and in def_output_pad, perhaps let's discuss it in person
| defp resolve_transcoding_policy(policy, _format), do: policy | ||
|
|
||
| defp resolve_output_stream_format(nil, input_format), do: input_format | ||
| defp apply_resolution(%{width: _width, height: _height} = format, {width, height}), |
There was a problem hiding this comment.
[NIT]
| defp apply_resolution(%{width: _width, height: _height} = format, {width, height}), | |
| defp apply_resolution(%{width: _width, height: _height} = format, {width, height} = _desired_resolution), |
Alternatively you can type spec this function and add some labels for arguments ;)
|
|
||
| defp resolve_output_stream_format(nil, input_format) do | ||
| case input_format do | ||
| %{width: _width, height: _height} -> %{input_format | width: nil, height: nil} |
There was a problem hiding this comment.
why would we discard width and height from the input_format?
| is_raw_video_format(format) | ||
|
|
||
| # Input format natively produces/consumes NV12 in the VK pipeline (H264 via VK decoder, or raw NV12) | ||
| defguardp is_nv12_native(format) |
There was a problem hiding this comment.
how about some names like is_vk_video_friendly_format and is_x264_friendly_format ?
Summary
%H264{width: 160, height: 90}) rather than as a separate optionSWScale.Converterhandles scaling when non-nil dimensions are presentTest plan
mix testto verify all integration tests pass🤖 Generated with Claude Code