Add hwaccel scale filter with preview scaling#1181
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds hardware-accelerated scaling filters for video decoding, enabling GPU-based scaling for multiple hardware acceleration backends (Vulkan, D3D11, VAAPI, VideoToolbox). The implementation conditionally applies hardware scaling when the consumer requests downscaling, reducing unnecessary transfers between GPU and CPU memory.
Key changes:
- Adds hardware-accelerated filter setup and application functions for different GPU backends
- Extends pixel format support to include NV12 and P010LE formats commonly used in hardware decoding
- Implements conditional filter initialization based on consumer scale factor and hardware format
- Propagates consumer scale property to frames for producer-side scaling decisions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/modules/avformat/producer_avformat.c | Implements hwaccel filter infrastructure with setup/apply functions; adds pixel format mappings; integrates conditional scaling based on consumer requirements |
| src/framework/mlt_consumer.c | Propagates consumer scale property to frame properties for producer access |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7044954 to
e86527a
Compare
|
Thanks a lot Dan for your work on this. Sorry I didn't manage to test it or give you feedback, but I had to go offline for some time due to personal family issues. I will definitely test this for our upcoming 26.04 version. |
@j-b-m I am doing some final testing before merging. This takes hwaccel to the next level and makes it usable. It goes a very long way to offset the slow speed of using the new 10-bit linear color processing.
A problem with hwaccel is the large amount of data to copy over a bus between CPU RAM and GPU VRAM if you can not keep everything in the GPU. But, it occurred to me that we can use it conjunction with preview scaling by using hwaccel scale filters directly in the producer!
scaleproperty) by using hwaccel scale filters.MLT_AVFORMAT_HWACCEL_PPSto set the maximum pixels per second to use hwaccel decode without consumer scale. I could see many people only want to work with 1080p on lower end devices, not always enable preview scale, and want to reduce CPU usage. Turn on preview scaling if you need more than this threshold, for example, 1080p60.Related Shotcut changes are minimal: https://github.com/mltframework/shotcut/compare/hwaccel?expand=1